|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Updated XSL support in IE5?
> They aren't precisely equivalent (affects position() and last()) but near
> enough for most purposes.
and for almost all the times when they are not equivalent you can use
the following technique to get position() and last() right.
(this fails if the original context was not in document order, and there
are not enough nodes in document order to construct lists of the
required length before and after the current node.)
David
<x>
<b id="a">
<c/>
<c/>
<c/>
</b>
<b id="b">
<c/>
<c/>
<c/>
<c/>
<c/>
</b>
<b id="c">
<c/>
<z/>
<c/>
<z/>
<c/>
<z/>
<c/>
</b>
</x>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
>
<xsl:output method="xml" indent="yes"/>
<xsl:template match="c"
>[<xsl:call-template name="test"/>], [<xsl:apply-templates
select="." mode="test"/>], [<xsl:text/>
<xsl:call-template name="testp"/>], [<xsl:text/>
<xsl:variable name="p" select="position()"/>
<xsl:variable name="x" select="1 + last() - $p"/>
<xsl:apply-templates
select="preceding::node()[position() < $p] |
. |
following::node()[position() < $x]"
mode="testp">
<xsl:with-param name="p" select="position()"/>
</xsl:apply-templates>], <xsl:text/>.
</xsl:template>
<xsl:template match="text()"/>
<xsl:template match="text()" mode="test"/>
<xsl:template match="text()" mode="testp"/>
<xsl:template match="*" name="test" mode="test">
<xsl:value-of select="concat(position(),' of ',last())"/>
</xsl:template>
<xsl:template match="*" name="testp" mode="testp">
<xsl:param name="p" select="position()"/>
<xsl:if test="$p=position()">
<xsl:value-of select="concat(position(),' of ',last())"/>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
Note that position() of last() is correct in the fourth column, but not
in the second.
bash-2.01$ xt named.xml named.xsl
<?xml version="1.0" encoding="utf-8"?>
[2 of 7], [1 of 1], [2 of 7], [2 of 7], .
[4 of 7], [1 of 1], [4 of 7], [4 of 7], .
[6 of 7], [1 of 1], [6 of 7], [6 of 7], .
[2 of 11], [1 of 1], [2 of 11], [2 of 11], .
[4 of 11], [1 of 1], [4 of 11], [4 of 11], .
[6 of 11], [1 of 1], [6 of 11], [6 of 11], .
[8 of 11], [1 of 1], [8 of 11], [8 of 11], .
[10 of 11], [1 of 1], [10 of 11], [10 of 11], .
[2 of 15], [1 of 1], [2 of 15], [2 of 15], .
[6 of 15], [1 of 1], [6 of 15], [6 of 15], .
[10 of 15], [1 of 1], [10 of 15], [10 of 15], .
[14 of 15], [1 of 1], [14 of 15], [14 of 15], .
bash-2.01$
On the other hand on the microsoft newsgroup it was indicated that named
templates would be arriving `within weeks'
David
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
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








