One last question, how do I prevent Saxon from outputing the
following on System.out when document() fails?:
You can recover silently from recoverable errors by using the switch -w0
from the command line
cheers
andrew
-----Original Message-----
From: Jeff Barrett [mailto:JBarrett(_at_)sawyermedia(_dot_)com]
Sent: 30 October 2002 00:42
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: RE: [xsl] handling failed document() invocations
Great!
One last question, how do I prevent Saxon from outputing the
following on System.out when document() fails?:
Recoverable error
Failure reading file:/C:/somefile.xml: no more input
thanks again,
+jeff
-----Original Message-----
From: Robert Koberg [mailto:rob(_at_)koberg(_dot_)com]
Sent: Tuesday, October 29, 2002 3:36 PM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: RE: [xsl] handling failed document() invocations
Hi,
Since you are using saxon you can simply do something like:
<xsl:choose>
<xsl:when test="boolean($item-doc")">
<xsl:apply-templates select="$item-doc"/>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="content_not_found"/>
</xsl:otherwise>
</xsl:choose>
If you want this to be non-(java)-processor-specific you
might want to use a(n?)
URIResolver to return some well-formed error info.
best,
-Rob
-----Original Message-----
From: owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
[mailto:owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com]On Behalf Of
Jeff Barrett
Sent: Tuesday, October 29, 2002 3:06 PM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] handling failed document() invocations
I have a main XML document that has references to other XML document
instances. These references take the form of an ID number that is
used to construct the path to an instance doc. For example:
<document>
<item id="14" />
<item id="94" />
</document>
<!----------------------------->
<xsl:stylesheet>
[...]
<xsl:variable name="instance-id" select="document/item/@id" />
<xsl:variable name="item-doc" select="document(
'documents/$instance-id/item.xml' )" />
[...]
</xsl:stylesheet>
The problem is there may not be a document there, which is an OK
state of affairs. What is the xsl code idiom for detecting when
document() is unable to find a document at the given
location, and to
handle this in a more meaningful way than exiting on error?
If it matters I'm using saxon 6.5.2.
thanks,
+jeff
XSL-List info and archive:
http://www.mulberrytech.com/xsl/xsl-list
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list