[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

incrementing the index value

Subject: incrementing the index value
From: Arulraj <p_arulraj@xxxxxxxxx>
Date: Thu, 9 Jun 2005 05:42:06 -0700 (PDT)
index value
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="{@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 

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.