I don't remember whether we added a convenience routine for this or not. 
It's pretty straightforward to hand-code against a DOM, by walking up the 
parents and building up a string such as "/a:foo[1]/@b:bar"... if you 
don't consider namespaces. Once you add them, you need to also accumulate 
those; the simple but ugly solution is to use steps like  /*[namespace()="
http://a.com"; and localname()="foo"][1], or you can accumulate a namespace 
context to use alongside the XPath (but in some cases that will require 
reconciling conflicting prefixes).

Of course in SAX you can do something similar by maintaining a context 
stack.

An XSLT version of this (minus the namespace ugliness) appeared in my 
DeveloperWorks article on "styling stylesheets", if that helps at all.

______________________________________
"... Three things see no end: A loop with exit code done wrong,
A semaphore untested, And the change that comes along. ..."
  -- "Threes" Rev 1.1 - Duane Elms / Leslie Fish (
http://www.ovff.org/pegasus/songs/threes-rev-11.html)

Reply via email to