Author: knoaman
Date: Mon Nov  3 08:31:51 2008
New Revision: 710097

URL: http://svn.apache.org/viewvc?rev=710097&view=rev
Log:
Add traversal support for assertions on complex types - patch by Mukul Ghandi

Modified:
    
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/SchemaSymbols.java
    
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSComplexTypeDecl.java
    
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSAttributeChecker.java
    
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDAbstractTraverser.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/xs/XSAssert.java
    
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/xs/XSComplexTypeDefinition.java

Modified: 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/SchemaSymbols.java
URL: 
http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/SchemaSymbols.java?rev=710097&r1=710096&r2=710097&view=diff
==============================================================================
--- 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/SchemaSymbols.java
 (original)
+++ 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/SchemaSymbols.java
 Mon Nov  3 08:31:51 2008
@@ -51,6 +51,7 @@
     // all possible schema element names
     public static final String ELT_ALL                    = "all".intern();
     public static final String ELT_ASSERT                 = "assert".intern();
+    public static final String ELT_ASSERTION              = 
"assertion".intern();    
     public static final String ELT_ALTERNATIVE            = 
"alternative".intern();
     public static final String ELT_ANNOTATION             = 
"annotation".intern();
     public static final String ELT_ANY                    = "any".intern();

Modified: 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSComplexTypeDecl.java
URL: 
http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSComplexTypeDecl.java?rev=710097&r1=710096&r2=710097&view=diff
==============================================================================
--- 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSComplexTypeDecl.java
 (original)
+++ 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSComplexTypeDecl.java
 Mon Nov  3 08:31:51 2008
@@ -95,6 +95,9 @@
 
     // the open content
     XSOpenContentDecl fOpenContent = null;
+    
+    // list of assertions affiliated with this type
+    XSObjectListImpl fAssertions = null;
 
     // DOM Level 3 TypeInfo Derivation Method constants
     static final int DERIVATION_ANY = 0;
@@ -169,6 +172,10 @@
         fMiscFlags |= CT_IS_ANONYMOUS;
     }
 
+    public void setAssertions(XSObjectListImpl assertions) {
+       fAssertions = assertions;
+    }
+
     public XSCMValidator getContentModel(CMBuilder cmBuilder) {
         return getContentModel(cmBuilder, false);
     }
@@ -559,6 +566,10 @@
             fAnnotations.clear();
         }
         fAnnotations = null;
