You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xalan.apache.org by "Mikael Petterson (KI/EAB)" <mi...@ericsson.com> on 2006/02/08 16:26:35 UTC

Counter in xsl with xalan

Hi,

Since there is no counter in xsl that is, where I can increment a number
( independent) of nodes.

I am using xalan to generate the following code:

new String [] {"eAgchCodes_name0",
"eAgchCodes_name1",..."eAgchCodes_name3"}

This is how the xml looks like:

<structMember name="eAgchCodes">
            <description>One to four codes.
            </description>
            <sequence>
                <long>
                    <range>
                        <min>0</min> <max>255</max>
                    </range>
                </long>
                <maxLength>4</maxLength>
            </sequence>
 </structMember>

In order to generate the names I need a counter to increase each time
until all four strings have been generated.
Any ideas how I can do that with Xalan-Java? Extensions?

cheers,

//mikael

RE: Counter in xsl with xalan

Posted by Steve Carton <st...@chesbay.net>.
Use recursion, passing the current count to a named template and
incrementing it.


  _____  

From: Mikael Petterson (KI/EAB) [mailto:mikael.petterson@ericsson.com] 
Sent: Wednesday, February 08, 2006 10:27 AM
To: xalan-j-users@xml.apache.org
Subject: Counter in xsl with xalan



Hi, 

Since there is no counter in xsl that is, where I can increment a number (
independent) of nodes. 

I am using xalan to generate the following code: 

new String [] {"eAgchCodes_name0", "eAgchCodes_name1",."eAgchCodes_name3"} 

This is how the xml looks like: 

<structMember name="eAgchCodes"> 
            <description>One to four codes. 
            </description> 
            <sequence> 
                <long> 
                    <range> 
                        <min>0</min> <max>255</max> 
                    </range> 
                </long> 
                <maxLength>4</maxLength> 
            </sequence> 
 </structMember> 

In order to generate the names I need a counter to increase each time until
all four strings have been generated. 
Any ideas how I can do that with Xalan-Java? Extensions? 

cheers, 

//mikael