Author: mrglavas
Date: Mon Nov 7 04:02:43 2011
New Revision: 1198620
URL: http://svn.apache.org/viewvc?rev=1198620&view=rev
Log:
Fixing a bug. The schema version property is supposed to be read-only. Users
can only choose the version when they create the SchemaFactory. This ensures
that the semantics of XML Schema 1.1 are applied consistently from schema
loading through instance validation.
Modified:
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/jaxp/validation/ValidatorHandlerImpl.java
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/jaxp/validation/ValidatorImpl.java
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/jaxp/validation/XMLSchemaValidatorComponentManager.java
Modified:
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/jaxp/validation/ValidatorHandlerImpl.java
URL:
http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/jaxp/validation/ValidatorHandlerImpl.java?rev=1198620&r1=1198619&r2=1198620&view=diff
==============================================================================
---
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/jaxp/validation/ValidatorHandlerImpl.java
(original)
+++
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/jaxp/validation/ValidatorHandlerImpl.java
Mon Nov 7 04:02:43 2011
@@ -135,6 +135,10 @@ final class ValidatorHandlerImpl extends
/** Property identifier: validation manager. */
private static final String VALIDATION_MANAGER =
Constants.XERCES_PROPERTY_PREFIX +
Constants.VALIDATION_MANAGER_PROPERTY;
+
+ /** Property identifier: xml schema version. */
+ private static final String XML_SCHEMA_VERSION =
+ Constants.XERCES_PROPERTY_PREFIX +
Constants.XML_SCHEMA_VERSION_PROPERTY;
//
// Data
@@ -321,6 +325,11 @@ final class ValidatorHandlerImpl extends
throw new
NullPointerException(JAXPValidationMessageFormatter.formatMessage(fComponentManager.getLocale(),
"ProperyNameNull", null));
}
+ if (XML_SCHEMA_VERSION.equals(name)) {
+ throw new SAXNotSupportedException(
+
SAXMessageFormatter.formatMessage(fComponentManager.getLocale(),
+ "property-read-only", new Object [] {name}));
+ }
try {
fComponentManager.setProperty(name, object);
}
Modified:
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/jaxp/validation/ValidatorImpl.java
URL:
http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/jaxp/validation/ValidatorImpl.java?rev=1198620&r1=1198619&r2=1198620&view=diff
==============================================================================
---
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/jaxp/validation/ValidatorImpl.java
(original)
+++
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/jaxp/validation/ValidatorImpl.java
Mon Nov 7 04:02:43 2011
@@ -64,6 +64,10 @@ final class ValidatorImpl extends Valida
private static final String CURRENT_ELEMENT_NODE =
Constants.XERCES_PROPERTY_PREFIX +
Constants.CURRENT_ELEMENT_NODE_PROPERTY;
+ /** Property identifier: xml schema version. */
+ private static final String XML_SCHEMA_VERSION =
+ Constants.XERCES_PROPERTY_PREFIX +
Constants.XML_SCHEMA_VERSION_PROPERTY;
+
//
// Data
//
@@ -268,7 +272,7 @@ final class ValidatorImpl extends Valida
throw new
NullPointerException(JAXPValidationMessageFormatter.formatMessage(fComponentManager.getLocale(),
"ProperyNameNull", null));
}
- if (CURRENT_ELEMENT_NODE.equals(name)) {
+ if (CURRENT_ELEMENT_NODE.equals(name) ||
XML_SCHEMA_VERSION.equals(name)) {
throw new SAXNotSupportedException(
SAXMessageFormatter.formatMessage(fComponentManager.getLocale(),
"property-read-only", new Object [] {name}));
Modified:
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/jaxp/validation/XMLSchemaValidatorComponentManager.java
URL:
http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/jaxp/validation/XMLSchemaValidatorComponentManager.java?rev=1198620&r1=1198619&r2=1198620&view=diff
==============================================================================
---
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/jaxp/validation/XMLSchemaValidatorComponentManager.java
(original)
+++
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/jaxp/validation/XMLSchemaValidatorComponentManager.java
Mon Nov 7 04:02:43 2011
@@ -173,6 +173,9 @@ final class XMLSchemaValidatorComponentM
*/
private boolean fUseGrammarPoolOnly;
+ /** Whether the XML Schema is 1.1 or not */
+ private final String fXSDVersion;
+
/** Lookup map for components required for validation. **/
private final HashMap fComponents = new HashMap();
@@ -235,7 +238,8 @@ final class XMLSchemaValidatorComponentM
fComponents.put(NAMESPACE_CONTEXT, fNamespaceContext);
fSchemaValidator = new XMLSchemaValidator();
- fSchemaValidator.setProperty(XML_SCHEMA_VERSION,
grammarContainer.getXMLSchemaVersion());
+ fXSDVersion = grammarContainer.getXMLSchemaVersion();
+ fSchemaValidator.setProperty(XML_SCHEMA_VERSION, fXSDVersion);
fComponents.put(SCHEMA_VALIDATOR, fSchemaValidator);
fValidationManager = new ValidationManager();
@@ -373,6 +377,9 @@ final class XMLSchemaValidatorComponentM
if (LOCALE.equals(propertyId)) {
return getLocale();
}
+ else if (XML_SCHEMA_VERSION.equals(propertyId)) {
+ return fXSDVersion;
+ }
final Object component = fComponents.get(propertyId);
if (component != null) {
return component;
@@ -395,7 +402,7 @@ final class XMLSchemaValidatorComponentM
if ( ENTITY_MANAGER.equals(propertyId) ||
ERROR_REPORTER.equals(propertyId) ||
NAMESPACE_CONTEXT.equals(propertyId) ||
SCHEMA_VALIDATOR.equals(propertyId) ||
SYMBOL_TABLE.equals(propertyId) ||
VALIDATION_MANAGER.equals(propertyId) ||
- XMLGRAMMAR_POOL.equals(propertyId)) {
+ XMLGRAMMAR_POOL.equals(propertyId) ||
XML_SCHEMA_VERSION.equals(propertyId)) {
throw new
XMLConfigurationException(XMLConfigurationException.NOT_SUPPORTED, propertyId);
}
fConfigUpdated = true;
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]