Author: remy.maucherat(a)jboss.com
Date: 2009-03-16 13:48:50 -0400 (Mon, 16 Mar 2009)
New Revision: 958
Modified:
trunk/PATCHES.txt
trunk/java/org/apache/catalina/startup/DigesterFactory.java
trunk/java/org/apache/tomcat/util/digester/Digester.java
Log:
- Port validation fix.
Modified: trunk/PATCHES.txt
===================================================================
--- trunk/PATCHES.txt 2009-03-12 18:09:30 UTC (rev 957)
+++ trunk/PATCHES.txt 2009-03-16 17:48:50 UTC (rev 958)
@@ -53,6 +53,6 @@
751502
Per context validation (incomplete, and looks a bit useless anyway)
-752651
+752651, 752936
XmlBase configuration
Modified: trunk/java/org/apache/catalina/startup/DigesterFactory.java
===================================================================
--- trunk/java/org/apache/catalina/startup/DigesterFactory.java 2009-03-12 18:09:30 UTC
(rev 957)
+++ trunk/java/org/apache/catalina/startup/DigesterFactory.java 2009-03-16 17:48:50 UTC
(rev 958)
@@ -68,10 +68,6 @@
digester.setValidating(xmlValidation);
digester.setUseContextClassLoader(true);
- if (xmlValidation || xmlNamespaceAware){
- configureSchema(digester);
- }
-
SchemaResolver schemaResolver = new SchemaResolver(digester);
registerLocalSchema(schemaResolver);
@@ -189,18 +185,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: trunk/java/org/apache/tomcat/util/digester/Digester.java
===================================================================
--- trunk/java/org/apache/tomcat/util/digester/Digester.java 2009-03-12 18:09:30 UTC (rev
957)
+++ trunk/java/org/apache/tomcat/util/digester/Digester.java 2009-03-16 17:48:50 UTC (rev
958)
@@ -280,20 +280,8 @@
*/
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>
- */
- protected String schemaLanguage = W3C_XML_SCHEMA;
-
-
+
/**
- * The XML schema to use for validating an XML instance.
- */
- protected String schemaLocation = null;
-
-
- /**
* The object stack being constructed.
*/
protected ArrayStack stack = new ArrayStack();
@@ -492,13 +480,28 @@
/**
* Return the SAXParserFactory we will use, creating one if necessary.
+ * @throws ParserConfigurationException
+ * @throws SAXNotSupportedException
+ * @throws SAXNotRecognizedException
*/
- public SAXParserFactory getFactory() {
+ 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);
@@ -693,16 +696,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);
@@ -808,50 +802,6 @@
/**
- * Return the XML Schema URI used for validating an XML instance.
- */
- public String getSchema() {
-
- return (this.schemaLocation);
-
- }
-
-
- /**
- * Set the XML Schema URI used for validating a XML Instance.
- *
- * @param schemaLocation a URI to the schema.
- */
- public void setSchema(String schemaLocation){
-
- this.schemaLocation = schemaLocation;
-
- }
-
-
- /**
- * Return the XML Schema language used when parsing.
- */
- public String getSchemaLanguage() {
-
- return (this.schemaLanguage);
-
- }
-
-
- /**
- * Set the XML Schema language used when parsing. By default, we use W3C.
- *
- * @param schemaLanguage a URI to the schema language.
- */
- public void setSchemaLanguage(String schemaLanguage){
-
- this.schemaLanguage = schemaLanguage;
-
- }
-
-
- /**
* Return the boolean as to whether the context classloader should be used.
*/
public boolean getUseContextClassLoader() {
@@ -1483,11 +1433,6 @@
entityURL = (String) entityValidator.get(publicId);
}
- // Redirect the schema location to a local destination
- if (schemaLocation != null && entityURL == null && systemId !=
null){
- entityURL = (String)entityValidator.get(systemId);
- }
-
if (entityURL == null) {
if (systemId == null) {
// cannot resolve
Show replies by date