Reputation:
HI,
I want to select all nodes other than first node.My xsl and xml are like this but I am not getting the output for it.
<Categories>
<Category>
<Title>Business</Title>
</Category>
<Category>
<Title>Politics</Title>
</Category>
</Categories>
my xsl
<xsl:template match="Categories">
<xsl:variable name="restallTitles">
<xsl:value-of select="//*[position() > 1]"/>
</xsl:variable>
<xsl:for-each select="Categories/Category">
<xsl:if test="$restallTitles">
<xsl:choose>
<xsl:when test="position() mod 2 = 1">
<li class=""><xsl:value-of select="Title"/></li>
</xsl:when>
<xsl:otherwise>
<li class="odd"><xsl:value-of select="Title"/></li>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:for-each>
</xsl:template>
Its not showing any output ...anyone is having idea where i m getting wrong::
Edited:: I m expecting output "politics" in this case but basically i want all but the "Business"
Upvotes: 0
Views: 1126
Reputation: 338148
If you mean "all <Category>
s except the first in the document", then try:
<xsl:for-each select="(Categories/Category)[position() gt; 1]">
<li>
<xsl:if test="position() mod 2 = 1">
<xsl:attribute name="class">odd</xsl:attribute>
</xsl:if>
<a class="video video-lightbox ratio-16-9" href="{$url1}">
<xsl:value-of select="Title"/>
</a>
</li>
</xsl:for-each>
Upvotes: 1