You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by mr...@apache.org on 2005/12/06 20:46:26 UTC

svn commit: r354522 - in /xerces/java/trunk/src/org/apache/xerces/dom: DOMConfigurationImpl.java DOMNormalizer.java

Author: mrglavas
Date: Tue Dec  6 11:46:23 2005
New Revision: 354522

URL: http://svn.apache.org/viewcvs?rev=354522&view=rev
Log:
Fixing validation support for XML 1.1 documents. The XML11DTDValidator requires
the XML11DTDDVFactory in order to function correctly. It also requires that the
DTD_VALIDATOR_PROPERTY be recognized.

Modified:
    xerces/java/trunk/src/org/apache/xerces/dom/DOMConfigurationImpl.java
    xerces/java/trunk/src/org/apache/xerces/dom/DOMNormalizer.java

Modified: xerces/java/trunk/src/org/apache/xerces/dom/DOMConfigurationImpl.java
URL: http://svn.apache.org/viewcvs/xerces/java/trunk/src/org/apache/xerces/dom/DOMConfigurationImpl.java?rev=354522&r1=354521&r2=354522&view=diff
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/dom/DOMConfigurationImpl.java (original)
+++ xerces/java/trunk/src/org/apache/xerces/dom/DOMConfigurationImpl.java Tue Dec  6 11:46:23 2005
@@ -67,6 +67,9 @@
     //
     // Constants
     //
+    
+    protected static final String XML11_DATATYPE_VALIDATOR_FACTORY =
+        "org.apache.xerces.impl.dv.dtd.XML11DTDDVFactoryImpl";
 
     // feature identifiers
 
@@ -164,6 +167,10 @@
     protected static final String JAXP_SCHEMA_SOURCE =
         Constants.JAXP_PROPERTY_PREFIX + Constants.SCHEMA_SOURCE;
     
+    /** Property identifier: DTD validator. */
+    protected final static String DTD_VALIDATOR_PROPERTY =
+        Constants.XERCES_PROPERTY_PREFIX + Constants.DTD_VALIDATOR_PROPERTY;
+    
     /** Property identifier: datatype validator factory. */
     protected static final String DTD_VALIDATOR_FACTORY_PROPERTY = 
         Constants.XERCES_PROPERTY_PREFIX + Constants.DATATYPE_VALIDATOR_FACTORY_PROPERTY;
@@ -220,6 +227,15 @@
 
     protected final DOMErrorHandlerWrapper fErrorHandlerWrapper =
                 new DOMErrorHandlerWrapper();
+    
+    /** Current Datatype validator factory. */
+    protected DTDDVFactory fCurrentDVFactory;
+    
+    /** The XML 1.0 Datatype validator factory. */
+    protected DTDDVFactory fDatatypeValidatorFactory;
+    
+    /** The XML 1.1 Datatype validator factory. **/
+    protected DTDDVFactory fXML11DatatypeFactory;
 
     // private data
 
@@ -316,6 +332,7 @@
             JAXP_SCHEMA_LANGUAGE,
             SCHEMA_LOCATION,
             SCHEMA_NONS_LOCATION,
+            DTD_VALIDATOR_PROPERTY,
             DTD_VALIDATOR_FACTORY_PROPERTY
         };
         addRecognizedProperties(recognizedProperties);
@@ -341,7 +358,10 @@
         setProperty(ERROR_REPORTER, fErrorReporter);
         addComponent(fErrorReporter);
 
-        setProperty(DTD_VALIDATOR_FACTORY_PROPERTY, DTDDVFactory.getInstance());
+        fDatatypeValidatorFactory = DTDDVFactory.getInstance();
+        fXML11DatatypeFactory = DTDDVFactory.getInstance(XML11_DATATYPE_VALIDATOR_FACTORY);
+        fCurrentDVFactory = fDatatypeValidatorFactory;
+        setProperty(DTD_VALIDATOR_FACTORY_PROPERTY, fCurrentDVFactory);
 		
         XMLEntityManager manager =  new XMLEntityManager();
         setProperty(ENTITY_MANAGER, manager);
@@ -1147,6 +1167,19 @@
 
     protected ValidationManager createValidationManager(){
         return new ValidationManager();
+    }
+    
+    protected final void setDTDValidatorFactory(String version) {
+        if ("1.1".equals(version)) {
+            if (fCurrentDVFactory != fXML11DatatypeFactory) {
+                fCurrentDVFactory = fXML11DatatypeFactory;
+                setProperty(DTD_VALIDATOR_FACTORY_PROPERTY, fCurrentDVFactory);
+            }
+        }
+        else if (fCurrentDVFactory != fDatatypeValidatorFactory) {
+            fCurrentDVFactory = fDatatypeValidatorFactory;
+            setProperty(DTD_VALIDATOR_FACTORY_PROPERTY, fCurrentDVFactory);
+        }
     }
 
 } // class XMLParser

Modified: xerces/java/trunk/src/org/apache/xerces/dom/DOMNormalizer.java
URL: http://svn.apache.org/viewcvs/xerces/java/trunk/src/org/apache/xerces/dom/DOMNormalizer.java?rev=354522&r1=354521&r2=354522&view=diff
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/dom/DOMNormalizer.java (original)
+++ xerces/java/trunk/src/org/apache/xerces/dom/DOMNormalizer.java Tue Dec  6 11:46:23 2005
@@ -206,10 +206,11 @@
             }
             else {
                 schemaType = XMLGrammarDescription.XML_DTD;
+                fConfiguration.setDTDValidatorFactory(xmlVersion);
                 fValidationHandler = CoreDOMImplementationImpl.singleton.getValidator(schemaType, xmlVersion);
                 DocumentTypeImpl docType = (DocumentTypeImpl) fDocument.getDoctype();
                 if (docType != null) {
-                    fConfiguration.setProperty(Constants.XERCES_PROPERTY_PREFIX + Constants.XMLGRAMMAR_POOL_PROPERTY, createGrammarPool(docType));
+                    fConfiguration.setProperty(DOMConfigurationImpl.GRAMMAR_POOL, createGrammarPool(docType));
                 }
                 fPSVI = false;
             }



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org