W3C home > Mailing lists > Public > public-qt-comments@w3.org > June 2015

[Bug 28775] [XSLT30] Suggestion: prioritise templates with named modes over templates with mode="#all"

From: <bugzilla@jessica.w3.org>
Date: Sun, 07 Jun 2015 09:42:59 +0000
To: public-qt-comments@w3.org
Message-ID: <bug-28775-523-d43txVlMGS@http.www.w3.org/Bugs/Public/>
https://www.w3.org/Bugs/Public/show_bug.cgi?id=28775

--- Comment #2 from Tom Hillman <tomos.hillman@oup.com> ---
This teaches me for writing examples without testing them!

Here's a better example:

Input document:

<text>Only the text such as <element><b>Hello</b> World!</element> will be
output</text>

Stylesheet:

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

  <xsl:output method="text"/>

  <xsl:template match="text()" mode="text">
    <xsl:value-of select="."/>
  </xsl:template>

  <xsl:template match="node() | @*" mode="#all">
    <xsl:apply-templates select="node() | @*" mode="#current"/>
  </xsl:template>

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

</xsl:stylesheet>

Desired output:
Hello World!

In it's current format, the stylesheet doesn't work (Saxon throws a couple of
ambiguous match warnings).  The stylesheet does work if you specify the
priority on the first template.

You can also resolve the behaviour by moving the match template to the end of
the stylesheet, but this seems unreliable to me and still leaves the warnings.

It is a shame that the behaviour isn't backwards compatible, and I would
understand if that precludes any change; I still think that for the future it's
better to have a defined behaviour than relying on implementation choices.

-- 
You are receiving this mail because:
You are the QA Contact for the bug.
Received on Sunday, 7 June 2015 09:43:08 UTC

This archive was generated by hypermail 2.3.1 : Sunday, 7 June 2015 09:43:08 UTC