I have the following code block that gets the name of the nodes down the tree, for example:
section/page/subPage
But I would like to get it before the following (only to create it):
section[@id='someId']/page/subPage[@user='UserA']/@title
I found the following code from one of these StackOverflow posts:
<xsl:attribute name="path">
<xsl:for-each select="ancestor-or-self::*">
<xsl:if test="name() != 'root'">
<xsl:value-of select="name()">
<xsl:if test="not(position()=last())">
<xsl:text>/</xsl:text>
</xsl:if>
</xsl:value-of>
</xsl:if>
</xsl:for-each>
</xsl:attribute>
Which gives me a direct path, but I would like to use more logic for this, so that it includes @id (or the corresponding attribute) and maybe something else that I canโt think of right now.
What is the best way to do this?
I checked the EXSLT functions that might work, but maybe you guys already solved this problem better.
Any ideas?
I use ruby โโnokogiri to parse xml / xslt if that helps.
Thank you very much spear