[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Is an XQuery Document an XML Document?

  • To: <xml-dev@l...>
  • Subject: Is an XQuery Document an XML Document?
  • From: "Roger L. Costello" <costello@m...>
  • Date: Sun, 28 Nov 2004 10:06:47 -0500
  • Thread-index: AcTVW+ElopXBiRvQSr6mpI9FiV0P2w==

xquery document
Hi Folks,
Here is an example of a fine XQuery document:
<HelloWorld>hello world</HelloWorld>
Is it an XML document?
There is no XML declaration so you might conclude, "No, an XQuery document is
not an XML document."
If that is so then I should be able to omit the end tag with no ill effects:
<HelloWorld>hello world
However, such a document yields an error.
So, you might conclude, "Yes, an XQuery document is an XML document."
Let's dig a little deeper.
A basic constraint in XML is that the "<" symbol is a reserved symbol.  If
you wish to use it in your data then you must escape it as such:
<Equation> if (1 &lt; 2) then "TRUE" else "FALSE" </Equation>
For those who have not ventured into XQuery, allow me to explain something
about the workings of XQuery. 
If you wish to tell an XQuery Processor that you want it to evaluate an
XPath expression then you wrap the XPath expression within curly braces. 
Here's an example:
<Name> {/FitnessCenter/Member[1]/Name} </Name>
The XQuery Processor will evaluate the XPath expression within the curly
braces.  The result will be:
(Jeff is the name of the first member)
In XPath 2.0 there is an if-then-else expression.  So, here is an example
of an XQuery document which uses an XPath if-then-else expression:
<Equation> {if (1 < 2) then "TRUE" else "FALSE"} </Equation>
The result of an XQuery Processor executing this will be:
Do you notice something odd about this example?  It uses the "<" symbol
without escaping it!  In fact, if you were to escape the "<" symbol ...
<Equation> {if (1 &lt; 2) then "TRUE" else "FALSE"} </Equation>
... it would result in an error being generated!
So, you might conclude, "A fundamental rule in XML is that the "<" symbol
is reserved and must be escaped.  XQuery does not heed this rule.
Therefore, an XQuery document is not an XML document."
Okay, I give up.  Which is it?  XML or not?  If it's not XML then why
is it called "XML Query Language"?  /Roger


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.

Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.