[Bug 13747] [XPath 3.0] Determinism of expressions returning constructed nodes

http://www.w3.org/Bugs/Public/show_bug.cgi?id=13747

--- Comment #4 from Vladimir Nesterovsky <vladimir@nesterovsky-bros.com> 2011-08-11 06:40:52 UTC ---
(In reply to comment #3)
> >This [t:copy-of()] MUST return a distinct nodes on each call.
> Can you show us a realistic application that fails if it doesn't? I.e., not an
> application whose sole purpose is to exploit the fact that it currently returns
> distinct nodes on each call?

This sample is based on real application:

<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:xs="http://www.w3.org/2001/XMLSchema"
  xmlns:t="http://www.nesterovsky-bros.com/xslt/public"
  exclude-result-prefixes="xs t">

  <xsl:output indent="yes"/>

  <xsl:variable name="input">
    <data>
      <block parts="a b c d"/>
      <block parts="c b"/>
      <block parts="d b"/>
    </data>
  </xsl:variable>

  <xsl:template match="/" name="main">
    <xsl:variable name="result">
      <result>
        <xsl:apply-templates mode="t:process" select="$input"/>
      </result>
    </xsl:variable>

    <xsl:message select="$result"/>

    <xsl:sequence select="$result"/>
  </xsl:template>

  <xsl:template mode="t:process" match="*">
    <xsl:copy>
      <xsl:sequence select="@*"/>
      <xsl:apply-templates mode="#current"/>
    </xsl:copy>
  </xsl:template>

  <xsl:template mode="t:process" match="block">
    <block>
      <xsl:for-each select="tokenize(@parts, '\s+')">
        <xsl:sequence select="t:generate-part(.)"/>
      </xsl:for-each>
    </block>
  </xsl:template>

  <xsl:function name="t:generate-part" as="element()">
    <xsl:param name="id" as="xs:string"/>

    <xsl:variable name="statements" as="element()+"
      select="t:get-statements-by-id($id)"/>

    <label id="{generate-id($statements[1])}">
      <xsl:sequence select="$statements"/>
    </label>
  </xsl:function>

  <xsl:function name="t:get-statements-by-id" as="element()">
    <xsl:param name="id" as="xs:string"/>

    <xsl:variable name="handler" as="element()">
      <xsl:element name="{$id}"/>
    </xsl:variable>

    <xsl:apply-templates mode="t:call" select="$handler"/>
  </xsl:function>

  <xsl:template mode="t:call" match="a">
    <scope>a statements ...</scope>
  </xsl:template>

  <xsl:template mode="t:call" match="b">
    <scope>b statements ...</scope>
  </xsl:template>

  <xsl:template mode="t:call" match="c">
    <scope>c statements ...</scope>
  </xsl:template>

  <xsl:template mode="t:call" match="d">
    <scope>d statements ...</scope>
  </xsl:template>

</xsl:stylesheet>

-- 
Configure bugmail: http://www.w3.org/Bugs/Public/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.

Received on Thursday, 11 August 2011 06:40:55 UTC