Hi, attached is a patch that implement the mechanism to turn off/on the XML validation and namespace awareness. Starting with this patch, validation/namespace will be turned off. If you want to turn it on, do:
<Host name="localhost" debug="0" appBase="webapps" unpackWARs="true" autoDeploy="true" xmlValidation="true" xmlNamespaceAware="true"> *xmlValidation and xmlNamespaceAware are optional attributes. Current server.xml file are still supported. I did not implement the functionality for server.xml and user.xml since the validation was turned off by default (and willnot work if validation is turned on). Thanks, -- Jeanfrancois
Index: server.xml =================================================================== RCS file: /home/cvspublic/jakarta-tomcat-catalina/catalina/src/conf/server.xml,v retrieving revision 1.3 diff -u -r1.3 server.xml --- server.xml 4 Aug 2002 19:41:06 -0000 1.3 +++ server.xml 20 Aug 2002 18:25:01 -0000 @@ -219,10 +219,19 @@ userRoleTable="user_roles" roleNameCol="role_name" /> --> - <!-- Define the default virtual host --> - <Host name="localhost" debug="0" appBase="webapps" + <!-- Define the default virtual host.--> + <!--<Host name="localhost" debug="0" appBase="webapps" unpackWARs="true" autoDeploy="true"> + --> + <!-- Define the default virtual host. Uncomment this element if you + want to turn on XML schema/dtd validation. --> + + <Host name="localhost" debug="0" appBase="webapps" + unpackWARs="true" autoDeploy="true" + xmlValidation="true" xmlNamespaceAware="true"> + + <!-- Normally, users must authenticate themselves to each web app individually. Uncomment the following entry if you would like a user to be authenticated the first time they encounter a Index: Host.java =================================================================== RCS file: /home/cvspublic/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/Host.java,v retrieving revision 1.1.1.1 diff -u -r1.1.1.1 Host.java --- Host.java 18 Jul 2002 16:47:37 -0000 1.1.1.1 +++ Host.java 20 Aug 2002 18:17:57 -0000 @@ -171,8 +171,39 @@ * @exception IllegalArgumentException if name is null */ public void setName(String name); + + + /** + * Get the server.xml <host> attribute's xmlNamespaceAware. + * @return true if namespace awarenes is enabled. + * + */ + public boolean getXmlNamespaceAware(); + + + /** + * Get the server.xml <host> attribute's xmlValidation. + * @return true if validation is enabled. + * + */ + public boolean getXmlValidation(); - + + /** + * Set the validation feature of the XML parser used when + * parsing xml instances. + * @param xmlValidation true to enable xml instance validation + */ + public void setXmlValidation(boolean xmlValidation); + + + /** + * Set the namespace aware feature of the XML parser used when + * parsing xml instances. + * @param xmlNamespaceAware true to enable namespace awareness + */ + public void setXmlNamespaceAware(boolean xmlNamespaceAware); + // --------------------------------------------------------- Public Methods Index: StandardHost.java =================================================================== RCS file: /home/cvspublic/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/StandardHost.java,v retrieving revision 1.1.1.1 diff -u -r1.1.1.1 StandardHost.java --- StandardHost.java 18 Jul 2002 16:48:08 -0000 1.1.1.1 +++ StandardHost.java 20 Aug 2002 18:18:35 -0000 @@ -211,7 +211,20 @@ * DefaultContext config */ private DefaultContext defaultContext; - + + + /** + * Attribute value used to turn on/off XML validation + */ + private boolean xmlValidation = false; + + + /** + * Attribute value used to turn on/off XML namespace awarenes. + */ + private boolean xmlNamespaceAware = false; + + // ------------------------------------------------------------- Properties @@ -519,8 +532,48 @@ this.workDir = workDir; } - - + + + /** + * Set the validation feature of the XML parser used when + * parsing xml instances. + * @param xmlValidation true to enable xml instance validation + */ + public void setXmlValidation(boolean xmlValidation){ + this.xmlValidation = xmlValidation; + } + + + /** + * Get the server.xml <host> attribute's xmlValidation. + * @return true if validation is enabled. + * + */ + public boolean getXmlValidation(){ + return xmlValidation; + } + + + /** + * Get the server.xml <host> attribute's xmlNamespaceAware. + * @return true if namespace awarenes is enabled. + * + */ + public boolean getXmlNamespaceAware(){ + return xmlNamespaceAware; + } + + + /** + * Set the namespace aware feature of the XML parser used when + * parsing xml instances. + * @param xmlNamespaceAware true to enable namespace awareness + */ + public void setXmlNamespaceAware(boolean xmlNamespaceAware){ Index: ContextConfig.java =================================================================== RCS file: /home/cvspublic/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/startup/ContextConfig.java,v retrieving revision 1.9 diff -u -r1.9 ContextConfig.java --- ContextConfig.java 20 Aug 2002 03:26:36 -0000 1.9 +++ ContextConfig.java 20 Aug 2002 18:30:50 -0000 @@ -139,7 +139,7 @@ * * @author Craig R. McClanahan * @author Jean-Francois Arcand - * @version $Revision: 1.9 $ $Date: 2002/08/20 03:26:36 $ + * @version $Revision: 1.8 $ $Date: 2002/08/10 22:42:34 $ */ public final class ContextConfig @@ -186,15 +186,26 @@ * The <code>Digester</code> we will use to process tag library * descriptor files. */ - private static Digester tldDigester = createTldDigester(); + private static Digester tldDigester = null; /** * The <code>Digester</code> we will use to process web application * deployment descriptor files. */ - private static Digester webDigester = createWebDigester(); + private static Digester webDigester = null; + + /** + * Attribute value used to turn on/off XML validation + */ + private static boolean xmlValidation = false; + + + /** + * Attribute value used to turn on/off XML namespace awarenes. + */ + private static boolean xmlNamespaceAware = false; // ------------------------------------------------------------- Properties @@ -271,7 +282,10 @@ log(sm.getString("contextConfig.applicationMissing")); return; } - + + if (webDigester == null){ + webDigester = createWebDigester(); + } // Process the application web.xml file synchronized (webDigester) { try { @@ -281,11 +295,11 @@ InputSource is = new InputSource(url.toExternalForm()); is.setByteStream(stream); webDigester.setDebug(getDebug()); + if (context instanceof StandardContext) { ((StandardContext) context).setReplaceWelcomeFiles(true); } - webDigester.clear(); webDigester.push(context); webDigester.parse(is); @@ -308,7 +322,6 @@ } } } - } @@ -417,8 +430,11 @@ boolean secure = false; Container container = context.getParent(); if (container instanceof Host) { + xmlValidation = ((Host)container).getXmlValidation(); + xmlNamespaceAware = ((Host)container).getXmlNamespaceAware(); container = container.getParent(); } + if (container instanceof Engine) { Service service = ((Engine)container).getService(); // The service can be null when Tomcat is run in embedded mode @@ -485,8 +501,8 @@ URL url = null; Digester tldDigester = new Digester(); - tldDigester.setNamespaceAware(true); - tldDigester.setValidating(true); + tldDigester.setNamespaceAware(xmlNamespaceAware); + tldDigester.setValidating(xmlValidation); if (tldDigester.getFactory().getClass().getName().indexOf("xerces")!=-1) { tldDigester = patchXerces(tldDigester); @@ -542,8 +558,8 @@ URL url = null; Digester webDigester = new Digester(); - webDigester.setNamespaceAware(true); - webDigester.setValidating(true); + webDigester.setNamespaceAware(xmlNamespaceAware); + webDigester.setValidating(xmlValidation); if (webDigester.getFactory().getClass().getName().indexOf("xerces")!=-1) { webDigester = patchXerces(webDigester); @@ -592,6 +608,10 @@ log(sm.getString("contextConfig.defaultMissing"), e); return; } + + if (webDigester == null){ + webDigester = createWebDigester(); + } // Process the default web.xml file synchronized (webDigester) { @@ -600,6 +620,7 @@ new InputSource("file://" + file.getAbsolutePath()); stream = new FileInputStream(file); is.setByteStream(stream); + webDigester.setDebug(getDebug()); if (context instanceof StandardContext) @@ -720,6 +741,8 @@ if( !context.getOverride() ) { if( container instanceof Host ) { ((Host)container).importDefaultContext(context); + xmlValidation = ((Host)container).getXmlValidation(); + xmlNamespaceAware = ((Host)container).getXmlNamespaceAware(); + container = container.getParent(); } if( container instanceof Engine ) { @@ -1063,7 +1086,11 @@ */ private void tldScanStream(InputStream resourceStream) throws Exception { - + + if (tldDigester == null){ + tldDigester = createTldDigester(); + } + synchronized (tldDigester) { tldDigester.clear(); tldDigester.push(context);
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>