Subject: sequential numbering in xslt
From: a kusa <akusa8@xxxxxxxxx>
Date: Sun, 3 Jan 2010 14:41:45 -0600
|
Hi:
I cannot post the input , output and XSLT since they are too big and
complicated, So I apologize and will try to explain my problem
conceptually.
I have a number of XML files as input, and I transform them into
another XML format using XSLT. The output XML file has a schema and
has a required 'seq' attribute in the root element that needs to be
incremented for each input XML file.
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?
Please advise on any other approach.
Thanks in advance.
|