You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by am...@apache.org on 2009/08/12 15:40:40 UTC

svn commit: r803507 - in /xerces/c/trunk/src/xercesc: internal/ validators/schema/identity/

Author: amassari
Date: Wed Aug 12 13:40:40 2009
New Revision: 803507

URL: http://svn.apache.org/viewvc?rev=803507&view=rev
Log:
When an identity constraint involves a QName, store the value using its Clark name so that values using different prefixes can be matched

Modified:
    xerces/c/trunk/src/xercesc/internal/IGXMLScanner.cpp
    xerces/c/trunk/src/xercesc/internal/SGXMLScanner.cpp
    xerces/c/trunk/src/xercesc/validators/schema/identity/IC_Selector.cpp
    xerces/c/trunk/src/xercesc/validators/schema/identity/IC_Selector.hpp
    xerces/c/trunk/src/xercesc/validators/schema/identity/IdentityConstraintHandler.cpp
    xerces/c/trunk/src/xercesc/validators/schema/identity/IdentityConstraintHandler.hpp
    xerces/c/trunk/src/xercesc/validators/schema/identity/XPathMatcher.cpp
    xerces/c/trunk/src/xercesc/validators/schema/identity/XPathMatcher.hpp

Modified: xerces/c/trunk/src/xercesc/internal/IGXMLScanner.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/internal/IGXMLScanner.cpp?rev=803507&r1=803506&r2=803507&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/internal/IGXMLScanner.cpp (original)
+++ xerces/c/trunk/src/xercesc/internal/IGXMLScanner.cpp Wed Aug 12 13:40:40 2009
@@ -1133,6 +1133,7 @@
                              (
                               (SchemaElementDecl *) topElem->fThisElement
                             , fContent.getRawBuffer()
+                            , fValidationContext
                              );
             }
 
@@ -2605,6 +2606,7 @@
                         , fPrefixBuf.getRawBuffer()
                         , *fAttrList
                         , attCount
+                        , fValidationContext
                         );
     }
 
@@ -2713,6 +2715,7 @@
                                    (
                                     (SchemaElementDecl *) elemDecl
                                   , fContent.getRawBuffer()
+                                  , fValidationContext
                                    );
                 }
 

Modified: xerces/c/trunk/src/xercesc/internal/SGXMLScanner.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/internal/SGXMLScanner.cpp?rev=803507&r1=803506&r2=803507&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/internal/SGXMLScanner.cpp (original)
+++ xerces/c/trunk/src/xercesc/internal/SGXMLScanner.cpp Wed Aug 12 13:40:40 2009
@@ -981,6 +981,7 @@
                         (
                          (SchemaElementDecl *) topElem->fThisElement
                        , fContent.getRawBuffer()
+                       , fValidationContext
                         );
         }
 
@@ -1602,6 +1603,7 @@
                         , fPrefixBuf.getRawBuffer()
                         , *fAttrList
                         , attCount
+                        , fValidationContext
                         );
 
     }
@@ -1709,6 +1711,7 @@
                        (
                         (SchemaElementDecl *) elemDecl
                       , fContent.getRawBuffer()
+                      , fValidationContext
                        );
             }
 

Modified: xerces/c/trunk/src/xercesc/validators/schema/identity/IC_Selector.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/validators/schema/identity/IC_Selector.cpp?rev=803507&r1=803506&r2=803507&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/validators/schema/identity/IC_Selector.cpp (original)
+++ xerces/c/trunk/src/xercesc/validators/schema/identity/IC_Selector.cpp Wed Aug 12 13:40:40 2009
@@ -61,9 +61,11 @@
                                    const unsigned int urlId,
                                    const XMLCh* const elemPrefix,
                                    const RefVectorOf<XMLAttr>& attrList,
