The question is often asked, and different people who ask it want different things. Some people want:
a/b/c/d/e
that is, a path containing the names of the ancestor elements (easily achieved in XSLT 2.0 with string-join(ancestor-or-self::*/name(), '/')).
Some people want
a[1]/b[3]/d[4]
that is, a path that identifies an element uniquely.
And in either case, people may or may not want the result to be namespace-sensitive. This is where things get difficult: name() returns a lexical QName that cannot be used to retrieve the node again unless you know the original namespace bindings. If you want a path that can be evaluated without a namespace context, then you have two choices:
*[1]/*[3]/*[4]
or
*[namespace-uri()='http://1/' and local-name()='a'][1]/*[namespace-uri()='http://2/' and local-name()='b'][3]/....
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
|