knoaman 2003/09/30 18:09:35
Modified: c/src/xercesc/internal IGXMLScanner2.cpp SGXMLScanner.cpp
c/src/xercesc/validators/datatype
AnySimpleTypeDatatypeValidator.cpp
AnySimpleTypeDatatypeValidator.hpp
DatatypeValidator.cpp DatatypeValidator.hpp
StringDatatypeValidator.cpp
StringDatatypeValidator.hpp
c/src/xercesc/validators/schema SchemaValidator.cpp
Log:
Refactoring of some code to improve performance.
Revision Changes Path
1.31 +53 -36 xml-xerces/c/src/xercesc/internal/IGXMLScanner2.cpp
Index: IGXMLScanner2.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/internal/IGXMLScanner2.cpp,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- IGXMLScanner2.cpp 14 Aug 2003 02:56:41 -0000 1.30
+++ IGXMLScanner2.cpp 1 Oct 2003 01:09:34 -0000 1.31
@@ -366,13 +366,16 @@
// If we found an attdef for this one, then lets validate it.
if (fNormalizeData)
{
- // normalize the attribute according to schema whitespace facet
- XMLBufBid bbtemp(&fBufMgr);
- XMLBuffer& tempBuf = bbtemp.getBuffer();
-
DatatypeValidator* tempDV = ((SchemaAttDef*)
attDefForWildCard)->getDatatypeValidator();
- ((SchemaValidator*) fValidator)->normalizeWhiteSpace(tempDV,
normBuf.getRawBuffer(), tempBuf);
- normBuf.set(tempBuf.getRawBuffer());
+ if (tempDV && tempDV->getWSFacet() !=
DatatypeValidator::PRESERVE)
+ {
+ // normalize the attribute according to schema whitespace
facet
+ XMLBufBid bbtemp(&fBufMgr);
+ XMLBuffer& tempBuf = bbtemp.getBuffer();
+
+ ((SchemaValidator*)
fValidator)->normalizeWhiteSpace(tempDV, normBuf.getRawBuffer(), tempBuf);
+ normBuf.set(tempBuf.getRawBuffer());
+ }
}
if (fValidate && !skipThisOne) {
@@ -408,13 +411,16 @@
{
if (fNormalizeData && (fGrammarType ==
Grammar::SchemaGrammarType))
{
- // normalize the attribute according to schema whitespace
facet
- XMLBufBid bbtemp(&fBufMgr);
- XMLBuffer& tempBuf = bbtemp.getBuffer();
-
DatatypeValidator* tempDV = ((SchemaAttDef*)
attDef)->getDatatypeValidator();
- ((SchemaValidator*)
fValidator)->normalizeWhiteSpace(tempDV, normBuf.getRawBuffer(), tempBuf);
- normBuf.set(tempBuf.getRawBuffer());
+ if (tempDV && tempDV->getWSFacet() !=
DatatypeValidator::PRESERVE)
+ {
+ // normalize the attribute according to schema
whitespace facet
+ XMLBufBid bbtemp(&fBufMgr);
+ XMLBuffer& tempBuf = bbtemp.getBuffer();
+
+ ((SchemaValidator*)
fValidator)->normalizeWhiteSpace(tempDV, normBuf.getRawBuffer(), tempBuf);
+ normBuf.set(tempBuf.getRawBuffer());
+ }
}
if (fValidate && !skipThisOne)
@@ -651,7 +657,6 @@
// Get the type and name
const XMLAttDef::AttTypes type = attDef->getType();
- const XMLCh* const attrName = attDef->getFullName();
// Assume its going to go fine, and empty the target buffer in preperation
bool retVal = true;
@@ -681,7 +686,7 @@
// not allowed in attribute values.
if (!escaped && (*srcPtr == chOpenAngle))
{
- emitError(XMLErrs::BracketInAttrValue, attrName);
+ emitError(XMLErrs::BracketInAttrValue, attDef->getFullName());
retVal = false;
}
@@ -697,7 +702,7 @@
{
// Can't have a standalone document declaration of "yes"
if attribute
// values are subject to normalisation
- fValidator->emitError(XMLValid::NoAttNormForStandalone,
attrName);
+ fValidator->emitError(XMLValid::NoAttNormForStandalone,
attDef->getFullName());
if(fGrammarType == Grammar::SchemaGrammarType) {
((SchemaAttDef
*)(attDef))->setValidity(PSVIDefs::INVALID);
}
@@ -739,7 +744,7 @@
{
// Can't have a standalone document declaration of
"yes" if attribute
// values are subject to normalisation
- fValidator->emitError(XMLValid::NoAttNormForStandalone,
attrName);
+ fValidator->emitError(XMLValid::NoAttNormForStandalone,
attDef->getFullName());
if(fGrammarType == Grammar::SchemaGrammarType) {
((SchemaAttDef
*)(attDef))->setValidity(PSVIDefs::INVALID);
}
@@ -1054,14 +1059,18 @@
else
{
if (fNormalizeData) {
- // normalize the character according to schema whitespace
facet
- XMLBufBid bbtemp(&fBufMgr);
- XMLBuffer& tempBuf = bbtemp.getBuffer();
DatatypeValidator* tempDV = ((SchemaElementDecl*)
topElem->fThisElement)->getDatatypeValidator();
- ((SchemaValidator*)
fValidator)->normalizeWhiteSpace(tempDV, rawBuf, tempBuf);
- rawBuf = tempBuf.getRawBuffer();
- len = tempBuf.getLen();
+ if (tempDV && tempDV->getWSFacet() !=
DatatypeValidator::PRESERVE)
+ {
+ // normalize the character according to schema
whitespace facet
+ XMLBufBid bbtemp(&fBufMgr);
+ XMLBuffer& tempBuf = bbtemp.getBuffer();
+
+ ((SchemaValidator*)
fValidator)->normalizeWhiteSpace(tempDV, rawBuf, tempBuf);
+ rawBuf = tempBuf.getRawBuffer();
+ len = tempBuf.getLen();
+ }
}
// tell the schema validation about the character data for
checkContent later
@@ -1091,14 +1100,18 @@
else
{
if (fNormalizeData) {
- // normalize the character according to schema whitespace
facet
- XMLBufBid bbtemp(&fBufMgr);
- XMLBuffer& tempBuf = bbtemp.getBuffer();
DatatypeValidator* tempDV = ((SchemaElementDecl*)
topElem->fThisElement)->getDatatypeValidator();
- ((SchemaValidator*)
fValidator)->normalizeWhiteSpace(tempDV, rawBuf, tempBuf);
- rawBuf = tempBuf.getRawBuffer();
- len = tempBuf.getLen();
+ if (tempDV && tempDV->getWSFacet() !=
DatatypeValidator::PRESERVE)
+ {
+ // normalize the character according to schema
whitespace facet
+ XMLBufBid bbtemp(&fBufMgr);
+ XMLBuffer& tempBuf = bbtemp.getBuffer();
+
+ ((SchemaValidator*)
fValidator)->normalizeWhiteSpace(tempDV, rawBuf, tempBuf);
+ rawBuf = tempBuf.getRawBuffer();
+ len = tempBuf.getLen();
+ }
}
// tell the schema validation about the character data for
checkContent later
@@ -2100,14 +2113,18 @@
if (fGrammarType == Grammar::SchemaGrammarType) {
- if (fNormalizeData) {
- // normalize the character according to schema whitespace facet
- XMLBufBid bbtemp(&fBufMgr);
- XMLBuffer& tempBuf = bbtemp.getBuffer();
-
+ if (fNormalizeData)
+ {
DatatypeValidator* tempDV = ((SchemaElementDecl*)
topElem->fThisElement)->getDatatypeValidator();
- ((SchemaValidator*) fValidator)->normalizeWhiteSpace(tempDV,
bbCData.getRawBuffer(), tempBuf);
- bbCData.set(tempBuf.getRawBuffer());
+ if (tempDV && tempDV->getWSFacet() !=
DatatypeValidator::PRESERVE)
+ {
+ // normalize the character according to schema whitespace
facet
+ XMLBufBid bbtemp(&fBufMgr);
+ XMLBuffer& tempBuf = bbtemp.getBuffer();
+
+ ((SchemaValidator*)
fValidator)->normalizeWhiteSpace(tempDV, bbCData.getRawBuffer(), tempBuf);
+ bbCData.set(tempBuf.getRawBuffer());
+ }
}
if (fValidate) {
1.36 +52 -34 xml-xerces/c/src/xercesc/internal/SGXMLScanner.cpp
Index: SGXMLScanner.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/internal/SGXMLScanner.cpp,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -r1.35 -r1.36
--- SGXMLScanner.cpp 22 Sep 2003 19:51:41 -0000 1.35
+++ SGXMLScanner.cpp 1 Oct 2003 01:09:34 -0000 1.36
@@ -2228,13 +2228,16 @@
// If we found an attdef for this one, then lets validate it.
if (fNormalizeData)
{
- // normalize the attribute according to schema whitespace facet
- XMLBufBid bbtemp(&fBufMgr);
- XMLBuffer& tempBuf = bbtemp.getBuffer();
-
DatatypeValidator* tempDV = ((SchemaAttDef*)
attDefForWildCard)->getDatatypeValidator();
- ((SchemaValidator*) fValidator)->normalizeWhiteSpace(tempDV,
normBuf.getRawBuffer(), tempBuf);
- normBuf.set(tempBuf.getRawBuffer());
+ if (tempDV && tempDV->getWSFacet() !=
DatatypeValidator::PRESERVE)
+ {
+ // normalize the attribute according to schema whitespace
facet
+ XMLBufBid bbtemp(&fBufMgr);
+ XMLBuffer& tempBuf = bbtemp.getBuffer();
+
+ ((SchemaValidator*)
fValidator)->normalizeWhiteSpace(tempDV, normBuf.getRawBuffer(), tempBuf);
+ normBuf.set(tempBuf.getRawBuffer());
+ }
}
if (fValidate && !skipThisOne) {
@@ -2268,13 +2271,16 @@
{
if (fNormalizeData && (fGrammarType ==
Grammar::SchemaGrammarType))
{
- // normalize the attribute according to schema whitespace
facet
- XMLBufBid bbtemp(&fBufMgr);
- XMLBuffer& tempBuf = bbtemp.getBuffer();
-
DatatypeValidator* tempDV = ((SchemaAttDef*)
attDef)->getDatatypeValidator();
- ((SchemaValidator*)
fValidator)->normalizeWhiteSpace(tempDV, normBuf.getRawBuffer(), tempBuf);
- normBuf.set(tempBuf.getRawBuffer());
+ if (tempDV && tempDV->getWSFacet() !=
DatatypeValidator::PRESERVE)
+ {
+ // normalize the attribute according to schema
whitespace facet
+ XMLBufBid bbtemp(&fBufMgr);
+ XMLBuffer& tempBuf = bbtemp.getBuffer();
+
+ ((SchemaValidator*)
fValidator)->normalizeWhiteSpace(tempDV, normBuf.getRawBuffer(), tempBuf);
+ normBuf.set(tempBuf.getRawBuffer());
+ }
}
if (fValidate && !skipThisOne)
@@ -2844,14 +2850,18 @@
XMLBuffer toFill(len+1, fMemoryManager);
toFill.set(rawBuf);
- if (fNormalizeData) {
- // normalize the character according to schema whitespace facet
- XMLBufBid bbtemp(&fBufMgr);
- XMLBuffer& tempBuf = bbtemp.getBuffer();
-
+ if (fNormalizeData)
+ {
DatatypeValidator* tempDV = ((SchemaElementDecl*)
topElem->fThisElement)->getDatatypeValidator();
- ((SchemaValidator*) fValidator)->normalizeWhiteSpace(tempDV,
toFill.getRawBuffer(), tempBuf);
- toFill.set(tempBuf.getRawBuffer());
+ if (tempDV && tempDV->getWSFacet() !=
DatatypeValidator::PRESERVE)
+ {
+ // normalize the character according to schema whitespace
facet
+ XMLBufBid bbtemp(&fBufMgr);
+ XMLBuffer& tempBuf = bbtemp.getBuffer();
+
+ ((SchemaValidator*)
fValidator)->normalizeWhiteSpace(tempDV, toFill.getRawBuffer(), tempBuf);
+ toFill.set(tempBuf.getRawBuffer());
+ }
}
// tell the schema validation about the character data for
checkContent later
@@ -2878,14 +2888,18 @@
XMLBuffer toFill(len+1, fMemoryManager);
toFill.set(rawBuf);
- if (fNormalizeData) {
- // normalize the character according to schema whitespace facet
- XMLBufBid bbtemp(&fBufMgr);
- XMLBuffer& tempBuf = bbtemp.getBuffer();
-
+ if (fNormalizeData)
+ {
DatatypeValidator* tempDV = ((SchemaElementDecl*)
topElem->fThisElement)->getDatatypeValidator();
- ((SchemaValidator*) fValidator)->normalizeWhiteSpace(tempDV,
toFill.getRawBuffer(), tempBuf);
- toFill.set(tempBuf.getRawBuffer());
+ if (tempDV && tempDV->getWSFacet() !=
DatatypeValidator::PRESERVE)
+ {
+ // normalize the character according to schema whitespace
facet
+ XMLBufBid bbtemp(&fBufMgr);
+ XMLBuffer& tempBuf = bbtemp.getBuffer();
+
+ ((SchemaValidator*)
fValidator)->normalizeWhiteSpace(tempDV, toFill.getRawBuffer(), tempBuf);
+ toFill.set(tempBuf.getRawBuffer());
+ }
}
// tell the schema validation about the character data for
checkContent later
@@ -3629,14 +3643,18 @@
if (fValidate) {
- if (fNormalizeData) {
- // normalize the character according to schema whitespace facet
- XMLBufBid bbtemp(&fBufMgr);
- XMLBuffer& tempBuf = bbtemp.getBuffer();
-
+ if (fNormalizeData)
+ {
DatatypeValidator* tempDV = ((SchemaElementDecl*)
topElem->fThisElement)->getDatatypeValidator();
- ((SchemaValidator*) fValidator)->normalizeWhiteSpace(tempDV,
bbCData.getRawBuffer(), tempBuf);
- bbCData.set(tempBuf.getRawBuffer());
+ if (tempDV && tempDV->getWSFacet() !=
DatatypeValidator::PRESERVE)
+ {
+ // normalize the character according to schema whitespace
facet
+ XMLBufBid bbtemp(&fBufMgr);
+ XMLBuffer& tempBuf = bbtemp.getBuffer();
+
+ ((SchemaValidator*)
fValidator)->normalizeWhiteSpace(tempDV, bbCData.getRawBuffer(), tempBuf);
+ bbCData.set(tempBuf.getRawBuffer());
+ }
}
// tell the schema validation about the character data for
checkContent later
1.7 +4 -1
xml-xerces/c/src/xercesc/validators/datatype/AnySimpleTypeDatatypeValidator.cpp
Index: AnySimpleTypeDatatypeValidator.cpp
===================================================================
RCS file:
/home/cvs/xml-xerces/c/src/xercesc/validators/datatype/AnySimpleTypeDatatypeValidator.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- AnySimpleTypeDatatypeValidator.cpp 15 May 2003 18:53:26 -0000 1.6
+++ AnySimpleTypeDatatypeValidator.cpp 1 Oct 2003 01:09:35 -0000 1.7
@@ -56,6 +56,9 @@
/*
* $Log$
+ * Revision 1.7 2003/10/01 01:09:35 knoaman
+ * Refactoring of some code to improve performance.
+ *
* Revision 1.6 2003/05/15 18:53:26 knoaman
* Partial implementation of the configurable memory manager.
*
@@ -95,7 +98,7 @@
AnySimpleTypeDatatypeValidator::AnySimpleTypeDatatypeValidator(MemoryManager* const
manager)
: DatatypeValidator(0, 0, SchemaSymbols::XSD_RESTRICTION,
DatatypeValidator::AnySimpleType, manager)
{
-
+ setWhiteSpace(DatatypeValidator::PRESERVE);
}
AnySimpleTypeDatatypeValidator::~AnySimpleTypeDatatypeValidator()
1.7 +1 -12
xml-xerces/c/src/xercesc/validators/datatype/AnySimpleTypeDatatypeValidator.hpp
Index: AnySimpleTypeDatatypeValidator.hpp
===================================================================
RCS file:
/home/cvs/xml-xerces/c/src/xercesc/validators/datatype/AnySimpleTypeDatatypeValidator.hpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- AnySimpleTypeDatatypeValidator.hpp 15 May 2003 18:53:26 -0000 1.6
+++ AnySimpleTypeDatatypeValidator.hpp 1 Oct 2003 01:09:35 -0000 1.7
@@ -100,12 +100,6 @@
//@{
/**
- * Returns default value (collapse) for whiteSpace facet.
- * This function is overwritten in StringDatatypeValidator.
- */
- short getWSFacet () const;
-
- /**
* Returns whether the type is atomic or not
*/
virtual bool isAtomic() const;
@@ -174,11 +168,6 @@
// ---------------------------------------------------------------------------
// DatatypeValidator: Getters
// ---------------------------------------------------------------------------
-inline short AnySimpleTypeDatatypeValidator::getWSFacet() const {
-
- return DatatypeValidator::PRESERVE;
-}
-
inline bool AnySimpleTypeDatatypeValidator::isAtomic() const {
return false;
1.10 +4 -0
xml-xerces/c/src/xercesc/validators/datatype/DatatypeValidator.cpp
Index: DatatypeValidator.cpp
===================================================================
RCS file:
/home/cvs/xml-xerces/c/src/xercesc/validators/datatype/DatatypeValidator.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- DatatypeValidator.cpp 30 Sep 2003 21:32:23 -0000 1.9
+++ DatatypeValidator.cpp 1 Oct 2003 01:09:35 -0000 1.10
@@ -56,6 +56,9 @@
/*
* $Log$
+ * Revision 1.10 2003/10/01 01:09:35 knoaman
+ * Refactoring of some code to improve performance.
+ *
* Revision 1.9 2003/09/30 21:32:23 peiyongz
* AnyURI, Base64, HexBin, NOTATION, List and QName
*
@@ -159,6 +162,7 @@
MemoryManager* const manager)
: fMemoryManager(manager)
, fAnonymous(false)
+ , fWhiteSpace(COLLAPSE)
, fFinalSet(finalSet)
, fFacetsDefined(0)
, fFixed(0)
1.14 +14 -4
xml-xerces/c/src/xercesc/validators/datatype/DatatypeValidator.hpp
Index: DatatypeValidator.hpp
===================================================================
RCS file:
/home/cvs/xml-xerces/c/src/xercesc/validators/datatype/DatatypeValidator.hpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- DatatypeValidator.hpp 29 Sep 2003 21:47:35 -0000 1.13
+++ DatatypeValidator.hpp 1 Oct 2003 01:09:35 -0000 1.14
@@ -67,7 +67,6 @@
#include <xercesc/util/XMLUniDefs.hpp>
#include <xercesc/util/regx/RegularExpression.hpp>
#include <xercesc/validators/schema/SchemaSymbols.hpp>
-
#include <xercesc/internal/XSerializable.hpp>
XERCES_CPP_NAMESPACE_BEGIN
@@ -183,7 +182,7 @@
* Returns default value (collapse) for whiteSpace facet.
* This function is overwritten in StringDatatypeValidator.
*/
- virtual short getWSFacet () const;
+ short getWSFacet () const;
/**
* Returns the base datatype validator if set.
@@ -379,6 +378,11 @@
void setType(ValidatorType);
/**
+ * set fWhiteSpace
+ */
+ void setWhiteSpace(short);
+
+ /**
* get WSString
*/
const XMLCh* getWSstring(const short WSType) const;
@@ -442,6 +446,7 @@
//
// -----------------------------------------------------------------------
bool fAnonymous;
+ short fWhiteSpace;
int fFinalSet;
int fFacetsDefined;
int fFixed;
@@ -476,7 +481,7 @@
inline short DatatypeValidator::getWSFacet() const {
- return COLLAPSE;
+ return fWhiteSpace;
}
inline DatatypeValidator::ValidatorType DatatypeValidator::getType() const
@@ -535,6 +540,11 @@
inline void DatatypeValidator::setType(ValidatorType theType)
{
fType = theType;
+}
+
+inline void DatatypeValidator::setWhiteSpace(short newValue)
+{
+ fWhiteSpace = newValue;
}
inline void DatatypeValidator::setFacetsDefined(int facets)
1.8 +8 -9
xml-xerces/c/src/xercesc/validators/datatype/StringDatatypeValidator.cpp
Index: StringDatatypeValidator.cpp
===================================================================
RCS file:
/home/cvs/xml-xerces/c/src/xercesc/validators/datatype/StringDatatypeValidator.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- StringDatatypeValidator.cpp 30 Sep 2003 21:31:37 -0000 1.7
+++ StringDatatypeValidator.cpp 1 Oct 2003 01:09:35 -0000 1.8
@@ -56,6 +56,9 @@
/*
* $Log$
+ * Revision 1.8 2003/10/01 01:09:35 knoaman
+ * Refactoring of some code to improve performance.
+ *
* Revision 1.7 2003/09/30 21:31:37 peiyongz
* Implementation of Serialization/Deserialization
*
@@ -147,8 +150,9 @@
// ---------------------------------------------------------------------------
StringDatatypeValidator::StringDatatypeValidator(MemoryManager* const manager)
:AbstractStringValidator(0, 0, 0, DatatypeValidator::String, manager)
-,fWhiteSpace(DatatypeValidator::PRESERVE)
-{}
+{
+ setWhiteSpace(DatatypeValidator::PRESERVE);
+}
StringDatatypeValidator::StringDatatypeValidator(
DatatypeValidator* const baseValidator
@@ -157,8 +161,8 @@
, const int finalSet
, MemoryManager* const manager)
:AbstractStringValidator(baseValidator, facets, finalSet,
DatatypeValidator::String, manager)
-,fWhiteSpace(DatatypeValidator::PRESERVE)
{
+ setWhiteSpace(DatatypeValidator::PRESERVE);
init(enums);
}
@@ -183,14 +187,9 @@
, const ValidatorType type
, MemoryManager* const manager)
:AbstractStringValidator(baseValidator, facets, finalSet, type, manager)
-,fWhiteSpace(DatatypeValidator::PRESERVE)
{
+ setWhiteSpace(DatatypeValidator::PRESERVE);
// do not invoke init() here!!!
-}
-
-short StringDatatypeValidator::getWSFacet() const
-{
- return fWhiteSpace;
}
// ---------------------------------------------------------------------------
1.6 +4 -30
xml-xerces/c/src/xercesc/validators/datatype/StringDatatypeValidator.hpp
Index: StringDatatypeValidator.hpp
===================================================================
RCS file:
/home/cvs/xml-xerces/c/src/xercesc/validators/datatype/StringDatatypeValidator.hpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- StringDatatypeValidator.hpp 29 Sep 2003 21:47:35 -0000 1.5
+++ StringDatatypeValidator.hpp 1 Oct 2003 01:09:35 -0000 1.6
@@ -57,6 +57,9 @@
/*
* $Id$
* $Log$
+ * Revision 1.6 2003/10/01 01:09:35 knoaman
+ * Refactoring of some code to improve performance.
+ *
* Revision 1.5 2003/09/29 21:47:35 peiyongz
* Implementation of Serialization/Deserialization
*
@@ -122,16 +125,6 @@
//@}
- // -----------------------------------------------------------------------
- // Getter methods
- // -----------------------------------------------------------------------
- /** @name Getter Functions */
- //@{
-
- virtual short getWSFacet() const;
-
- //@}
-
/**
* Returns an instance of the base datatype validator class
* Used by the DatatypeValidatorFactory.
@@ -175,26 +168,7 @@
virtual void checkValueSpace(const XMLCh* const content);
virtual int getLength(const XMLCh* const content) const;
-
-private:
-
- inline void setWhiteSpace(short);
-
- // -----------------------------------------------------------------------
- // Private data members
- //
- // -----------------------------------------------------------------------
- short fWhiteSpace; //DatatypeValidator::PRESERVE
-
};
-
-// -----------------------------------------------------------------------
-// Getter methods
-// -----------------------------------------------------------------------
-inline void StringDatatypeValidator::setWhiteSpace(short newValue)
-{
- fWhiteSpace = newValue;
-}
XERCES_CPP_NAMESPACE_END
1.37 +15 -23 xml-xerces/c/src/xercesc/validators/schema/SchemaValidator.cpp
Index: SchemaValidator.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/schema/SchemaValidator.cpp,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -r1.36 -r1.37
--- SchemaValidator.cpp 14 Aug 2003 03:01:04 -0000 1.36
+++ SchemaValidator.cpp 1 Oct 2003 01:09:35 -0000 1.37
@@ -56,6 +56,9 @@
/*
* $Log$
+ * Revision 1.37 2003/10/01 01:09:35 knoaman
+ * Refactoring of some code to improve performance.
+ *
* Revision 1.36 2003/08/14 03:01:04 knoaman
* Code refactoring to improve performance of validation.
*
@@ -626,7 +629,6 @@
//
XMLAttDef::AttTypes type = attDef->getType();
const XMLAttDef::DefAttTypes defType = attDef->getDefaultType();
- const XMLCh* const fullName = attDef->getFullName();
bool valid = true;
//
@@ -641,7 +643,7 @@
{
const XMLCh* const valueText = attDef->getValue();
if (!XMLString::equals(attrValue, valueText)) {
- emitError(XMLValid::NotSameAsFixedValue, fullName, attrValue,
valueText);
+ emitError(XMLValid::NotSameAsFixedValue, attDef->getFullName(),
attrValue, valueText);
valid = false;
}
}
@@ -649,7 +651,7 @@
// An empty string cannot be valid for non_CDATA any of the other types
if (!attrValue[0] && type != XMLAttDef::Simple)
{
- emitError(XMLValid::InvalidEmptyAttValue, fullName);
+ emitError(XMLValid::InvalidEmptyAttValue, attDef->getFullName());
((SchemaElementDecl *)(elemDecl))->setValidity(PSVIDefs::INVALID);
((SchemaAttDef *)(attDef))->setValidity(PSVIDefs::INVALID);
return;
@@ -657,7 +659,7 @@
DatatypeValidator* attDefDV = ((SchemaAttDef*) attDef)->getDatatypeValidator();
if (!attDefDV) {
- emitError(XMLValid::NoDatatypeValidatorForAttribute, fullName);
+ emitError(XMLValid::NoDatatypeValidatorForAttribute, attDef->getFullName());
valid = false;
}
else {
@@ -1209,16 +1211,14 @@
//
void SchemaValidator::normalizeWhiteSpace(DatatypeValidator* dV, const XMLCh* const
value, XMLBuffer& toFill)
{
+ short wsFacet = dV->getWSFacet();
+
toFill.reset();
//empty string
if (!*value)
return;
- short fWhiteSpace = DatatypeValidator::PRESERVE;
- if (dV)
- fWhiteSpace = dV->getWSFacet();
-
enum States
{
InWhitespace
@@ -1227,27 +1227,20 @@
States curState = InContent;
- //
- // Loop through the chars of the source value and normalize it according
- // to the whitespace facet
- //
+ // Loop through the chars of the source value and normalize it
+ // according to the whitespace facet
bool firstNonWS = false;
XMLCh nextCh;
const XMLCh* srcPtr = value;
XMLReader* fCurReader = getReaderMgr()->getCurrentReader();
- if ((fWhiteSpace==DatatypeValidator::COLLAPSE) && fTrailing)
+ if ((wsFacet==DatatypeValidator::COLLAPSE) && fTrailing)
toFill.append(chSpace);
while (*srcPtr)
{
nextCh = *srcPtr;
-
- if (fWhiteSpace == DatatypeValidator::PRESERVE)
- {
- // do nothing
- }
- else if (fWhiteSpace == DatatypeValidator::REPLACE)
+ if (wsFacet == DatatypeValidator::REPLACE)
{
if (fCurReader->isWhitespace(nextCh))
nextCh = chSpace;
@@ -1263,13 +1256,13 @@
curState = InContent;
firstNonWS = true;
}
- else
+ else
{
srcPtr++;
continue;
}
}
- else if (curState == InContent)
+ else if (curState == InContent)
{
if (fCurReader->isWhitespace(nextCh))
{
@@ -1286,8 +1279,7 @@
// And move up to the next character in the source
srcPtr++;
}
- srcPtr--;
- if (fCurReader->isWhitespace(*srcPtr))
+ if (fCurReader->isWhitespace(*(srcPtr-1)))
fTrailing = true;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]