Confusing incrementation

  • Thread starter Petterson Mikael
  • Start date
P

Petterson Mikael

Hi,

I am generating code using xsl. I have two templates for that. One for
the name and one for the value ( these are pairs). I have checked that
maxCount is the same for both ( e.g. 4) but I get something like:

from template for names:

<sequencename>_name0
<sequencename>_name1
<sequencename>_name2
<sequencename>_name3

from template for values:

<sequencename>_value[0]
<sequencename>_value[1]
<sequencename>_value[2]
<sequencename>_value[3]
<sequencename>_value[4]

Anyone that can see why?

cheers,

//mikael

Template for names:
===================
<!-- Template that create "<sequencename>_name0", "<sequencename>_name1"..:
super(new String[] {
"scramblingCode", "noOfEAgchCodes", "eAgchCodes_name_0",
"eAgchCodes_name_1", "eAgchCodes_name_2",
"eAgchCodes_name_3", "noOfEHichERgchCodes",
"eHichERgchCodes_name_0", "eHichERgchCodes_name_1",
"eHichERgchCodes_name_2", "eHichERgchCodes_name_3",
"eulMaxTargetRtwp"
}-->
<xsl:template name="sequenceNameString">
<xsl:param name="sequenceName"/>
<xsl:param name="maxCount"/>
<xsl:param name="value"/>
<!--<xsl:param name="arrayMax" select="$maxCount"/>-->
<!--<xsl:if test="$value &lt;= $arrayMax">-->
<xsl:if test="$value &lt;= $maxCount">
<xsl:text>"</xsl:text>
<xsl:value-of select="concat(concat($sequenceName,'_name_'),$value)"/>
<xsl:text>"</xsl:text>
<!--<xsl:if test="$value != $arrayMax">-->
<xsl:if test="$value != $maxCount">
<xsl:text>,</xsl:text>
</xsl:if>
<xsl:call-template name="sequenceNameString">
<xsl:with-param name="value" select="$value + 1"/>
<xsl:with-param name="sequenceName" select="$sequenceName"/>
<xsl:with-param name="maxCount" select="$maxCount"/>
</xsl:call-template>
</xsl:if>
</xsl:template>

Template for value:
===================
<xsl:template name="sequenceValueObject">
<xsl:param name="sequenceName"/>
<xsl:param name="maxCount"/>
<xsl:param name="dataType"/>
<xsl:param name="value"/>
<xsl:if test="$value &lt;= $maxCount">
<xsl:choose>
<xsl:when test="$dataType = 'long'">
<xsl:text>new Integer</xsl:text>
</xsl:when>
<xsl:when test="$dataType = 'boolean'">
<xsl:text>new Boolean</xsl:text>
</xsl:when>
<xsl:when test="$dataType = 'string'">
<xsl:text>new String</xsl:text>
</xsl:when>
<xsl:when test="$dataType = 'longlong'">
<xsl:text>new Long</xsl:text>
</xsl:when>
<xsl:eek:therwise><xsl:call-template name="notImplemented">
<xsl:with-param name="sequnceName" select="$sequenceName"/>
<xsl:with-param name="error" select="$dataType"/>
</xsl:call-template></xsl:eek:therwise>

</xsl:choose>
<xsl:text>(</xsl:text>
<xsl:value-of select="concat($sequenceName,concat('_value [',$value))"/>
<xsl:text>])</xsl:text>
<xsl:if test="$value != $maxCount">
<xsl:text>,</xsl:text>
</xsl:if>
<xsl:call-template name="sequenceValueObject">
<xsl:with-param name="sequenceName" select="$sequenceName"/>
<xsl:with-param name="value" select="$value + 1"/>
<xsl:with-param name="maxCount" select="$maxCount"/>
<xsl:with-param name="dataType" select="$dataType"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,705
Latest member
Stefkari24

Latest Threads

Top