+        if (fAssertions != null) {
+               fAssertions.clear();
+        }
+        fAssertions = null;
     }
 
     /**
@@ -737,5 +748,9 @@
     public XSOpenContent getOpenContent() {
         return fOpenContent;
     }
+    
+    public XSObjectList getAssertions() {
+        return (fAssertions != null) ? fAssertions : 
XSObjectListImpl.EMPTY_LIST;
+    }
 
 } // class XSComplexTypeDecl

Modified: 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSAttributeChecker.java
URL: 
http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSAttributeChecker.java?rev=710097&r1=710096&r2=710097&view=diff
==============================================================================
--- 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSAttributeChecker.java
 (original)
+++ 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSAttributeChecker.java
 Mon Nov  3 08:31:51 2008
@@ -1212,6 +1212,8 @@
         // xpathDefaultNamespace = (anyURI | (##defaultNamespace | 
##targetNamespace | ##local))
         attrList.put(SchemaSymbols.ATT_XPATH_DEFAULT_NS, 
allAttrs[ATT_DEFAULT_XPATH_NS_N]);
         fEleAttrs11MapL.put(SchemaSymbols.ELT_ASSERT, attrList);
+        // for element "assertion" - local // mukul
+        fEleAttrs11MapL.put(SchemaSymbols.ELT_ASSERTION, attrList);
 
         // for element "defaultOpenContent" - global
         attrList = Container.getContainer(3);

Modified: 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDAbstractTraverser.java
URL: 
http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDAbstractTraverser.java?rev=710097&r1=710096&r2=710097&view=diff
==============================================================================
--- 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDAbstractTraverser.java
 (original)
+++ 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDAbstractTraverser.java
 Mon Nov  3 08:31:51 2008
@@ -376,8 +376,8 @@
                     reportSchemaError("s4s-elt-must-match.1", new 
Object[]{"pattern", "(annotation?)", DOMUtil.getLocalName(child)}, child);
                 }
             }
-            // process 'assert' facet. introduced in XML Schema 1.1
-            else if (facet.equals(SchemaSymbols.ELT_ASSERT)) {                
+            // process 'assertion' facet. introduced in XML Schema 1.1
+            else if (facet.equals(SchemaSymbols.ELT_ASSERTION)) {
                 attrs = fAttrChecker.checkAttributes(content, false, 
schemaDoc);
                 String test = (String) attrs[XSAttributeChecker.ATTIDX_XPATH];
                 String defaultNamespace = (String) 
attrs[XSAttributeChecker.ATTIDX_XPATHDEFAULTNS];

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/apache/xerces/impl/xs/traversers/XSDComplexTypeTraverser.java?rev=710097&r1=710096&r2=710097&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
 Mon Nov  3 08:31:51 2008
@@ -22,6 +22,8 @@
 import org.apache.xerces.impl.dv.XSFacets;
 import org.apache.xerces.impl.dv.XSSimpleType;
 import org.apache.xerces.impl.dv.xs.XSSimpleTypeDecl;
+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;
@@ -33,6 +35,8 @@
 import org.apache.xerces.impl.xs.XSOpenContentDecl;
 import org.apache.xerces.impl.xs.XSParticleDecl;
 import org.apache.xerces.impl.xs.XSWildcardDecl;
+import org.apache.xerces.impl.xs.assertion.Test;
+import org.apache.xerces.impl.xs.assertion.XSAssertImpl;
 import org.apache.xerces.impl.xs.util.XInt;
 import org.apache.xerces.impl.xs.util.XSObjectListImpl;
 import org.apache.xerces.util.DOMUtil;
@@ -67,7 +71,7 @@
 class  XSDComplexTypeTraverser extends XSDAbstractParticleTraverser {
     
     // size of stack to hold globals:
-    private final static int GLOBAL_NUM = 12;
+    private final static int GLOBAL_NUM = 13;
     
     // globals for building XSComplexTypeDecls
     private String fName = null;
@@ -84,6 +88,7 @@
     private XSComplexTypeDecl fComplexTypeDecl = null;
     private XSAnnotationImpl [] fAnnotations = null;
     private XSOpenContentDecl fOpenContent = null;
+    private XSAssertImpl[] fAssertions = null;
     
     private XSParticleDecl fEmptyParticle = null;
     
@@ -270,6 +275,7 @@
         fIsAbstract = (abstractAtt != null && abstractAtt.booleanValue());
         fAnnotations = null;
         fOpenContent = null;
+        fAssertions = null;
         
         Element child = null;
         
@@ -383,6 +389,8 @@
                 fDerivedBy, fFinal, fBlock, fContentType, fIsAbstract,
                 fAttrGrp, fXSSimpleType, fParticle, new 
XSObjectListImpl(fAnnotations, 
                         fAnnotations == null? 0 : fAnnotations.length), 
fOpenContent);
+        fComplexTypeDecl.setAssertions(fAssertions != null 
+                ? new XSObjectListImpl(fAssertions, fAssertions.length) : 
null);
         return fComplexTypeDecl;
     }
     
@@ -602,14 +610,14 @@
             // 
-----------------------------------------------------------------------
             // Traverse any facets
             // 
-----------------------------------------------------------------------
-            Element attrNode = null;
+            Element attrOrAssertNode = null;
             XSFacets facetData = null;
             short presentFacets = 0 ;
             short fixedFacets = 0 ;
             
             if (simpleContent!=null) {
                 FacetInfo fi = traverseFacets(simpleContent, baseValidator, 
schemaDoc);
-                attrNode = fi.nodeAfterFacets;
+                attrOrAssertNode = fi.nodeAfterFacets;
                 facetData = fi.facetdata;
                 presentFacets = fi.fPresentFacets;
                 fixedFacets = fi.fFixedFacets;
@@ -630,22 +638,36 @@
             // 
-----------------------------------------------------------------------
             // Traverse any attributes
             // 
-----------------------------------------------------------------------
-            if (attrNode != null) {
-                if (!isAttrOrAttrGroup(attrNode)) {
-                    fAttrChecker.returnAttrArray(simpleContentAttrValues, 
schemaDoc);
-                    fAttrChecker.returnAttrArray(derivationTypeAttrValues, 
schemaDoc);
-                    throw new 
ComplexTypeRecoverableError("s4s-elt-invalid-content.1",
-                            new Object[]{fName,DOMUtil.getLocalName(attrNode)},
-                            attrNode);
+            if (attrOrAssertNode != null) {
+               if (isAttrOrAttrGroup(attrOrAssertNode)) {
+                       Element 
node=traverseAttrsAndAttrGrps(attrOrAssertNode,fAttrGrp,
+                            schemaDoc,grammar,fComplexTypeDecl);
+
+                    if (node != null) {
+                        if (isAssert(node)) {
+                            traverseAsserts(node, schemaDoc, grammar,
+                                    fComplexTypeDecl);
+                        } else {
+                            // a non assert element after attributes is an 
error
+                            
fAttrChecker.returnAttrArray(simpleContentAttrValues, schemaDoc);
+                            
fAttrChecker.returnAttrArray(derivationTypeAttrValues, schemaDoc);
+                            throw new ComplexTypeRecoverableError(
+                                    "s4s-elt-invalid-content.1",
+                                    new Object[] { fName,
+                                            DOMUtil.getLocalName(node) }, 
node);
+                        }
+                    }
                 }
-                Element node=traverseAttrsAndAttrGrps(attrNode,fAttrGrp,
-                        schemaDoc,grammar,fComplexTypeDecl);
-                if (node!=null) {
+               else if (isAssert(attrOrAssertNode)) {
+                    traverseAsserts(attrOrAssertNode, schemaDoc, grammar,
+                            fComplexTypeDecl);
+               }
+               else  {
                     fAttrChecker.returnAttrArray(simpleContentAttrValues, 
schemaDoc);
                     fAttrChecker.returnAttrArray(derivationTypeAttrValues, 
schemaDoc);
                     throw new 
ComplexTypeRecoverableError("s4s-elt-invalid-content.1",
-                            new Object[]{fName,DOMUtil.getLocalName(node)},
-                            node);
+                            new 
Object[]{fName,DOMUtil.getLocalName(attrOrAssertNode)},
+                            attrOrAssertNode);
                 }
             }
             
@@ -664,7 +686,7 @@
                 fAttrChecker.returnAttrArray(simpleContentAttrValues, 
schemaDoc);
                 fAttrChecker.returnAttrArray(derivationTypeAttrValues, 
schemaDoc);
                 throw new 
ComplexTypeRecoverableError((String)errArgs[errArgs.length-1],
-                        errArgs, attrNode);
+                        errArgs, attrOrAssertNode);
             }
             
         }
@@ -677,23 +699,36 @@
                 // 
-----------------------------------------------------------------------
                 // Traverse any attributes
                 // 
-----------------------------------------------------------------------
-                Element attrNode = simpleContent;
-                if (!isAttrOrAttrGroup(attrNode)) {
-                    fAttrChecker.returnAttrArray(simpleContentAttrValues, 
schemaDoc);
-                    fAttrChecker.returnAttrArray(derivationTypeAttrValues, 
schemaDoc);
-                    throw new 
ComplexTypeRecoverableError("s4s-elt-invalid-content.1",
-                            new Object[]{fName,DOMUtil.getLocalName(attrNode)},
-                            attrNode);
+                Element attrOrAssertNode = simpleContent;
+                if (isAttrOrAttrGroup(attrOrAssertNode)) {
+                    Element node = traverseAttrsAndAttrGrps(attrOrAssertNode,
+                            fAttrGrp, schemaDoc, grammar, fComplexTypeDecl);
+
+                    if (node != null) {
+                        if (isAssert(node)) {
+                            traverseAsserts(node, schemaDoc, grammar,
+                                    fComplexTypeDecl);
+                        } else {
+                            // a non assert element after attributes is an 
error
+                            
fAttrChecker.returnAttrArray(simpleContentAttrValues, schemaDoc);
+                            
fAttrChecker.returnAttrArray(derivationTypeAttrValues, schemaDoc);              
           
+                            throw new ComplexTypeRecoverableError(
+                                    "s4s-elt-invalid-content.1",
+                                    new Object[] { fName,
+                                            DOMUtil.getLocalName(node) }, 
node);
+                        }
+                    }
                 }
-                Element node=traverseAttrsAndAttrGrps(attrNode,fAttrGrp,
-                        schemaDoc,grammar,fComplexTypeDecl);
-                
-                if (node!=null) {
+                else if (isAssert(attrOrAssertNode)) {
+                    traverseAsserts(attrOrAssertNode, schemaDoc, grammar,
+                            fComplexTypeDecl);
+                }
+                else {
                     fAttrChecker.returnAttrArray(simpleContentAttrValues, 
schemaDoc);
                     fAttrChecker.returnAttrArray(derivationTypeAttrValues, 
schemaDoc);
                     throw new 
ComplexTypeRecoverableError("s4s-elt-invalid-content.1",
-                            new Object[]{fName,DOMUtil.getLocalName(node)},
-                            node);
+                            new 
Object[]{fName,DOMUtil.getLocalName(attrOrAssertNode)},
+                            attrOrAssertNode);
                 }
                 // Remove prohibited uses.   Should be done prior to any merge.
                 fAttrGrp.removeProhibitedAttrs();
@@ -1188,7 +1223,7 @@
             XSDocumentInfo schemaDoc, SchemaGrammar grammar)
     throws ComplexTypeRecoverableError {
         
-        Element attrNode = null;
+        Element attrOrAssertNode = null;
         XSParticleDecl particle = null;
         
         // whether there is a particle with empty model group
@@ -1213,7 +1248,7 @@
                 
                 particle = 
fSchemaHandler.fGroupTraverser.traverseLocal(complexContentChild,
                         schemaDoc, grammar);
-                attrNode = DOMUtil.getNextSiblingElement(complexContentChild);
+                attrOrAssertNode = 
DOMUtil.getNextSiblingElement(complexContentChild);
             }
             else if (childName.equals(SchemaSymbols.ELT_SEQUENCE)) {
                 particle = 
traverseSequence(complexContentChild,schemaDoc,grammar,
@@ -1223,7 +1258,7 @@
                     if (group.fParticleCount == 0)
                         emptyParticle = true;
                 }
-                attrNode = DOMUtil.getNextSiblingElement(complexContentChild);
+                attrOrAssertNode = 
DOMUtil.getNextSiblingElement(complexContentChild);
             }
             else if (childName.equals(SchemaSymbols.ELT_CHOICE)) {
                 particle = 
traverseChoice(complexContentChild,schemaDoc,grammar,
@@ -1233,7 +1268,7 @@
                     if (group.fParticleCount == 0)
                         emptyParticle = true;
                 }
-                attrNode = DOMUtil.getNextSiblingElement(complexContentChild);
+                attrOrAssertNode = 
DOMUtil.getNextSiblingElement(complexContentChild);
             }
             else if (childName.equals(SchemaSymbols.ELT_ALL)) {
                 particle = traverseAll(complexContentChild,schemaDoc,grammar,
@@ -1243,11 +1278,11 @@
                     if (group.fParticleCount == 0)
                         emptyParticle = true;
                 }
-                attrNode = DOMUtil.getNextSiblingElement(complexContentChild);
+                attrOrAssertNode = 
DOMUtil.getNextSiblingElement(complexContentChild);
             }
             else {
                 // Should be attributes here - will check below...
-                attrNode = complexContentChild;
+                attrOrAssertNode = complexContentChild;
             }
         }
         
@@ -1300,31 +1335,42 @@
         // -------------------------------------------------------------
         // Now, process attributes
         // -------------------------------------------------------------
-        if (attrNode != null) {
-            if (!isAttrOrAttrGroup(attrNode)) {
-                throw new 
ComplexTypeRecoverableError("s4s-elt-invalid-content.1",
-                        new Object[]{fName,DOMUtil.getLocalName(attrNode)},
-                        attrNode);
+        if (attrOrAssertNode != null) {
+            if (isAttrOrAttrGroup(attrOrAssertNode)) {
+                Element node = traverseAttrsAndAttrGrps(attrOrAssertNode,
+                        fAttrGrp, schemaDoc, grammar, fComplexTypeDecl);
+
+                // Only remove prohibited attribute uses if this isn't a 
derived type
+                // Derivation-specific code worries about this elsewhere
+                if (!isDerivation) {
+                    fAttrGrp.removeProhibitedAttrs();
+                }
+                
+                if (node != null) {
+                    if (isAssert(node)) {
+                        traverseAsserts(node, schemaDoc, grammar,
+                                fComplexTypeDecl);
+                    } else {
+                        // a non assert element after attributes is an error
+                        throw new ComplexTypeRecoverableError(
+                                "s4s-elt-invalid-content.1", new Object[] {
+                                        fName, DOMUtil.getLocalName(node) },
+                                node);
+                    }
+                }
             }
-            Element node =
-                
traverseAttrsAndAttrGrps(attrNode,fAttrGrp,schemaDoc,grammar,fComplexTypeDecl);
-            if (node!=null) {
-                throw new 
ComplexTypeRecoverableError("s4s-elt-invalid-content.1",
-                        new Object[]{fName,DOMUtil.getLocalName(node)},
-                        node);
+            else if (isAssert(attrOrAssertNode)) {
+                traverseAsserts(attrOrAssertNode, schemaDoc, grammar,
+                        fComplexTypeDecl);
             }
-            // Only remove prohibited attribute uses if this isn't a derived 
type
-            // Derivation-specific code worries about this elsewhere
-            if (!isDerivation) {
-                fAttrGrp.removeProhibitedAttrs();
+            else {
+                throw new 
ComplexTypeRecoverableError("s4s-elt-invalid-content.1",
+                        new 
Object[]{fName,DOMUtil.getLocalName(attrOrAssertNode)},
+                        attrOrAssertNode);
             }
         }
-        
-        
-        
     } // end processComplexContent
-    
-    
+
     private boolean isAttrOrAttrGroup(Element e) {
         String elementName = DOMUtil.getLocalName(e);
         
@@ -1335,14 +1381,112 @@
         else
             return false;
     }
-    
+
+    private boolean isAssert(Element e) {
+        String elementName = DOMUtil.getLocalName(e);
+        return elementName.equals(SchemaSymbols.ELT_ASSERT);
+    }
+
     private void traverseSimpleContentDecl(Element simpleContentDecl) {
     }
     
     private void traverseComplexContentDecl(Element complexContentDecl,
             boolean mixedOnComplexTypeDecl) {
     }
-    
+
+    /*
+     * traversal support, for XML Schema 1.1 'assertions'.
+     */
+    private void traverseAsserts(Element assertElement,
+            XSDocumentInfo schemaDoc, SchemaGrammar grammar,
+            XSComplexTypeDecl enclosingCT) throws ComplexTypeRecoverableError {
+
+        Object[] attrValues = fAttrChecker.checkAttributes(assertElement,
+                false, schemaDoc);
+        String test = (String) attrValues[XSAttributeChecker.ATTIDX_XPATH];
+        String defaultNamespace = (String) 
attrValues[XSAttributeChecker.ATTIDX_XPATHDEFAULTNS];
+
+        if (test != null) {
+            // get 'annotation'
+            Element childNode = DOMUtil.getFirstChildElement(assertElement);
+            XSAnnotationImpl annotation = null;
+
+            // first child could be an annotation
+            if (childNode != null
+                    && DOMUtil.getLocalName(childNode).equals(
+                            SchemaSymbols.ELT_ANNOTATION)) {
+                annotation = traverseAnnotationDecl(childNode, attrValues,
+                        false, schemaDoc);
+                // now move on to the next child element
+                childNode = DOMUtil.getNextSiblingElement(childNode);
+
+                if (childNode != null) {
+                    // it's an error to have something after the
+                    // annotation, in 'assert'
+                    reportSchemaError("xxx-define this", new Object[] { DOMUtil
+                            .getLocalName(childNode) }, childNode);
+                }
+            } else {
+                String text = DOMUtil.getSyntheticAnnotation(childNode);
+                if (text != null) {
+                    annotation = traverseSyntheticAnnotation(childNode, text,
+                            attrValues, false, schemaDoc);
+                }
+            }
+
+            XSObjectList annotations = null;
+            if (annotation != null) {
+                annotations = new XSObjectListImpl();
+                ((XSObjectListImpl) annotations).add(annotation);
+            } else {
+                // if no annotations are present add an empty list to
+                // the assertion
+                annotations = XSObjectListImpl.EMPTY_LIST;
+            }
+
+            XSAssertImpl assertImpl = new XSAssertImpl(enclosingCT, 
annotations);
+            Test testExpr = null;
+            // set the test attribute value
+            try {
+                testExpr = new Test(new XPath20(test, fSymbolTable,
+                        schemaDoc.fNamespaceSupport), assertImpl);
+            } catch (XPathException e) {
+                // if the xpath is invalid create a Test without an
+                // expression
+                reportSchemaError(e.getKey(), new Object[] { test },
+                        assertElement);
+                testExpr = new Test(null, assertImpl);
+            }
+
+            assertImpl.setTest(testExpr);
+            assertImpl.setXPathDefauleNamespace(defaultNamespace);
+
+            addAssertion(assertImpl);
+
+            Element sibling = DOMUtil.getNextSiblingElement(assertElement);
+            // if there is sibling element
+            if (sibling != null) {
+                if (sibling.getLocalName().equals(SchemaSymbols.ELT_ASSERT)) {
+                    // traverse sibling assertion elements recursively, till
+                    // none is found
+                    traverseAsserts(sibling, schemaDoc, grammar, enclosingCT);
+                } else {
+                    // a non assert element after assert is an error
+                       fAttrChecker.returnAttrArray(attrValues, schemaDoc);
+                    throw new ComplexTypeRecoverableError(
+                            "s4s-elt-invalid-content.1", new Object[] { fName,
+                                    DOMUtil.getLocalName(sibling) }, sibling);
+                }
+            }
+        } else {
+            // 'test' attribute is mandatory in assert element
+            reportSchemaError("src-assert.3.13.1", new Object[] { DOMUtil
+                    .getLocalName(assertElement) }, assertElement);
+        }
+
+        fAttrChecker.returnAttrArray(attrValues, schemaDoc);
+    }
+
     /*
      * Generate a name for an anonymous type
      */
