Hi there,
I have the following block of code that gets the name of the nodes down the tree, like this:
section/page/subPage
But I would like to be able to get it down to the following (just making it up):
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 the straight path, but I would like to run more logic on it to make it so it included the @id (or relevant attribute), and maybe some more stuff I can't think of at the moment.
What is the best way to do this?
I've checked into EXSLT functions, which may work, but maybe you guys have already solved this problem a better way.
Any ideas?
I'm using ruby's nokogiri to parse the xml/xslt if that helps.
Thanks a lot, Lance