You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xalan.apache.org by Zeljko Velaja <zv...@VisualFriendly.com> on 2003/10/24 17:53:39 UTC

binding variables to values in XPath

I'm reading in the XPath language specification that the lexical production $QName retrieves the value of the QName variable. Yet I cannot find anything in the XPath specification to declare a new variable and assign a value to it within an XPath expression. Did I miss something in the specification or does Xalan define a language extension wich should be usefull in what I mean to do ?

Re: binding variables to values in XPath

Posted by Joseph Kesselman <ke...@us.ibm.com>.



XPath has no syntax for defining variables. That's left to the environment
in which the XPath is being invoked.

If you're using XPaths within XSLT, XSLT does have a syntax for defining
variables/parameters.

If you're invoking XPaths directly, you need to look at the APIs to see if
they provide a way to set variables before running the XPath. I don't think
our XPathAPI class currently provides an easy way to do that; this might be
a worthwhile enhancement to request. For now you may be stuck with
manipulating the lower-level classes, in particular building a
VariableStack and setting that into the XPathContext before executing the
path expression.

______________________________________
Joe Kesselman, IBM Next-Generation Web Technologies: XML, XSL and more.
"The world changed profoundly and unpredictably the day Tim Berners Lee
got bitten by a radioactive spider." -- Rafe Culpin, in r.m.filk


Re: binding variables to values in XPath

Posted by Richard Cao <ri...@ca.ibm.com>.



Hi,

Have a look at "xsl:variable" and "xsl:param" in the XSLT [1]
specifications for binding variables.

[1] http://www.w3.org/TR/xslt#variables

Thanks,

Richard Cao
XSLT Development, Toronto IBM Lab
(905) 413-2454 T/L 969-2454
richcao@ca.ibm.com



                                                                           
             "Zeljko Velaja"                                               
             <zvelaja@VisualFr                                             
             iendly.com>                                                To 
                                       <xa...@xml.apache.org>      
             10/24/2003 11:53                                           cc 
             AM                                                            
                                                                   Subject 
                                       binding variables to values in      
                                       XPath                               
                                                                           
                                                                           
                                                                           
                                                                           
                                                                           
                                                                           




I'm reading in the XPath language specification that the lexical production
$QName retrieves the value of the QName variable. Yet I cannot find
anything in the XPath specification to declare a new variable and assign a
value to it within an XPath expression. Did I miss something in the
specification or does Xalan define a language extension wich should be
usefull in what I mean to do ?