[XSL-LIST Mailing List Archive Home]
Re: [xsl] XPath context evaluation
Subject: Re: [xsl] XPath context evaluation|
From: Victor Toni <xsl-list@xxxxxxxxx>
Date: Sat, 13 May 2006 01:09:54 +0200
Michael Kay wrote:
In the meantime I found a nearly trivial solution which lets
my keep my
"subsequence(//info,index-of(//info/id, .), 1)"
These functions were easy to implement and solved the issue I
had. Since performance doesn't count for this use case I am
glad it works :-)
This isn't 100% equivalent to //info[id = current()], unless you make
assumptions about the data, for example that there is no more than one
This is indeed the assumption made and is even required in my use case.
But if you're using XPath 2.0, then what's wrong with
for $x in . return //info[id = $x]
(which is equivalent: in fact it's essentially what Saxon compiles the
original code into)
I am not really using XPath 2.0. Actually it's dom4j with some extension
functions for Jaxen.since Jaxen 1.1 beta X is not XPath 2.0 "ready" it
does not support all the features (e.g. current() ).
After writing the functions it's a one-liner to register it to the
function context making it very easy for me to add functionality (with
the limitations given by the current Jaxen model)
I have written some XPath 2.0 functions for Jaxen on my own which seemed
trival to write and still supported by the current Jaxen model
(string-join(), subsequence(), index-of() ) and some more not belonging
to the standard e.g. an XSL like sort function which uses additional
XPath expression to determine the sort order.
Especially the sort function is crucial for my use case and as long I
can work around Jaxen's limitations I prefer not to bother about porting
it to another XPath implementation :-)