XMLBeans External Entity Resolver

This page is a mini spec on how to resolve external entities.

Support for using a class that implements org.xml.sax.EntityResolver interface in two places:

  • when parsing regular XML documents that contain references to external entities
    Ex:
           <!ENTITY open-hatch
             SYSTEM "http://www.textuality.com/boilerplate/OpenHatch.xml">
           <!ENTITY open-hatch
             PUBLIC "-//Textuality//TEXT Standard open-hatch boilerplate//EN"
             "http://www.textuality.com/boilerplate/OpenHatch.xml">
           <!ENTITY hatch-pic
             SYSTEM "../grafix/OpenHatch.gif"
             NDATA gif >
  • when parsing XMLSchema documents or WSDL documents that contain imports or includes
    Ex:
           <xs:schema  xmlns:xs="http://www.w3.org/2001/XMLSchema"
             ... >
             <xs:include schemaLocation="included.xsd"/>

How to set the resolver

  1. Use XmlOptions.setEntityResolver(EntityResolver resolver) to pass in the resolver to be used for parsing XML documents {{ XmlObject.parse(...) }} or compiling XMLSchema or WSDL documents {{ SchemaTypeSystemCompiler.compile(...) }}

2. If no entity resolver has been set in XmlOptions, org.apache.xml.resolver.tools.CatalogResolver will be used as a resolver if Apache's XmlCommons resolver.jar is on the classpath and a catalog file has been specified.

      scomp -catalog catalog_file.cat

3. If the previous conditions failed, the xmlbean.entityResolver system property will specify the name of a global, read only resolver.

4. If all previous attempts failed, the resolver will be at the discretion of the used XML parser for XML documents and for XMLSchema and WSDL documents a simple resolver implementation will be used if
{{ XmlOptions.setCompileDownloadUrls() }}
or
{{ scomp -dl ... }}
is used.

  • No labels