Author: borisk
Date: Tue Jun 24 04:22:29 2008
New Revision: 671133

URL: http://svn.apache.org/viewvc?rev=671133&view=rev
Log:
Implement the revised interpretation of ##other in which unqualified names are 
not matched. Fixes XERCESC-1758, XERCESC-1655.

Added:
    xerces/c/trunk/tests/src/XSTSHarness/regression/XERCESC-1758/
    xerces/c/trunk/tests/src/XSTSHarness/regression/XERCESC-1758/test.xml
    xerces/c/trunk/tests/src/XSTSHarness/regression/XERCESC-1758/test.xsd   
(with props)
Modified:
    xerces/c/trunk/src/xercesc/internal/IGXMLScanner2.cpp
    xerces/c/trunk/src/xercesc/internal/SGXMLScanner.cpp
    xerces/c/trunk/src/xercesc/validators/common/DFAContentModel.cpp
    xerces/c/trunk/src/xercesc/validators/common/MixedContentModel.cpp
    xerces/c/trunk/src/xercesc/validators/schema/SchemaValidator.cpp
    xerces/c/trunk/src/xercesc/validators/schema/SubstitutionGroupComparator.cpp
    xerces/c/trunk/src/xercesc/validators/schema/XercesElementWildcard.cpp
    xerces/c/trunk/tests/src/XSTSHarness/regression/Xerces.testSet

