Reputation: 86905
How can I add evaluation on a xslt property, and skip a for-each
node by condition of that evaluation?
<some>
<deep>
<level availability="10" code="A"/>
</deep>
</some>
<xsl:template match="some">
<xsl:for-each select="//deep//level">
<xsl:value-of select=".//@code, .//@availability" separator=";"/>
<xsl:for-each>
</xsl:template>
Question: how can I skip if availability < 5
?
Upvotes: 0
Views: 70
Reputation: 70648
Rather than thinking about "skipping" elements, think about what you want to select, and then put a condition for this in square brackets after the nodes you select
Try this template....
<xsl:template match="some">
<xsl:for-each select="deep/level[number(@availability) ge 5]">
<xsl:value-of select="@code, @availability" separator=";"/>
</xsl:for-each>
</xsl:template>
Note that //
will search all descendant nodes, not just the immediate child node, which I am not sure you need here.
Upvotes: 1