Literals and Comments

XQuery uses "smiley faces" to begin and end comments. This cheerful notation was originally suggested by Jeni Tennison. Here is an example of a comment:

 (: Thanks, Jeni! :) 

Note that XQuery comments are comments found in a query. XML documents may also have comments, like the comment found in an earlier example:

 <! document order > 

XQuery comments do not create XML comments ”XQuery has a constructor for this purpose, which is discussed later in the section on constructors.

XQuery supports three kinds of numeric literals. Any number may begin with an optional + or “ sign. A number that has only digits is an integer, a number containing only digits and a single decimal point is a decimal, and any valid floating-point literal containing an e or E is a double. These correspond to the XML Schema simple types xs:integer , xs:decimal , and xs:double .

 1       (: An integer :) -2      (: An integer :) +2      (: An integer :) 1.23    (: A decimal  :) -1.23   (: A decimal  :) 1.2e5   (: A double   :) -1.2E5  (: A double   :) 

String literals are delimited by quotation marks or apostrophes. If a string is delimited by quotation marks, it may contain apostrophes; if a string is delimited by apostrophes , it may contain quotation marks:

 "a string" 'a string' "This is a string, isn't it?" 'This is a "string"' 

If the literal is delimited by apostrophes, two adjacent apostrophes within the literal are interpreted as a single apostrophe. Similarly, if the literal is delimited by quotation marks, two adjacent quotation marks within the literal are interpreted as one quotation mark. The following two string literals are identical:

 "a "" or a ' delimits a string literal" 'a " or a '' delimits a string literal' 

A string literal may contain predefined entity references. The entity references shown in Table 1.1 are predefined in XQuery.

Here is a string literal that contains two predefined entity references:

 '&lt;bold&gt;A sample element.&lt;/bold&gt;' 


XQuery from the Experts(c) A Guide to the W3C XML Query Language
Beginning ASP.NET Databases Using VB.NET
ISBN: N/A
EAN: 2147483647
Year: 2005
Pages: 102

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net