FileDocCategorySizeDatePackage
GenericParser.javaAPI DocApache Tomcat 6.0.143221Fri Jul 20 04:20:34 BST 2007org.apache.tomcat.util.digester

GenericParser

public class GenericParser extends Object
Create a SAXParser configured to support XML Schema and DTD.
since
1.6

Fields Summary
protected static org.apache.juli.logging.Log
log
The Log to which all SAX event related logging calls will be made.
private static final String
JAXP_SCHEMA_SOURCE
The JAXP 1.2 property required to set up the schema location.
protected static String
JAXP_SCHEMA_LANGUAGE
The JAXP 1.2 property to set up the schemaLanguage used.
Constructors Summary
Methods Summary
public static javax.xml.parsers.SAXParsernewSAXParser(java.util.Properties properties)
Create a SAXParser configured to support XML Scheman and DTD

param
properties parser specific properties/features
return
an XML Schema/DTD enabled SAXParser


                              
        
              
                   
                    

        SAXParserFactory factory = 
                        (SAXParserFactory)properties.get("SAXParserFactory");
        SAXParser parser = factory.newSAXParser();
        String schemaLocation = (String)properties.get("schemaLocation");
        String schemaLanguage = (String)properties.get("schemaLanguage");

        try{
            if (schemaLocation != null) {
                parser.setProperty(JAXP_SCHEMA_LANGUAGE, schemaLanguage);
                parser.setProperty(JAXP_SCHEMA_SOURCE, schemaLocation);
            }
        } catch (SAXNotRecognizedException e){
            log.info(parser.getClass().getName() + ": "  
                                        + e.getMessage() + " not supported."); 
        }
        return parser;