You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by mu...@apache.org on 2011/05/04 12:54:06 UTC

svn commit: r1099408 - in /xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl: msg/XMLSchemaMessages.properties xs/traversers/XSDSimpleTypeTraverser.java

Author: mukulg
Date: Wed May  4 10:54:06 2011
New Revision: 1099408

URL: http://svn.apache.org/viewvc?rev=1099408&view=rev
Log:
committing an improvement to schema 1.1 simpleType-> {list|union} implementation.

schema 1.1 requires that itemType of xs:list and memberTypes of xs:union cannot refer to special simple types, xs:anyAtomicType or xs:anySimpleType. there are also few test cases in XML Schema 1.1 test suite, which do such tests.

this commit makes this improvement.

Modified:
    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/XSDSimpleTypeTraverser.java

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=1099408&r1=1099407&r2=1099408&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 Wed May  4 10:54:06 2011
@@ -308,6 +308,7 @@
 #        We're using sch-props-correct.2 instead of the old src-redefine.1
 #        src-redefine.1 = src-redefine.1: The component ''{0}'' is begin redefined, but its corresponding component isn't in the schema document being redefined (with namespace ''{2}''), but in a different document, with namespace ''{1}''.
         sch-props-correct.2 = sch-props-correct.2: A schema cannot contain two global components with the same name; this schema contains two occurrences of ''{0}''.
+        st-props-correct.1 = st-props-correct.1: ''itemType'' of xs:list and ''memberTypes'' of xs:union cannot refer to special types, xs:anyAtomicType or xs:anySimpleType. 
         st-props-correct.2 = st-props-correct.2: Circular definitions have been detected for simple type ''{0}''. This means that ''{0}'' is contained in its own type hierarchy, which is an error.
         st-props-correct.3 = st-props-correct.3: Error for type ''{0}''. The value of '{'final'}' of the '{'base type definition'}', ''{1}'', forbids derivation by restriction.
         totalDigits-valid-restriction = totalDigits-valid-restriction: In the definition of {2}, the value ''{0}'' for the facet ''totalDigits'' is invalid, because it must be <= the value for ''totalDigits'' which was set to ''{1}'' in one of the ancestor types.

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/apache/xerces/impl/xs/traversers/XSDSimpleTypeTraverser.java?rev=1099408&r1=1099407&r2=1099408&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 Wed May  4 10:54:06 2011
@@ -302,6 +302,11 @@ class XSDSimpleTypeTraverser extends XSD
                 return null;
             }
         }
+        
+        if (fSchemaHandler.fSchemaVersion == Constants.SCHEMA_VERSION_1_1 && list && baseValidator != null && isSpecialSimpleType(baseValidator)) {
+            reportSchemaError("st-props-correct.1", new Object[0], child);  
+        }
+        
         // get types from "memberTypes" attribute
         ArrayList dTValidators = null;
         XSSimpleType dv = null;
@@ -315,6 +320,9 @@ class XSDSimpleTypeTraverser extends XSD
                 dv = findDTValidator(child, name, (QName)memberTypes.elementAt(i),
                         XSConstants.DERIVATION_UNION, schemaDoc);
                 if (dv != null) {
+                    if (fSchemaHandler.fSchemaVersion == Constants.SCHEMA_VERSION_1_1 && isSpecialSimpleType(dv)) {
+                        reportSchemaError("st-props-correct.1", new Object[0], child);  
+                    }
                     // if it's a union, expand it
                     // In XML Schema 1.1, we do not expand
                     if (dv.getVariety() == XSSimpleType.VARIETY_UNION &&
@@ -576,4 +584,15 @@ class XSDSimpleTypeTraverser extends XSD
         return null;
     }
     
+    /*
+     * Check if a simpleType definition is one of special types (i.e xs:anyAtomicType or xs:anySimpleType).
+     */
+    private boolean isSpecialSimpleType(XSSimpleType simpleType) {        
+        boolean isSpecialSimpleType = false;        
+        if (Constants.NS_XMLSCHEMA.equals(simpleType.getNamespace()) && (SchemaSymbols.ATTVAL_ANYATOMICTYPE.equals(simpleType.getName()) || SchemaSymbols.ATTVAL_ANYSIMPLETYPE.equals(simpleType.getName()))) {
+            isSpecialSimpleType = true; 
+        }        
+        return isSpecialSimpleType;        
+    } // isSpecialSimpleType
+    
 }//class XSDSimpleTypeTraverser



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