Hi Peter,

The fallback is only used in the event of a resource error [1]. For
example, the file doesn't exist or possibly there's some kind of connection
problem which prevents the parser from accessing the URI (specified as the
value of href). Well formedness errors within the included XML document are
always fatal.

Thanks.

[1] http://www.w3.org/TR/xinclude/#dt-resource-error

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrgla...@ca.ibm.com
E-mail: mrgla...@apache.org

"Peter A. Kirk" <p...@alpha-solutions.dk> wrote on 11/07/2010 07:50:09 PM:

> Hi
>
> I'm new to the Xerces xml parser, and would like some help loading/
> parsing xml documents using Xi Include.
>
> I have two xml files, "mainxml.xml" and "includexml.xml".
> MainXml looks like this:
> <?xml version="1.0" encoding="utf-8" ?>
> <config xmlns:xi="http://www.w3.org/2001/XInclude";>.
>  <abc>
>   <xi:include href="includexml.xml">
>    <xi:fallback>
>     <str name="fallback include">
>       failure include
>     </str>
>    </xi:fallback>
>   </xi:include>
>  </abc>
> </config>
>
> and IncludeXml looks like:
> <str name="include">asd</str>>
>
>
> I'm trying to load the MainXml file like this:
>
> DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
> dbf.setNamespaceAware(true);
> dbf.setXIncludeAware(true);
>
> DocumentBuilder db = dbf.newDocumentBuilder();
>
> Document doc = db.parse("mainxml.xml");).
>
>
> Which works ok, unless there is an error in "includexml.xml". If
> there is an error, then the fallback is not used - why not? An error
> could be en empty "includexml.xml" file, or if the xml was invalid.
>
> How do I get the fallback to be used?
>
>
>
> Thanks,
> Peter

Reply via email to