You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Gary Brown <Ga...@spirit-soft.com> on 2001/10/08 14:50:04 UTC

XPath and binding variables

Hi,
 
Apologies if this is not the appropriate email address for this sort of
question, but I have just downloaded Xalan and tried experimenting with
XPath. According to the W3C spec, you should be able to specify
variables that bind to values in the context. For example,
 
Loading classes, parsing foo.xml, and setting up serializer
Querying DOM using /doc/name[@first=$person]
<output>
Exception in thread "main" java.lang.RuntimeException: Variable not
resolvable:
person
        at
org.apache.xpath.axes.PredicatedNodeTest.acceptNode(PredicatedNodeTest.j
ava:449)
        at
org.apache.xpath.axes.AxesWalker.nextNode(AxesWalker.java:392)
        at
org.apache.xpath.axes.WalkingIterator.nextNode(WalkingIterator.java:182)
        at
org.apache.xml.dtm.ref.DTMNodeIterator.nextNode(DTMNodeIterator.java:195
)
        at ApplyXPath.doMain(ApplyXPath.java:134)
        at ApplyXPath.main(ApplyXPath.java:159)

However, as you can see, the expected result is that it complains that
it cannot resolve the variable -which is fair enough as the simple
ApplyXPath example does not include any such variables being bound to
the context.
 
My question is, how can I bind named variables to the context? Have you
got an example of how this is done using Xalan?
 
Can these variables be simple types or nodes?
 
Thanks in advance,
Gary Brown