[
Lists Home |
Date Index |
Thread Index
]
- To: <xml-dev@lists.xml.org>
- Subject: Is an XQuery Document an XML Document?
- From: "Roger L. Costello" <costello@mitre.org>
- Date: Sun, 28 Nov 2004 10:06:47 -0500
- Thread-index: AcTVW+ElopXBiRvQSr6mpI9FiV0P2w==
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 < 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:
<Name>Jeff</Name>
(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:
<Equation>TRUE</Equation>
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 < 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
|