-                                   const XMLSize_t attrCount) {
+                                   const XMLSize_t attrCount,
+                                   ValidationContext* validationContext /*=0*/) 
+{
 
-    XPathMatcher::startElement(elemDecl, urlId, elemPrefix, attrList, attrCount);
+    XPathMatcher::startElement(elemDecl, urlId, elemPrefix, attrList, attrCount, validationContext);
     fElementDepth++;
 
     // activate the fields, if selector is matched
@@ -80,15 +82,17 @@
         for (XMLSize_t i = 0; i < count; i++) {
 
             XPathMatcher* matcher = fFieldActivator->activateField(ic->getFieldAt(i), fInitialDepth);
-            matcher->startElement(elemDecl, urlId, elemPrefix, attrList, attrCount);
+            matcher->startElement(elemDecl, urlId, elemPrefix, attrList, attrCount, validationContext);
         }
     }
 }
 
 void SelectorMatcher::endElement(const XMLElementDecl& elemDecl,
-                                 const XMLCh* const elemContent) {
+                                 const XMLCh* const elemContent, 
+                                 ValidationContext* validationContext /*=0*/) 
+{
 
-    XPathMatcher::endElement(elemDecl, elemContent);
+    XPathMatcher::endElement(elemDecl, elemContent, validationContext);
 
     if (fElementDepth-- == fMatchedDepth) {
 

Modified: xerces/c/trunk/src/xercesc/validators/schema/identity/IC_Selector.hpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/validators/schema/identity/IC_Selector.hpp?rev=803507&r1=803506&r2=803507&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/validators/schema/identity/IC_Selector.hpp (original)
+++ xerces/c/trunk/src/xercesc/validators/schema/identity/IC_Selector.hpp Wed Aug 12 13:40:40 2009
@@ -102,14 +102,16 @@
     // -----------------------------------------------------------------------
     //  XMLDocumentHandler methods
     // -----------------------------------------------------------------------
-    void startDocumentFragment();
-    void startElement(const XMLElementDecl& elemDecl,
-                      const unsigned int urlId,
-                      const XMLCh* const elemPrefix,
-		              const RefVectorOf<XMLAttr>& attrList,
-                      const XMLSize_t attrCount);
-    void endElement(const XMLElementDecl& elemDecl,
-                    const XMLCh* const elemContent);
+    virtual void startDocumentFragment();
+    virtual void startElement(const XMLElementDecl& elemDecl,
+                              const unsigned int urlId,
+                              const XMLCh* const elemPrefix,
+		                      const RefVectorOf<XMLAttr>& attrList,
+                              const XMLSize_t attrCount,
+                              ValidationContext* validationContext = 0);
+    virtual void endElement(const XMLElementDecl& elemDecl,
+                            const XMLCh* const elemContent,
+                            ValidationContext* validationContext = 0);
 
 private:
     // -----------------------------------------------------------------------

Modified: xerces/c/trunk/src/xercesc/validators/schema/identity/IdentityConstraintHandler.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/validators/schema/identity/IdentityConstraintHandler.cpp?rev=803507&r1=803506&r2=803507&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/validators/schema/identity/IdentityConstraintHandler.cpp (original)
+++ xerces/c/trunk/src/xercesc/validators/schema/identity/IdentityConstraintHandler.cpp Wed Aug 12 13:40:40 2009
@@ -76,7 +76,8 @@
 //  IdentityConstraintHandler:  methods
 // ---------------------------------------------------------------------------
 void IdentityConstraintHandler::deactivateContext(      SchemaElementDecl* const elem
-                                                , const XMLCh*             const content)
+                                                , const XMLCh*             const content
+                                                , ValidationContext*       validationContext /*=0*/)
 {
 
     XMLSize_t oldCount = fMatcherStack->getMatcherCount();
@@ -87,7 +88,7 @@
         for (XMLSize_t i = oldCount; i > 0; i--) 
         {
             XPathMatcher* matcher = fMatcherStack->getMatcherAt(i-1);
-            matcher->endElement(*(elem), content);
+            matcher->endElement(*(elem), content, validationContext);
         }
 
         if (fMatcherStack->size() > 0) 
@@ -136,7 +137,7 @@
                      , const XMLCh*                 const elemPrefix
                      , const RefVectorOf<XMLAttr>&        attrList
                      , const XMLSize_t                    attrCount
-                      )
+                     , ValidationContext*                 validationContext /*=0*/)
 {
 
     XMLSize_t count = elem->getIdentityConstraintCount();
@@ -159,7 +160,7 @@
         for (XMLSize_t j = 0; j < count; j++) 
         {
             XPathMatcher* matcher = fMatcherStack->getMatcherAt(j);
-            matcher->startElement(*elem, uriId, elemPrefix, attrList, attrCount);
+            matcher->startElement(*elem, uriId, elemPrefix, attrList, attrCount, validationContext);
         }
     }
 }

Modified: xerces/c/trunk/src/xercesc/validators/schema/identity/IdentityConstraintHandler.hpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/validators/schema/identity/IdentityConstraintHandler.hpp?rev=803507&r1=803506&r2=803507&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/validators/schema/identity/IdentityConstraintHandler.hpp (original)
+++ xerces/c/trunk/src/xercesc/validators/schema/identity/IdentityConstraintHandler.hpp Wed Aug 12 13:40:40 2009
@@ -72,7 +72,7 @@
                              (
                                     SchemaElementDecl* const elem
                             , const XMLCh*             const content
-                              );
+                            , ValidationContext*       validationContext = 0);
 
             void         activateIdentityConstraint
                                (
@@ -82,7 +82,7 @@
                              , const XMLCh*                 const elemPrefix
                              , const RefVectorOf<XMLAttr>&        attrList
                              , const XMLSize_t                    attrCount
-                               );
+                             , ValidationContext*                 validationContext = 0 );
 
             void         reset();
 

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=803507&r1=803506&r2=803507&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/validators/schema/identity/XPathMatcher.cpp (original)
+++ xerces/c/trunk/src/xercesc/validators/schema/identity/XPathMatcher.cpp Wed Aug 12 13:40:40 2009
@@ -29,6 +29,7 @@
 #include <xercesc/validators/schema/SchemaSymbols.hpp>
 #include <xercesc/util/RuntimeException.hpp>
 #include <xercesc/util/OutOfMemoryException.hpp>
+#include <xercesc/framework/ValidationContext.hpp>
 
 XERCES_CPP_NAMESPACE_BEGIN
 
@@ -149,7 +150,8 @@
                                 const unsigned int urlId,
                                 const XMLCh* const elemPrefix,
 								const RefVectorOf<XMLAttr>& attrList,
-                                const XMLSize_t attrCount) {
+                                const XMLSize_t attrCount,
+                                ValidationContext* validationContext /*=0*/) {
 
     for (XMLSize_t i = 0; i < fLocationPathSize; i++) {
 
@@ -263,7 +265,31 @@
 
                                 SchemaAttDef* attDef = ((SchemaElementDecl&) elemDecl).getAttDef(curDef->getName(), curDef->getURIId());
                                 DatatypeValidator* dv = (attDef) ? attDef->getDatatypeValidator() : 0;
-                                matched(curDef->getValue(), dv, false);
+                                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
+                                    {
+                                        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);
+                                    }
+                                }
+                                else
+                                    matched(value, dv, false);
                             }
                         }
                         break;
@@ -286,7 +312,8 @@
 }
 
 void XPathMatcher::endElement(const XMLElementDecl& elemDecl,
-                              const XMLCh* const elemContent) {
+                              const XMLCh* const elemContent,
+                              ValidationContext* validationContext /*=0*/) {
 
     for(XMLSize_t i = 0; i < fLocationPathSize; i++) {
 
@@ -314,7 +341,30 @@
             DatatypeValidator* dv = ((SchemaElementDecl*) &elemDecl)->getDatatypeValidator();
             bool isNillable = (((SchemaElementDecl *) &elemDecl)->getMiscFlags() & SchemaSymbols::XSD_NILLABLE) != 0;
 
-            matched(elemContent, dv, isNillable);
+            // store QName using their Clark name
+            if(dv && dv->getType()==DatatypeValidator::QName)
+            {
+                int index=XMLString::indexOf(elemContent, chColon);
+                if(index==-1)
+                    matched(elemContent, dv, isNillable);
+                else
+                {
+                    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, elemContent, 0, (XMLSize_t)index, fMemoryManager);
+                        buff.append(validationContext->getURIForPrefix(prefix));
+                    }
+                    buff.append(chCloseCurly);
+                    buff.append(elemContent+index+1);
+                    matched(buff.getRawBuffer(), dv, isNillable);
+                }
+            }
+            else
+                matched(elemContent, dv, isNillable);
             fMatched[i] = 0;
         }
     }

Modified: xerces/c/trunk/src/xercesc/validators/schema/identity/XPathMatcher.hpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/validators/schema/identity/XPathMatcher.hpp?rev=803507&r1=803506&r2=803507&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/validators/schema/identity/XPathMatcher.hpp (original)
+++ xerces/c/trunk/src/xercesc/validators/schema/identity/XPathMatcher.hpp Wed Aug 12 13:40:40 2009
@@ -44,6 +44,7 @@
 class XMLAttr;
 class XercesNodeTest;
 class QName;
+class ValidationContext;
 
 class VALIDATORS_EXPORT XPathMatcher : public XMemory
 {
@@ -81,9 +82,11 @@
                               const unsigned int urlId,
                               const XMLCh* const elemPrefix,
                               const RefVectorOf<XMLAttr>& attrList,
-                              const XMLSize_t attrCount);
+                              const XMLSize_t attrCount,
+                              ValidationContext* validationContext = 0);
     virtual void endElement(const XMLElementDecl& elemDecl,
-                            const XMLCh* const elemContent);
+                            const XMLCh* const elemContent,
+                            ValidationContext* validationContext = 0);
 
     enum
     {



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