[prev in list] [next in list] [prev in thread] [next in thread] 

List:       xerces-cvs
Subject:    svn commit: r791813 - in
From:       mukulg () apache ! org
Date:       2009-07-07 12:26:22
Message-ID: 20090707122622.8CFE92388866 () eris ! apache ! org
[Download RAW message or body]

Author: mukulg
Date: Tue Jul  7 12:26:22 2009
New Revision: 791813

URL: http://svn.apache.org/viewvc?rev=791813&view=rev
Log:
solved a bug with assertions processing, when having content model, "complexType with \
simpleContent"

Modified:
    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


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=791813&r1=791812&r2=791813&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 \
Tue Jul  7 12:26:22 2009 @@ -50,6 +50,7 @@
 import org.apache.xerces.impl.xs.models.CMBuilder;
 import org.apache.xerces.impl.xs.models.CMNodeFactory;
 import org.apache.xerces.impl.xs.models.XSCMValidator;
+import org.apache.xerces.impl.xs.util.XSObjectListImpl;
 import org.apache.xerces.util.AugmentationsImpl;
 import org.apache.xerces.util.IntStack;
 import org.apache.xerces.util.SymbolTable;
@@ -78,6 +79,7 @@
 import org.apache.xerces.xs.AttributePSVI;
 import org.apache.xerces.xs.ElementPSVI;
 import org.apache.xerces.xs.ShortList;
+import org.apache.xerces.xs.XSAssert;
 import org.apache.xerces.xs.XSComplexTypeDefinition;
 import org.apache.xerces.xs.XSConstants;
 import org.apache.xerces.xs.XSMultiValueFacet;
@@ -2336,19 +2338,48 @@
         // process assertions
         if (fSchemaVersion == Constants.SCHEMA_VERSION_1_1) {
             XSTypeDefinition typeDef = fCurrentPSVI.getTypeDefinition();
-
             Object assertObject = null;
+            
             if (typeDef.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE) {
+                // if elements's governing type is a "complex type"
+                XSObjectListImpl assertions = new XSObjectListImpl();                \
                
                 XSComplexTypeDefinition complexTypeDef = (XSComplexTypeDefinition) \
                typeDef;
-                XSObjectList assertions = complexTypeDef.getAssertions();
-                if (assertions.getLength() > 0) {
-                    assertObject = assertions;
-                    // instantiate the assertions processor
-                    if (assertionProcessor == null) {
-                        initializeAssertProcessor();
-                    }
+                
+                // there could be assertion facets from complexType -> simpleContent
+                // (xs:assertion). add them to the list of assertions to be \
evaluated. +                XSSimpleTypeDefinition simpleContentModel = \
complexTypeDef.getSimpleType();                 +                if \
(simpleContentModel != null) { +                   XSObjectList facets = \
simpleContentModel.getMultiValueFacets(); +                   for (int i = 0; i < \
facets.getLength(); i++) { +                      XSMultiValueFacet facet = \
(XSMultiValueFacet) facets.item(i); +                      if (facet.getFacetKind() \
== XSSimpleTypeDefinition.FACET_ASSERT) { +                        Vector \
simpleTypeAsserts = facet.getAsserts(); +                        for (int j = 0; j < \
simpleTypeAsserts.size(); j++) { +                          \
assertions.addXSObject((XSAssert)simpleTypeAsserts.elementAt(j));     +               \
}                         +                        break;
+                     }
+                  }  
+              }
+              
+              // there could be assertions, from the complex type definition
+              // (xs:assert). add them to the list of assertions to be evaluated.
+              XSObjectList complexTypeAsserts = complexTypeDef.getAssertions();
+              if (complexTypeAsserts.getLength() > 0) {
+                for (int i = 0; i < complexTypeAsserts.getLength(); i++) {
+                  assertions.addXSObject((XSAssert)complexTypeAsserts.get(i));
+                }
+              }
+              
+              if (assertions.size() > 0) {
+                assertObject = assertions;
+                // instantiate the assertions processor
+                if (assertionProcessor == null) {
+                   initializeAssertProcessor();
                 }
+              }
             } else if (typeDef.getTypeCategory() == XSTypeDefinition.SIMPLE_TYPE) {
+                // if elements's governing type is a "simple type"
                 XSSimpleTypeDefinition simpleTypeDef = (XSSimpleTypeDefinition) \
                typeDef;
                 XSObjectList facets = simpleTypeDef.getMultiValueFacets();
                 for (int i = 0; i < facets.getLength(); i++) {

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=791813&r1=791812&r2=791813&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 \
Tue Jul  7 12:26:22 2009 @@ -676,21 +676,21 @@
             if (fXSSimpleType instanceof XSSimpleTypeDecl) {
                 ((XSSimpleTypeDecl)fXSSimpleType).setAnonymous(true);
             }
-            try{
+            try {
                 fValidationState.setNamespaceSupport(schemaDoc.fNamespaceSupport);
                 fXSSimpleType.applyFacets(facetData, presentFacets, fixedFacets, \
                fValidationState);
-            }catch(InvalidDatatypeFacetException ex){
+            }
+            catch(InvalidDatatypeFacetException ex){
                 reportSchemaError(ex.getKey(), ex.getArgs(), simpleContent);
             }
             
             // -----------------------------------------------------------------------
                
-            // Traverse any attributes
+            // Traverse any attributes/asserts
             // -----------------------------------------------------------------------
  if (attrOrAssertNode != null) {
                 if (isAttrOrAttrGroup(attrOrAssertNode)) {
                     Element node=traverseAttrsAndAttrGrps(attrOrAssertNode,fAttrGrp,
                             schemaDoc,grammar,fComplexTypeDecl);
-
                     if (node != null) {
                         if (isAssert(node)) {
                             traverseAsserts(node, schemaDoc, grammar,
@@ -705,12 +705,10 @@
                                             DOMUtil.getLocalName(node) }, node);
                         }
                     }
-                }
-                else if (isAssert(attrOrAssertNode)) {
+                } else if (isAssert(attrOrAssertNode)) {
                     traverseAsserts(attrOrAssertNode, schemaDoc, grammar,
                             fComplexTypeDecl);
-                }
-                else  {
+                } else  {
                     fAttrChecker.returnAttrArray(simpleContentAttrValues, \
                schemaDoc);
                     fAttrChecker.returnAttrArray(derivationTypeAttrValues, \
                schemaDoc);
                     throw new \
ComplexTypeRecoverableError("s4s-elt-invalid-content.1", @@ -745,7 +743,7 @@
             fXSSimpleType = baseValidator;
             if (simpleContent != null) {
                 // -----------------------------------------------------------------------
                
-                // Traverse any attributes
+                // Traverse any attributes/asserts
                 // -----------------------------------------------------------------------
  Element attrOrAssertNode = simpleContent;
                 if (isAttrOrAttrGroup(attrOrAssertNode)) {



---------------------------------------------------------------------
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