R
readytohelp
I have the following XML
<root>
<Companies>
<Name>Labs</Name>
<display>Labs </display>
<val>1</val>
<Products>
<val>1</val>
<display>Maxa</display>
<CompanyKey>1</CompanyKey>
<Topics>
<val>3</val>
<display>Psychological</display>
<CompanyKey>1</CompanyKey>
<product>1</product>
</Topics>
<Topics>
<val>5</val>
<display>Finance</display>
<CompanyKey>1</CompanyKey>
<product>1</product>
</Topics>
And the following XSL
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xslaram name="listboxname" />
<xslaram name="mainTable" />
<xslaram name="subTable" />
<xsl:template match="/">
<xsl:call-template name="main" >
<xsl:with-param name="nodes" select="child::node()"/>
</xsl:call-template>
</xsl:template>
<xsl:template name="main">
<xslaram name="nodes"/>
<xsl:for-each select="$nodes">
<xsl:value-of select="parent::val"/>
<xsl:if test="val">
<xsl:value-of select="concat(val,'-')" />
</xsl:if>
<xsl:if test="display">
<xsl:value-of select="concat(display,'*')" />
</xsl:if>
<xsl:call-template name="main">
<xsl:with-param name="nodes" select="child::node()"/>
</xsl:call-template>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
The output is:
1-Labs *11-Maxa*13-Psychological*35-Finance*56-Managed Care (MSMs
Representative Only)*62-Namenda*22-Alzheimer's
Disease*23C8B03C9-44A0-4C9B-82E1-B2CD95FDC13A-Long-Term
Care*3C8B03C9-44A0-4C9B-82E1-B2CD95FDC13A652089A7-E8BC-42AB-BC75-833280A
B65AF-Managed
Care*652089A7-E8BC-42AB-BC75-833280AB65AF
For <xsl:value-of select="parent::val"/>
Why does it not print the val of the parent.
For e.g. for Finance it should print 1 (val of Products) why is is
printing 3, which is the val of Psychological
<root>
<Companies>
<Name>Labs</Name>
<display>Labs </display>
<val>1</val>
<Products>
<val>1</val>
<display>Maxa</display>
<CompanyKey>1</CompanyKey>
<Topics>
<val>3</val>
<display>Psychological</display>
<CompanyKey>1</CompanyKey>
<product>1</product>
</Topics>
<Topics>
<val>5</val>
<display>Finance</display>
<CompanyKey>1</CompanyKey>
<product>1</product>
</Topics>
And the following XSL
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xslaram name="listboxname" />
<xslaram name="mainTable" />
<xslaram name="subTable" />
<xsl:template match="/">
<xsl:call-template name="main" >
<xsl:with-param name="nodes" select="child::node()"/>
</xsl:call-template>
</xsl:template>
<xsl:template name="main">
<xslaram name="nodes"/>
<xsl:for-each select="$nodes">
<xsl:value-of select="parent::val"/>
<xsl:if test="val">
<xsl:value-of select="concat(val,'-')" />
</xsl:if>
<xsl:if test="display">
<xsl:value-of select="concat(display,'*')" />
</xsl:if>
<xsl:call-template name="main">
<xsl:with-param name="nodes" select="child::node()"/>
</xsl:call-template>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
The output is:
1-Labs *11-Maxa*13-Psychological*35-Finance*56-Managed Care (MSMs
Representative Only)*62-Namenda*22-Alzheimer's
Disease*23C8B03C9-44A0-4C9B-82E1-B2CD95FDC13A-Long-Term
Care*3C8B03C9-44A0-4C9B-82E1-B2CD95FDC13A652089A7-E8BC-42AB-BC75-833280A
B65AF-Managed
Care*652089A7-E8BC-42AB-BC75-833280AB65AF
For <xsl:value-of select="parent::val"/>
Why does it not print the val of the parent.
For e.g. for Finance it should print 1 (val of Products) why is is
printing 3, which is the val of Psychological