This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: mystery #2: testing document() without failure


> 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]