Author: cargilld
Date: Sun Dec  3 13:54:02 2006
New Revision: 481934

URL: http://svn.apache.org/viewvc?view=rev&rev=481934
Log:
Schema derivation fixes.

Modified:
    
xerces/c/branches/xerces-2.7/src/xercesc/validators/schema/SchemaValidator.cpp
    
xerces/c/branches/xerces-2.7/src/xercesc/validators/schema/TraverseSchema.cpp

Modified: 
xerces/c/branches/xerces-2.7/src/xercesc/validators/schema/SchemaValidator.cpp
URL: 
http://svn.apache.org/viewvc/xerces/c/branches/xerces-2.7/src/xercesc/validators/schema/SchemaValidator.cpp?view=diff&rev=481934&r1=481933&r2=481934
==============================================================================
--- 
xerces/c/branches/xerces-2.7/src/xercesc/validators/schema/SchemaValidator.cpp 
(original)
+++ 
xerces/c/branches/xerces-2.7/src/xercesc/validators/schema/SchemaValidator.cpp 
Sun Dec  3 13:54:02 2006
@@ -1425,11 +1425,13 @@
 
     // case of mixed complex types with attributes only
     if (derivedURI == XMLElementDecl::fgPCDataElemId) {
-        if (!XMLString::equals(derivedName, baseName) || derivedURI != baseURI)
-            ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::PD_NameTypeOK1, 
fMemoryManager);
         return;
     }
 
+    if (!XMLString::equals(derivedName, baseName) || derivedURI != baseURI) {
+        ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::PD_NameTypeOK1, 
fMemoryManager);        
+    }
+
     SchemaGrammar* aGrammar = currentGrammar;
     const XMLCh* schemaURI = 
fGrammarResolver->getStringPool()->getValueForId(derivedURI);
 
@@ -1632,28 +1634,85 @@
 
 void
 SchemaValidator::checkRecurseAsIfGroup(SchemaGrammar* const currentGrammar,
-                                       ContentSpecNode* const derivedSpecNode,
+                                       ContentSpecNode* const 
derivedSpecNodeIn,
                                        const int derivedScope,
                                        const ContentSpecNode* const 
baseSpecNode,
                                        const int baseScope,
                                        ValueVectorOf<ContentSpecNode*>* const 
baseNodes,
                                        const ComplexTypeInfo* const baseInfo) {
 
-    ContentSpecNode::NodeTypes baseType = baseSpecNode->getType();
-    ValueVectorOf<ContentSpecNode*> derivedNodes(1, fMemoryManager);
+    ContentSpecNode::NodeTypes baseType = baseSpecNode->getType();   
     bool toLax = false;
 
     //Treat the element as if it were in a group of the same variety as base
-    ContentSpecNode derivedGroupNode(baseType, derivedSpecNode, 0, false, 
true, fMemoryManager);
-
-    derivedNodes.addElement(derivedSpecNode);
+    ContentSpecNode derivedGroupNode(baseType, derivedSpecNodeIn, 0, false, 
true, fMemoryManager);
+    const ContentSpecNode* const derivedSpecNode = &derivedGroupNode;
 
     if ((baseSpecNode->getType() & 0x0f) == ContentSpecNode::Choice) {
         toLax = true;
     }
+    // Instead of calling this routine, inline it
+    // checkRecurse(currentGrammar, &derivedGroupNode, derivedScope, 
&derivedNodes,
+    //             baseSpecNode, baseScope, baseNodes, baseInfo, toLax);
+ 
+    if (!isOccurrenceRangeOK(derivedSpecNode->getMinOccurs(), 
derivedSpecNode->getMaxOccurs(),
+                             baseSpecNode->getMinOccurs(), 
baseSpecNode->getMaxOccurs())) {
+        ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::PD_Recurse1, 
fMemoryManager);
+    }
+
+    // check for mapping of children
+    XMLExcepts::Codes codeToThrow = XMLExcepts::NoError;   
+    unsigned int count2= baseNodes->size();
+    unsigned int current = 0;    
+
+    {
+        bool matched = false;
+
+        for (unsigned int j = current; j < count2; j++) {
+
+            ContentSpecNode* baseNode = baseNodes->elementAt(j);
+            current++;
+
+            bool bDoBreak=false;    // workaround for Borland bug with 'break' 
in 'catch'
+            try {
+
+                checkParticleDerivationOk(currentGrammar, derivedSpecNodeIn,
+                                          derivedScope, baseNode, baseScope, 
baseInfo);
+                matched = true;
+                break;
+            }
+            catch(const XMLException&) {
+                if (!toLax && baseNode->getMinTotalRange()) {
+                    bDoBreak=true;
+                }
+            }
+            if(bDoBreak)
+                break;
+        }
+
+        // did not find a match
+        if (!matched) {
+            codeToThrow = XMLExcepts::PD_Recurse2;            
+        }
+    }
+
+    // Now, see if there are some elements in the base we didn't match up
+    // in case of Sequence or All
+    if (!toLax && codeToThrow == XMLExcepts::NoError &&
+        (true || (baseType & 0x0f) == ContentSpecNode::All || 
+         derivedSpecNodeIn->getElement()->getURI() != 
XMLElementDecl::fgPCDataElemId)) {
+        for (unsigned int j = current; j < count2; j++) {
+            if (baseNodes->elementAt(j)->getMinTotalRange() * 
baseSpecNode->getMinOccurs()) { //!emptiable
+                codeToThrow =  XMLExcepts::PD_Recurse2;                
+                break;
+            }
+        }
+    }
+
+    if (codeToThrow != XMLExcepts::NoError) {
+        ThrowXMLwithMemMgr(RuntimeException, codeToThrow, fMemoryManager);
+    }
 
-    checkRecurse(currentGrammar, &derivedGroupNode, derivedScope, 
&derivedNodes,
-                 baseSpecNode, baseScope, baseNodes, baseInfo, toLax);
 }
 
 void

Modified: 
xerces/c/branches/xerces-2.7/src/xercesc/validators/schema/TraverseSchema.cpp
URL: 
http://svn.apache.org/viewvc/xerces/c/branches/xerces-2.7/src/xercesc/validators/schema/TraverseSchema.cpp?view=diff&rev=481934&r1=481933&r2=481934
==============================================================================
--- 
xerces/c/branches/xerces-2.7/src/xercesc/validators/schema/TraverseSchema.cpp 
(original)
+++ 
xerces/c/branches/xerces-2.7/src/xercesc/validators/schema/TraverseSchema.cpp 
Sun Dec  3 13:54:02 2006
@@ -6174,7 +6174,12 @@
             // Compose the final content model by concatenating the base and
             // the current in sequence
             if (!specNode) {
-
+                if (isMixed) {
+                    if (baseSpecNode && baseSpecNode->hasAllContent()) {
+                        reportSchemaError(ctElem, XMLUni::fgXMLErrDomain, 
XMLErrs::NotAllContent);
+                        throw TraverseSchema::InvalidComplexTypeInfo; // 
REVISIT - should we continue
+                    }
+                }
                 if (baseSpecNode) {
                     specNodeJan.reset(new (fGrammarPoolMemoryManager) 
ContentSpecNode(*baseSpecNode));
                     specNode = specNodeJan.get();



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

Reply via email to