Hi I would like to know how in XSLT to select the QTY into a variable and the use that to repeat the GIR, that number of times?
e.g. if QTY 12 need to repeat GIR 12 times


<QTY>
<QTY01-QuantityDetails>
<QTY0101-QuantityQualifier>1</QTY0101-QuantityQualifier>
<QTY0102-Quantity>
<xsl:value-of select="QTY"/>
</QTY0102-Quantity>
</QTY01-QuantityDetails>
</QTY>
<GIR>
<GIR01-SetIdentificationQualifier/>
<GIR02-IdentificationNumber>xxxx
<GIR0201-IdentityNumber>
<xsl:value-of select="GIRLLO"/>
</GIR0201-IdentityNumber>
</GIR02-IdentificationNumber>
</GIR>
<GROUP_31>

If you are using XSLT 1.0, use recursive method to solve this. And example stylesheet is below.

<xsl:template match="a">
<xsl:copy-of select="QTY"/>
<xsl:call-template name="test">
<xsl:with-param name="s" select="QTY//QTY0101-QuantityQualifier"/>
</xsl:call-template>
</xsl:template>

<xsl:template name="test">
<xsl:param name="s"/>
<xsl:choose>
<xsl:when test="$s &gt; 1">
<xsl:copy-of select="//GIR"/>
<xsl:call-template name="test">
<xsl:with-param name="s" select="$s - 1"></xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="//GIR"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.