xsl condition
Given this XML;
<Nodes>
<Node>
<Software id="A" version="1.2.3.4"/>
<Software id="B" version="2.2.3.4"/>
<Software id="C" version="3.2.3.4"/>
Trying to get version for Software with ID='a', doing this fails;
<xsl:for-each select="/Nodes/Node">
<xsl:value-of select="./Software[@id='A']/@version"/>
</xsl:for-each>
The two below work fine but are not specific enough (can fail if order is different)
<xsl:for-each select="/Nodes/Node">
<xsl:value-of select="./Software/@version"/>
</xsl:for-each>
//and
<xsl:for-each select="/Nodes/Node">
<xsl:value-of select="./Software[1]/@version"/>
</xsl:for-each>
Appreciate any input (apologise for any typo's - typed the example in by memory).
[931 byte] By [
laasunde] at [2007-11-20 6:36:37]

# 1 Re: xsl condition
this may not be the best solution.. but this will work...
Cheers
Venu
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:template match="Nodes">
<NodeDetails xmlns="http://tempuri.org">
<xsl:for-each select="/Nodes/Node/Software">
<xsl:if test="@id='B'">
<ver> <xsl:value-of select="@version"/> </ver>
</xsl:if>
</xsl:for-each>
</NodeDetails>
</xsl:template>
</xsl:stylesheet>
# 2 Re: xsl condition
Thanks for the reply.
This didn't work, nothing appears inbetween <ver>.
<xsl:for-each select="/Software">
<xsl:if test="@id='B'">
<ver> <xsl:value-of select="@version"/></ver>
</xsl:if>
</xsl:for-each>
However this works but obviously prints both versions. Is there anything special regarding the equals operation?
<xsl:for-each select="/Software">
<xsl:if test="@id">
<ver> <xsl:value-of select="@version"/></ver>
</xsl:if>
</xsl:for-each>
Using Winxp sp2, .NET 1.1 and IIS 5.1