At 2011-12-03 21:20 +0800, [email protected] 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:[email protected]
Google+ profile: https://plus.google.com/116832879756988317389/about
Legal business disclaimers:    http://www.CraneSoftwrights.com/legal

_______________________________________________
[email protected]
http://x-query.com/mailman/listinfo/talk

Reply via email to