Author: markt Date: Thu Mar 12 22:09:44 2009 New Revision: 753035 URL: http://svn.apache.org/viewvc?rev=753035&view=rev Log: Get validation working properly. This will still throw two errors on start-up due to errors in two of the tld's included in standard.jar in the examples app.
Modified: tomcat/trunk/java/org/apache/catalina/startup/DigesterFactory.java tomcat/trunk/java/org/apache/tomcat/util/digester/Digester.java Modified: tomcat/trunk/java/org/apache/catalina/startup/DigesterFactory.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/startup/DigesterFactory.java?rev=753035&r1=753034&r2=753035&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/catalina/startup/DigesterFactory.java (original) +++ tomcat/trunk/java/org/apache/catalina/startup/DigesterFactory.java Thu Mar 12 22:09:44 2009 @@ -68,10 +68,6 @@ digester.setValidating(xmlValidation); digester.setUseContextClassLoader(true); - if (xmlValidation || xmlNamespaceAware){ - configureSchema(digester); - } - SchemaResolver schemaResolver = new SchemaResolver(digester); registerLocalSchema(schemaResolver); @@ -188,19 +184,4 @@ } } - - /** - * Turn on DTD and/or validation (based on the parser implementation) - */ - protected static void configureSchema(Digester digester){ - URL url = DigesterFactory.class - .getResource(Constants.WebSchemaResourcePath_25); - - if(url == null) { - log.error("Could not get url for " - + Constants.WebSchemaResourcePath_25); - } else { - digester.setSchema(url.toString()); - } - } } Modified: tomcat/trunk/java/org/apache/tomcat/util/digester/Digester.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/digester/Digester.java?rev=753035&r1=753034&r2=753035&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/util/digester/Digester.java (original) +++ tomcat/trunk/java/org/apache/tomcat/util/digester/Digester.java Thu Mar 12 22:09:44 2009 @@ -30,7 +30,6 @@ import java.util.Iterator; import java.util.List; import java.util.Map; -import java.util.Properties; import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.SAXParser; @@ -276,7 +275,7 @@ */ protected Rules rules = null; - /** + /** * The XML schema language to use for validating an XML instance. By * default this value is set to <code>W3C_XML_SCHEMA</code> */ @@ -459,13 +458,28 @@ /** * Return the SAXParserFactory we will use, creating one if necessary. - */ - public SAXParserFactory getFactory() { + * @throws ParserConfigurationException + * @throws SAXNotSupportedException + * @throws SAXNotRecognizedException + */ + public SAXParserFactory getFactory() + throws SAXNotRecognizedException, SAXNotSupportedException, + ParserConfigurationException { if (factory == null) { factory = SAXParserFactory.newInstance(); factory.setNamespaceAware(namespaceAware); factory.setValidating(validating); + if (validating) { + // Enable DTD validation + factory.setFeature( + "http://xml.org/sax/features/validation", + true); + // Enable schema validation + factory.setFeature( + "http://apache.org/xml/features/validation/schema", + true); + } } return (factory); @@ -660,16 +674,7 @@ // Create a new parser try { - if (validating) { - Properties properties = new Properties(); - properties.put("SAXParserFactory", getFactory()); - if (schemaLocation != null) { - properties.put("schemaLocation", schemaLocation); - properties.put("schemaLanguage", schemaLanguage); - } - parser = ParserFeatureSetterFactory.newSAXParser(properties); } else { - parser = getFactory().newSAXParser(); - } + parser = getFactory().newSAXParser(); } catch (Exception e) { log.error("Digester.getParser: ", e); return (null); @@ -1431,11 +1436,6 @@ entityURL = entityValidator.get(publicId); } - // Redirect the schema location to a local destination - if (schemaLocation != null && entityURL == null && systemId != null){ - entityURL = entityValidator.get(systemId); - } - if (entityURL == null) { if (systemId == null) { // cannot resolve --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org