EDIT: The Example now contains all tags that are in my main document
Hello everyone! I just had a quick question about XSLT. I have a large xml file with many <DIMENSION_Id> nodes nested inside each other. In each <DIMENSION_Id> node there are two SYN tags: <SYN>String</SYN><SYN>Integer</SYN> What I am trying to do is take the furthest child node of each DIMENSION_Id and connect it with all of its ancestor paths to create a URL.
i.e.
<DIMENSIONS VERSION="1.0.0">
<DIMENSION NAME="Category" SRC_TYPE="INTERNAL">
<DIMENSION_NODE ID="1000"/>
<DIMENSION_Id>
<SYN>Text</SYN>
<SYN>Number</SYN>
<DIMENSION_Id>
<SYN>More Text</SYN>
<SYN>Another Number</SYN>
</DIMENSION_Id>
</DIMENSION_Id>
</DIMENSION>
</DIMENSIONS>
I wrote this XSLT to get all information from the parent nodes first, then the child node last to create a full URL. Unfortunately it only gives me the information of the furthest child node...I do not know how to append any other text to it. (it should read something like: furthest-parent/closer-parent/parent/item_selected)
Unfortunately all it does is give me the value of the current node.... Here is the XSLT that I wrote:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" />
<xsl:template match="/DIMENSION_NODE">
<xsl:for-each select="ancestor-or-self::*">
<xsl:value-of select="@SYN" />
<xsl:text>/</xsl:text>
<xsl:value-of select="." />
<xsl:value-of select="@SYN" />
<xsl:text>/</xsl:text>
<xsl:value-of select="." />
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Thanks in advance for your help!
GRANDPARENT_SYN_VALuE/PARENT_SYN_VALUE... but you have twoSYNelements; your stylesheet match aDIMENSION_NODEroot element not present in input sample; you are trying to output aSYNattribute with<xsl:value-of select="@SYN"/>and the string value for theDIMENSION_NODEelement...