xsl-list
[Top] [All Lists]

[xsl] XSLT 3.0: Are modes containing only templates that match a node?

2014-12-21 13:21:46
In section "6.6 Modes" of the 2nd Last Call of the W3C XSLT 3.0
specification (http://www.w3.org/TR/2014/WD-xslt-30-20141002/#modes)
we read:

 "[Definition:  Modes allow a node in a source tree to be processed
multiple times, each time producing a different result. They also
allow different sets of template rules to be active when processing
different trees, for example when processing documents loaded using
the document function (see 20.1 fn:document) or when processing
temporary trees".



This is true, but the definition mentions only processing "a node" and
leaves out the fact that a mode may contain templates that match an
atomic item or a function.

In the whole text throughout this section, only processing of nodes is
mentioned and this leaves the perception that it isn't allowed for a
mode to contain templates that match non-node items.

In case this perception is sound, the specification should explicitly
say so, in order to eliminate the currently arising confusion and
questions like this one.

I verified that actually a template that matches an atomic item can be
part of a mode  --  for example the following transformation runs
without a problem and produces the expected, correct result.

In case templates matching a non-node item are allowed as part of a
mode, then the current text of section 6.6 can be improved, by
explicitly acknowledging this fact, and replacing any generic
mentioning of "node" with "item".

<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
  xmlns:xs="http://www.w3.org/2001/XMLSchema"; expand-text="yes">
  <xsl:output method="text"/>

  <xsl:variable name="vNums" select="1 to 10"/>

  <xsl:template match="/">
    <xsl:apply-templates select="$vNums" mode="squares"/>
    <xsl:text>&#xA;</xsl:text>
    <xsl:apply-templates select="$vNums" mode="cubes"/>
  </xsl:template>

  <xsl:template match=".[. instance of xs:integer]" mode="squares">
    <xsl:sequence select=". * ."/>
  </xsl:template>

  <xsl:template match=".[. instance of xs:integer]" mode="cubes">
    <xsl:sequence select=". * . * ."/>
  </xsl:template>
</xsl:stylesheet>


-- 
Cheers,
Dimitre Novatchev
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--

<Prev in Thread] Current Thread [Next in Thread>
  • [xsl] XSLT 3.0: Are modes containing only templates that match a node?, Dimitre Novatchev dnovatchev(_at_)gmail(_dot_)com <=