hope you can help me out. I'm searching for an generic XSLT match template that matches all Elements of a certain Name after to first occurance. In this example everything should be copied with an identity transform, the first occurance of "line" Needs "do something" logic and all "line" Elements after the first one should be ignored. "line" Elements can occure infinite times in theory.
Sample Source XML:
<?xml version="1.0" encoding="UTF-8"?>
<sampledoc>
<header1>a1</header1>
<header2>b1</header2>
<header3>c1</header3>
<line>a2</line>
<line>b2</line>
<line>c2</line>
<line>c3</line>
<line>c4</line>
<footer>bye</footer>
</sampledoc>
I would expect something like following::line[1]
but not get it to work. So this is my "static" Version:
<?xml version="1.0" encoding="UTF-8"?>
<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="*"/>
<xsl:template match="/">
<xsl:apply-templates select="@*|node()"/>
</xsl:template>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="line[1]">
<!-- Do something -->
</xsl:template>
<xsl:template match="line[2]"/>
<xsl:template match="line[3]"/>
<xsl:template match="line[4]"/>
<xsl:template match="line[5]"/>
<xsl:template match="line[6]"/>
<xsl:template match="line[7]"/>
</xsl:stylesheet>
Thanks!