You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by kn...@apache.org on 2011/09/19 17:12:32 UTC

svn commit: r1172656 - in /xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl: dv/xs/XSSimpleTypeDecl.java msg/XMLSchemaMessages.properties xs/traversers/XSDAttributeTraverser.java xs/traversers/XSDElementTraverser.java

Author: knoaman
Date: Mon Sep 19 15:12:32 2011
New Revision: 1172656

URL: http://svn.apache.org/viewvc?rev=1172656&view=rev
Log:
NOTATION datatype - Schema Component Constraint - Jira issue 1536
https://issues.apache.org/jira/browse/XERCESJ-1536

Modified:
    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/msg/XMLSchemaMessages.properties
    xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDAttributeTraverser.java
    xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDElementTraverser.java

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/apache/xerces/impl/dv/xs/XSSimpleTypeDecl.java?rev=1172656&r1=1172655&r2=1172656&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 Mon Sep 19 15:12:32 2011
@@ -979,7 +979,7 @@ public class XSSimpleTypeDecl implements
             } else {
                 maxInclusiveAnnotation = facets.maxInclusiveAnnotation;
                 try {
-                    fMaxInclusive = fBase.getActualValue(facets.maxInclusive, context, tempInfo, true);
+                    fMaxInclusive = fBase.getActualValue(facets.maxInclusive, context, tempInfo, true, false);
                     fFacetsDefined |= FACET_MAXINCLUSIVE;
                     if ((fixedFacet & FACET_MAXINCLUSIVE) != 0)
                         fFixedFacet |= FACET_MAXINCLUSIVE;
@@ -1015,7 +1015,7 @@ public class XSSimpleTypeDecl implements
             } else {
                 maxExclusiveAnnotation = facets.maxExclusiveAnnotation;
                 try {
-                    fMaxExclusive = fBase.getActualValue(facets.maxExclusive, context, tempInfo, true);
+                    fMaxExclusive = fBase.getActualValue(facets.maxExclusive, context, tempInfo, true, false);
                     fFacetsDefined |= FACET_MAXEXCLUSIVE;
                     if ((fixedFacet & FACET_MAXEXCLUSIVE) != 0)
                         fFixedFacet |= FACET_MAXEXCLUSIVE;
@@ -1062,7 +1062,7 @@ public class XSSimpleTypeDecl implements
             } else {
                 minExclusiveAnnotation = facets.minExclusiveAnnotation;
                 try {
-                    fMinExclusive = fBase.getActualValue(facets.minExclusive, context, tempInfo, true);
+                    fMinExclusive = fBase.getActualValue(facets.minExclusive, context, tempInfo, true, false);
                     fFacetsDefined |= FACET_MINEXCLUSIVE;
                     if ((fixedFacet & FACET_MINEXCLUSIVE) != 0)
                         fFixedFacet |= FACET_MINEXCLUSIVE;
@@ -1108,7 +1108,7 @@ public class XSSimpleTypeDecl implements
             } else {
                 minInclusiveAnnotation = facets.minInclusiveAnnotation;
                 try {
-                    fMinInclusive = fBase.getActualValue(facets.minInclusive, context, tempInfo, true);
+                    fMinInclusive = fBase.getActualValue(facets.minInclusive, context, tempInfo, true, false);
                     fFacetsDefined |= FACET_MININCLUSIVE;
                     if ((fixedFacet & FACET_MININCLUSIVE) != 0)
                         fFixedFacet |= FACET_MININCLUSIVE;
@@ -1743,7 +1743,7 @@ public class XSSimpleTypeDecl implements
 
         // first normalize string value, and convert it to actual value
         boolean needNormalize = context==null||context.needToNormalize();
-        Object ob = getActualValue(content, context, validatedInfo, needNormalize);
+        Object ob = getActualValue(content, context, validatedInfo, needNormalize, false);
 
         validate(context, validatedInfo);
 
@@ -1753,13 +1753,18 @@ public class XSSimpleTypeDecl implements
 
     protected ValidatedInfo getActualEnumValue(String lexical, ValidationContext ctx, ValidatedInfo info)
     throws InvalidDatatypeValueException {
-        return fBase.validateWithInfo(lexical, ctx, info);
+        return fBase.validateWithInfo(lexical, ctx, info, true);
     }
 
     /**
      * validate a value, and return the compiled form
      */
     public ValidatedInfo validateWithInfo(String content, ValidationContext context, ValidatedInfo validatedInfo) throws InvalidDatatypeValueException {
+        return validateWithInfo(content, context, validatedInfo, false);
+    }
+    
+    private ValidatedInfo validateWithInfo(String content, ValidationContext context,
+            ValidatedInfo validatedInfo, boolean enumerationValidation) throws InvalidDatatypeValueException {
 
         if (context == null)
             context = fEmptyContext;
@@ -1771,7 +1776,7 @@ public class XSSimpleTypeDecl implements
 
         // first normalize string value, and convert it to actual value
         boolean needNormalize = context==null||context.needToNormalize();
-        getActualValue(content, context, validatedInfo, needNormalize);
+        getActualValue(content, context, validatedInfo, needNormalize, enumerationValidation);
 
         validate(context, validatedInfo);
 
@@ -1794,7 +1799,7 @@ public class XSSimpleTypeDecl implements
 
         // first normalize string value, and convert it to actual value
         boolean needNormalize = context==null||context.needToNormalize();
-        Object ob = getActualValue(content, context, validatedInfo, needNormalize);
+        Object ob = getActualValue(content, context, validatedInfo, needNormalize, false);
 
         validate(context, validatedInfo);
 
@@ -2019,7 +2024,8 @@ public class XSSimpleTypeDecl implements
 
     //we can still return object for internal use.
     private Object getActualValue(Object content, ValidationContext context,
-            ValidatedInfo validatedInfo, boolean needNormalize)
+            ValidatedInfo validatedInfo, boolean needNormalize,
+            boolean enumerationValidation)
     throws InvalidDatatypeValueException{        
         String nvalue;
         if (needNormalize) {
@@ -2067,7 +2073,19 @@ public class XSSimpleTypeDecl implements
                 }
             }
 
-            validatedInfo.normalizedValue = nvalue;            
+            validatedInfo.normalizedValue = nvalue;
+            
+            // XML Schema 1.1
+            // xs:Notation cannot be used directly to validate values
+            // without enumeration facet - exception is enumeration values
+            if (context.getTypeValidatorHelper().isXMLSchema11()) {
+                if (fValidationDV == DV_NOTATION &&
+                    (getDefinedFacets() & XSSimpleType.FACET_ENUMERATION) == 0 &&
+                    !enumerationValidation) {
+                    throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.4",
+                            new Object[]{fTypeName, content});
+                }
+            }
             Object avalue = fDVs[fValidationDV].getActualValue(nvalue, context);
             validatedInfo.actualValue = avalue;
             validatedInfo.actualValueType = fBuiltInKind;
@@ -2092,7 +2110,7 @@ public class XSSimpleTypeDecl implements
                 // so we take two steps to get the actual value:
                 // 1. fItemType.getActualValue()
                 // 2. fItemType.chekcFacets()
-                avalue[i] = fItemType.getActualValue(parsedList.nextToken(), context, validatedInfo, false);
+                avalue[i] = fItemType.getActualValue(parsedList.nextToken(), context, validatedInfo, false, enumerationValidation);
                 if (context.needFacetChecking() &&
                         (fItemType.fFacetsDefined != 0 && fItemType.fFacetsDefined != FACET_WHITESPACE)) {
                     fItemType.checkFacets(validatedInfo, context);
@@ -2124,7 +2142,7 @@ public class XSSimpleTypeDecl implements
                     // so we take two steps to get the actual value:
                     // 1. fMemberType[i].getActualValue()
                     // 2. fMemberType[i].chekcFacets()
-                    Object aValue = fMemberTypes[i].getActualValue(_content, context, validatedInfo, true);
+                    Object aValue = fMemberTypes[i].getActualValue(_content, context, validatedInfo, true, enumerationValidation);
                     if (context.needFacetChecking() &&
                             (fMemberTypes[i].fFacetsDefined != 0 && fMemberTypes[i].fFacetsDefined != FACET_WHITESPACE)) {
                         fMemberTypes[i].checkFacets(validatedInfo, context);

Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/msg/XMLSchemaMessages.properties
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/msg/XMLSchemaMessages.properties?rev=1172656&r1=1172655&r2=1172656&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/msg/XMLSchemaMessages.properties (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/msg/XMLSchemaMessages.properties Mon Sep 19 15:12:32 2011
@@ -73,6 +73,7 @@
         cvc-datatype-valid.1.2.1 = cvc-datatype-valid.1.2.1: ''{0}'' is not a valid value for ''{1}''.
         cvc-datatype-valid.1.2.2 = cvc-datatype-valid.1.2.2: ''{0}'' is not a valid value of list type ''{1}''.
         cvc-datatype-valid.1.2.3 = cvc-datatype-valid.1.2.3: ''{0}'' is not a valid value of union type ''{1}''.
+        cvc-datatype-valid.1.2.4 = cvc-datatype-valid.1.2.4: The NOTATION type, ''{0}'' used to validate ''{1}'', must have an enumeration facet value which specifies the notation elements used by this type.
         cvc-elt.1.a = cvc-elt.1.a: Cannot find the declaration of element ''{0}''.
         cvc-elt.1.b = cvc-elt.1.b: The name of the element does not match the name of the element declaration. Saw ''{0}''. Expected ''{1}''.
         cvc-elt.2 = cvc-elt.2: The value of '{'abstract'}' in the element declaration for ''{0}'' must be false.

Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDAttributeTraverser.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDAttributeTraverser.java?rev=1172656&r1=1172655&r2=1172656&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDAttributeTraverser.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDAttributeTraverser.java Mon Sep 19 15:12:32 2011
@@ -426,7 +426,10 @@ class XSDAttributeTraverser extends XSDA
         
         // Step 5: check 3.2.6 constraints
         // check for NOTATION type
-        checkNotationType(nameAtt, attrType, attrDecl);
+        // Only for XML Schema 1.0
+        if (fSchemaHandler.fSchemaVersion < Constants.SCHEMA_VERSION_1_1) {
+            checkNotationType(nameAtt, attrType, attrDecl);
+        }
         
         // 6 If the targetNamespace attribute is present then all of the following must be true:         
         if (targetNsAtt != null) {

Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDElementTraverser.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDElementTraverser.java?rev=1172656&r1=1172655&r2=1172656&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDElementTraverser.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDElementTraverser.java Mon Sep 19 15:12:32 2011
@@ -544,7 +544,10 @@ class XSDElementTraverser extends XSDAbs
         
         // Step 5: check 3.3.6 constraints
         // check for NOTATION type
-        checkNotationType(nameAtt, elementType, elmDecl);
+        // Only for XML Schema 1.0
+        if (fSchemaHandler.fSchemaVersion < Constants.SCHEMA_VERSION_1_1) {
+            checkNotationType(nameAtt, elementType, elmDecl);
+        }
         
         // e-props-correct
         



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