[jdom-interest] XPath examples

Michael Kay mike at saxonica.com
Thu May 31 00:59:48 PDT 2012


>>
>> Do the variables have to be xpath values (i.e., in quotes), or can 
>> any part of the xpath expression be put into a variable?
>>
>> Peter Kronenberg

Variables in XPath represent values, not fragments of expression text: 
XPath isn't like shell scripts where variables are essentially macros. 
So you can't put "+" or "-" into a variable $op and then do (3 $op 2). 
Because the language is orthogonal, a variable reference can be used 
anywhere an expression can be used. That rules out things like 
child::$e, a/$e (which becomes acceptable in XPath 2.0, but doesn't mean 
what people sometimes imagine), or $e(2) (which becomes acceptable in 
XPath 3.0, where functions are first-class values).

Michael Kay
Saxonica


More information about the jdom-interest mailing list