The simplest way to enable XInclude processing is to use a
org.apache.xerces.parsers.XIncludeParserConfiguration as your
parser configuration. This configuration includes a DTD validator, a namespace
binder, and a Schema validator, in addition to a handler for XInclude. See
this FAQ for
instructions about how to change your parser configuration.
If XIncludeParserConfiguration doesn't meet your needs, then you'll
have to write your own parser configuration. Make sure that this configuration
includes a org.apache.xerces.xinclude.XIncludeHandler, and that the
property "http://apache.org/xml/properties/internal/namespace-context" is an instance of
org.apache.xerces.xinclude.XIncludeNamespaceSupport. It is strongly
recommended that the XIncludeHandler be placed in the pipeline
before the Schema validator, if there is one. PSVI information cannot be
guaranteed to be valid after XInclude processing.
Why are xml:base attributes added, which make Schema validation fail?
According to the specification for XInclude, processors must add an xml:base
attribute to elements included from locations with a different base URI. Without
these attributes, the resulting infoset information would be incorrect. Unfortunatly,
these attributes make XInclude processing not transparent to Schema validation.
The solution to this is to modify your schema to allow xml:base
attributes to appear on elements that might be included from different base URIs.
If this solution is really unappealing to you, voice your concerns on the
xerces-j-user mailing list.
Why doesn't including document fragments work?
Currently, our implementation of XInclude is not fully complete, and we do
not support XPointer
references. We hope that in the future we will have a
fully compliant XInclude processor that can handle this feature.
Why doesn't Xerces recognize xml:base attributes?
The XInclude specification requires processors to use the base URI
(as specified in the XML Base
recommendation) to resolve relative IURIs to compute the
include location.
Currently, our implementation of XInclude is not fully complete, and we do
not support the XML Base recommendation. We hope that in the future we
will have a fully compliant XInclude processor that can handle this feature.