We have fixed this problem as part of the resolution of this bug:
https://www.w3.org/Bugs/Public/show_bug.cgi?id=27051
Sorry, but the discussion contains a number of links to member-only email
archives.
Abel pointed out in the bug report that we had made unintentional changes with
the consequence that <xsl:apply-templates select="@*"/> was no longer
streamable. The fix we adopted changes the posture of the expression @* from
climbing to striding. Saxon 9.6 implements the "unintentional changes".
Of course, in XSLT 3.0 you no longer need the identity template. You can
instead write
<xsl:mode on-no-match="shallow-copy"/>
A workaround for Saxon 9.6 is to apply-templates to copies of attributes made
using copy-of().
Michael Kay
Saxonica
mike@xxxxxxxxxxxx
+44 (0) 118 946 5893
On 25 Jan 2015, at 15:14, Martin Honnen martin.honnen@xxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
>
> 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?
|