xsl-list
[Top] [All Lists]

incrementing the index value

2005-06-09 05:42:06
Hi,

I have a problem in incrementing the variable values.
Please suggest me the solution for this problem..

I have following XML file.
----------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<Layout>
        <Box>
                <textbox id="textbox">
                        <value/>
                </textbox>
                <label name="LabelField1">
                        <value>Label field1</value>
                </label>
                <textbox id="textbox1">
                        <value/>
                </textbox>
                <label name="LabelField">
                        <value>Label field</value>
                </label>
        </Box>
        <Box>
                <textbox id="TextBox2">
                        <value/>
                </textbox>
                <textbox id="TextBox3">
                        <value/>
                </textbox>
                <label name="LabelField3">
                        <value>Rajan</value>
                </label>
                <label name="LabelField2" >
                        <value>Arul</value>
                </label>
        </Box>

</Layout>

I am using following XSL
-----------------------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
xmlns:xalan="http://xml.apache.org/xslt";>
<xsl:output method="xml" indent="yes"
xalan:indent-amount="4"/>


<xsl:template match="Layout">
<taborder>
<fieldlist>
        <xsl:for-each select="child::*">
                <xsl:choose>
                        <xsl:when test="self::Box">
                                <xsl:call-template name="getintoBox"/>
                        </xsl:when>
                </xsl:choose>
        </xsl:for-each>
</fieldlist>    
</taborder>     
</xsl:template>

<xsl:template name="getintoBox">
        <xsl:for-each select="child::*">
                <xsl:choose>
                        <xsl:when test="self::textbox">
                                <xsl:call-template name="GetTextboxProperty"/>
                        </xsl:when>
                </xsl:choose>
                
        </xsl:for-each>
</xsl:template>

<xsl:template name="GetTextboxProperty">

<field name="{(_at_)id}" tabindex="{position()}"/>
</xsl:template>
</xsl:stylesheet>


I am getting the following output
------------------------------------

<?xml version="1.0" encoding="UTF-8"?>
<taborder>
    <fieldlist>
        <field tabindex="1" name="TextBox"/>
        <field tabindex="3" name="TextBox1"/>
        <field tabindex="1" name="TextBox2"/>
        <field tabindex="2" name="TextBox3"/>
    </fieldlist>
</taborder>

But i want to generate following output like

------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<taborder>
    <fieldlist>
        <field tabindex="1" name="TextBox"/>
        <field tabindex="2" name="TextBox1"/>
        <field tabindex="3" name="TextBox2"/>
        <field tabindex="4" name="TextBox3"/>
    </fieldlist>
</taborder>

I want to use the variable and incretment the count. 
How to do this? please give me the suggestion

Thanks in advance

Regards,
Arul




__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--