I'm trying to use XSLT to print a barcode label a specific number of times based on the value of an XML tag that's being passed to it. For example, if the XML has a Quantity value of 10, I'd like to apply the template multiple times so that a barcode is created for each item.
At the moment, I already have things working to where it'll print out a single tag, but I'm getting stuck trying to sort out how to get it to apply multiple times based off of the XML.
Below is the latest bit I tried; I was attempting to set a variable based on the XML and then loop based on the variable. My understanding is that there are ways to apply a template based on the number of matching nodes in an XML file, but since each XML file would just have one Quantity node in this case, I don't think that method will work.
I apologize that I'm likely doing quite a bit wrong here; I'm fairly new to XSLT. Any help is greatly appreciated!
<xsl:template match="//Order/OrderLine">
<xsl:param name="var" select="..//Order/OrderLine/Product/Properties/Quantity/"/>
<xsl:if test="$var > 0">
<!-- code to create barcode label would be here-->
<xsl:value-of select="$var"/>
<xsl:call-template name="//Order/OrderLine">
<xsl:with-param name="var" select="$var - 1"/>
</xsl:call-template>
</xsl:if>
</xsl:template>