You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by ca...@apache.org on 2008/05/20 20:24:19 UTC

svn commit: r658374 - in /xerces/c/branches/xerces-2/src/xercesc/validators/schema: GeneralAttributeCheck.cpp SchemaValidator.cpp SchemaValidator.hpp

Author: cargilld
Date: Tue May 20 11:24:19 2008
New Revision: 658374

URL: http://svn.apache.org/viewvc?rev=658374&view=rev
Log:
Schema fixes for e1-16 errata and full schema checking of any choice restricted by any

Modified:
    xerces/c/branches/xerces-2/src/xercesc/validators/schema/GeneralAttributeCheck.cpp
    xerces/c/branches/xerces-2/src/xercesc/validators/schema/SchemaValidator.cpp
    xerces/c/branches/xerces-2/src/xercesc/validators/schema/SchemaValidator.hpp

Modified: xerces/c/branches/xerces-2/src/xercesc/validators/schema/GeneralAttributeCheck.cpp
URL: http://svn.apache.org/viewvc/xerces/c/branches/xerces-2/src/xercesc/validators/schema/GeneralAttributeCheck.cpp?rev=658374&r1=658373&r2=658374&view=diff
==============================================================================
--- xerces/c/branches/xerces-2/src/xercesc/validators/schema/GeneralAttributeCheck.cpp (original)
+++ xerces/c/branches/xerces-2/src/xercesc/validators/schema/GeneralAttributeCheck.cpp Tue May 20 11:24:19 2008
@@ -794,7 +794,7 @@
   { 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 0, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0},
   { 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 0, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0},
   { 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 0, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0},
-  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 34, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0},
+  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 34, 0, 0, 0, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0},
   { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0},
   { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0},
   { 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},

Modified: xerces/c/branches/xerces-2/src/xercesc/validators/schema/SchemaValidator.cpp
URL: http://svn.apache.org/viewvc/xerces/c/branches/xerces-2/src/xercesc/validators/schema/SchemaValidator.cpp?rev=658374&r1=658373&r2=658374&view=diff
==============================================================================
--- xerces/c/branches/xerces-2/src/xercesc/validators/schema/SchemaValidator.cpp (original)
+++ xerces/c/branches/xerces-2/src/xercesc/validators/schema/SchemaValidator.cpp Tue May 20 11:24:19 2008
@@ -1211,6 +1211,12 @@
             case ContentSpecNode::All:
             case ContentSpecNode::Leaf:
                 {
+                    if (baseNodeType == ContentSpecNode::Any_NS_Choice) {
+                        if (checkNSSubsetChoiceRoot(curSpecNode, baseSpecNode)) {
+                            return;
+                        }
+                    }
+
                     ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::PD_ForbiddenRes1, fMemoryManager);
                 }
             default:
@@ -1831,6 +1837,45 @@
     }
 }
 
+bool SchemaValidator::checkNSSubsetChoiceRoot(const ContentSpecNode* const derivedSpecNode,
+                                    const ContentSpecNode* const baseSpecNode) {
+    bool found = false;       
+
+    if (baseSpecNode->getType() == ContentSpecNode::Any_NS_Choice) {
+        const ContentSpecNode* first = baseSpecNode->getFirst();
+        const ContentSpecNode* second = baseSpecNode->getSecond();
+
+        if (first) {
+            found = checkNSSubsetChoiceRoot(derivedSpecNode, first);
+            if (found) return true;
+        }
+        if (second) { 
+            found = checkNSSubsetChoiceRoot(derivedSpecNode, second);
+            if (found) return true;
+        }
+    }
+    else { // should be Any_NS
+        found = checkNSSubsetChoice(derivedSpecNode, baseSpecNode);
+    }
+
+    return found; 
+}
+
+bool SchemaValidator::checkNSSubsetChoice(const ContentSpecNode* const derivedSpecNode,
+                                    const ContentSpecNode* const baseSpecNode) {
+
+    // check Occurrence ranges
+    if (!isOccurrenceRangeOK(derivedSpecNode->getMinOccurs(), derivedSpecNode->getMaxOccurs(),
+                             baseSpecNode->getMinOccurs(), baseSpecNode->getMaxOccurs())) {
+        return false;
+    }
+
+    if (!isWildCardEltSubset(derivedSpecNode, baseSpecNode)) {
+        return false;
+    }
+    return true;
+}
+
 bool
 SchemaValidator::isWildCardEltSubset(const ContentSpecNode* const derivedSpecNode,
                                      const ContentSpecNode* const baseSpecNode) {

Modified: xerces/c/branches/xerces-2/src/xercesc/validators/schema/SchemaValidator.hpp
URL: http://svn.apache.org/viewvc/xerces/c/branches/xerces-2/src/xercesc/validators/schema/SchemaValidator.hpp?rev=658374&r1=658373&r2=658374&view=diff
==============================================================================
--- xerces/c/branches/xerces-2/src/xercesc/validators/schema/SchemaValidator.hpp (original)
+++ xerces/c/branches/xerces-2/src/xercesc/validators/schema/SchemaValidator.hpp Tue May 20 11:24:19 2008
@@ -211,6 +211,10 @@
                       const bool toLax = false);
     void checkNSSubset(const ContentSpecNode* const derivedSpecNode,
                        const ContentSpecNode* const baseSpecNode);
+    bool checkNSSubsetChoiceRoot(const ContentSpecNode* const derivedSpecNode,
+                       const ContentSpecNode* const baseSpecNode);
+    bool checkNSSubsetChoice(const ContentSpecNode* const derivedSpecNode,
+                       const ContentSpecNode* const baseSpecNode);
     bool isWildCardEltSubset(const ContentSpecNode* const derivedSpecNode,
                              const ContentSpecNode* const baseSpecNode);
     void checkNSRecurseCheckCardinality(SchemaGrammar* const currentGrammar,



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