Erwan AMOUREUX wrote:
I frequently use this with msmxl or altova engine.
In that case, it's a 'default' position() by parent node , using the xml tree
entirely .
Well the XSLT 2.0 specification at least is clear about that, see
http://www.w3.org/TR/xslt20/#key which says "When the key specifier of
that xsl:key declaration is evaluated with a singleton focus based on
$N". Singleton focus means "A singleton focus based on a node N has the
context item (and therefore the context node) set to N, and the context
position and context size both set to 1".
I am sure some months ago I filed a bug on the AltovaXML Tools engine
and at least their XSLT 2.0 engine in the version "AltovaXML Community
Edition Version 2011" correctly implements that by now. So with the XML
input being
<root>
<foo>1</foo>
<foo>2</foo>
</root>
and the stylesheet being
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="2.0">
<xsl:output method="text"/>
<xsl:key name="context-position" match="foo" use="position()"/>
<xsl:key name="context-size" match="foo" use="last()"/>
<xsl:template match="/">
<xsl:value-of select="count(key('context-position', 1)),
count(key('context-size', 1))" separator=" "/>
</xsl:template>
</xsl:stylesheet>
the result is
2
2
with both Saxon 9.2 and the AltovaXML Tools engine with the version
named above.
--
Martin Honnen
http://msmvps.com/blogs/martin_honnen/
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--