Version 6

    JBossEntityResolver

    The org.jboss.util.xml.JBossEntityResolver is an implementation of the org.xml.sax.EntityResolver interface that is used to handle entity resolution for standard J2EE DTDs and schemas as well as JBoss specific DTDs and schemas. In 4.0.3 the logic for resolving a dtd/schema has been updated to:

    1. Check the publicId against the current registered values in the class mapping of entity name to dtd/schema file name. If found, the resulting file name is passed to the loadClasspathResource to locate the file as a classpath resource.

    2. Check the systemId against the current registered values in the class mapping of entity name to dtd/schema file name. If found, the resulting file name is passed to the loadClasspathResource to locate the file as a classpath resource.

    3. Strip the systemId name down to the simple file name by removing an URL style path elements (myschemas/x.dtd becomes x.dtd), and call loadClasspathResource to locate the simple file name as a classpath resource.

    4. Attempt to resolve the systemId as a URL from which the schema can be read. If the URL input stream can be opened this returned as the resolved input.

     

    JBossEntityResolverMgr (4.0.3+)

    As of 4.0.3, there is an org.jboss.services.xml.JBossEntityResolverMgr MBean that can be used to configure application dtd/schema mapping as well as overriding the server mappings. Its supported attributes include:

    • WarnOnNonFileURLs - flag that when true indicates that any attempt to resolve a systemID as a URL whose protocol is not "file" should generate a warning level log message.

    • EntityMap - a java.util.Properties of the publicID/systemID key to dtd/xsd schema file name. Note that if any key termination characters appear in the publicId/systemId key of the entity map entry, they must be escaped with a backslash as in the example below. From the Javadoc of java.util.Properties, the key termination characters are the equals sign (=), a colon ( or whitespace. Formal Public Identifiers (FPI) of many DTDs contain whitespace as in the example below. See the javadocs for java.util.Properties for more information on the expected format of entries in the EntityMap attribute.

     

    A sample xmlresolver-service.xml descriptor is:

    <server>
       <mbean code="org.jboss.services.xml.JBossEntityResolverMgr"
          name="jboss.xml:service=JBossEntityResolverMgr">
          <attribute name="WarnOnNonFileURLs">true</attribute>
          <attribute name="EntityMap">
             urn:jboss:some-ns:1.0=somens_1_0.xsd
             urn:jboss:bean-deployer=bean-deployer_1_0a.xsd
             -//SOME//DTD\ WITH\ WHITESPACE//EN=dtd-with-whitespace.dtd
          </attribute>
       </mbean>
    </server>
    
    

     

     

    SchemaBindingResolver

    The org.jboss.xb.binding.sunday.unmarshalling.SchemaBindingResolver is an interface used by the JBossXB framework to resolve the SchemaBinding for a namespace URI.

    /*
     * JBoss, Home of Professional Open Source
     *
     * Distributable under LGPL license.
     * See terms of license at gnu.org.
     */
    package org.jboss.xb.binding.sunday.unmarshalling;
    
    /**
     * @author <a href="mailto:alex@jboss.org">Alexey Loubyansky</a>
     * @version <tt>$Revision: 1.1.2.3 $</tt>
     */
    public interface SchemaBindingResolver
    {
       String getBaseURI();
       void setBaseURI(String baseURI);
    
       /**
        * Returns an instance of SchemaBinding corresponding to the namespace URI.
        *
        * @param nsUri - namespace URI of the element with the schema reference
        * @param localName - the local name of the element
        * @param baseURI - an optional baseURI for resolving the schemaLocation.
        * @param schemaLocation - the option schema location uri that matches
        *    nsUri if one exists
        * @return an instance of SchemaBinding correspnding to the namespace URI
        * or null if the namespace URI is not recognized (though, in this case it
        * could also throw an exception)
        */
       SchemaBinding resolve(String nsUri, String localName, String baseURI, String schemaLocation);
    }
    

     

    DefaultSchemaResolver

    The org.jboss.xb.binding.sunday.unmarshalling.DefaultSchemaResolver is an implementation of SchemaBindingResolver that leverages the JBossEntityResolver. Its logic is:

    1. Call JBossEntityResolver.resolveEntity using nsUri as the systemID

    2. Call JBossEntityResolver.resolveEntity using the schemaLocation as the systemID

    3. If that fails, and the baseURI is not null, the xsd is located using URL(baseURL, schemaLocation)

    4. If that the failes, and if the baseURI is null, the xsd is located using URL(schemaLocation)

     

    Related