Hi
I am trying to count nodes after a certain node and am having
difficulties with it.
Here is my snippet:
<level1>
<item>Sample</item>
<level2>
<item>Sample</item>
<product>sample prod1</product>
<product>sample prod2</product>
<product>sample prod3</product>
<level3>
<item>Sample</item>
<item>Sample</item>
</level3>
</level2>
<level1>
So I am trying to count all 'product elements after <item> in the
template level2.
Here is a part of my xslt.
<xsl:template match="level2">
<xsl:if
test="following-sibling::*[1][self::product[preceding-sibling::*[1][self::item]
and following-sibling::*[self::product[(position()=last()) and
not(string(following-sibling::*[1]))]]]]">
<xsl:variable name="count"
select="count(./following-sibling::product[position()!=last()])"/>
<xsl:if test="$count>= 1">
<xsl:apply-templates
select="./following-sibling::product[position() < $count]"/>
</xsl:if>
</xsl:if>
</xsl:template>
I am trying to find out if there is more than one 'product' after
<item> and if that occurs at the end of <item> just before <level3>
starts. The transformation is a lot more complicated than just this,
since these are all nested levels and this kind of structure can occur
in an another <level3> element down the node tree.
After I check that, I count the product elements and transform them.
But when I use ./following-sibling::product[position() < $count],
it only shows 1 product element.
How do I count all the product elements and display until the last one?
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--