xerces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amass...@apache.org
Subject svn commit: r804234 - in /xerces/c/trunk: src/xercesc/util/ src/xercesc/validators/schema/identity/ tests/src/XSTSHarness/regression/ tests/src/XSTSHarness/regression/XERCESC-809/
Date Fri, 14 Aug 2009 14:20:16 GMT
Author: amassari
Date: Fri Aug 14 14:20:16 2009
New Revision: 804234

URL: http://svn.apache.org/viewvc?rev=804234&view=rev
Log:
When matching an XPath expression, don't accept a node only if it's the first branch of an
union that matches. The XPath parser takes care of removing identical branches (XERCESC-809)

Added:
    xerces/c/trunk/tests/src/XSTSHarness/regression/XERCESC-809/
    xerces/c/trunk/tests/src/XSTSHarness/regression/XERCESC-809/test.xml
    xerces/c/trunk/tests/src/XSTSHarness/regression/XERCESC-809/test.xsd
Modified:
    xerces/c/trunk/src/xercesc/util/QName.cpp
    xerces/c/trunk/src/xercesc/validators/schema/identity/XPathMatcher.cpp
    xerces/c/trunk/src/xercesc/validators/schema/identity/XercesXPath.cpp
    xerces/c/trunk/tests/src/XSTSHarness/regression/Xerces.testSet

