Subject: Re: [xsl] sequential numbering in xslt From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Sun, 03 Jan 2010 15:48:55 -0500 |
I have a number of XML files as input, and I transform them into another XML format using XSLT. ... So, for example, if I had 5 input xml files a.xml, b.xml, c.xml, d.xml, e.xml, and I transformed them into Aout.xml, Bout.xml, Cout.xml, Dout.xml and Eout.xml ,
the output of which looks something like below: Output XML:
<car seq="1"> <req>....<req>
<body id="c1">
</body>
</car>
for every input file, in the transformation, I want to increment attribute 'seq' in the output file by 1 when I transform the input files using xslt.
I have tried <xsl:number>
and tried writing a function. But the problem is that since variables in xslt are constants, there is no way to increment a number, store it in a temp variable and increment it for the next time in xslt 2.0 unlike procedural languages like C or C++.
Is there any other way of achieving this in XSLT 2.0?
<xsl:for-each select="('a.xml','b.xml','c.xml','d.xml','e.xml')"> <xsl:result-document href="{replace(.,'\.','out.')}"> <car seq="{position()}"> <xsl:apply-templates select="doc(.)"/> ...
<xsl:for-each select="('a.xml','b.xml','c.xml','d.xml','e.xml')"> <xsl:variable name="seq" select="position()"/> <xsl:result-document href="{replace(.,'\.','out.')}"> <xsl:for=each select="doc(.)"> <car seq="{$seq}"> ...
-- UBL and Code List training: Copenhagen, Denmark 2010-02-08/10 XSLT/XQuery/XPath training after http://XMLPrague.cz 2010-03-15/19 XSLT/XQuery/XPath training: San Carlos, California 2010-04-26/30 Vote for your XML training: http://www.CraneSoftwrights.com/s/i/ Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video Video lesson: http://www.youtube.com/watch?v=PrNjJCh7Ppg&fmt=18 Video overview: http://www.youtube.com/watch?v=VTiodiij6gE&fmt=18 G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Male Cancer Awareness Nov'07 http://www.CraneSoftwrights.com/s/bc Legal business disclaimers: http://www.CraneSoftwrights.com/legal
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] sequential numbering in xslt, a kusa | Thread | Re: [xsl] sequential numbering in x, a kusa |
[xsl] sequential numbering in xslt, a kusa | Date | Re: [xsl] Modern web site design wi, Michael Dykman |
Month |