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/06/21 19:19:08 UTC
cvs commit: xml-xerces/java/src/org/apache/xerces/jaxp SchemaValidatorConfiguration.java SAXParserImpl.java DocumentBuilderImpl.java
mrglavas 2005/06/21 10:19:08
Modified: java/src/org/apache/xerces/jaxp
SchemaValidatorConfiguration.java
SAXParserImpl.java DocumentBuilderImpl.java
Log:
Supporting validation of xs:ENTITY and also fixing a bug.
We need to use a different ValidationManager than the
one in the configuration so that the validators in the pipeline
don't interfere with the one for the Schema.
Revision Changes Path
1.2 +15 -3 xml-xerces/java/src/org/apache/xerces/jaxp/SchemaValidatorConfiguration.java
Index: SchemaValidatorConfiguration.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/jaxp/SchemaValidatorConfiguration.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- SchemaValidatorConfiguration.java 20 Jun 2005 04:47:59 -0000 1.1
+++ SchemaValidatorConfiguration.java 21 Jun 2005 17:19:08 -0000 1.2
@@ -18,6 +18,7 @@
import org.apache.xerces.impl.Constants;
import org.apache.xerces.impl.XMLErrorReporter;
+import org.apache.xerces.impl.validation.ValidationManager;
import org.apache.xerces.impl.xs.XSMessageFormatter;
import org.apache.xerces.jaxp.validation.XSGrammarPoolContainer;
import org.apache.xerces.xni.grammars.XMLGrammarPool;
@@ -55,6 +56,10 @@
private static final String ERROR_REPORTER =
Constants.XERCES_PROPERTY_PREFIX + Constants.ERROR_REPORTER_PROPERTY;
+ /** Property identifier: validation manager. */
+ private static final String VALIDATION_MANAGER =
+ Constants.XERCES_PROPERTY_PREFIX + Constants.VALIDATION_MANAGER_PROPERTY;
+
/** Property identifier: grammar pool. */
private static final String XMLGRAMMAR_POOL =
Constants.XERCES_PROPERTY_PREFIX + Constants.XMLGRAMMAR_POOL_PROPERTY;
@@ -67,7 +72,7 @@
private final XMLComponentManager fParentComponentManager;
/** The Schema's grammar pool. **/
- private final XMLGrammarPool fGrammarPool;
+ private final XMLGrammarPool fGrammarPool;
/**
* Tracks whether the validator should use components from
@@ -75,11 +80,15 @@
*/
private final boolean fUseGrammarPoolOnly;
+ /** Validation manager. */
+ private final ValidationManager fValidationManager;
+
public SchemaValidatorConfiguration(XMLComponentManager parentManager,
- XSGrammarPoolContainer grammarContainer) {
+ XSGrammarPoolContainer grammarContainer, ValidationManager validationManager) {
fParentComponentManager = parentManager;
fGrammarPool = grammarContainer.getGrammarPool();
fUseGrammarPoolOnly = grammarContainer.isFullyComposed();
+ fValidationManager = validationManager;
// add schema message formatter to error reporter
try {
XMLErrorReporter errorReporter = (XMLErrorReporter) fParentComponentManager.getProperty(ERROR_REPORTER);
@@ -134,6 +143,9 @@
if (XMLGRAMMAR_POOL.equals(propertyId)) {
return fGrammarPool;
}
+ else if (VALIDATION_MANAGER.equals(propertyId)) {
+ return fValidationManager;
+ }
return fParentComponentManager.getProperty(propertyId);
}
}
1.33 +17 -2 xml-xerces/java/src/org/apache/xerces/jaxp/SAXParserImpl.java
Index: SAXParserImpl.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/jaxp/SAXParserImpl.java,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -r1.32 -r1.33
--- SAXParserImpl.java 20 Jun 2005 19:50:56 -0000 1.32
+++ SAXParserImpl.java 21 Jun 2005 17:19:08 -0000 1.33
@@ -27,6 +27,7 @@
import javax.xml.validation.Schema;
import org.apache.xerces.impl.Constants;
+import org.apache.xerces.impl.validation.ValidationManager;
import org.apache.xerces.impl.xs.XMLSchemaValidator;
import org.apache.xerces.impl.xs.XSMessageFormatter;
import org.apache.xerces.jaxp.validation.XSGrammarPoolContainer;
@@ -36,6 +37,7 @@
import org.apache.xerces.xni.parser.XMLComponent;
import org.apache.xerces.xni.parser.XMLComponentManager;
import org.apache.xerces.xni.parser.XMLConfigurationException;
+import org.apache.xerces.xni.parser.XMLDTDFilter;
import org.apache.xerces.xni.parser.XMLDocumentSource;
import org.apache.xerces.xni.parser.XMLParserConfiguration;
import org.apache.xerces.xs.AttributePSVI;
@@ -92,6 +94,7 @@
private XMLComponent fSchemaValidator;
private XMLComponentManager fSchemaValidatorComponentManager;
+ private ValidationManager fSchemaValidationManager;
/** Initial ErrorHandler */
private final ErrorHandler fInitErrorHandler;
@@ -163,7 +166,13 @@
/** For Xerces grammars, use built-in schema validator. **/
if (grammar instanceof XSGrammarPoolContainer) {
validatorComponent = new XMLSchemaValidator();
- fSchemaValidatorComponentManager = new SchemaValidatorConfiguration(config, (XSGrammarPoolContainer) grammar);
+ fSchemaValidationManager = new ValidationManager();
+ XMLDTDFilter entityHandler = new UnparsedEntityHandler(fSchemaValidationManager);
+ config.setDTDHandler(entityHandler);
+ entityHandler.setDTDHandler(xmlReader);
+ xmlReader.setDTDSource(entityHandler);
+ fSchemaValidatorComponentManager = new SchemaValidatorConfiguration(config,
+ (XSGrammarPoolContainer) grammar, fSchemaValidationManager);
}
/** For third party grammars, use the JAXP validator component. **/
else {
@@ -505,6 +514,9 @@
public void parse(InputSource inputSource)
throws SAXException, IOException {
if (fSAXParser != null && fSAXParser.fSchemaValidator != null) {
+ if (fSAXParser.fSchemaValidationManager != null) {
+ fSAXParser.fSchemaValidationManager.reset();
+ }
resetSchemaValidator();
}
super.parse(inputSource);
@@ -513,6 +525,9 @@
public void parse(String systemId)
throws SAXException, IOException {
if (fSAXParser != null && fSAXParser.fSchemaValidator != null) {
+ if (fSAXParser.fSchemaValidationManager != null) {
+ fSAXParser.fSchemaValidationManager.reset();
+ }
resetSchemaValidator();
}
super.parse(systemId);
1.33 +14 -2 xml-xerces/java/src/org/apache/xerces/jaxp/DocumentBuilderImpl.java
Index: DocumentBuilderImpl.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/jaxp/DocumentBuilderImpl.java,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -r1.32 -r1.33
--- DocumentBuilderImpl.java 20 Jun 2005 19:50:56 -0000 1.32
+++ DocumentBuilderImpl.java 21 Jun 2005 17:19:08 -0000 1.33
@@ -26,6 +26,7 @@
import org.apache.xerces.dom.DOMImplementationImpl;
import org.apache.xerces.dom.DOMMessageFormatter;
import org.apache.xerces.impl.Constants;
+import org.apache.xerces.impl.validation.ValidationManager;
import org.apache.xerces.impl.xs.XMLSchemaValidator;
import org.apache.xerces.jaxp.validation.XSGrammarPoolContainer;
import org.apache.xerces.parsers.DOMParser;
@@ -34,6 +35,7 @@
import org.apache.xerces.xni.parser.XMLComponent;
import org.apache.xerces.xni.parser.XMLComponentManager;
import org.apache.xerces.xni.parser.XMLConfigurationException;
+import org.apache.xerces.xni.parser.XMLDTDFilter;
import org.apache.xerces.xni.parser.XMLDocumentSource;
import org.apache.xerces.xni.parser.XMLParserConfiguration;
import org.w3c.dom.DOMImplementation;
@@ -94,6 +96,7 @@
private XMLComponent fSchemaValidator;
private XMLComponentManager fSchemaValidatorComponentManager;
+ private ValidationManager fSchemaValidationManager;
/** Initial ErrorHandler */
private final ErrorHandler fInitErrorHandler;
@@ -156,7 +159,13 @@
/** For Xerces grammars, use built-in schema validator. **/
if (grammar instanceof XSGrammarPoolContainer) {
validatorComponent = new XMLSchemaValidator();
- fSchemaValidatorComponentManager = new SchemaValidatorConfiguration(config, (XSGrammarPoolContainer) grammar);
+ fSchemaValidationManager = new ValidationManager();
+ XMLDTDFilter entityHandler = new UnparsedEntityHandler(fSchemaValidationManager);
+ config.setDTDHandler(entityHandler);
+ entityHandler.setDTDHandler(domParser);
+ domParser.setDTDSource(entityHandler);
+ fSchemaValidatorComponentManager = new SchemaValidatorConfiguration(config,
+ (XSGrammarPoolContainer) grammar, fSchemaValidationManager);
}
/** For third party grammars, use the JAXP validator component. **/
else {
@@ -266,6 +275,9 @@
"jaxp-null-input-source", null));
}
if (fSchemaValidator != null) {
+ if (fSchemaValidationManager != null) {
+ fSchemaValidationManager.reset();
+ }
resetSchemaValidator();
}
domParser.parse(is);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org