|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Following-sibling - question
Your suggested input is not well formed, and one of the entries changes
from 2 to 4 and no indication is given about where teh extra entry is
added, in your example it is added in position 1,2,4 is this powers of 2?
anyway the following adds the element in positions 1,2,3 producing the
following once the input is made well formed.
<table>
<tbody>
<row>
<entry>1</entry>
<entry>2</entry>
</row>
<row>
<entry>Added</entry>
<entry>3</entry>
<entry>2</entry>
</row>
<row>
<entry>4</entry>
<entry>Added</entry>
<entry>2</entry>
</row>
<row>
<entry>5</entry>
<entry>2</entry>
<entry>Added</entry>
<entry>2</entry>
</row>
<row>
<entry>6</entry>
</row>
</tbody>
</table>
David
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:strip-space elements="tbody row"/>
<xsl:param name="n" select="3"/>
<xsl:output indent="yes"/>
<xsl:template match="*|node()">
<xsl:copy>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
<xsl:template match="row">
<xsl:copy>
<xsl:variable name="r" select="position()"/>
<xsl:apply-templates select="entry">
<xsl:with-param name="r" select="$r"/>
</xsl:apply-templates>
</xsl:copy></xsl:template>
<xsl:template match="entry">
<xsl:param name="r"/>
<xsl:variable name="e" select="position()"/>
<xsl:if test="$r - 2 lt $n and $e = $r - 1">
<entry>Added</entry>
</xsl:if>
<xsl:copy-of select="."/>
</xsl:template>
</xsl:stylesheet>
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