@@ -1431,9 +1575,11 @@
         fGlobalStore[fGlobalStorePos++] = fXSSimpleType;
         fGlobalStore[fGlobalStorePos++] = fAnnotations;
         fGlobalStore[fGlobalStorePos++] = fOpenContent;
+        fGlobalStore[fGlobalStorePos++] = fAssertions;
     }
     
     private void contentRestore() {
+       fAssertions = (XSAssertImpl[])fGlobalStore[--fGlobalStorePos];
         fOpenContent = (XSOpenContentDecl)fGlobalStore[--fGlobalStorePos];
         fAnnotations = (XSAnnotationImpl [])fGlobalStore[--fGlobalStorePos];
         fXSSimpleType = (XSSimpleType)fGlobalStore[--fGlobalStorePos];
@@ -1468,4 +1614,23 @@
         }
         fAnnotations[fAnnotations.length-1] = annotation;
     }
+    
+    private void addAssertion(XSAssertImpl assertion) {
+        if (assertion == null) {
+            return;
+        }
+        // it isn't very likely that there will be more than one annotation
+        // in a complexType decl.  This saves us fromhaving to push/pop
+        // one more object from the fGlobalStore, and that's bound
+        // to be a savings for most applications
+        if (fAssertions == null) {
+            fAssertions = new XSAssertImpl[1];
+        }
+        else {
+               XSAssertImpl [] tempArray = new XSAssertImpl[fAssertions.length 
+ 1];
+            System.arraycopy(fAssertions, 0, tempArray, 0, fAssertions.length);
+            fAssertions = tempArray;
+        }
+        fAssertions[fAssertions.length-1] = assertion;
+    }
 }

Modified: 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/xs/XSAssert.java
URL: 
http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/xs/XSAssert.java?rev=710097&r1=710096&r2=710097&view=diff
==============================================================================
--- 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/xs/XSAssert.java 
(original)
+++ 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/xs/XSAssert.java 
Mon Nov  3 08:31:51 2008
@@ -19,7 +19,7 @@
 
 /**
  * This interface represents the XML Schema assertion component. Assertion
- * components were first introduced in the XML schema structures 1.1
+ * components were first introduced in the XML Schema structures 1.1
  * specification, as a means of constraining the existence and values of 
  * related elements and attributes.
  * 

Modified: 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/xs/XSComplexTypeDefinition.java
URL: 
http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/xs/XSComplexTypeDefinition.java?rev=710097&r1=710096&r2=710097&view=diff
==============================================================================
--- 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/xs/XSComplexTypeDefinition.java
 (original)
+++ 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/xs/XSComplexTypeDefinition.java
 Mon Nov  3 08:31:51 2008
@@ -114,5 +114,10 @@
      * An open content
      */
     public XSOpenContent getOpenContent();
+    
+    /**
+     * A sequence of [assertions] or an empty <code>XSObjectList</code>.
+     */
+    public XSObjectList getAssertions();
 
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to