|
[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Is an XQuery Document an XML Document?
I'm not sure what you mean by 'an XQuery document'. However if you mean an XQuery query that generates an XML document, there is no guarantee that it should always be a well-formed XML 1.0 document. After all <foo />, <bar /> is a valid XQuery expression and it isn't a well formed XML document, then again it doesn't generate a well-formed XML document either. -- PITHY WORDS OF WISDOM There is nothing more satisfying that having someone take a shot at you, and miss. ________________________________ From: Roger L. Costello [mailto:costello@m...] Sent: Sun 11/28/2004 7:06 AM To: xml-dev@l... Subject: Is an XQuery Document an XML 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 < 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|
|||||||||

Cart








