[prev in list] [next in list] [prev in thread] [next in thread]
List: xerces-cvs
Subject: svn commit: r1072361 - in
From: mukulg () apache ! org
Date: 2011-02-19 15:46:26
Message-ID: 20110219154626.6B3DE2388A38 () eris ! apache ! org
[Download RAW message or body]
Author: mukulg
Date: Sat Feb 19 15:46:25 2011
New Revision: 1072361
URL: http://svn.apache.org/viewvc?rev=1072361&view=rev
Log:
improving upon dateTime and dateTimeStamp type implementations. dateTime in XML \
Schema 1.1 allows the year 0000 -- this change improves upon this. I've added methods \
in ValidationContext interface to support this change (essentially to set \
schemaLanguage version from the traverser layer).
Modified:
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dv/ValidationContext.java
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dv/xs/AbstractDateTimeDV.java
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dv/xs/DateTimeDV.java
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dv/xs/DateTimeStampDV.java
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dv/xs/XSSimpleTypeDecl.java
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/validation/ValidationState.java
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDComplexTypeTraverser.java
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDSimpleTypeTraverser.java
Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dv/ValidationContext.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apac \
he/xerces/impl/dv/ValidationContext.java?rev=1072361&r1=1072360&r2=1072361&view=diff \
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dv/ValidationContext.java \
(original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dv/ValidationContext.java \
Sat Feb 19 15:46:25 2011 @@ -65,4 +65,8 @@ public interface ValidationContext {
// TypeValidatorHelper
public TypeValidatorHelper getTypeValidatorHelper();
+
+ // indicating XML Schema 1.1 support
+ public void setIsSchema11Context(boolean isSchema11Type);
+ public boolean getIsSchema11Context();
}
Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dv/xs/AbstractDateTimeDV.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apac \
he/xerces/impl/dv/xs/AbstractDateTimeDV.java?rev=1072361&r1=1072360&r2=1072361&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dv/xs/AbstractDateTimeDV.java \
(original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dv/xs/AbstractDateTimeDV.java \
Sat Feb 19 15:46:25 2011 @@ -413,14 +413,6 @@ public abstract class \
AbstractDateTimeDV //REVISIT: should we throw an exception for not valid dates
// or reporting an error message should be sufficient?
- /**
- * XML Schema 1.1 - RQ-123: Allow year 0000 in date related types.
- */
- if (!Constants.SCHEMA_1_1_SUPPORT && data.year==0 ) {
- throw new RuntimeException("The year \"0000\" is an illegal year value");
-
- }
-
if ( data.month<1 || data.month>12 ) {
throw new RuntimeException("The month must have values 1 to 12");
@@ -477,6 +469,18 @@ public abstract class AbstractDateTimeDV
}
+ protected void validateDateTime (DateTimeData data, boolean isSchema11Type) {
+ /**
+ * XML Schema 1.1: Allow year 0000 in date related types.
+ */
+ if (isSchema11Type) {
+ validateDateTime(data);
+ }
+ else if (!isSchema11Type && data.year==0) {
+ throw new RuntimeException("The year \"0000\" is an illegal year \
value"); + }
+ }
+
/**
* Return index of UTC char: 'Z', '+', '-'
*
Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dv/xs/DateTimeDV.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dv/xs/DateTimeDV.java?rev=1072361&r1=1072360&r2=1072361&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dv/xs/DateTimeDV.java \
(original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dv/xs/DateTimeDV.java \
Sat Feb 19 15:46:25 2011 @@ -37,8 +37,11 @@ import org.apache.xerces.impl.dv.Validat
*/
public class DateTimeDV extends AbstractDateTimeDV {
+ private boolean fIsSchema11Context = false;
+
public Object getActualValue(String content, ValidationContext context) throws \
InvalidDatatypeValueException { try{
+ fIsSchema11Context = context.getIsSchema11Context();
return parse(content);
} catch(Exception ex){
throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new \
Object[]{content, "dateTime"}); @@ -73,7 +76,7 @@ public class DateTimeDV extends \
Abstract //validate and normalize
//REVISIT: do we need SchemaDateTimeException?
- validateDateTime(date);
+ validateDateTime(date, fIsSchema11Context);
//save unnormalized values
saveUnnormalized(date);
@@ -84,6 +87,10 @@ public class DateTimeDV extends Abstract
return date;
}
+ protected void setIsSchema11Context(boolean isSchema11Context) {
+ fIsSchema11Context = isSchema11Context;
+ }
+
protected XMLGregorianCalendar getXMLGregorianCalendar(DateTimeData date) {
return datatypeFactory.newXMLGregorianCalendar(BigInteger.valueOf(date.unNormYear), \
date.unNormMonth, date.unNormDay, date.unNormHour, date.unNormMinute,
Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dv/xs/DateTimeStampDV.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apac \
he/xerces/impl/dv/xs/DateTimeStampDV.java?rev=1072361&r1=1072360&r2=1072361&view=diff \
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dv/xs/DateTimeStampDV.java \
(original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dv/xs/DateTimeStampDV.java \
Sat Feb 19 15:46:25 2011 @@ -36,11 +36,16 @@ public class DateTimeStampDV extends Dat
throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new \
Object[]{content, "dateTimeStamp"}); }
}
-
- protected void validateDateTime (DateTimeData data){
- super.validateDateTime(data);
- if (data.utc == 0)
+
+ protected DateTimeData parse(String str) throws SchemaDateTimeException {
+ setIsSchema11Context(true);
+ DateTimeData parsedDateTime = super.parse(str);
+ if (parsedDateTime.utc == 0) {
throw new RuntimeException("dateTimeStamp must have timezone");
+ }
+ else {
+ return parsedDateTime;
+ }
}
}
Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dv/xs/XSSimpleTypeDecl.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apac \
he/xerces/impl/dv/xs/XSSimpleTypeDecl.java?rev=1072361&r1=1072360&r2=1072361&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dv/xs/XSSimpleTypeDecl.java \
(original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/dv/xs/XSSimpleTypeDecl.java \
Sat Feb 19 15:46:25 2011 @@ -243,6 +243,13 @@ public class XSSimpleTypeDecl \
implements public TypeValidatorHelper getTypeValidatorHelper() {
return TypeValidatorHelper.getInstance(Constants.SCHEMA_VERSION_1_0);
}
+ public boolean getIsSchema11Context() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+ public void setIsSchema11Context(boolean isSchema11Type) {
+ // TODO Auto-generated method stub
+ }
};
protected static TypeValidator[] getGDVs() {
@@ -817,7 +824,7 @@ public class XSSimpleTypeDecl implements
*/
void applyFacets(XSFacets facets, int presentFacet, int fixedFacet, short \
patternType, ValidationContext context) throws InvalidDatatypeFacetException {
-
+
// if the object is immutable, should not apply facets...
if(fIsImmutable) return;
ValidatedInfo tempInfo = new ValidatedInfo();
@@ -2046,8 +2053,7 @@ public class XSSimpleTypeDecl implements
//we can still return object for internal use.
private Object getActualValue(Object content, ValidationContext context,
ValidatedInfo validatedInfo, boolean needNormalize)
- throws InvalidDatatypeValueException{
-
+ throws InvalidDatatypeValueException{
String nvalue;
if (needNormalize) {
nvalue = normalize(content, fWhiteSpace);
@@ -2092,7 +2098,7 @@ public class XSSimpleTypeDecl implements
}
}
- validatedInfo.normalizedValue = nvalue;
+ validatedInfo.normalizedValue = nvalue;
Object avalue = fDVs[fValidationDV].getActualValue(nvalue, context);
validatedInfo.actualValue = avalue;
validatedInfo.actualValueType = fBuiltInKind;
@@ -3155,6 +3161,15 @@ public class XSSimpleTypeDecl implements
public TypeValidatorHelper getTypeValidatorHelper() {
return TypeValidatorHelper.getInstance(Constants.SCHEMA_VERSION_1_0);
}
+
+ public boolean getIsSchema11Context() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public void setIsSchema11Context(boolean isSchema11Type) {
+ // TODO Auto-generated method stub
+ }
};
private boolean fAnonymous = false;
@@ -3231,6 +3246,15 @@ public class XSSimpleTypeDecl implements
public TypeValidatorHelper getTypeValidatorHelper() {
return fExternal.getTypeValidatorHelper();
}
+
+ public boolean getIsSchema11Context() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public void setIsSchema11Context(boolean isSchema11Type) {
+ // TODO Auto-generated method stub
+ }
}
public void reset(){
Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/validation/ValidationState.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apac \
he/xerces/impl/validation/ValidationState.java?rev=1072361&r1=1072360&r2=1072361&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/validation/ValidationState.java \
(original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/validation/ValidationState.java \
Sat Feb 19 15:46:25 2011 @@ -56,6 +56,8 @@ public class ValidationState implements
private final static Object fNullValue = new Object();
private TypeValidatorHelper fTypeValidatorHelper = null;
+
+ private boolean fIsSchema11Context = false;
//
// public methods
@@ -215,4 +217,12 @@ public class ValidationState implements
public TypeValidatorHelper getTypeValidatorHelper() {
return fTypeValidatorHelper;
}
+
+ public boolean getIsSchema11Context() {
+ return fIsSchema11Context;
+ }
+
+ public void setIsSchema11Context(boolean isSchema11Context) {
+ fIsSchema11Context = isSchema11Context;
+ }
}
Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apac \
he/xerces/impl/xs/XMLSchemaValidator.java?rev=1072361&r1=1072360&r2=1072361&view=diff \
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java \
(original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java \
Sat Feb 19 15:46:25 2011 @@ -749,6 +749,7 @@ public class XMLSchemaValidator
throws XNIException {
fValidationState.setNamespaceSupport(namespaceContext);
+ fValidationState.setIsSchema11Context(fSchemaVersion == \
Constants.SCHEMA_VERSION_1_1); \
fState4XsiType.setNamespaceSupport(namespaceContext); \
fState4ApplyDefault.setNamespaceSupport(namespaceContext); fLocator = locator;
Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDComplexTypeTraverser.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apac \
he/xerces/impl/xs/traversers/XSDComplexTypeTraverser.java?rev=1072361&r1=1072360&r2=1072361&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDComplexTypeTraverser.java \
(original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDComplexTypeTraverser.java \
Sat Feb 19 15:46:25 2011 @@ -763,6 +763,7 @@ class XSDComplexTypeTraverser extends X
fXSSimpleType = \
fSchemaHandler.fDVFactory.createTypeRestriction(name,schemaDoc.fTargetNamespace,(short)0,baseValidator,null);
try{
fValidationState.setNamespaceSupport(schemaDoc.fNamespaceSupport);
+ fValidationState.setIsSchema11Context(fSchemaHandler.fSchemaVersion \
== Constants.SCHEMA_VERSION_1_1);
fXSSimpleType.applyFacets(facetData, presentFacets, fixedFacets, \
fValidationState); }catch(InvalidDatatypeFacetException ex){
reportSchemaError(ex.getKey(), ex.getArgs(), simpleContent);
Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDSimpleTypeTraverser.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apac \
he/xerces/impl/xs/traversers/XSDSimpleTypeTraverser.java?rev=1072361&r1=1072360&r2=1072361&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDSimpleTypeTraverser.java \
(original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDSimpleTypeTraverser.java \
Sat Feb 19 15:46:25 2011 @@ -436,6 +436,7 @@ class XSDSimpleTypeTraverser extends XSD
try {
fValidationState.setNamespaceSupport(schemaDoc.fNamespaceSupport);
+ fValidationState.setIsSchema11Context(fSchemaHandler.fSchemaVersion \
== Constants.SCHEMA_VERSION_1_1);
newDecl.applyFacets(fi.facetdata, fi.fPresentFacets, \
fi.fFixedFacets, fValidationState); } catch (InvalidDatatypeFacetException ex) {
reportSchemaError(ex.getKey(), ex.getArgs(), child);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic