xerces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amass...@apache.org
Subject svn commit: r803885 - in /xerces/c/trunk/src/xercesc/validators/schema: TraverseSchema.cpp identity/XercesXPath.cpp
Date Thu, 13 Aug 2009 13:49:59 GMT
Author: amassari
Date: Thu Aug 13 13:49:59 2009
New Revision: 803885

URL: http://svn.apache.org/viewvc?rev=803885&view=rev
Log:
Don't manipulate the XPath expression to ensure it starts with "./" before parsing; add the
proper token after the scanner phase

Modified:
    xerces/c/trunk/src/xercesc/validators/schema/TraverseSchema.cpp
    xerces/c/trunk/src/xercesc/validators/schema/identity/XercesXPath.cpp

Modified: xerces/c/trunk/src/xercesc/validators/schema/TraverseSchema.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/validators/schema/TraverseSchema.cpp?rev=803885&r1=803884&r2=803885&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/validators/schema/TraverseSchema.cpp (original)
+++ xerces/c/trunk/src/xercesc/validators/schema/TraverseSchema.cpp Thu Aug 13 13:49:59 2009
@@ -109,21 +109,6 @@
     chLatin_e, chLatin_d, chNull
 };
 
-static const XMLCh fgSkip[] =
-{
-    chLatin_s, chLatin_k, chLatin_i, chLatin_p, chNull
-};
-
-static const XMLCh fgLax[] =
-{
-    chLatin_l, chLatin_a, chLatin_x, chNull
-};
-
-static const XMLCh fgStrict[] =
-{
-    chLatin_s, chLatin_t, chLatin_r, chLatin_i, chLatin_c, chLatin_t, chNull
-};
-
 static const XMLCh fgValueOne[] =
 {
     chDigit_1, chNull
@@ -134,21 +119,6 @@
     chDigit_0, chNull
 };
 
-static const XMLCh fgForwardSlash[] =
-{
-    chForwardSlash, chNull
-};
-
-static const XMLCh fgDot[] =
-{
-    chPeriod, chNull
-};
-
-static const XMLCh fgDotForwardSlash[] =
-{
-    chPeriod, chForwardSlash, chNull
-};
-
 static const XMLCh* fgIdentityConstraints[] =
 {
     SchemaSymbols::fgELT_UNIQUE,
@@ -1985,15 +1955,15 @@
     ContentSpecNode::NodeTypes anyOtherType = ContentSpecNode::Any_Other;
 
     if ((processContents && *processContents)
-        && !XMLString::equals(processContents, fgStrict)) {
+        && !XMLString::equals(processContents, SchemaSymbols::fgATTVAL_STRICT)) {
 
-        if (XMLString::equals(processContents, fgLax)) {
+        if (XMLString::equals(processContents, SchemaSymbols::fgATTVAL_LAX)) {
 
             anyType = ContentSpecNode::Any_Lax;
             anyOtherType = ContentSpecNode::Any_Other_Lax;
             anyLocalType = ContentSpecNode::Any_NS_Lax;
         }
-        else if (XMLString::equals(processContents, fgSkip)) {
+        else if (XMLString::equals(processContents, SchemaSymbols::fgATTVAL_SKIP)) {
 
             anyType = ContentSpecNode::Any_Skip;
             anyOtherType = ContentSpecNode::Any_Other_Skip;
@@ -4548,41 +4518,12 @@
         return false;
     }
 
-    fBuffer.reset();
-
-    XMLSize_t startIndex = 0;
-
-    while (startIndex < xpathLen) {
-        if(XMLChar1_0::isWhitespace(*(xpathExpr+startIndex)))
-        {
-            fBuffer.append(xpathExpr + startIndex, 1);
-            startIndex++;
-            continue;
-        }
-
-        if (!XMLString::startsWith(xpathExpr + startIndex, fgForwardSlash)
-            && !XMLString::startsWith(xpathExpr + startIndex, fgDot)) {
-            fBuffer.append(fgDotForwardSlash);
-        }
-
-        int chOffset = XMLString::indexOf(xpathExpr, chPipe, startIndex, fMemoryManager);
-
-        if (chOffset == -1)
-            break;
-
-        fBuffer.append(xpathExpr + startIndex, chOffset + 1 - startIndex);
-        startIndex = chOffset + 1;
-    }
-
-    if (startIndex < xpathLen)
-        fBuffer.append(xpathExpr + startIndex);
-
     // ------------------------------------------------------------------
     // Parse xpath expression
     // ------------------------------------------------------------------
     try {
 
-        XercesXPath* sXPath = new (fGrammarPoolMemoryManager) XercesXPath(fBuffer.getRawBuffer(),
fStringPool, fSchemaInfo->getNamespaceScope(), fEmptyNamespaceURI, true, fGrammarPoolMemoryManager);
+        XercesXPath* sXPath = new (fGrammarPoolMemoryManager) XercesXPath(xpathExpr, fStringPool,
fSchemaInfo->getNamespaceScope(), fEmptyNamespaceURI, true, fGrammarPoolMemoryManager);
         IC_Selector* icSelector = new (fGrammarPoolMemoryManager) IC_Selector(sXPath, ic);
         ic->setSelector(icSelector);
     }
@@ -4636,21 +4577,11 @@
                 return false;
             }
 
-            if (XMLString::startsWith(xpathExpr, fgForwardSlash)
-                || XMLString::startsWith(xpathExpr, fgDot)) {
-                fBuffer.set(xpathExpr);
-            }
-            else {
-
-                fBuffer.set(fgDotForwardSlash);
-                fBuffer.append(xpathExpr);
-            }
-
             try {
 
                 XercesXPath* fieldXPath = new (fGrammarPoolMemoryManager) XercesXPath
                 (
-                    fBuffer.getRawBuffer()
+                    xpathExpr
                     , fStringPool
                     , fSchemaInfo->getNamespaceScope()
                     , fEmptyNamespaceURI

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=803885&r1=803884&r2=803885&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/validators/schema/identity/XercesXPath.cpp (original)
+++ xerces/c/trunk/src/xercesc/validators/schema/identity/XercesXPath.cpp Thu Aug 13 13:49:59
2009
@@ -420,6 +420,13 @@
                     ThrowXMLwithMemMgr(XPathException, XMLExcepts::XPath_NoMultipleUnion,
fMemoryManager);
                 }
 
+                if(stepsVector->elementAt(0)->getAxisType()!=XercesStep::AxisType_SELF)
+                {
+                    // prepend ./
+                    XercesNodeTest* nodeTest = new (fMemoryManager) XercesNodeTest(XercesNodeTest::NodeType_NODE,
fMemoryManager);
+                    XercesStep* step = new (fMemoryManager) XercesStep(XercesStep::AxisType_SELF,
nodeTest);
+                    stepsVector->insertElementAt(step, 0);
+                }
                 fLocationPaths->addElement(new (fMemoryManager) XercesLocationPath(stepsVector));
                 janSteps.orphan();
                 stepsVector = new (fMemoryManager) RefVectorOf<XercesStep>(16, true,
fMemoryManager);
@@ -624,6 +631,10 @@
                     ThrowXMLwithMemMgr(XPathException, XMLExcepts::XPath_ExpectedStep3, fMemoryManager);
                 }
 
+                aToken = tokens.elementAt(i+1);
+                if(aToken == XercesXPath::EXPRTOKEN_OPERATOR_SLASH || aToken == XercesXPath::EXPRTOKEN_OPERATOR_DOUBLE_SLASH
|| aToken == XercesXPath::EXPRTOKEN_OPERATOR_UNION)
+                    ThrowXMLwithMemMgr(XPathException, XMLExcepts::XPath_ExpectedStep3, fMemoryManager);
+
                 firstTokenOfLocationPath=false;
                 break;
             }
@@ -643,6 +654,13 @@
         }
     }
 
+    if(stepsVector->elementAt(0)->getAxisType()!=XercesStep::AxisType_SELF)
+    {
+        // prepend ./
+        XercesNodeTest* nodeTest = new (fMemoryManager) XercesNodeTest(XercesNodeTest::NodeType_NODE,
fMemoryManager);
+        XercesStep* step = new (fMemoryManager) XercesStep(XercesStep::AxisType_SELF, nodeTest);
+        stepsVector->insertElementAt(step, 0);
+    }
     fLocationPaths->addElement(new (fMemoryManager) XercesLocationPath(stepsVector));
     janSteps.orphan();
 }
@@ -842,7 +860,7 @@
                     ch = data[currentOffset];
                 } while (XMLChar1_0::isWhitespace(ch));
 
-                if (currentOffset == endOffset || ch == chPipe) {
+                if (currentOffset == endOffset || ch == chPipe || ch == chForwardSlash) {
 				    addToken(tokens, XercesXPath::EXPRTOKEN_PERIOD);
                     starIsMultiplyOperator = true;
                     break;



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


Mime
View raw message