Subject: [xsl] incrementing the index value From: Arulraj <p_arulraj@xxxxxxxxx> Date: Thu, 9 Jun 2005 05:42:06 -0700 (PDT) |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Processing Efficiently, tomas.vanek | Thread | Re: [xsl] incrementing the index va, David Carlisle |
Re: [xsl] Functions as data types w, Mukul Gandhi | Date | RE: [xsl] Weird XPath evaluation di, Michael Kay |
Month |