Generating XPaths to a specific node is an outstanding wishlist item. It
wouldn't be hard... except that XPath failed to define any way of declaring
namespaces, so we'd need to invent some magic to go along with it to create
those declarations (and, if necessary, new prefixes to disambiguate cases
where a prefix was reused).

I discussed some of those issues, and showed a non-namespace-correct
"pseudo XPath" generator template, in my article on styling stylesheets:
      http://www-106.ibm.com/developerworks/xml/library/x-styless2/
That logic could be trivially rewritten in Java or C++, but namespaces
would remain a nuisance.

The paths it produces are from the root rather than from a given source
node, which may not be optimal for your needs. It could probably be
rewritten to find the lowest common ancestor and go through that instead,
but even that may not be as good a choice as an XPath constructed manually.

Have fun. If you come up with anything really good, consider sharing it
with us.

______________________________________
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

Reply via email to