This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: mystery #2: testing document() without failure
- From: "Michael Kay" <michael dot h dot kay at ntlworld dot com>
- To: <xsl-list at lists dot mulberrytech dot com>
- Date: Sat, 13 Apr 2002 16:31:59 +0100
- Subject: RE: [xsl] mystery #2: testing document() without failure
- Reply-to: xsl-list at lists dot mulberrytech dot com
> So is it wrong to rely on something like (if processor
> independence is
> important):
>
> <xsl:variable name="test" select="document('test.xml')/test"/>
> <xsl:choose>
> <xsl:when test="boolean($test)">
> <xsl:apply-templates select="$test"/>
> </xsl:when>
> <xsl:otherwise>
> <!-- error display -->
> </xsl:otherwise>
> </xsl:choose>
>
> it works in saxon.
>
Yes, it's explicitly implementation-defined what happens when the document
referred to by the document() function doesn't exist. Either you get an
error, or you get an empty node-set.
Saxon gives you a user option to choose whether the error is fatal or not
(this is a global switch that applies to all recoverable dynamic errors, not
to this one explicitly). There are three settings: ignore the error and take
the prescribed recovery action; issue a warning message and take the
recovery action; produce a fatal error and stop. But there's no portable way
of setting such options.
Michael Kay
Software AG
home: Michael.H.Kay@ntlworld.com
work: Michael.Kay@softwareag.com
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list