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
Saxonica

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

Hello,

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

for eg, below is my xml

<mainNode>
      <element1>
               <firstName>Kunal</firstName>
               <lastName>Chauhan</lastName>
      </element1>
</mainNode>


Now, if I pass below XPath to any method.
   //firstName 
    OR
   /mainNode/./firstName

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

Thanks and Regards,

--
Kunal Chauhan
[+918655517141]
------------------------------------------------------------------------------
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!
http://www2.precog.com/precogplatform/slashdotnewsletter_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
saxon-help@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/saxon-help