Hi need some help in XSLT formatting for creating a sequence number for Element tag. Mostly Element tag misses some numbers in sequence and i need to get an output in a sequential format as shown below by adding missing numbers to Element tag in the same sequence of Seat tag.
Any help in this is much appreciated, thanks in advance.
Input
<book>
<Seat>
<seatNumber>12A</seatNumber>
<Element>1</Element>
<Number>1</Number>
</Seat>
<Seat>
<seatNumber>12B</seatNumber>
<Element>3</Element>
<Number>1</Number>
</Seat>
<Seat>
<seatNumber>12C</seatNumber>
<Element>4</Element>
<Number>1</Number>
</Seat>
<Seat>
<seatNumber>12D</seatNumber>
<Element>5</Element>
<Number>1</Number>
</Seat>
<Seat>
<seatNumber>12E</seatNumber>
<Element>7</Element>
<Number>1</Number>
</Seat>
</book>
Output
<book>
<Seat>
<seatNumber>12A</seatNumber>
<Element>1</Element>
<Number>1</Number>
</Seat>
<Seat>
<seatNumber>12B</seatNumber>
<Element>2</Element>
<Number>1</Number>
</Seat>
<Seat>
<seatNumber>12C</seatNumber>
<Element>3</Element>
<Number>1</Number>
</Seat>
<Seat>
<seatNumber>12D</seatNumber>
<Element>4</Element>
<Number>1</Number>
</Seat>
<Seat>
<seatNumber>12E</seatNumber>
<Element>5</Element>
<Number>1</Number>
</Seat>
</book>
Try it this way:
XSLT 1.0
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:strip-space elements="*"/>
<!-- identity transform -->
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="Element">
<xsl:copy>
<xsl:number count="Seat"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>