xml editor

Supported platforms

Compatible with Windows7 & Mac OS X Snow Leopard

Ready for data server software
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

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
environment:


"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
match.

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 :-)


Victor


Current Thread
Keywords
XML Editor | XML Author | WYSIWYG Editors | Schema Editor | XSD Documentation | XSL/XSLT Editor | XQuery | XML Databases | SVN Client
© 2002-2011 SyncRO Soft Ltd. All rights reserved. | Sitemap | Privacy Policy | This website was created & generated with <oXygen/>®XML Editor