xsl-list
[Top] [All Lists]

handling failed document() invocations

2002-10-29 16:05:53
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



<Prev in Thread] Current Thread [Next in Thread>