[xquery-talk] why must one have something inside {} ?
David Lee
dlee at calldei.com
Sat Dec 3 05:40:05 PST 2011
While certainly I agree with the solution ... use this form
{ (: comment :) () }
Or this
{ () (: comment :) }
I think the question still stands as valid (although almost pointless except
historical interest asking 'why' questions from standards bodies ..)
Why is {} not equal to { () }
>From a syntax and readability point of view I don't see why {} can be
equivalent to {()} ... but it's not.
----------------------------------------
David A. Lee
dlee at calldei.com
http://www.xmlsh.org
-----Original Message-----
From: talk-bounces at x-query.com [mailto:talk-bounces at x-query.com] On Behalf
Of G. Ken Holman
Sent: Saturday, December 03, 2011 8:29 AM
To: talk at x-query.com
Subject: Re: [xquery-talk] why must one have something inside {} ?
At 2011-12-03 21:20 +0800, jidanni at jidanni.org 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:gkholman at CraneSoftwrights.com
Google+ profile: https://plus.google.com/116832879756988317389/about
Legal business disclaimers: http://www.CraneSoftwrights.com/legal
_______________________________________________
talk at x-query.com
http://x-query.com/mailman/listinfo/talk
More information about the talk
mailing list