theriom.com
This blog is mainly for me, a way of remembering things I've done; when I couldn't find an answer on Google, I wrote about it here. Hopefully, other people may find it helpful too.
XSL to re-number sequences

Say you have an XML file, some of the elementa have attributes with sequence numbers, and you want to re-number them all consecutively, try this XSL:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns1="http://www.opentravel.org/OTA/2003/05" exclude-result-prefixes="ns1" xmlns:r="urn:reservation.rqrs.datalex.com" >
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="@* | node()">
 <xsl:copy>
  <xsl:apply-templates select="@* | node()"/>
 </xsl:copy>
</xsl:template>

<xsl:template match="@Sequence">
 <xsl:attribute name="Sequence">
  <xsl:number from="/" level="any"/>
 </xsl:attribute>
</xsl:template>

</xsl:stylesheet>

Last modified on 2012-07-14