[XQuery Talk Mailing List Archive Home] [By Date] [By Thread] [By Subject] [By Author] [Recent Entries] [Reply To This Message]

why must one have something inside {} ?

G. Ken Holman gkholman at CraneSoftwrights.com
Sat Dec 3 05:29:01 PST 2011


  why must one have something inside {} ?
At 2011-12-03 21:20 +0800, http://x-query.com/mailman/listinfo/talk wrote:
>Gentlemen, what a spiteful language xquery is, not allowing an empty
>statement. I want to "comment out" a line,
>
>  <Document>
>  {doc("p.xml")//STYLES/*} <--- Let's comment out this line
>
>  <Document>
>  {(: doc("p.xml")//STYLES/* :)}
>BaseX makes [XPST0003] Expecting valid expression after "{".
>
>  <Document>
>  <!-- {doc("p.xml")//STYLES/*} -->
>Works but ends up in output.
>
>It's all because {} for some reason needs to be filled with some junk.
>OK, adding "" works:
>  <Document>
>  {""(: doc("p.xml")//STYLES/* :)}

In XPath syntax, the empty string is not a valid expression:

   http://www.w3.org/TR/2007/REC-xpath20-20070123/#prod-xpath-XPath

Your use of curly braces has to be populated with an XPath 
expression.  An XPath expression is evaluated after comments have 
been removed.

   http://www.w3.org/TR/2007/REC-xpath20-20070123/#comments
   "Comments are lexical constructs only, and do not affect expression
    processing."

Thus you need *something* to prevent the contents of the curly braces 
to be empty after removing comments.

I tell my students to use () rather than "".  This is an explicit 
lesson in the class because of the intuition that a comment is an 
expression, when it isn't.

I hope this explanation helps.

. . . . . . . . .  Ken


--
Contact us for world-wide XML consulting and instructor-led training
Free 5-hour video lecture: XSLT/XPath 1.0 & 2.0 http://ude.my/t37DVX
Crane Softwrights Ltd.            http://www.CraneSoftwrights.com/q/
G. Ken Holman                   mailto:http://x-query.com/mailman/listinfo/talk
Google+ profile: https://plus.google.com/116832879756988317389/about
Legal business disclaimers:    http://www.CraneSoftwrights.com/legal



PURCHASE STYLUS STUDIO ONLINE TODAY!

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.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
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-2011 All Rights Reserved.