Nice demonstration and explanation.  Thanks.

On Wed, Aug 7, 2013 at 12:13 AM, Sebastian Rahtz <> wrote:
Consider this piece of XSL. it reports the position() of each text() node in a file.

    <xsl:template match="*">
            <xsl:apply-templates select="@*|node()"/>
    <xsl:template match="text()">
      <xsl:message><xsl:value-of select="(name(parent::*),position(),.)" separator="/"/></xsl:message>

if its run on this XML:

        <x><a rend="one"> stuff 1 </a><a> stuff 2 </a></x>

it produces

        a/2/ stuff 1
        a/1/ stuff 2

which shows that the value of position() varies according to whether or not there is an attribute present. Can that really
be right?

If I change the code to

          <xsl:apply-templates select="@*/>
          <xsl:apply-templates select="node()"/>

then the position() is show as 1 each time, as I would expect.

Am I misunderstanding what position() means?
Sebastian Rahtz
Get 100% visibility into Java/.NET code with AppDynamics Lite!
It's a free troubleshooting tool designed for production.
Get down to code-level detail for bottlenecks, with <2% overhead.
Download for free and get started troubleshooting in minutes.
saxon-help mailing list archived at