xsl-list
[Top] [All Lists]

[xsl] xsl:number from="/" level="any"

2007-03-09 04:42:47
This is in the context of xsl:number with @level="any".

Reading the XSLT 2.0 recommendation it looks like @from is allowed to be "/" to indicate a document node.

Yet I get empty sequences whenever I try it with Saxon 8.8.

I get the behaviour I expect with @from="/*".

Here's an example, which uses processing instructions to show a case where / has more than one child.

Document:
<?xml version="1.0" encoding="UTF-8"?>
<?thing?>
<top>
    <?thing?>
    <child>
        <?thing?>
        <child><?thing?></child>
    </child>
    <child>
        <?thing?>
    </child>
</top>
<?thing?>

Stylesheet:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="2.0">

    <xsl:template match="processing-instruction(thing)">
        <xsl:message>
            <xsl:text>This thing gets xsl:number "</xsl:text>
<xsl:number count="processing-instruction('thing')" from="/" level="any"/>
            <xsl:text>" from / and xsl:number "</xsl:text>
<xsl:number count="processing-instruction('thing')" from="/*" level="any"></xsl:number>
            <xsl:text>" from /*.</xsl:text>
        </xsl:message>
        <xsl:apply-templates></xsl:apply-templates>
    </xsl:template>
</xsl:stylesheet>

Output:
This thing gets xsl:number "" from / and xsl:number "" from /*.
This thing gets xsl:number "" from / and xsl:number "1" from /*.
This thing gets xsl:number "" from / and xsl:number "2" from /*.
This thing gets xsl:number "" from / and xsl:number "3" from /*.
This thing gets xsl:number "" from / and xsl:number "4" from /*.
This thing gets xsl:number "" from / and xsl:number "5" from /*.

--~------------------------------------------------------------------
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>
--~--

<Prev in Thread] Current Thread [Next in Thread>