Modified: xerces/c/trunk/src/xercesc/internal/IGXMLScanner2.cpp
URL: 
http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/internal/IGXMLScanner2.cpp?rev=671133&r1=671132&r2=671133&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/internal/IGXMLScanner2.cpp (original)
+++ xerces/c/trunk/src/xercesc/internal/IGXMLScanner2.cpp Tue Jun 24 04:22:29 
2008
@@ -3247,7 +3247,7 @@
                 anyEncountered = true;
             }
             else if ((type & 0x0f) == ContentSpecNode::Any_Other) {
-                if (uri != elementURI) {
+                if (uri != elementURI && elementURI != fEmptyNamespaceId) {
                     anyEncountered = true;
                 }
             }

Modified: xerces/c/trunk/src/xercesc/internal/SGXMLScanner.cpp
URL: 
http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/internal/SGXMLScanner.cpp?rev=671133&r1=671132&r2=671133&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/internal/SGXMLScanner.cpp (original)
+++ xerces/c/trunk/src/xercesc/internal/SGXMLScanner.cpp Tue Jun 24 04:22:29 
2008
@@ -4683,7 +4683,7 @@
                 anyEncountered = true;
             }
             else if ((type & 0x0f) == ContentSpecNode::Any_Other) {
-                if (uri != elementURI) {
+                if (uri != elementURI && elementURI != fEmptyNamespaceId) {
                     anyEncountered = true;
                 }
             }

Modified: xerces/c/trunk/src/xercesc/validators/common/DFAContentModel.cpp
URL: 
http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/validators/common/DFAContentModel.cpp?rev=671133&r1=671132&r2=671133&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/validators/common/DFAContentModel.cpp (original)
+++ xerces/c/trunk/src/xercesc/validators/common/DFAContentModel.cpp Tue Jun 24 
04:22:29 2008
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -205,7 +205,10 @@
                 }
                 else if ((type & 0x0f) == ContentSpecNode::Any_Other)
                 {
-                    if (inElem->getURI() != curElem->getURI()) {
+                    // Here we assume that empty string has id 1.
+                   //
+                    unsigned int uriId = curElem->getURI();
+                    if (uriId != 1 && uriId != inElem->getURI()) {
                         nextState = fTransTable[curState][elemIndex];
                         if (nextState != XMLContentModel::gInvalidTrans)
                             break;
@@ -303,7 +306,10 @@
             }
             else if ((type & 0x0f) == ContentSpecNode::Any_Other)
             {
-                if (inElem->getURI() != curElem->getURI())
+                // Here we assume that empty string has id 1.
+               //
+                unsigned int uriId = curElem->getURI();
+                if (uriId != 1 && uriId != inElem->getURI())
                 {
                     nextState = fTransTable[curState][elemIndex];
                     if (nextState != XMLContentModel::gInvalidTrans)
@@ -537,7 +543,7 @@
 
         for (unsigned int leafIndex = 0; leafIndex < fLeafCount; leafIndex++)
         {
-            const QName* leaf = fLeafList[leafIndex]->getElement();            
+            const QName* leaf = fLeafList[leafIndex]->getElement();
             if (fDTD) {
                 if (XMLString::equals(leaf->getRawName(), elementRawName)) {
                     fLeafSorter[fSortCount++] = leafIndex;
@@ -566,7 +572,7 @@
     //  have to expand though, it if does, the overhead will be somewhat ugly.
     //
     unsigned int curArraySize = fLeafCount * 4;
-    const CMStateSet** statesToDo = (const CMStateSet**) 
+    const CMStateSet** statesToDo = (const CMStateSet**)
         fMemoryManager->allocate
         (
             curArraySize * sizeof(const CMStateSet*)
@@ -778,7 +784,7 @@
                     //  size by 50% and allocate new arrays.
                     //
                     const unsigned int newSize = (unsigned int)(curArraySize * 
1.5);
-                    const CMStateSet** newToDo = (const CMStateSet**) 
+                    const CMStateSet** newToDo = (const CMStateSet**)
                         fMemoryManager->allocate
                         (
                             newSize * sizeof(const CMStateSet*)
@@ -1217,4 +1223,3 @@
 }
 
 XERCES_CPP_NAMESPACE_END
-

Modified: xerces/c/trunk/src/xercesc/validators/common/MixedContentModel.cpp
URL: 
http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/validators/common/MixedContentModel.cpp?rev=671133&r1=671132&r2=671133&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/validators/common/MixedContentModel.cpp 
(original)
+++ xerces/c/trunk/src/xercesc/validators/common/MixedContentModel.cpp Tue Jun 
24 04:22:29 2008
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -178,8 +178,12 @@
                 if (inChild->getURI() != curChild->getURI())
                     return outIndex;
             }
-            else if (type == ContentSpecNode::Any_Other) {
-                if (inChild->getURI() == curChild->getURI())
+            else if (type == ContentSpecNode::Any_Other)
+            {
+                // Here we assume that empty string has id 1.
+               //
+                unsigned int uriId = curChild->getURI();
+                if (uriId == 1 || uriId == inChild->getURI())
                     return outIndex;
             }
 
@@ -225,9 +229,13 @@
                     if (inChild->getURI() == curChild->getURI())
                         break;
                 }
-                else if (type == ContentSpecNode::Any_Other) {
-                    if (inChild->getURI() != curChild->getURI())
-                        break;
+                else if (type == ContentSpecNode::Any_Other)
+                {
+                  // Here we assume that empty string has id 1.
+                 //
+                  unsigned int uriId = curChild->getURI();
+                  if (uriId != 1 && uriId != inChild->getURI())
+                    break;
                 }
 
                 // REVISIT: What about checking for multiple ANY matches?
@@ -282,9 +290,13 @@
                 if (inChild->getURI() != curChild->getURI())
                     return outIndex;
             }
-            else if (type == ContentSpecNode::Any_Other) {
-                if (inChild->getURI() == curChild->getURI())
-                    return outIndex;
+            else if (type == ContentSpecNode::Any_Other)
+            {
+              // Here we assume that empty string has id 1.
+              //
+              unsigned int uriId = curChild->getURI();
+              if (uriId == 1 || uriId == inChild->getURI())
+                return outIndex;
             }
 
             // advance index
@@ -320,9 +332,13 @@
                     if (inChild->getURI() == curChild->getURI())
                         break;
                 }
-                else if (type == ContentSpecNode::Any_Other) {
-                    if (inChild->getURI() != curChild->getURI())
-                        break;
+                else if (type == ContentSpecNode::Any_Other)
+                {
+                  // Here we assume that empty string has id 1.
+                  //
+                  unsigned int uriId = curChild->getURI();
+                  if (uriId != 1 && uriId != inChild->getURI())
+                    break;
                 }
 
                 // REVISIT: What about checking for multiple ANY matches?
@@ -388,4 +404,3 @@
 }
 
 XERCES_CPP_NAMESPACE_END
-

Modified: xerces/c/trunk/src/xercesc/validators/schema/SchemaValidator.cpp
URL: 
http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/validators/schema/SchemaValidator.cpp?rev=671133&r1=671132&r2=671133&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/validators/schema/SchemaValidator.cpp (original)
+++ xerces/c/trunk/src/xercesc/validators/schema/SchemaValidator.cpp Tue Jun 24 
04:22:29 2008
@@ -1840,7 +1840,7 @@
 
 bool SchemaValidator::checkNSSubsetChoiceRoot(const ContentSpecNode* const 
derivedSpecNode,
                                     const ContentSpecNode* const baseSpecNode) 
{
-    bool found = false;       
+    bool found = false;
 
     if (baseSpecNode->getType() == ContentSpecNode::Any_NS_Choice) {
         const ContentSpecNode* first = baseSpecNode->getFirst();
@@ -1850,7 +1850,7 @@
             found = checkNSSubsetChoiceRoot(derivedSpecNode, first);
             if (found) return true;
         }
-        if (second) { 
+        if (second) {
             found = checkNSSubsetChoiceRoot(derivedSpecNode, second);
             if (found) return true;
         }
@@ -1859,7 +1859,7 @@
         found = checkNSSubsetChoice(derivedSpecNode, baseSpecNode);
     }
 
-    return found; 
+    return found;
 }
 
 bool SchemaValidator::checkNSSubsetChoice(const ContentSpecNode* const 
derivedSpecNode,
@@ -1891,9 +1891,11 @@
     unsigned int baseURI = baseSpecNode->getElement()->getURI();
     unsigned int derivedURI = derivedSpecNode->getElement()->getURI();
 
+    // Below we assume that empty string has id 1.
+    //
     if (((derivedType & 0x0f) == ContentSpecNode::Any_Other) &&
         ((baseType & 0x0f) == ContentSpecNode::Any_Other) &&
-        baseURI == derivedURI) {
+        baseURI == derivedURI || baseURI == 1) {
         return true;
     }
 
@@ -1905,7 +1907,7 @@
         }
 
         if (((baseType & 0x0f) == ContentSpecNode::Any_Other) &&
-            baseURI != derivedURI) {
+            derivedURI == 1 || baseURI != derivedURI) {
             return true;
         }
     }

Modified: 
xerces/c/trunk/src/xercesc/validators/schema/SubstitutionGroupComparator.cpp
URL: 
http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/validators/schema/SubstitutionGroupComparator.cpp?rev=671133&r1=671132&r2=671133&view=diff
==============================================================================
--- 
xerces/c/trunk/src/xercesc/validators/schema/SubstitutionGroupComparator.cpp 
(original)
+++ 
xerces/c/trunk/src/xercesc/validators/schema/SubstitutionGroupComparator.cpp 
Tue Jun 24 04:22:29 2008
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -123,12 +123,12 @@
     // {disallowed substitution}
     int devMethod = 0;
     int blockConstraint = exemplarBlockSet;
-        
+
     ComplexTypeInfo *exemplarComplexType = pElemDecl->getComplexTypeInfo();
     ComplexTypeInfo *tempType = aComplexType;;
 
     while (tempType != 0 &&
-        tempType != exemplarComplexType) 
+        tempType != exemplarComplexType)
     {
         devMethod |= tempType->getDerivedBy();
         tempType = tempType->getBaseComplexTypeInfo();
@@ -154,8 +154,11 @@
     // whether the uri is allowed directly by the wildcard
     unsigned int uriId = element->getURI();
 
+    // Here we assume that empty string has id 1.
+    //
     if ((!wother && uriId == wuri) ||
         (wother &&
+         uriId != 1 &&
          uriId != wuri &&
          uriId != XMLContentModel::gEOCFakeId &&
          uriId != XMLContentModel::gEpsilonFakeId &&
@@ -183,8 +186,11 @@
     {
         unsigned int subUriId = 
subsElements->elementAt(i)->getElementName()->getURI();
 
+        // Here we assume that empty string has id 1.
+        //
         if ((!wother && subUriId == wuri) ||
             (wother &&
+             subUriId != 1 &&
              subUriId != wuri &&
              subUriId != XMLContentModel::gEOCFakeId &&
              subUriId != XMLContentModel::gEpsilonFakeId &&
@@ -202,4 +208,3 @@
 /**
   * End of file SubstitutionGroupComparator.cpp
   */
-

Modified: xerces/c/trunk/src/xercesc/validators/schema/XercesElementWildcard.cpp
URL: 
http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/validators/schema/XercesElementWildcard.cpp?rev=671133&r1=671132&r2=671133&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/validators/schema/XercesElementWildcard.cpp 
(original)
+++ xerces/c/trunk/src/xercesc/validators/schema/XercesElementWildcard.cpp Tue 
Jun 24 04:22:29 2008
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -93,22 +93,26 @@
         return true;
     }
     else if (((t1 & 0x0f) == ContentSpecNode::Any_NS) &&
-             ((t2 & 0x0f) == ContentSpecNode::Any_NS) &&
-             (w1 == w2)) {
+             ((t2 & 0x0f) == ContentSpecNode::Any_NS)) {
         // if both are "some_namespace" and equal, then intersects
-        return true;
+        return w1 == w2;
     }
     else if (((t1 & 0x0f) == ContentSpecNode::Any_Other) &&
              ((t2 & 0x0f) == ContentSpecNode::Any_Other)) {
-        // if both are "##other", and equal, then intersects
+        // if both are "##other", then intersects
         return true;
     }
-    else if (((((t1 & 0x0f) == ContentSpecNode::Any_NS) &&
-               ((t2 & 0x0f) == ContentSpecNode::Any_Other)) ||
-              (((t1 & 0x0f) == ContentSpecNode::Any_Other) &&
-               ((t2 & 0x0f) == ContentSpecNode::Any_NS))) &&
-             (w1 != w2)) {
-        return true;
+    // Below we assume that empty string has id 1.
+    //
+    else if (((t1 & 0x0f) == ContentSpecNode::Any_NS) &&
+             ((t2 & 0x0f) == ContentSpecNode::Any_Other))
+    {
+      return w1 != w2 && w1 != 1;
+    }
+    else if (((t1 & 0x0f) == ContentSpecNode::Any_Other) &&
+             ((t2 & 0x0f) == ContentSpecNode::Any_NS))
+    {
+      return w1 != w2 && w2 != 1;
     }
     return false;
 }

Added: xerces/c/trunk/tests/src/XSTSHarness/regression/XERCESC-1758/test.xml
URL: 
http://svn.apache.org/viewvc/xerces/c/trunk/tests/src/XSTSHarness/regression/XERCESC-1758/test.xml?rev=671133&view=auto
==============================================================================
--- xerces/c/trunk/tests/src/XSTSHarness/regression/XERCESC-1758/test.xml 
(added)
+++ xerces/c/trunk/tests/src/XSTSHarness/regression/XERCESC-1758/test.xml Tue 
Jun 24 04:22:29 2008
@@ -0,0 +1,11 @@
+<t:root xmlns:t="test"
+       xmlns:o="foo"
+        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+        xsi:schemaLocation="test test.xsd">
+
+  <upa><o:a>a</o:a></upa>
+  <upa><a>a</a></upa>
+
+  <derived><a>a</a></derived>
+
+</t:root>

Added: xerces/c/trunk/tests/src/XSTSHarness/regression/XERCESC-1758/test.xsd
URL: 
http://svn.apache.org/viewvc/xerces/c/trunk/tests/src/XSTSHarness/regression/XERCESC-1758/test.xsd?rev=671133&view=auto
==============================================================================
--- xerces/c/trunk/tests/src/XSTSHarness/regression/XERCESC-1758/test.xsd 
(added)
+++ xerces/c/trunk/tests/src/XSTSHarness/regression/XERCESC-1758/test.xsd Tue 
Jun 24 04:22:29 2008
@@ -0,0 +1,36 @@
+<?xml version="1.0"?>
+<schema xmlns="http://www.w3.org/2001/XMLSchema"; xmlns:t="test" 
targetNamespace="test">
+
+  <complexType name="upa">
+    <choice>
+      <any namespace="##other" processContents="skip"/>
+      <any namespace="##local" processContents="skip"/>
+    </choice>
+  </complexType>
+
+  <complexType name="base">
+    <sequence>
+      <any namespace="##other" processContents="skip"/>
+    </sequence>
+  </complexType>
+
+  <complexType name="derived">
+    <complexContent>
+      <restriction base="t:base">
+        <sequence>
+          <any namespace="##local" processContents="skip"/>
+        </sequence>
+      </restriction>
+    </complexContent>
+  </complexType>
+
+  <complexType name="type">
+    <sequence>
+      <element name="upa" type="t:upa" maxOccurs="unbounded"/>
+      <element name="derived" type="t:derived" maxOccurs="unbounded"/>
+    </sequence>
+  </complexType>
+
+  <element name="root" type="t:type"/>
+
+</schema>

Propchange: 
xerces/c/trunk/tests/src/XSTSHarness/regression/XERCESC-1758/test.xsd
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
xerces/c/trunk/tests/src/XSTSHarness/regression/XERCESC-1758/test.xsd
------------------------------------------------------------------------------
    svn:keywords = 

Modified: xerces/c/trunk/tests/src/XSTSHarness/regression/Xerces.testSet
URL: 
http://svn.apache.org/viewvc/xerces/c/trunk/tests/src/XSTSHarness/regression/Xerces.testSet?rev=671133&r1=671132&r2=671133&view=diff
==============================================================================
--- xerces/c/trunk/tests/src/XSTSHarness/regression/Xerces.testSet (original)
+++ xerces/c/trunk/tests/src/XSTSHarness/regression/Xerces.testSet Tue Jun 24 
04:22:29 2008
@@ -451,4 +451,20 @@
                        <current status="accepted" date="2008-03-14"/>
                </schemaTest>
        </testGroup>
-</testSet>
\ No newline at end of file
+       <testGroup name="XERCESC-1758">
+               <annotation>
+                       <documentation>Outdated interpretation of 
##other</documentation>
+               </annotation>
+               <documentationReference 
xlink:href="https://issues.apache.org/jira/browse/XERCESC-1758"/>
+               <schemaTest name="XERCESC-1758-1">
+                       <schemaDocument xlink:href="./XERCESC-1758/test.xsd"/>
+                       <expected validity="valid"/>
+                       <current status="accepted" date="2008-06-24"/>
+               </schemaTest>
+                <instanceTest name="XERCESC-1758-2">
+                       <instanceDocument xlink:href="./XERCESC-1758/test.xml"/>
+                       <expected validity="valid"/>
+                       <current status="accepted" date="2008-06-24"/>
+               </instanceTest>
+       </testGroup>
+</testSet>



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

Reply via email to