[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] streaming identity transformation


Subject: [xsl] streaming identity transformation
From: "Martin Honnen martin.honnen@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Sun, 25 Jan 2015 15:14:09 -0000

I am wondering how one would write the identity transformation template

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

in an XSLT 3.0 stylesheet supposed to work with streaming. The section http://www.w3.org/TR/xslt-30/#built-in-templates-shallow-copy in the XSLT 3.0 specification has a template

<xsl:template match="." mode="M">
  <xsl:copy validation="preserve">
    <xsl:apply-templates select="@*" mode="M"/>
    <xsl:apply-templates select="node()" mode="M"/>
  </xsl:copy>
</xsl:template>

and explains "A further reason for choosing this form is for streamability: this formulation is guaranteed-streamable".

However, when I try

<xsl:stylesheet version="3.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:xs="http://www.w3.org/2001/XMLSchema"
  exclude-result-prefixes="xs">

<xsl:mode streamable="yes"/>

<xsl:template match=".">
  <xsl:copy validation="preserve">
    <xsl:apply-templates select="@*"/>
    <xsl:apply-templates select="node()"/>
  </xsl:copy>
</xsl:template>

</xsl:stylesheet>

with Saxon 9.6 EE I get a compilation error saying:

Error at xsl:template on line 8 column 25 of test2015012505.xsl:
XTSE3430: Template rule is declared streamable but it does not satisfy the streamability rules.
* In a streaming apply-templates instruction, the select expression cannot select
ancestors or attributes (that is, it must not have climbing posture)


So how would one write a template doing a shallow copy and then processing any attribute and child nodes in a streaming way?


Current Thread
Keywords