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

[Bug 28888] New: [xslt 3.0] xsl:on-empty with xsl:value-of

From: <bugzilla@jessica.w3.org>
Date: Fri, 03 Jul 2015 09:23:19 +0000
To: public-qt-comments@w3.org
Message-ID: <bug-28888-523@http.www.w3.org/Bugs/Public/>

            Bug ID: 28888
           Summary: [xslt 3.0] xsl:on-empty with xsl:value-of
           Product: XPath / XQuery / XSLT
           Version: Last Call drafts
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: XSLT 3.0
          Assignee: mike@saxonica.com
          Reporter: mike@saxonica.com
        QA Contact: public-qt-comments@w3.org

Given the following:

  <xsl:value-of select="@href"/>
  <xsl:on-empty select="'(no link)'"/>

users might find it surprising that if there is no @href attribute, the result
will be the empty element <a/>. The reason is that in this situation the result
of the xsl:value-of instruction is a text node whose string value is zero
length; it is not an empty sequence. Therefore as far as xsl:on-empty is
concerned, the result of the sequence constructor is non-empty.

Zero-length text nodes are ignored in the rules for constructing complex
content (e.g. the content of the a element) but they are not ignored for the
purposes of xsl:on-empty.

It's complicated by the fact that zero-length text nodes are not ignored
everywhere, e.g in the body of xsl:variable or xsl:function:

<xsl:variable name="x" as="item()*">
  <xsl:value-of select="@href"/>
  <xsl:on-empty select="'(no link)'"/>

Simply changing the rule so that xsl:on-empty ignores zero-length text nodes
gives streamability problems with, for example,

<xsl:variable name="x" as="item()*">
  <xsl:on-empty select="'(no link)'"/>
  <xsl:value-of select="@href"/>
  <xsl:value-of select="@href"/>
  <xsl:value-of select="a"/>

where the result of on-empty needs to be inserted into the result sequence
before the three zero-length text nodes, but we can't evaluate it until the

There is a workaround, which is to write

    <xsl:value-of select="@href"/>
  <xsl:on-empty select="'(no link)'"/>

but it's not pretty.

You are receiving this mail because:
You are the QA Contact for the bug.
Received on Friday, 3 July 2015 09:23:22 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 16:57:55 UTC