You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Rob van Wees <r....@chello.nl> on 2001/02/14 20:11:54 UTC
ApplyXPath example: statement doesn't do what I think it ought to
Hello there,
I'm unfamiliar with the mailing list, please tell me if I should ask
somewhere else.
I have been trying out the ApplyXPAth example with the xalan-j v2_0_0 stuff
and I ran into something I did not quite understand. Could you help me?
When I executed the following XPath statement:
//name[..//@level=\"2\"|..//class=\"Cleric\"]
on the attached file, I expected to get some output starting with:
<name>Aid</name>
However, the output was like below:
Loading classes, parsing tmpspells.xml, and setting up serializer
Querying DOM using //name[..//@level="2"|..//class="Cleric"]
<output>
</output>
My question(s):
1) Am I mistaken in the XPAth syntax?
I expected it to behave somewhat like "SELECT name WHERE @level=2 AND
class=Cleric". Is this correct? The previous Xalan version behaved
differently in that it returned "unknown axis 'name'", this version tells me
"No records selected..."
2) Did I do something wrong?
Does XPath support the above construct (multiple clauses in a condition
statement)? It does seem to work for the non-conditional:
//name|//short-description
3) If it was me (and too if it wasn't), do you know of a proper XPath
(preferably short-notation) explanation? The notation texts at W3C are a
little hard for me to read...
Thanks in advance,
Rob van Wees
Re: ApplyXPath example: statement doesn't do what I think it ought to
Posted by Gary L Peskin <ga...@firstech.com>.
Rob van Wees wrote:
>
> Hello there,
>
> I'm unfamiliar with the mailing list, please tell me if I should ask
> somewhere else.
No, here is fine though you'll probably get faster results for straight
XSLT questions on the XSL-LIST (see
http://www.mulberrytech.com/xsl/xsl-list/index.html).
> I have been trying out the ApplyXPAth example with the xalan-j v2_0_0 stuff
> and I ran into something I did not quite understand. Could you help me?
>
> When I executed the following XPath statement:
>
> //name[..//@level=\"2\"|..//class=\"Cleric\"]
>
> My question(s):
> 1) Am I mistaken in the XPAth syntax?
> I expected it to behave somewhat like "SELECT name WHERE @level=2 AND
> class=Cleric". Is this correct? The previous Xalan version behaved
> differently in that it returned "unknown axis 'name'", this version tells me
> "No records selected..."
>
> 2) Did I do something wrong?
> Does XPath support the above construct (multiple clauses in a condition
> statement)? It does seem to work for the non-conditional:
> //name|//short-description
You are using the | operator inside a predicate (the part enclosed by
[]). I believe that this is parsed as
//name[..//@level=('2'|..//class='Cleric')]
which is not what you want. Note that I've converted your \" to ' which
I think makes things more readable.
I think you want
//name[..//@level='2'] | //name[..//class='Cleric']
which seems to produce what you want.
>
> 3) If it was me (and too if it wasn't), do you know of a proper XPath
> (preferably short-notation) explanation? The notation texts at W3C are a
> little hard for me to read...
I highly recommend Mike Kay's XSLT Programmer's Reference published by
Wrox, ISBN 1861003129. A new version is due out in March if you want to
wait.
HTH,
Gary