FileDocCategorySizeDatePackage
DigesterFactory.javaAPI DocApache Tomcat 6.0.145903Fri Jul 20 04:20:36 BST 2007org.apache.catalina.startup

DigesterFactory

public class DigesterFactory extends Object
Wrapper class around the Digester that hide Digester's initialization details
author
Jean-Francois Arcand

Fields Summary
protected static org.apache.juli.logging.Log
log
The log.
private static org.apache.catalina.util.SchemaResolver
schemaResolver
The XML entiry resolver used by the Digester.
Constructors Summary
Methods Summary
protected static voidconfigureSchema(org.apache.tomcat.util.digester.Digester digester)
Turn on DTD and/or validation (based on the parser implementation)

        URL url = DigesterFactory.class
                        .getResource(Constants.WebSchemaResourcePath_24);
  
        if(url == null) {
            log.error("Could not get url for " 
                                        + Constants.WebSchemaResourcePath_24);
        } else {
            digester.setSchema(url.toString());     
        }
    
public static org.apache.tomcat.util.digester.DigesternewDigester()
Create a Digester parser with no Rule associated and XML validation turned off.



                      
       
        return newDigester(false, false, null);
    
public static org.apache.tomcat.util.digester.DigesternewDigester(org.apache.tomcat.util.digester.RuleSet rule)
Create a Digester parser with XML validation turned off.

param
rule an instance of RuleSet used for parsing the xml.

        return newDigester(false,false,rule);
    
public static org.apache.tomcat.util.digester.DigesternewDigester(boolean xmlValidation, boolean xmlNamespaceAware, org.apache.tomcat.util.digester.RuleSet rule)
Create a Digester parser.

param
xmlValidation turn on/off xml validation
param
xmlNamespaceAware turn on/off namespace validation
param
rule an instance of RuleSet used for parsing the xml.

        Digester digester = new Digester();
        digester.setNamespaceAware(xmlNamespaceAware);
        digester.setValidating(xmlValidation);
        digester.setUseContextClassLoader(true);

        if (xmlValidation || xmlNamespaceAware){
            configureSchema(digester);        
        }

        schemaResolver = new SchemaResolver(digester);
        registerLocalSchema();
        
        digester.setEntityResolver(schemaResolver);
        if ( rule != null ) {
            digester.addRuleSet(rule);
        }

        return (digester);
    
protected static voidregister(java.lang.String resourceURL, java.lang.String resourcePublicId)
Load the resource and add it to the resolver.

        URL url = DigesterFactory.class.getResource(resourceURL);
   
        if(url == null) {
            log.warn("Could not get url for " + resourceURL);
        } else {
            schemaResolver.register(resourcePublicId , url.toString() );
        }
    
protected static voidregisterLocalSchema()
Utilities used to force the parser to use local schema, when available, instead of the schemaLocation XML element.

        // J2EE
        register(Constants.J2eeSchemaResourcePath_14,
                 Constants.J2eeSchemaPublicId_14);
        // W3C
        register(Constants.W3cSchemaResourcePath_10,
                 Constants.W3cSchemaPublicId_10);
        // JSP
        register(Constants.JspSchemaResourcePath_20,
                 Constants.JspSchemaPublicId_20);

        register(Constants.JspSchemaResourcePath_21,
                Constants.JspSchemaPublicId_21);

        // TLD
        register(Constants.TldDtdResourcePath_11,  
                 Constants.TldDtdPublicId_11);
        
        register(Constants.TldDtdResourcePath_12,
                 Constants.TldDtdPublicId_12);

        register(Constants.TldSchemaResourcePath_20,
                 Constants.TldSchemaPublicId_20);

        register(Constants.TldSchemaResourcePath_21,
                Constants.TldSchemaPublicId_21);

        // web.xml    
        register(Constants.WebDtdResourcePath_22,
                 Constants.WebDtdPublicId_22);

        register(Constants.WebDtdResourcePath_23,
                 Constants.WebDtdPublicId_23);

        register(Constants.WebSchemaResourcePath_24,
                 Constants.WebSchemaPublicId_24);

        register(Constants.WebSchemaResourcePath_25,
                Constants.WebSchemaPublicId_25);

        // Web Service
        register(Constants.J2eeWebServiceSchemaResourcePath_11,
                 Constants.J2eeWebServiceSchemaPublicId_11);

        register(Constants.J2eeWebServiceClientSchemaResourcePath_11,
                 Constants.J2eeWebServiceClientSchemaPublicId_11);