W3C home > Mailing lists > Public > xsl-editors@w3.org > July to September 1999

Re: empty string as empty node-set: why not?

From: James Clark <jjc@jclark.com>
Date: Wed, 15 Sep 1999 21:19:19 +0700
Message-ID: <37DFAAE7.DFEB00F6@jclark.com>
To: Mike Brown <mbrown@netignite.com>
CC: "'xsl-editors@w3.org'" <xsl-editors@w3.org>
Mike Brown wrote:

> Per section 11.2 of the XSLT draft, "If the variable-binding element has
> empty content and does not have a select attribute, then the value of the
> variable is an empty string."
> 
> So, if I were to do this:
> 
>         <xsl:call-template name="do_something">
>                 <!-- not passing a parameter "foo" -->
>         </xsl:call-template>
> 
>         <xsl:template name="do_something">
>             <xsl:param name="foo"/>
>             <!-- I wish $foo were a node-set -->
>             <xsl:if test="$foo/SomeChildren">I see SomeChildren</xsl:if>
>         </xsl:template>
> 
> ...I would be committing a crime because $foo is a string at this point (an
> empty string), not a node-set, and nothing can be converted to a node-set,
> per section 3.3 of the XPath draft.
> 
> I can work around this a couple of ways:
> 
> 1. A default value for the parameter can be fudged to be an empty
> node-set...
> 
>         <xsl:param name="foo" select="/nonexistent/path"/>
> 
> This is ugly and /nonexistent/path could conceivably return a non-empty
> node-set, unless one imposes a restriction on source trees to never contain
> nodes that would match that pattern.

This was discussed at an XSL WG meeting, and it was pointed out that

  select="/.."

is a simple way to get a node-set that is guaranteed to be empty.  We
felt this was enough for XSLT v1.

James
Received on Wednesday, 15 September 1999 12:32:20 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 7 December 2009 10:59:49 GMT