xerces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amass...@apache.org
Subject svn commit: r803839 - in /xerces/c/trunk/src/xercesc: internal/IGXMLScanner2.cpp internal/SGXMLScanner.cpp internal/XSAXMLScanner.cpp validators/schema/SchemaValidator.cpp validators/schema/SchemaValidator.hpp
Date Thu, 13 Aug 2009 10:53:55 GMT
Author: amassari
Date: Thu Aug 13 10:53:54 2009
New Revision: 803839

URL: http://svn.apache.org/viewvc?rev=803839&view=rev
Log:
Attributes in the xsi namespace were not whitespace-normalized

Modified:
    xerces/c/trunk/src/xercesc/internal/IGXMLScanner2.cpp
    xerces/c/trunk/src/xercesc/internal/SGXMLScanner.cpp
    xerces/c/trunk/src/xercesc/internal/XSAXMLScanner.cpp
    xerces/c/trunk/src/xercesc/validators/schema/SchemaValidator.cpp
    xerces/c/trunk/src/xercesc/validators/schema/SchemaValidator.hpp

Modified: xerces/c/trunk/src/xercesc/internal/IGXMLScanner2.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/internal/IGXMLScanner2.cpp?rev=803839&r1=803838&r2=803839&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/internal/IGXMLScanner2.cpp (original)
+++ xerces/c/trunk/src/xercesc/internal/IGXMLScanner2.cpp Thu Aug 13 10:53:54 2009
@@ -271,6 +271,8 @@
 
                     if (fValidate && attrValidator && ValueValidate)
                     {
+                        ((SchemaValidator*) fValidator)->normalizeWhiteSpace(attrValidator,
normBuf.getRawBuffer(), normBuf, true);
+
                         ValidationContext* const    theContext =
                             getValidationContext();
 
@@ -548,7 +550,7 @@
                 if (tempDV && tempDV->getWSFacet() != DatatypeValidator::PRESERVE)
                 {
                     // normalize the attribute according to schema whitespace facet
-                    ((SchemaValidator*) fValidator)->normalizeWhiteSpace(tempDV, xsNormalized,
fWSNormalizeBuf);
+                    ((SchemaValidator*) fValidator)->normalizeWhiteSpace(tempDV, xsNormalized,
fWSNormalizeBuf, true);
                     xsNormalized = fWSNormalizeBuf.getRawBuffer();
 
                     if (fNormalizeData && fValidate) {
@@ -590,7 +592,7 @@
                         if (tempDV && tempDV->getWSFacet() != DatatypeValidator::PRESERVE)
                         {
                             // normalize the attribute according to schema whitespace facet
-                            ((SchemaValidator*) fValidator)->normalizeWhiteSpace(tempDV,
xsNormalized, fWSNormalizeBuf);
+                            ((SchemaValidator*) fValidator)->normalizeWhiteSpace(tempDV,
xsNormalized, fWSNormalizeBuf, true);
                             xsNormalized = fWSNormalizeBuf.getRawBuffer();
                             if (fNormalizeData && fValidate && !skipThisOne)
{
                                 normBuf.set(xsNormalized);
@@ -1716,13 +1718,24 @@
                 else if (XMLString::equals(suffPtr, SchemaSymbols::fgXSI_NONAMESPACESCHEMALOCATION))
                     resolveSchemaGrammar(valuePtr, XMLUni::fgZeroLenString);
 
-                if (XMLString::equals(suffPtr, SchemaSymbols::fgXSI_TYPE)) {
-                        fXsiType.set(valuePtr);
-                }
-                else if (XMLString::equals(suffPtr, SchemaSymbols::fgATT_NILL)
-                         && fValidator && fValidator->handlesSchema()
-                         && XMLString::equals(valuePtr, SchemaSymbols::fgATTVAL_TRUE))
{
+                if( fValidator && fValidator->handlesSchema() )
+                {
+                    if (XMLString::equals(suffPtr, SchemaSymbols::fgXSI_TYPE)) 
+                    {
+                        // normalize the attribute according to schema whitespace facet
+                        DatatypeValidator* tempDV = DatatypeValidatorFactory::getBuiltInRegistry()->get(SchemaSymbols::fgDT_QNAME);
+                        ((SchemaValidator*) fValidator)->normalizeWhiteSpace(tempDV, valuePtr,
fXsiType, true);
+                    }
+                    else if (XMLString::equals(suffPtr, SchemaSymbols::fgATT_NILL))
+                    {
+                        // normalize the attribute according to schema whitespace facet
+                        XMLBuffer& fXsiNil = fBufMgr.bidOnBuffer();
+                        DatatypeValidator* tempDV = DatatypeValidatorFactory::getBuiltInRegistry()->get(SchemaSymbols::fgDT_BOOLEAN);
+                        ((SchemaValidator*) fValidator)->normalizeWhiteSpace(tempDV, valuePtr,
fXsiNil, true);
+                        if(XMLString::equals(fXsiNil.getRawBuffer(), SchemaSymbols::fgATTVAL_TRUE))
                             ((SchemaValidator*)fValidator)->setNillable(true);
+                        fBufMgr.releaseBuffer(fXsiNil);
+                    }
                 }
             }
         }

Modified: xerces/c/trunk/src/xercesc/internal/SGXMLScanner.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/internal/SGXMLScanner.cpp?rev=803839&r1=803838&r2=803839&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/internal/SGXMLScanner.cpp (original)
+++ xerces/c/trunk/src/xercesc/internal/SGXMLScanner.cpp Thu Aug 13 10:53:54 2009
@@ -2308,6 +2308,8 @@
 
                     if (fValidate && attrValidator && ValueValidate)
                     {
+                        ((SchemaValidator*) fValidator)->normalizeWhiteSpace(attrValidator,
normBuf.getRawBuffer(), normBuf, true);
+
                         ValidationContext* const    theContext =
                             getValidationContext();
 
@@ -2551,7 +2553,7 @@
                 if (tempDV && tempDV->getWSFacet() != DatatypeValidator::PRESERVE)
                 {
                     // normalize the attribute according to schema whitespace facet
-                    ((SchemaValidator*) fValidator)->normalizeWhiteSpace(tempDV, xsNormalized,
fWSNormalizeBuf);
+                    ((SchemaValidator*) fValidator)->normalizeWhiteSpace(tempDV, xsNormalized,
fWSNormalizeBuf, true);
                     xsNormalized = fWSNormalizeBuf.getRawBuffer();
                     if (fNormalizeData && fValidate) {
                         normBuf.set(xsNormalized);
@@ -2592,7 +2594,7 @@
                         if (tempDV && tempDV->getWSFacet() != DatatypeValidator::PRESERVE)
                         {
                             // normalize the attribute according to schema whitespace facet
-                            ((SchemaValidator*) fValidator)->normalizeWhiteSpace(tempDV,
xsNormalized, fWSNormalizeBuf);
+                            ((SchemaValidator*) fValidator)->normalizeWhiteSpace(tempDV,
xsNormalized, fWSNormalizeBuf, true);
                             xsNormalized = fWSNormalizeBuf.getRawBuffer();
                             if (fNormalizeData && fValidate && !skipThisOne)
{
                                 normBuf.set(xsNormalized);
@@ -3602,13 +3604,24 @@
                 else if (XMLString::equals(suffPtr, SchemaSymbols::fgXSI_NONAMESPACESCHEMALOCATION))
                     resolveSchemaGrammar(valuePtr, XMLUni::fgZeroLenString);
 
-                if (XMLString::equals(suffPtr, SchemaSymbols::fgXSI_TYPE)) {
-                        fXsiType.set(valuePtr);
-                }
-                else if (XMLString::equals(suffPtr, SchemaSymbols::fgATT_NILL)
-                         && fValidator && fValidator->handlesSchema()
-                         && XMLString::equals(valuePtr, SchemaSymbols::fgATTVAL_TRUE))
{
+                if( fValidator && fValidator->handlesSchema() )
+                {
+                    if (XMLString::equals(suffPtr, SchemaSymbols::fgXSI_TYPE)) 
+                    {
+                        // normalize the attribute according to schema whitespace facet
+                        DatatypeValidator* tempDV = DatatypeValidatorFactory::getBuiltInRegistry()->get(SchemaSymbols::fgDT_QNAME);
+                        ((SchemaValidator*) fValidator)->normalizeWhiteSpace(tempDV, valuePtr,
fXsiType, true);
+                    }
+                    else if (XMLString::equals(suffPtr, SchemaSymbols::fgATT_NILL))
+                    {
+                        // normalize the attribute according to schema whitespace facet
+                        XMLBuffer& fXsiNil = fBufMgr.bidOnBuffer();
+                        DatatypeValidator* tempDV = DatatypeValidatorFactory::getBuiltInRegistry()->get(SchemaSymbols::fgDT_BOOLEAN);
+                        ((SchemaValidator*) fValidator)->normalizeWhiteSpace(tempDV, valuePtr,
fXsiNil, true);
+                        if(XMLString::equals(fXsiNil.getRawBuffer(), SchemaSymbols::fgATTVAL_TRUE))
                             ((SchemaValidator*)fValidator)->setNillable(true);
+                        fBufMgr.releaseBuffer(fXsiNil);
+                    }
                 }
             }
         }

Modified: xerces/c/trunk/src/xercesc/internal/XSAXMLScanner.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/internal/XSAXMLScanner.cpp?rev=803839&r1=803838&r2=803839&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/internal/XSAXMLScanner.cpp (original)
+++ xerces/c/trunk/src/xercesc/internal/XSAXMLScanner.cpp Thu Aug 13 10:53:54 2009
@@ -661,12 +661,21 @@
                 const XMLCh* valuePtr = curPair->getValue();
                 const XMLCh* suffPtr = attName.getLocalPart();
 
-                if (XMLString::equals(suffPtr, SchemaSymbols::fgXSI_TYPE)) {
-                    fXsiType.set(valuePtr);
+                if (XMLString::equals(suffPtr, SchemaSymbols::fgXSI_TYPE)) 
+                {
+                    // normalize the attribute according to schema whitespace facet
+                    DatatypeValidator* tempDV = DatatypeValidatorFactory::getBuiltInRegistry()->get(SchemaSymbols::fgDT_QNAME);
+                    ((SchemaValidator*) fValidator)->normalizeWhiteSpace(tempDV, valuePtr,
fXsiType, true);
                 }
-                else if (XMLString::equals(suffPtr, SchemaSymbols::fgATT_NILL)
-                         && XMLString::equals(valuePtr, SchemaSymbols::fgATTVAL_TRUE))
{
-                    ((SchemaValidator*)fValidator)->setNillable(true);
+                else if (XMLString::equals(suffPtr, SchemaSymbols::fgATT_NILL))
+                {
+                    // normalize the attribute according to schema whitespace facet
+                    XMLBuffer& fXsiNil = fBufMgr.bidOnBuffer();
+                    DatatypeValidator* tempDV = DatatypeValidatorFactory::getBuiltInRegistry()->get(SchemaSymbols::fgDT_BOOLEAN);
+                    ((SchemaValidator*) fValidator)->normalizeWhiteSpace(tempDV, valuePtr,
fXsiNil, true);
+                    if(XMLString::equals(fXsiNil.getRawBuffer(), SchemaSymbols::fgATTVAL_TRUE))
+                        ((SchemaValidator*)fValidator)->setNillable(true);
+                    fBufMgr.releaseBuffer(fXsiNil);
                 }
             }
         }

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=803839&r1=803838&r2=803839&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/validators/schema/SchemaValidator.cpp (original)
+++ xerces/c/trunk/src/xercesc/validators/schema/SchemaValidator.cpp Thu Aug 13 10:53:54 2009
@@ -962,16 +962,19 @@
 //            contiguous sequences of #x20s are collapsed to a single #x20,
 //            and initial and/or final #x20s are deleted.
 //
-void SchemaValidator::normalizeWhiteSpace(DatatypeValidator* dV, const XMLCh* const value,
XMLBuffer& toFill)
+void SchemaValidator::normalizeWhiteSpace(DatatypeValidator* dV, const XMLCh* const value,
XMLBuffer& toFill, bool bStandalone /*= false*/)
 {
-    short wsFacet = dV->getWSFacet();
-
     toFill.reset();
 
     //empty string
     if (!*value)
         return;
 
+    if(bStandalone)
+        fTrailing = fSeenNonWhiteSpace = false;
+
+    short wsFacet = dV->getWSFacet();
+
     //  Loop through the chars of the source value and normalize it
     //  according to the whitespace facet
     XMLCh nextCh;
@@ -1028,6 +1031,8 @@
         else
           fTrailing = false;
     }
+    if(bStandalone)
+        fTrailing = fSeenNonWhiteSpace = false;
 }
 
 

Modified: xerces/c/trunk/src/xercesc/validators/schema/SchemaValidator.hpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/validators/schema/SchemaValidator.hpp?rev=803839&r1=803838&r2=803839&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/validators/schema/SchemaValidator.hpp (original)
+++ xerces/c/trunk/src/xercesc/validators/schema/SchemaValidator.hpp Thu Aug 13 10:53:54 2009
@@ -109,7 +109,7 @@
     // -----------------------------------------------------------------------
     //  Schema Validator methods
     // -----------------------------------------------------------------------
-    void normalizeWhiteSpace(DatatypeValidator* dV, const XMLCh* const value, XMLBuffer&
toFill);
+    void normalizeWhiteSpace(DatatypeValidator* dV, const XMLCh* const value, XMLBuffer&
toFill, bool bStandalone = false);
 
     // -----------------------------------------------------------------------
     //  Setter methods



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


Mime
View raw message