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 2009/12/10 19:33:27 UTC

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

Author: knoaman
Date: Thu Dec 10 18:33:26 2009
New Revision: 889357

URL: http://svn.apache.org/viewvc?rev=889357&view=rev
Log:
Make sure that the type of the CTA is either xs:error or is validly derived from the type of the element.

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/XSDTypeAlternativeTraverser.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=889357&r1=889356&r2=889357&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 Thu Dec 10 18:33:26 2009
@@ -229,6 +229,7 @@
         e-props-correct.4 = e-props-correct.4: The '{'type definition'}' of element ''{0}'' is not validly derived from the '{'type definition'}' of the substitutionHead ''{1}'', or the '{'substitution group exclusions'}' property of ''{1}'' does not allow this derivation.
         e-props-correct.5 = e-props-correct.5: A '{'value constraint'}' must not be present on element ''{0}'', because the element''s '{'type definition'}' or '{'type definition'}'''s '{'content type'}' is ID, or is derived from ID.
         e-props-correct.6 = e-props-correct.6: Circular substitution group detected for element ''{0}''.
+        e-props-correct.7 = e-props-correct.7: Type alternative ''{1}'' is not xs:error or is not validly derived from the type definition, ''{2}'', of element ''{0}''.
         fractionDigits-valid-restriction = fractionDigits-valid-restriction: In the definition of {2}, the value ''{0}'' for the facet ''fractionDigits'' is invalid, because it must be <= the value for ''fractionDigits'' which was set to ''{1}'' in one of the ancestor types.
         fractionDigits-totalDigits = fractionDigits-totalDigits: In the definition of {2}, the value ''{0}'' for the facet ''fractionDigits'' is invalid, because the value must be <= the value for ''totalDigits'' which is ''{1}''.
         length-minLength-maxLength.1.1 = length-minLength-maxLength.1.1: For type {0}, it is an error for the value of length ''{1}'' to be less than the value of minLength ''{2}''.

Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDTypeAlternativeTraverser.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDTypeAlternativeTraverser.java?rev=889357&r1=889356&r2=889357&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDTypeAlternativeTraverser.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDTypeAlternativeTraverser.java Thu Dec 10 18:33:26 2009
@@ -17,11 +17,14 @@
 
 package org.apache.xerces.impl.xs.traversers;
 
+import org.apache.xerces.impl.Constants;
+import org.apache.xerces.impl.dv.XSSimpleType;
 import org.apache.xerces.impl.xpath.XPath20;
 import org.apache.xerces.impl.xpath.XPathException;
 import org.apache.xerces.impl.xs.SchemaGrammar;
 import org.apache.xerces.impl.xs.SchemaSymbols;
 import org.apache.xerces.impl.xs.XSAnnotationImpl;
+import org.apache.xerces.impl.xs.XSComplexTypeDecl;
 import org.apache.xerces.impl.xs.XSElementDecl;
 import org.apache.xerces.impl.xs.alternative.Test;
 import org.apache.xerces.impl.xs.alternative.XSTypeAlternativeImpl;
@@ -54,6 +57,12 @@
  * @version $Id$
  */
 class XSDTypeAlternativeTraverser extends XSDAbstractTraverser {
+    
+    private static final XSSimpleType fErrorType;
+    static {
+        SchemaGrammar grammar = SchemaGrammar.getS4SGrammar(Constants.SCHEMA_VERSION_1_1);
+        fErrorType = (XSSimpleType)grammar.getGlobalTypeDecl("error");
+    }
 
     XSDTypeAlternativeTraverser (XSDHandler handler,
             XSAttributeChecker attrChecker) {
@@ -141,10 +150,28 @@
         if (typeAtt == null && !hasAnonType) {
             reportSchemaError("src-type-alternative.3.12.13.2", null, altElement);
         }
-        
+
         // fall back to the element declaration's type
         if (alternativeType == null) {
-            alternativeType= element.fType;
+            alternativeType = element.fType;
+        }
+        // Element Properties Correct
+        // 7.1 T is validly substitutable for E.{type definition}, subject to
+        //     the blocking keywords of E.{disallowed substitutions}.
+        // 7.2 T is the type xs:error
+        else if (alternativeType != fErrorType){
+            short block = element.fBlock; 
+            if (element.fType.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE) {
+                block |= ((XSComplexTypeDecl) element.fType).getProhibitedSubstitutions();
+            }
+            if (!fSchemaHandler.fXSConstraints.checkTypeDerivationOk(alternativeType, element.fType, block)) {
+                reportSchemaError(
+                        "e-props-correct.7",
+                        new Object[] { element.getName(), alternativeType.getName(), element.fType.getName()},
+                        altElement);
+            }
+            // fall back to element declaration's type
+            alternativeType = element.fType;
         }
 
         // not expecting any more children
@@ -185,7 +212,7 @@
             //set the xpathDefaultNamespace attribute value
             typeAlternative.setXPathDefauleNamespace(xpathNS);
         }
-
+        
         grammar.addTypeAlternative(element, typeAlternative);
         fAttrChecker.returnAttrArray(attrValues, schemaDoc);
     }



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