Freigeben über


Triple dot syntax for descendants axis in VB 9.0

Many people asked us why did we choose the triple dot syntax for the descendants axis in the VB 9.0 Xml members syntax. Before I go into the reasoning for that choice here is a small example of the triple dot syntax. In the following sample, the variable "authors" pointes to all the "author" elements that are descendents of the "book" element:

Dim book = <book year="2000">

  <title>Data on the Web</title>

  <authors>

                 <author>Serge Abiteboul</author>

                 <author>Peter Buneman</author>

                 <author>Dan Suciu</author>

              </authors>

           </book>

Dim authors = book...<author>

This statement is compiled to the following statement using the XLinq API:

Dim authors = book.Descendants("author")

We got many suggestions for alternative syntax, the most popular suggestion was to use double dot based on the logic that a single dot maps to XPath single slash thus the double dot should map to double slashes. Another suggestion was to use slashes after the dot or to add them to the element name. Another one was to use a different notation inside the angle brackets such as “*” or just empty tag, for example book.<*>.<author>.

The following are the reasons that this syntax was chosen by the language designers (the incubation work that led to the Xml features in VB 9.0) and the reasons we are keeping it:

  • The double dot is the XPath, DOS and Unix notation for parent.
  • The triple dot notation is already used by some applications such as our source control program for descendants.
  • Triple dot is often used to denote ellipsis (i.e. etc.) in English. The descendants axis in XPath and the descendants method in XLinq are somewhat similar to this concept since it allows omitting parts of the path that are not important.
  • Triple dot is more visible then two dots, the visual difference between single dot to double dot is smaller them between single to double slash.

Please continue to let us know what you think, your feedback is very important to us.

Avner

Comments

  • Anonymous
    April 07, 2006
    Sounds good to me.
  • Anonymous
    April 08, 2006
    Avner,

    The parallel to ellipses is even better than you indicate. You say the ellipsis in English text means "etc", but in fact that is just a special case. Etc means "similar items omitted". An ellipsis means "Something in the original text has been omitted at this point for clarity. Trust me."  

    This seems like an apt analogy for what you are doing:  omitting intermediate nodes that you wish to consider insignificant.
  • Anonymous
    April 13, 2006
    Avner,

    If you would also implement a better way to do XMLRPC with VB along with this that would make this even better. But I will take this simplicity over searching nodelists anyday of the week.

    Thanks,
    Sam
  • Anonymous
    April 29, 2006
    Looking at the tripple-dot syntax, I think it's extremely ugly and verbose. Who would ever suggest addressing child nodes using "..." ?!

    I'd rather skip that part and use .Descendants instead!
  • Anonymous
    April 30, 2006
    I like ... notation.