Look at the extension function saxon:path() or the XPath 3.0 function fn:path().

They may or may not meet your needs. It depends whether you want the names to be namespace-qualified, and it depends whether you want subscripts indicating the position of each node among its siblings. If you just want the element names and don't care about namespaces, then string-join(ancestor-or-self::*/name(), '/') does the job perfectly well.

Michael Kay

On 15 Apr 2013, at 12:54, Kunal Chauhan wrote:


Is there any method available through which I can convert relative XPath to absolute XPath.

for eg, below is my xml


Now, if I pass below XPath to any method.

I will get below my expected XPath
my expected XPath is :   /mainNode/element1/firstName

Thanks and Regards,

Kunal Chauhan
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis & visualization. Get a free account!
saxon-help mailing list archived at http://saxon.markmail.org/