Is it possible to make the expression variable and still to retrieve the content of a node?
example:
xml file1 need to be transformed to another xml file2.
file1 contains a repeating part (messagedetail)
<code>
<messagedetail>
<LITNOrder_qty_1>0</LITNOrder_qty_1>
<LITNOrder_qty_2>0</LITNOrder_qty_2>
</messagedetail>
...
</code>
file2 should be of the form:
<code>
<schedule>
<Qty Commit="4" Freq="T" New="0" />
<Qty Commit="4" Freq="T" New="0" />
</schedule>
...
</code>
The xsl file does this as followed:
<code>
<schedule>
<Qty Commit="4" Freq="T">
<xsl:attribute name="New">
<xsl:value-of select="LITNOrder_qty_1"/>
</xsl:attribute>
</schedule>
...
</code>
The value of the select expression is fixed, although it would be more interesting when it was variable. (in this case the qty number is from 1 to 12) I tried using the concat function and some looping resulting in following code
<code>
<xsl:call-template name="retrieve_schedule">
<xsl:with-param name="count" select="1"/>
</xsl:call-template>
<xsl:template name="retrieve_schedule">
<xslaram name="count"/>
<xsl:if test="$count < 3">
<Qty Commit="4" Freq="T">
<xsl:attribute name="New">
<xsl:value-of select="concat('LITNOrder_qty_',$count)"/>
</xsl:attribute>
</Qty>
<xsl:call-template name="retrieve_schedule">
<xsl:with-param name="count" select="$count + 1"/>
</xsl:call-template>
<xsl:if
</xsl:template>
</code>
Unfortunately, the result was not the expected qty, but the name of the field.
<code>
<schedule>
<Qty Commit="4" Freq="T" New="LITNOrder_qty_1" />
<Qty Commit="4" Freq="T" New="LITNOrder_qty_2" />
</schedule>
...
</code>
Placing the concatination in a variable and calling this variable gives the same wrong result.
Any suggestions would be welcome
example:
xml file1 need to be transformed to another xml file2.
file1 contains a repeating part (messagedetail)
<code>
<messagedetail>
<LITNOrder_qty_1>0</LITNOrder_qty_1>
<LITNOrder_qty_2>0</LITNOrder_qty_2>
</messagedetail>
...
</code>
file2 should be of the form:
<code>
<schedule>
<Qty Commit="4" Freq="T" New="0" />
<Qty Commit="4" Freq="T" New="0" />
</schedule>
...
</code>
The xsl file does this as followed:
<code>
<schedule>
<Qty Commit="4" Freq="T">
<xsl:attribute name="New">
<xsl:value-of select="LITNOrder_qty_1"/>
</xsl:attribute>
</schedule>
...
</code>
The value of the select expression is fixed, although it would be more interesting when it was variable. (in this case the qty number is from 1 to 12) I tried using the concat function and some looping resulting in following code
<code>
<xsl:call-template name="retrieve_schedule">
<xsl:with-param name="count" select="1"/>
</xsl:call-template>
<xsl:template name="retrieve_schedule">
<xslaram name="count"/>
<xsl:if test="$count < 3">
<Qty Commit="4" Freq="T">
<xsl:attribute name="New">
<xsl:value-of select="concat('LITNOrder_qty_',$count)"/>
</xsl:attribute>
</Qty>
<xsl:call-template name="retrieve_schedule">
<xsl:with-param name="count" select="$count + 1"/>
</xsl:call-template>
<xsl:if
</xsl:template>
</code>
Unfortunately, the result was not the expected qty, but the name of the field.
<code>
<schedule>
<Qty Commit="4" Freq="T" New="LITNOrder_qty_1" />
<Qty Commit="4" Freq="T" New="LITNOrder_qty_2" />
</schedule>
...
</code>
Placing the concatination in a variable and calling this variable gives the same wrong result.
Any suggestions would be welcome