XPath context as a sequence
Added by Anonymous over 16 years ago
Legacy ID: #5014511 Legacy Poster: David Lee (daldei)
This may be a crazy question ... but is there a way to set the context item for XPath as a sequence instead of an XdmItem ? I.e. set it as an XdmValue. Using S9API ... Suppose, for example, I have a sequence (1,2,3) - could be from a previous xpath or xquery call. This is stored in a XdmValue. I would like to set this sequence as the context for an xpath expression so I could evaluate expressions like "count()" or "[2]" or "[position() > 3]" As far as I can tell, I must set the context as an XdmItem not an XdmValue ... so I cant do the above. XPathSelector.setContextItem( XdmItem item ); // cant be a sequence ! Is this a specification issue ? That is, is XPath required to only operate on items not sequences ? or is this a implementation limitation ? Or maybe I'm just missing something obvious on how to put a sequence into an item ... (but I think that would then enable XdmValue's to contain sequences of sequences, which is not valid in xquery or xpath. Suggestions appreciated ! -David dlee@calldei.com www.xmlsh.org
Replies (1)
RE: XPath context as a sequence - Added by Anonymous over 16 years ago
Legacy ID: #5014539 Legacy Poster: Michael Kay (mhkay)
The context item is defined to be an item. If you want to supply a sequence as input to an XPath expression, the answer is to use a variable: write the expression as "count($value)" and bind the variable $value from the s9api client program. (You need to declare the variable in the XPathCompiler, and give it a value in the XPathSelector).
Please register to reply