Nice demonstration and explanation.  Thanks.


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

<xsl:stylesheet
  version="2.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="*">
        <xsl:copy>
            <xsl:apply-templates select="@*|node()"/>
        </xsl:copy>
    </xsl:template>
    <xsl:template match="text()">
      <xsl:message><xsl:value-of select="(name(parent::*),position(),.)" separator="/"/></xsl:message>
    </xsl:template>
</xsl:stylesheet>

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.
http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
saxon-help@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/saxon-help