You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by bo...@apache.org on 2009/02/12 15:10:05 UTC
svn commit: r743755 - in /xerces/c/trunk/src/xercesc/validators/schema:
SchemaValidator.cpp SchemaValidator.hpp
Author: borisk
Date: Thu Feb 12 14:10:05 2009
New Revision: 743755
URL: http://svn.apache.org/viewvc?rev=743755&view=rev
Log:
More robust handling of leading/trailing whitespaces (XERCESC-1838).
Modified:
xerces/c/trunk/src/xercesc/validators/schema/SchemaValidator.cpp
xerces/c/trunk/src/xercesc/validators/schema/SchemaValidator.hpp
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=743755&r1=743754&r2=743755&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/validators/schema/SchemaValidator.cpp (original)
+++ xerces/c/trunk/src/xercesc/validators/schema/SchemaValidator.cpp Thu Feb 12 14:10:05 2009
@@ -56,6 +56,7 @@
, fNotationBuf(0)
, fDatatypeBuffer(1023, manager)
, fTrailing(false)
+ , fSeenNonWhiteSpace(false)
, fSeenId(false)
, fTypeStack(0)
, fMostRecentAttrValidator(0)
@@ -308,6 +309,7 @@
// since it may need to query its contents after this method completes
fNil = false;
fTrailing=false;
+ fSeenNonWhiteSpace = false;
fCurrentDatatypeValidator = 0;
// Went ok, so return success
@@ -337,6 +339,7 @@
void SchemaValidator::reset()
{
fTrailing = false;
+ fSeenNonWhiteSpace = false;
fSeenId = false;
fTypeStack->removeAllElements();
delete fXsiType;
@@ -523,8 +526,7 @@
fMostRecentAttrValidator = DatatypeValidatorFactory::getBuiltInRegistry()->get(SchemaSymbols::fgDT_ANYSIMPLETYPE);
}
fTrailing = false;
-
-
+ fSeenNonWhiteSpace = false;
}
void SchemaValidator::validateElement(const XMLElementDecl* elemDef)
@@ -726,6 +728,7 @@
fDatatypeBuffer.reset();
fTrailing = false;
+ fSeenNonWhiteSpace = false;
fSeenId = false;
}
@@ -967,12 +970,6 @@
const XMLCh* srcPtr = value;
XMLReader* fCurReader = getReaderMgr()->getCurrentReader();
- if ((wsFacet==DatatypeValidator::COLLAPSE) && fTrailing) {
- nextCh = *srcPtr;
- if (!fCurReader->isWhitespace(nextCh))
- toFill.append(chSpace);
- }
-
if (wsFacet == DatatypeValidator::REPLACE)
{
while (*srcPtr)
@@ -992,8 +989,7 @@
, InContent
};
- bool firstNonWS = false;
- States curState = InContent;
+ States curState = fTrailing ? InWhitespace : InContent;
while (*srcPtr)
{
nextCh = *srcPtr++;
@@ -1004,25 +1000,26 @@
curState = InWhitespace;
continue;
}
- firstNonWS = true;
+ fSeenNonWhiteSpace = true;
}
else if (curState == InWhitespace)
{
if (fCurReader->isWhitespace(nextCh))
continue;
- if (firstNonWS)
+ if (fSeenNonWhiteSpace)
toFill.append(chSpace);
curState = InContent;
- firstNonWS = true;
+ fSeenNonWhiteSpace = true;
}
// Add this char to the target buffer
toFill.append(nextCh);
}
+
+ if (fCurReader->isWhitespace(*(srcPtr-1)))
+ fTrailing = true;
+ else
+ fTrailing = false;
}
- if (fCurReader->isWhitespace(*(srcPtr-1)))
- fTrailing = true;
- else
- fTrailing = 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=743755&r1=743754&r2=743755&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/validators/schema/SchemaValidator.hpp (original)
+++ xerces/c/trunk/src/xercesc/validators/schema/SchemaValidator.hpp Thu Feb 12 14:10:05 2009
@@ -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.
@@ -269,6 +269,9 @@
// fTrailing
// Previous chunk had a trailing space
//
+ // fSeenNonWhiteSpace
+ // Seen a non-whitespace character in the previous chunk
+ //
// fSeenId
// Indicate if an attribute of ID type has been seen already, reset per element.
//
@@ -293,6 +296,7 @@
XMLBuffer* fNotationBuf;
XMLBuffer fDatatypeBuffer;
bool fTrailing;
+ bool fSeenNonWhiteSpace;
bool fSeenId;
XSDErrorReporter fSchemaErrorReporter;
ValueStackOf<ComplexTypeInfo*>* fTypeStack;
@@ -345,7 +349,7 @@
return fTypeStack->peek();
}
-inline DatatypeValidator * SchemaValidator::getCurrentDatatypeValidator() const
+inline DatatypeValidator * SchemaValidator::getCurrentDatatypeValidator() const
{
return fCurrentDatatypeValidator;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org