R
R
Hello everybody.
I've got a problem with one loop.
Given XML:
<Types>
<Type><range>1</range><name>Gast</name></Type>
<Type><range>2</range><name>Rekt</name></Type>
<Type><range>2</range><name>Sigm</name></Type>
<!-- range is 1-6 -->
</Types>
I want to produce HTML output like this (grouped by range):
<li>Gast</li>
<li>Rekt, Sigm</li>
well I can produce the single <li> element for 'Gast and 'Rekt, Sigm'
output but I don't know how to iterate through all the 'range'
I did sth like:
1) produce <li> for range='1'
2) produce <li> for range='2'
....
6) produce <li> for range='6'
how to itrate through ranges from 1 to 6 automatically?
I know that ranges are sorted, there cannot be 5 before 2 etc.
this is my step-by-step version
<xsl:template match="Types" mode="searching">
<!-- do it for range='1' -->
<li>
<!-- variable needed for the comma -->
<xsl:variable name="last">
<xsl:value-of select="count(Type[./range='1'])"/></xsl:variable>
<xsl:for-each select="Type[./range='1']">
<xsl:value-of select="name"/>
<xsl:if test="$last != position()">, </xsl:if>
</xsl:for-each>
</li>
<li>
<xsl:variable name="last">
<xsl:value-of select="count(Type[./range='1'])"/></xsl:variable>
<xsl:for-each select="Type[./range='1']">
<xsl:value-of select="name"/>
<xsl:if test="$last != position()">, </xsl:if>
</xsl:for-each>
</li>
<!-- and for the rest of ranges 3, 4, 5, 6 the same -->
</xsl:template>
thanks for any help
best regards R
I've got a problem with one loop.
Given XML:
<Types>
<Type><range>1</range><name>Gast</name></Type>
<Type><range>2</range><name>Rekt</name></Type>
<Type><range>2</range><name>Sigm</name></Type>
<!-- range is 1-6 -->
</Types>
I want to produce HTML output like this (grouped by range):
<li>Gast</li>
<li>Rekt, Sigm</li>
well I can produce the single <li> element for 'Gast and 'Rekt, Sigm'
output but I don't know how to iterate through all the 'range'
I did sth like:
1) produce <li> for range='1'
2) produce <li> for range='2'
....
6) produce <li> for range='6'
how to itrate through ranges from 1 to 6 automatically?
I know that ranges are sorted, there cannot be 5 before 2 etc.
this is my step-by-step version
<xsl:template match="Types" mode="searching">
<!-- do it for range='1' -->
<li>
<!-- variable needed for the comma -->
<xsl:variable name="last">
<xsl:value-of select="count(Type[./range='1'])"/></xsl:variable>
<xsl:for-each select="Type[./range='1']">
<xsl:value-of select="name"/>
<xsl:if test="$last != position()">, </xsl:if>
</xsl:for-each>
</li>
<li>
<xsl:variable name="last">
<xsl:value-of select="count(Type[./range='1'])"/></xsl:variable>
<xsl:for-each select="Type[./range='1']">
<xsl:value-of select="name"/>
<xsl:if test="$last != position()">, </xsl:if>
</xsl:for-each>
</li>
<!-- and for the rest of ranges 3, 4, 5, 6 the same -->
</xsl:template>
thanks for any help
best regards R