Modified: xerces/c/trunk/src/xercesc/util/QName.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/util/QName.cpp?rev=804234&r1=804233&r2=804234&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/util/QName.cpp (original)
+++ xerces/c/trunk/src/xercesc/util/QName.cpp Fri Aug 14 14:20:16 2009
@@ -399,6 +399,10 @@
 // -----------------------------------------------------------------------
 bool QName::operator==(const QName& qname) const
 {
+    // if we are an unitialized QName, check that the other is unitialized too
+    if (!fLocalPart && !fPrefix)
+        return !qname.fLocalPart && !qname.fPrefix;
+
     if (fURIId == 0) // null URI
         return (XMLString::equals(getRawName(),qname.getRawName()));
 

Modified: xerces/c/trunk/src/xercesc/validators/schema/identity/XPathMatcher.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/validators/schema/identity/XPathMatcher.cpp?rev=804234&r1=804233&r2=804234&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/validators/schema/identity/XPathMatcher.cpp (original)
+++ xerces/c/trunk/src/xercesc/validators/schema/identity/XPathMatcher.cpp Fri Aug 14 14:20:16
2009
@@ -257,40 +257,34 @@
                         if (fCurrentStep[i] == stepSize) {
 
                             fMatched[i] = XP_MATCHED_A;
-                            XMLSize_t j=0;
 
-                            for(; j<i && ((fMatched[j] & XP_MATCHED) != XP_MATCHED);
j++) ;
-
-                            if(j == i) {
-
-                                SchemaAttDef* attDef = ((SchemaElementDecl&) elemDecl).getAttDef(curDef->getName(),
curDef->getURIId());
-                                DatatypeValidator* dv = (attDef) ? attDef->getDatatypeValidator()
: 0;
-                                const XMLCh* value = curDef->getValue();
-                                // store QName using their Clark name
-                                if(dv && dv->getType()==DatatypeValidator::QName)
+                            SchemaAttDef* attDef = ((SchemaElementDecl&) elemDecl).getAttDef(curDef->getName(),
curDef->getURIId());
+                            DatatypeValidator* dv = (attDef) ? attDef->getDatatypeValidator()
: 0;
+                            const XMLCh* value = curDef->getValue();
+                            // store QName using their Clark name
+                            if(dv && dv->getType()==DatatypeValidator::QName)
+                            {
+                                int index=XMLString::indexOf(value, chColon);
+                                if(index==-1)
+                                    matched(value, dv, false);
+                                else
                                 {
-                                    int index=XMLString::indexOf(value, chColon);
-                                    if(index==-1)
-                                        matched(value, dv, false);
-                                    else
+                                    XMLBuffer buff(1023, fMemoryManager);
+                                    buff.append(chOpenCurly);
+                                    if(validationContext)
                                     {
-                                        XMLBuffer buff(1023, fMemoryManager);
-                                        buff.append(chOpenCurly);
-                                        if(validationContext)
-                                        {
-                                            XMLCh* prefix=(XMLCh*)fMemoryManager->allocate((index+1)*sizeof(XMLCh));
-                                            ArrayJanitor<XMLCh> janPrefix(prefix, fMemoryManager);
-                                            XMLString::subString(prefix, value, 0, (XMLSize_t)index,
fMemoryManager);
-                                            buff.append(validationContext->getURIForPrefix(prefix));
-                                        }
-                                        buff.append(chCloseCurly);
-                                        buff.append(value+index+1);
-                                        matched(buff.getRawBuffer(), dv, false);
+                                        XMLCh* prefix=(XMLCh*)fMemoryManager->allocate((index+1)*sizeof(XMLCh));
+                                        ArrayJanitor<XMLCh> janPrefix(prefix, fMemoryManager);
+                                        XMLString::subString(prefix, value, 0, (XMLSize_t)index,
fMemoryManager);
+                                        buff.append(validationContext->getURIForPrefix(prefix));
                                     }
+                                    buff.append(chCloseCurly);
+                                    buff.append(value+index+1);
+                                    matched(buff.getRawBuffer(), dv, false);
                                 }
-                                else
-                                    matched(value, dv, false);
                             }
+                            else
+                                matched(value, dv, false);
                         }
                         break;
                     }
@@ -328,13 +322,10 @@
         // signal match, if appropriate
         else {
 
-            XMLSize_t j=0;
-            for(; j<i && ((fMatched[j] & XP_MATCHED) != XP_MATCHED); j++)
;
-
-            if ((j < i) || (fMatched[j] == 0)) {
+            if (fMatched[i] == 0)
                 continue;
-            }
-            if ((fMatched[j] & XP_MATCHED_A) == XP_MATCHED_A) {
+            
+            if ((fMatched[i] & XP_MATCHED_A) == XP_MATCHED_A) {
                 fMatched[i] = 0;
                 continue;
             }

Modified: xerces/c/trunk/src/xercesc/validators/schema/identity/XercesXPath.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/validators/schema/identity/XercesXPath.cpp?rev=804234&r1=804233&r2=804234&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/validators/schema/identity/XercesXPath.cpp (original)
+++ xerces/c/trunk/src/xercesc/validators/schema/identity/XercesXPath.cpp Fri Aug 14 14:20:16
2009
@@ -427,8 +427,19 @@
                     XercesStep* step = new (fMemoryManager) XercesStep(XercesStep::AxisType_SELF,
nodeTest);
                     stepsVector->insertElementAt(step, 0);
                 }
-                fLocationPaths->addElement(new (fMemoryManager) XercesLocationPath(stepsVector));
+                XercesLocationPath* newPath = new (fMemoryManager) XercesLocationPath(stepsVector);
                 janSteps.orphan();
+                bool bFound=false;
+                for(XMLSize_t i=0;i<fLocationPaths->size();i++)
+                    if((*(fLocationPaths->elementAt(i)))==(*newPath))
+                    {
+                        bFound=true;
+                        break;
+                    }
+                if(bFound)
+                    delete newPath;
+                else
+                    fLocationPaths->addElement(newPath);
                 stepsVector = new (fMemoryManager) RefVectorOf<XercesStep>(16, true,
fMemoryManager);
                 janSteps.reset(stepsVector);
                 firstTokenOfLocationPath = true;
@@ -661,8 +672,19 @@
         XercesStep* step = new (fMemoryManager) XercesStep(XercesStep::AxisType_SELF, nodeTest);
         stepsVector->insertElementAt(step, 0);
     }
-    fLocationPaths->addElement(new (fMemoryManager) XercesLocationPath(stepsVector));
+    XercesLocationPath* newPath = new (fMemoryManager) XercesLocationPath(stepsVector);
     janSteps.orphan();
+    bool bFound=false;
+    for(XMLSize_t i=0;i<fLocationPaths->size();i++)
+        if((*(fLocationPaths->elementAt(i)))==(*newPath))
+        {
+            bFound=true;
+            break;
+        }
+    if(bFound)
+        delete newPath;
+    else
+        fLocationPaths->addElement(newPath);
 }
 
 /***

Added: xerces/c/trunk/tests/src/XSTSHarness/regression/XERCESC-809/test.xml
URL: http://svn.apache.org/viewvc/xerces/c/trunk/tests/src/XSTSHarness/regression/XERCESC-809/test.xml?rev=804234&view=auto
==============================================================================
--- xerces/c/trunk/tests/src/XSTSHarness/regression/XERCESC-809/test.xml (added)
+++ xerces/c/trunk/tests/src/XSTSHarness/regression/XERCESC-809/test.xml Fri Aug 14 14:20:16
2009
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<sm:root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="SP
test.xsd" xmlns:sm="SP">
+	<sm:a aID="1" x="1" y="1"/>
+</sm:root>
\ No newline at end of file

Added: xerces/c/trunk/tests/src/XSTSHarness/regression/XERCESC-809/test.xsd
URL: http://svn.apache.org/viewvc/xerces/c/trunk/tests/src/XSTSHarness/regression/XERCESC-809/test.xsd?rev=804234&view=auto
==============================================================================
--- xerces/c/trunk/tests/src/XSTSHarness/regression/XERCESC-809/test.xsd (added)
+++ xerces/c/trunk/tests/src/XSTSHarness/regression/XERCESC-809/test.xsd Fri Aug 14 14:20:16
2009
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="SP" xmlns:sm="SP"
attributeFormDefault="unqualified" elementFormDefault="qualified">
+
+	<xsd:complexType name="CTa">
+		<xsd:attribute name="aID" type="xsd:integer" use="required"/>
+		<xsd:attribute name="x" type="xsd:integer" use="optional"/>
+		<xsd:attribute name="y" type="xsd:integer" use="optional"/>
+		<xsd:attribute name="z" type="xsd:integer" use="optional"/>
+	</xsd:complexType>
+
+	<!-- DEFINITION OF THE ONLY ALLOWED ROOT ELEMENT -->
+	<xsd:element name="root">
+		<xsd:complexType>
+			<xsd:sequence>
+				<xsd:element name="a" type="sm:CTa" maxOccurs="unbounded">
+					<xsd:key name="xORzKEY">
+						<xsd:selector xpath="."/>
+						<xsd:field xpath="@x|@y"/>
+						<!--<xsd:field xpath="@x|@z"/>-->
+					</xsd:key>
+				</xsd:element>
+			</xsd:sequence>
+		</xsd:complexType>
+	</xsd:element>
+</xsd:schema>
\ No newline at end of file

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=804234&r1=804233&r2=804234&view=diff
==============================================================================
--- xerces/c/trunk/tests/src/XSTSHarness/regression/Xerces.testSet (original)
+++ xerces/c/trunk/tests/src/XSTSHarness/regression/Xerces.testSet Fri Aug 14 14:20:16 2009
@@ -139,6 +139,22 @@
 			<current status="accepted" date="2008-02-13"/>
 		</instanceTest>
 	</testGroup>
+	<testGroup name="XERCESC-809">
+		<annotation>
+			<documentation>Does implement co-occurence constraints</documentation>
+		</annotation>
+		<documentationReference xlink:href="https://issues.apache.org/jira/browse/XERCESC-809"/>
+		<schemaTest name="XERCESC-809-1">
+			<schemaDocument xlink:href="./XERCESC-809/test.xsd"/>
+			<expected validity="valid"/>
+			<current status="accepted" date="2009-08-14"/>
+		</schemaTest>
+		<instanceTest name="XERCESC-809-2">
+			<instanceDocument xlink:href="./XERCESC-809/test.xml"/>
+			<expected validity="invalid"/>
+			<current status="accepted" date="2009-08-14"/>
+		</instanceTest>
+	</testGroup>
 	<testGroup name="XERCESC-830">
 		<annotation>
 			<documentation>Empty complex type definition is always non-mixed even if declaration
says otherwise</documentation>



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


Mime
View raw message