0

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>

2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by msbalaji
0

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>

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.