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 Lingzhi Zhang <lz...@cse.ogi.edu> on 2003/06/04 18:20:52 UTC

get a complete path from Xalan

Hi,

I am new to Xalan. I am trying to use Xalan to get a complete  path
for a given XPath expression. For example, for a given XPath expression
like /A//B/ and XML document foo.xml, I am looking for all the possible
path in foo.xml, which starts with A and ends with B, such as /A/C/B,
A/D/E/B ...

Thanks in advance.

Stephen



Re: get a complete path from Xalan

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



> For example, for a given XPath expression
>like /A//B/ and XML document foo.xml, I am looking for all the possible
>path in foo.xml, which starts with A and ends with B, such as /A/C/B,
>A/D/E/B

Xalan can find all the nodes which match this XPath, but does not provide a
routine to generate an XPath to a node. I believe there's an outstanding
request-for-enhancement for Xalan to add this, but nobody's found the time
to work on it.

You can compute that yourself, of course, by examining the ancestors of
each node. As I said in the Xerces list, my recent article on
developerWorks included an XSLT template which generates a path to a node.
It isn't a fully compliant XPath, for reasons discussed in that article,
but it demonstrates one way to do it.

If you aren't working in XSLT, you can achieve the same result in your own
code by navigating the ancestors using the DOM APIs and assembling the
appropriate string. If you come up with a particularly good version
(especially one that deals with the namespace challenges), please submit it
as a response to that enhancement request!

______________________________________
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