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 2008/07/10 10:50:06 UTC
svn commit: r675478 - in /xerces/c/trunk/src/xercesc: framework/ internal/
validators/DTD/ validators/common/ validators/schema/
Author: amassari
Date: Thu Jul 10 01:50:04 2008
New Revision: 675478
URL: http://svn.apache.org/viewvc?rev=675478&view=rev
Log:
- fEntityExpansionLimit should be an XMLSize_t as it is in SecurityManager
- changed checkContent/validateContent/validateContentSpecial not to return a signed int that means either success or the location of the validation failure
- reduced dimension of the table used by UPA validation
Modified:
xerces/c/trunk/src/xercesc/framework/XMLContentModel.hpp
xerces/c/trunk/src/xercesc/framework/XMLValidator.hpp
xerces/c/trunk/src/xercesc/internal/DGXMLScanner.cpp
xerces/c/trunk/src/xercesc/internal/IGXMLScanner.cpp
xerces/c/trunk/src/xercesc/internal/SGXMLScanner.cpp
xerces/c/trunk/src/xercesc/internal/XMLScanner.hpp
xerces/c/trunk/src/xercesc/internal/XSAXMLScanner.cpp
xerces/c/trunk/src/xercesc/validators/DTD/DTDValidator.cpp
xerces/c/trunk/src/xercesc/validators/DTD/DTDValidator.hpp
xerces/c/trunk/src/xercesc/validators/common/AllContentModel.cpp
xerces/c/trunk/src/xercesc/validators/common/AllContentModel.hpp
xerces/c/trunk/src/xercesc/validators/common/DFAContentModel.cpp
xerces/c/trunk/src/xercesc/validators/common/DFAContentModel.hpp
xerces/c/trunk/src/xercesc/validators/common/MixedContentModel.cpp
xerces/c/trunk/src/xercesc/validators/common/MixedContentModel.hpp
xerces/c/trunk/src/xercesc/validators/common/SimpleContentModel.cpp
xerces/c/trunk/src/xercesc/validators/common/SimpleContentModel.hpp
xerces/c/trunk/src/xercesc/validators/schema/SchemaValidator.cpp
xerces/c/trunk/src/xercesc/validators/schema/SchemaValidator.hpp
Modified: xerces/c/trunk/src/xercesc/framework/XMLContentModel.hpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/framework/XMLContentModel.hpp?rev=675478&r1=675477&r2=675478&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/framework/XMLContentModel.hpp (original)
+++ xerces/c/trunk/src/xercesc/framework/XMLContentModel.hpp Thu Jul 10 01:50:04 2008
@@ -78,21 +78,23 @@
// -----------------------------------------------------------------------
// The virtual content model interface provided by derived classes
// -----------------------------------------------------------------------
- virtual int validateContent
+ virtual bool validateContent
(
QName** const children
- , const unsigned int childCount
- , const unsigned int emptyNamespaceId
+ , unsigned int childCount
+ , unsigned int emptyNamespaceId
+ , unsigned int* indexFailingChild
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
) const = 0;
- virtual int validateContentSpecial
+ virtual bool validateContentSpecial
(
QName** const children
- , const unsigned int childCount
- , const unsigned int emptyNamespaceId
+ , unsigned int childCount
+ , unsigned int emptyNamespaceId
, GrammarResolver* const pGrammarResolver
, XMLStringPool* const pStringPool
+ , unsigned int* indexFailingChild
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
) const =0;
@@ -109,8 +111,8 @@
virtual ContentLeafNameTypeVector* getContentLeafNameTypeVector()
const = 0;
- virtual unsigned int getNextState(const unsigned int currentState,
- const unsigned int elementIndex) const = 0;
+ virtual unsigned int getNextState(unsigned int currentState,
+ unsigned int elementIndex) const = 0;
protected :
// -----------------------------------------------------------------------
Modified: xerces/c/trunk/src/xercesc/framework/XMLValidator.hpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/framework/XMLValidator.hpp?rev=675478&r1=675477&r2=675478&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/framework/XMLValidator.hpp (original)
+++ xerces/c/trunk/src/xercesc/framework/XMLValidator.hpp Thu Jul 10 01:50:04 2008
@@ -94,12 +94,18 @@
*
* @param childCount The number of elements in the childIds array. It can
* be zero if the element had none.
+ *
+ * @param indexFailingChild On return, it will contain the index of the
+ * children failing validation, if the retun value
+ * is false
+ *
*/
- virtual int checkContent
+ virtual bool checkContent
(
XMLElementDecl* const elemDecl
, QName** const children
- , const unsigned int childCount
+ , unsigned int childCount
+ , unsigned int* indexFailingChild
) = 0;
/**
Modified: xerces/c/trunk/src/xercesc/internal/DGXMLScanner.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/internal/DGXMLScanner.cpp?rev=675478&r1=675477&r2=675478&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/internal/DGXMLScanner.cpp (original)
+++ xerces/c/trunk/src/xercesc/internal/DGXMLScanner.cpp Thu Jul 10 01:50:04 2008
@@ -686,14 +686,16 @@
);
}
- int res = fValidator->checkContent
+ unsigned int failure;
+ bool res = fValidator->checkContent
(
topElem->fThisElement
, topElem->fChildren
, topElem->fChildCount
+ , &failure
);
- if (res >= 0)
+ if (!res)
{
// One of the elements is not valid for the content. NOTE that
// if no children were provided but the content model requires
@@ -708,7 +710,7 @@
, topElem->fThisElement->getFormattedContentModel()
);
}
- else if ((unsigned int)res >= topElem->fChildCount)
+ else if (failure >= topElem->fChildCount)
{
fValidator->emitError
(
@@ -721,7 +723,7 @@
fValidator->emitError
(
XMLValid::ElementNotValidForContent
- , topElem->fChildren[res]->getRawName()
+ , topElem->fChildren[failure]->getRawName()
, topElem->fThisElement->getFormattedContentModel()
);
}
@@ -1486,8 +1488,9 @@
// If validating, then insure that its legal to have no content
if (fValidate)
{
- const int res = fValidator->checkContent(elemDecl, 0, 0);
- if (res >= 0)
+ unsigned int failure;
+ bool res = fValidator->checkContent(elemDecl, 0, 0, &failure);
+ if (!res)
{
fValidator->emitError
(
@@ -1945,8 +1948,9 @@
// If validating, then insure that its legal to have no content
if (fValidate)
{
- const int res = fValidator->checkContent(elemDecl, 0, 0);
- if (res >= 0)
+ unsigned int failure;
+ bool res = fValidator->checkContent(elemDecl, 0, 0, &failure);
+ if (!res)
{
fValidator->emitError
(
Modified: xerces/c/trunk/src/xercesc/internal/IGXMLScanner.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/internal/IGXMLScanner.cpp?rev=675478&r1=675477&r2=675478&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/internal/IGXMLScanner.cpp (original)
+++ xerces/c/trunk/src/xercesc/internal/IGXMLScanner.cpp Thu Jul 10 01:50:04 2008
@@ -1072,14 +1072,16 @@
, topElem->fThisElement->getFullName()
);
}
- int res = fValidator->checkContent
+ unsigned int failure;
+ bool res = fValidator->checkContent
(
topElem->fThisElement
, topElem->fChildren
, topElem->fChildCount
+ , &failure
);
- if (res >= 0)
+ if (!res)
{
// One of the elements is not valid for the content. NOTE that
// if no children were provided but the content model requires
@@ -1094,7 +1096,7 @@
, topElem->fThisElement->getFormattedContentModel()
);
}
- else if ((unsigned int)res >= topElem->fChildCount)
+ else if (failure >= topElem->fChildCount)
{
fValidator->emitError
(
@@ -1107,7 +1109,7 @@
fValidator->emitError
(
XMLValid::ElementNotValidForContent
- , topElem->fChildren[res]->getRawName()
+ , topElem->fChildren[failure]->getRawName()
, topElem->fThisElement->getFormattedContentModel()
);
}
@@ -2052,8 +2054,9 @@
// If validating, then insure that its legal to have no content
if (fValidate)
{
- const int res = fValidator->checkContent(elemDecl, 0, 0);
- if (res >= 0)
+ unsigned int failure;
+ bool res = fValidator->checkContent(elemDecl, 0, 0, &failure);
+ if (!res)
{
fValidator->emitError
(
@@ -2673,8 +2676,9 @@
// If validating, then insure that its legal to have no content
if (fValidate)
{
- const int res = fValidator->checkContent(elemDecl, 0, 0);
- if (res >= 0)
+ unsigned int failure;
+ bool res = fValidator->checkContent(elemDecl, 0, 0, &failure);
+ if (!res)
{
fValidator->emitError
(
Modified: xerces/c/trunk/src/xercesc/internal/SGXMLScanner.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/internal/SGXMLScanner.cpp?rev=675478&r1=675477&r2=675478&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/internal/SGXMLScanner.cpp (original)
+++ xerces/c/trunk/src/xercesc/internal/SGXMLScanner.cpp Thu Jul 10 01:50:04 2008
@@ -916,14 +916,16 @@
DatatypeValidator* psviMemberType = 0;
if (fValidate)
{
- int res = fValidator->checkContent
+ unsigned int failure;
+ bool res = fValidator->checkContent
(
topElem->fThisElement
, topElem->fChildren
, topElem->fChildCount
+ , &failure
);
- if (res >= 0)
+ if (!res)
{
// One of the elements is not valid for the content. NOTE that
// if no children were provided but the content model requires
@@ -938,7 +940,7 @@
, topElem->fThisElement->getFormattedContentModel()
);
}
- else if ((unsigned int)res >= topElem->fChildCount)
+ else if (failure >= topElem->fChildCount)
{
fValidator->emitError
(
@@ -951,7 +953,7 @@
fValidator->emitError
(
XMLValid::ElementNotValidForContent
- , topElem->fChildren[res]->getRawName()
+ , topElem->fChildren[failure]->getRawName()
, topElem->fThisElement->getFormattedContentModel()
);
}
@@ -1665,8 +1667,9 @@
// If validating, then insure that its legal to have no content
if (fValidate)
{
- const int res = fValidator->checkContent(elemDecl, 0, 0);
- if (res >= 0)
+ unsigned int failure;
+ bool res = fValidator->checkContent(elemDecl, 0, 0, &failure);
+ if (!res)
{
// REVISIT: in the case of xsi:type, this may
// return the wrong string...
Modified: xerces/c/trunk/src/xercesc/internal/XMLScanner.hpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/internal/XMLScanner.hpp?rev=675478&r1=675477&r2=675478&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/internal/XMLScanner.hpp (original)
+++ xerces/c/trunk/src/xercesc/internal/XMLScanner.hpp Thu Jul 10 01:50:04 2008
@@ -754,8 +754,8 @@
bool fSkipDTDValidation;
bool fHandleMultipleImports;
int fErrorCount;
- unsigned int fEntityExpansionLimit;
- unsigned int fEntityExpansionCount;
+ XMLSize_t fEntityExpansionLimit;
+ XMLSize_t fEntityExpansionCount;
unsigned int fEmptyNamespaceId;
unsigned int fUnknownNamespaceId;
unsigned int fXMLNamespaceId;
Modified: xerces/c/trunk/src/xercesc/internal/XSAXMLScanner.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/internal/XSAXMLScanner.cpp?rev=675478&r1=675477&r2=675478&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/internal/XSAXMLScanner.cpp (original)
+++ xerces/c/trunk/src/xercesc/internal/XSAXMLScanner.cpp Thu Jul 10 01:50:04 2008
@@ -112,12 +112,16 @@
// this element and let him validate it.
if (fValidate)
{
- int res = fValidator->checkContent
+ unsigned int failure;
+ bool res = fValidator->checkContent
(
- topElem->fThisElement, topElem->fChildren, topElem->fChildCount
+ topElem->fThisElement
+ , topElem->fChildren
+ , topElem->fChildCount
+ , &failure
);
- if (res >= 0)
+ if (!res)
{
// One of the elements is not valid for the content. NOTE that
// if no children were provided but the content model requires
@@ -132,7 +136,7 @@
, topElem->fThisElement->getFormattedContentModel()
);
}
- else if ((unsigned int)res >= topElem->fChildCount)
+ else if (failure >= topElem->fChildCount)
{
fValidator->emitError
(
@@ -145,7 +149,7 @@
fValidator->emitError
(
XMLValid::ElementNotValidForContent
- , topElem->fChildren[res]->getRawName()
+ , topElem->fChildren[failure]->getRawName()
, topElem->fThisElement->getFormattedContentModel()
);
}
@@ -454,8 +458,9 @@
// If validating, then insure that its legal to have no content
if (fValidate)
{
- const int res = fValidator->checkContent(elemDecl, 0, 0);
- if (res >= 0)
+ unsigned int failure;
+ bool res = fValidator->checkContent(elemDecl, 0, 0, &failure);
+ if (!res)
{
// REVISIT: in the case of xsi:type, this may
// return the wrong string...
Modified: xerces/c/trunk/src/xercesc/validators/DTD/DTDValidator.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/validators/DTD/DTDValidator.cpp?rev=675478&r1=675477&r2=675478&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/validators/DTD/DTDValidator.cpp (original)
+++ xerces/c/trunk/src/xercesc/validators/DTD/DTDValidator.cpp Thu Jul 10 01:50:04 2008
@@ -51,9 +51,10 @@
// ---------------------------------------------------------------------------
// DTDValidator: Implementation of the XMLValidator interface
// ---------------------------------------------------------------------------
-int DTDValidator::checkContent(XMLElementDecl* const elemDecl
- , QName** const children
- , const unsigned int childCount)
+bool DTDValidator::checkContent(XMLElementDecl* const elemDecl
+ , QName** const children
+ , unsigned int childCount
+ , unsigned int* indexFailingChild)
{
//
// Look up the element id in our element decl pool. This will get us
@@ -75,7 +76,10 @@
// we return 0 as the index of the first bad child.
//
if (childCount)
- return 0;
+ {
+ *indexFailingChild=0;
+ return false;
+ }
}
else if (modelType == DTDElementDecl::Any)
{
@@ -88,7 +92,7 @@
const XMLContentModel* elemCM = elemDecl->getContentModel();
// Ask it to validate and return its return
- return elemCM->validateContent(children, childCount, getScanner()->getEmptyNamespaceId(), getScanner()->getMemoryManager());
+ return elemCM->validateContent(children, childCount, getScanner()->getEmptyNamespaceId(), indexFailingChild, getScanner()->getMemoryManager());
}
else
{
@@ -96,7 +100,7 @@
}
// Went ok, so return success
- return -1;
+ return true;
}
Modified: xerces/c/trunk/src/xercesc/validators/DTD/DTDValidator.hpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/validators/DTD/DTDValidator.hpp?rev=675478&r1=675477&r2=675478&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/validators/DTD/DTDValidator.hpp (original)
+++ xerces/c/trunk/src/xercesc/validators/DTD/DTDValidator.hpp Thu Jul 10 01:50:04 2008
@@ -50,11 +50,12 @@
// -----------------------------------------------------------------------
// Implementation of the XMLValidator interface
// -----------------------------------------------------------------------
- virtual int checkContent
+ virtual bool checkContent
(
XMLElementDecl* const elemDecl
, QName** const children
- , const unsigned int childCount
+ , unsigned int childCount
+ , unsigned int* indexFailingChild
);
virtual void faultInAttr
Modified: xerces/c/trunk/src/xercesc/validators/common/AllContentModel.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/validators/common/AllContentModel.cpp?rev=675478&r1=675477&r2=675478&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/validators/common/AllContentModel.cpp (original)
+++ xerces/c/trunk/src/xercesc/validators/common/AllContentModel.cpp Thu Jul 10 01:50:04 2008
@@ -104,16 +104,17 @@
//must agree with
//the order and number of child elements specified in the model.
//
-int
+bool
AllContentModel::validateContent( QName** const children
- , const unsigned int childCount
- , const unsigned int
+ , unsigned int childCount
+ , unsigned int
+ , unsigned int* indexFailingChild
, MemoryManager* const manager) const
{
// If <all> had minOccurs of zero and there are
// no children to validate, trivially validate
if (childCount == 0 && (fHasOptionalContent || !fNumRequired))
- return -1;
+ return true;
// keep track of the required element seen
unsigned int numRequiredSeen = 0;
@@ -148,7 +149,8 @@
// If this element was seen already, indicate an error was
// found at the duplicate index.
if (elementSeen[inIndex]) {
- return outIndex;
+ *indexFailingChild=outIndex;
+ return false;
}
else
elementSeen[inIndex] = true;
@@ -162,7 +164,8 @@
// We did not find this one, so the validation failed
if (inIndex == fCount) {
- return outIndex;
+ *indexFailingChild=outIndex;
+ return false;
}
}
@@ -170,25 +173,27 @@
// Were all the required elements of the <all> encountered?
if (numRequiredSeen != fNumRequired) {
- return childCount;
+ *indexFailingChild=childCount;
+ return false;
}
// Everything seems to be ok, so return success
- return -1;
+ return true;
}
-int AllContentModel::validateContentSpecial(QName** const children
- , const unsigned int childCount
- , const unsigned int
+bool AllContentModel::validateContentSpecial(QName** const children
+ , unsigned int childCount
+ , unsigned int
, GrammarResolver* const pGrammarResolver
, XMLStringPool* const pStringPool
+ , unsigned int* indexFailingChild
, MemoryManager* const manager) const
{
// If <all> had minOccurs of zero and there are
// no children to validate, trivially validate
if (childCount == 0 && (fHasOptionalContent || !fNumRequired))
- return -1;
+ return true;
// keep track of the required element seen
unsigned int numRequiredSeen = 0;
@@ -224,7 +229,8 @@
// If this element was seen already, indicate an error was
// found at the duplicate index.
if (elementSeen[inIndex]) {
- return outIndex;
+ *indexFailingChild=outIndex;
+ return false;
}
else
elementSeen[inIndex] = true;
@@ -238,7 +244,8 @@
// We did not find this one, so the validation failed
if (inIndex == fCount) {
- return outIndex;
+ *indexFailingChild=outIndex;
+ return false;
}
}
@@ -246,11 +253,12 @@
// Were all the required elements of the <all> encountered?
if (numRequiredSeen != fNumRequired) {
- return childCount;
+ *indexFailingChild=childCount;
+ return false;
}
// Everything seems to be ok, so return success
- return -1;
+ return true;
}
@@ -317,7 +325,8 @@
// Recurse on the left and right nodes
buildChildList(leftNode, toFill, toOptional);
- buildChildList(rightNode, toFill, toOptional);
+ if(rightNode)
+ buildChildList(rightNode, toFill, toOptional);
}
else if (curType == ContentSpecNode::Leaf)
{
Modified: xerces/c/trunk/src/xercesc/validators/common/AllContentModel.hpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/validators/common/AllContentModel.hpp?rev=675478&r1=675477&r2=675478&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/validators/common/AllContentModel.hpp (original)
+++ xerces/c/trunk/src/xercesc/validators/common/AllContentModel.hpp Thu Jul 10 01:50:04 2008
@@ -57,28 +57,30 @@
// -----------------------------------------------------------------------
// Implementation of the ContentModel virtual interface
// -----------------------------------------------------------------------
- virtual int validateContent
+ virtual bool validateContent
(
QName** const children
- , const unsigned int childCount
- , const unsigned int emptyNamespaceId
+ , unsigned int childCount
+ , unsigned int emptyNamespaceId
+ , unsigned int* indexFailingChild
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
) const;
- virtual int validateContentSpecial
+ virtual bool validateContentSpecial
(
- QName** const children
- , const unsigned int childCount
- , const unsigned int emptyNamespaceId
+ QName** const children
+ , unsigned int childCount
+ , unsigned int emptyNamespaceId
, GrammarResolver* const pGrammarResolver
, XMLStringPool* const pStringPool
+ , unsigned int* indexFailingChild
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
) const;
virtual ContentLeafNameTypeVector* getContentLeafNameTypeVector() const ;
- virtual unsigned int getNextState(const unsigned int currentState,
- const unsigned int elementIndex) const;
+ virtual unsigned int getNextState(unsigned int currentState,
+ unsigned int elementIndex) const;
virtual void checkUniqueParticleAttribution
(
@@ -144,8 +146,8 @@
}
inline unsigned int
-AllContentModel::getNextState(const unsigned int,
- const unsigned int) const {
+AllContentModel::getNextState(unsigned int,
+ unsigned int) const {
return XMLContentModel::gInvalidTrans;
}
Modified: xerces/c/trunk/src/xercesc/validators/common/DFAContentModel.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/validators/common/DFAContentModel.cpp?rev=675478&r1=675477&r2=675478&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/validators/common/DFAContentModel.cpp (original)
+++ xerces/c/trunk/src/xercesc/validators/common/DFAContentModel.cpp Thu Jul 10 01:50:04 2008
@@ -120,17 +120,18 @@
fMemoryManager->deallocate(fElemMapType); //delete [] fElemMapType;
fMemoryManager->deallocate(fLeafListType); //delete [] fLeafListType;
- delete fLeafNameTypeVector;
+ delete fLeafNameTypeVector;
}
// ---------------------------------------------------------------------------
// DFAContentModel: Implementation of the ContentModel virtual interface
// ---------------------------------------------------------------------------
-int
+bool
DFAContentModel::validateContent( QName** const children
- , const unsigned int childCount
- , const unsigned int
+ , unsigned int childCount
+ , unsigned int
+ , unsigned int* indexFailingChild
, MemoryManager* const) const
{
//
@@ -140,8 +141,11 @@
//
if (!childCount)
{
- // success -1
- return fEmptyOk ? -1 : 0;
+ // success
+ if(fEmptyOk)
+ return true;
+ *indexFailingChild=0;
+ return false;
}
//
@@ -206,7 +210,7 @@
else if ((type & 0x0f) == ContentSpecNode::Any_Other)
{
// Here we assume that empty string has id 1.
- //
+ //
unsigned int uriId = curElem->getURI();
if (uriId != 1 && uriId != inElem->getURI()) {
nextState = fTransTable[curState][elemIndex];
@@ -219,11 +223,17 @@
// If "nextState" is -1, we found a match, but the transition is invalid
if (nextState == XMLContentModel::gInvalidTrans)
- return childIndex;
+ {
+ *indexFailingChild=childIndex;
+ return false;
+ }
// If we didn't find it, then obviously not valid
if (elemIndex == fElemMapSize)
- return childIndex;
+ {
+ *indexFailingChild=childIndex;
+ return false;
+ }
curState = nextState;
nextState = 0;
@@ -236,24 +246,33 @@
// our ending state is a final state.
//
if (!fFinalStateFlags[curState])
- return childIndex;
+ {
+ *indexFailingChild=childIndex;
+ return false;
+ }
//success
- return -1;
+ return true;
}
-int DFAContentModel::validateContentSpecial(QName** const children
- , const unsigned int childCount
- , const unsigned int
+bool DFAContentModel::validateContentSpecial(QName** const children
+ , unsigned int childCount
+ , unsigned int
, GrammarResolver* const pGrammarResolver
, XMLStringPool* const pStringPool
+ , unsigned int* indexFailingChild
, MemoryManager* const) const
{
SubstitutionGroupComparator comparator(pGrammarResolver, pStringPool);
if (childCount == 0)
- return fEmptyOk ? -1 : 0;
+ {
+ if(fEmptyOk)
+ return true;
+ *indexFailingChild=0;
+ return false;
+ }
//
// Lets loop through the children in the array and move our way
@@ -293,7 +312,7 @@
{
nextState = fTransTable[curState][elemIndex];
if (nextState != XMLContentModel::gInvalidTrans)
- break;
+ break;
}
else if ((type & 0x0f) == ContentSpecNode::Any_NS)
{
@@ -307,7 +326,7 @@
else if ((type & 0x0f) == ContentSpecNode::Any_Other)
{
// Here we assume that empty string has id 1.
- //
+ //
unsigned int uriId = curElem->getURI();
if (uriId != 1 && uriId != inElem->getURI())
{
@@ -320,11 +339,17 @@
// If "nextState" is -1, we found a match, but the transition is invalid
if (nextState == XMLContentModel::gInvalidTrans)
- return childIndex;
+ {
+ *indexFailingChild=childIndex;
+ return false;
+ }
// If we didn't find it, then obviously not valid
if (elemIndex == fElemMapSize)
- return childIndex;
+ {
+ *indexFailingChild=childIndex;
+ return false;
+ }
curState = nextState;
nextState = 0;
@@ -337,10 +362,13 @@
// our ending state is a final state.
//
if (!fFinalStateFlags[curState])
- return childIndex;
+ {
+ *indexFailingChild=childIndex;
+ return false;
+ }
//success
- return -1;
+ return true;
}
@@ -351,7 +379,6 @@
{
unsigned int index;
-
//
// The first step we need to take is to rewrite the content model using
// our CMNode objects, and in the process get rid of any repetition short
@@ -572,10 +599,10 @@
// have to expand though, it if does, the overhead will be somewhat ugly.
//
unsigned int curArraySize = fLeafCount * 4;
- const CMStateSet** statesToDo = (const CMStateSet**)
+ CMStateSet** statesToDo = (CMStateSet**)
fMemoryManager->allocate
(
- curArraySize * sizeof(const CMStateSet*)
+ curArraySize * sizeof(CMStateSet*)
); //new const CMStateSet*[curArraySize];
fFinalStateFlags = (bool*) fMemoryManager->allocate
(
@@ -590,7 +617,7 @@
// Ok we start with the initial set as the first pos set of the head node
// (which is the seq node that holds the content model and the EOC node.)
//
- const CMStateSet* setT = new (fMemoryManager) CMStateSet(fHeadNode->getFirstPos());
+ CMStateSet* setT = new (fMemoryManager) CMStateSet(fHeadNode->getFirstPos());
//
// Init our two state flags. Basically the unmarked state counter is
@@ -614,11 +641,9 @@
//
// the stateTable is an auxiliary means to fast
// identification of new state created (instead
- // of squential loop statesToDo to find out),
+ // of sequential loop statesToDo to find out),
// while the role that statesToDo plays remain unchanged.
//
- // TODO: in the future, we may change the 29 to something
- // derived from curArraySize.
RefHashTableOf<XMLInteger> *stateTable =
new (fMemoryManager) RefHashTableOf<XMLInteger>
(
@@ -738,7 +763,7 @@
}
***/
- XMLInteger *stateObj = (XMLInteger*) (stateTable->get(newSet));
+ XMLInteger *stateObj = stateTable->get(newSet);
unsigned int stateIndex = (stateObj == 0 ? curState : stateObj->intValue());
// If we did not find it, then add it
@@ -784,10 +809,10 @@
// size by 50% and allocate new arrays.
//
const unsigned int newSize = (unsigned int)(curArraySize * 1.5);
- const CMStateSet** newToDo = (const CMStateSet**)
+ CMStateSet** newToDo = (CMStateSet**)
fMemoryManager->allocate
(
- newSize * sizeof(const CMStateSet*)
+ newSize * sizeof(CMStateSet*)
); //new const CMStateSet*[newSize];
bool* newFinalFlags = (bool*) fMemoryManager->allocate
(
@@ -859,7 +884,7 @@
delete stateTable;
for (index = 0; index < curState; index++)
- delete (CMStateSet*)statesToDo[index];
+ delete statesToDo[index];
fMemoryManager->deallocate(statesToDo); //delete [] statesToDo;
for (index = 0; index < fLeafCount; index++)
@@ -990,7 +1015,7 @@
}
}
else if (curType == ContentSpecNode::ZeroOrMore ||
- curType == ContentSpecNode::OneOrMore )
+ curType == ContentSpecNode::OneOrMore )
{
// Recurse first
calcFollowList(((CMUnaryOp*)curNode)->getChild());
@@ -1119,7 +1144,7 @@
ContentLeafNameTypeVector* DFAContentModel::getContentLeafNameTypeVector() const
{
//later change it to return the data member
- return fLeafNameTypeVector;
+ return fLeafNameTypeVector;
}
void DFAContentModel::checkUniqueParticleAttribution (SchemaGrammar* const pGrammar,
@@ -1150,19 +1175,18 @@
// Unique Particle Attribution
// store the conflict results between any two elements in fElemMap
// XMLContentModel::gInvalidTrans: not compared; 0: no conflict; 1: conflict
- unsigned int** fConflictTable = (unsigned int**) fMemoryManager->allocate
+ XMLByte** conflictTable = (XMLByte**) fMemoryManager->allocate
(
- fElemMapSize * sizeof(unsigned int*)
+ fElemMapSize * sizeof(XMLByte*)
); //new unsigned int*[fElemMapSize];
// initialize the conflict table
for (j = 0; j < fElemMapSize; j++) {
- fConflictTable[j] = (unsigned int*) fMemoryManager->allocate
+ conflictTable[j] = (XMLByte*) fMemoryManager->allocate
(
- fElemMapSize * sizeof(unsigned int)
+ fElemMapSize * sizeof(XMLByte)
); //new unsigned int[fElemMapSize];
- for (k = j+1; k < fElemMapSize; k++)
- fConflictTable[j][k] = XMLContentModel::gInvalidTrans;
+ memset(conflictTable[j], 0, fElemMapSize*sizeof(XMLByte));
}
// for each state, check whether it has overlap transitions
@@ -1171,7 +1195,7 @@
for (k = j+1; k < fElemMapSize; k++) {
if (fTransTable[i][j] != XMLContentModel::gInvalidTrans &&
fTransTable[i][k] != XMLContentModel::gInvalidTrans &&
- fConflictTable[j][k] == XMLContentModel::gInvalidTrans) {
+ conflictTable[j][k] == 0) {
// If this is text in a Schema mixed content model, skip it.
if ( fIsMixed &&
@@ -1185,7 +1209,7 @@
fElemMapType[k],
fElemMap[k],
&comparator)) {
- fConflictTable[j][k] = 1;
+ conflictTable[j][k] = 1;
XMLBuffer buf1(1023, fMemoryManager);
if (((fElemMapType[j] & 0x0f) == ContentSpecNode::Any) ||
@@ -1211,15 +1235,15 @@
buf2.getRawBuffer());
}
else
- fConflictTable[j][k] = 0;
+ conflictTable[j][k] = -1;
}
}
}
}
for (i = 0; i < fElemMapSize; i++)
- fMemoryManager->deallocate(fConflictTable[i]); //delete [] fConflictTable[i];
- fMemoryManager->deallocate(fConflictTable); //delete [] fConflictTable;
+ fMemoryManager->deallocate(conflictTable[i]); //delete [] conflictTable[i];
+ fMemoryManager->deallocate(conflictTable); //delete [] conflictTable;
}
XERCES_CPP_NAMESPACE_END
Modified: xerces/c/trunk/src/xercesc/validators/common/DFAContentModel.hpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/validators/common/DFAContentModel.hpp?rev=675478&r1=675477&r2=675478&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/validators/common/DFAContentModel.hpp (original)
+++ xerces/c/trunk/src/xercesc/validators/common/DFAContentModel.hpp Thu Jul 10 01:50:04 2008
@@ -72,21 +72,23 @@
// -----------------------------------------------------------------------
// Implementation of the virtual content model interface
// -----------------------------------------------------------------------
- virtual int validateContent
+ virtual bool validateContent
(
QName** const children
- , const unsigned int childCount
- , const unsigned int emptyNamespaceId
+ , unsigned int childCount
+ , unsigned int emptyNamespaceId
+ , unsigned int* indexFailingChild
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
) const;
- virtual int validateContentSpecial
+ virtual bool validateContentSpecial
(
QName** const children
- , const unsigned int childCount
- , const unsigned int emptyNamespaceId
+ , unsigned int childCount
+ , unsigned int emptyNamespaceId
, GrammarResolver* const pGrammarResolver
, XMLStringPool* const pStringPool
+ , unsigned int* indexFailingChild
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
) const;
@@ -102,8 +104,8 @@
virtual ContentLeafNameTypeVector* getContentLeafNameTypeVector() const ;
- virtual unsigned int getNextState(const unsigned int currentState,
- const unsigned int elementIndex) const;
+ virtual unsigned int getNextState(unsigned int currentState,
+ unsigned int elementIndex) const;
private :
// -----------------------------------------------------------------------
@@ -205,29 +207,29 @@
// fIsMixed
// DFA ContentModel with mixed PCDATA.
// -----------------------------------------------------------------------
- QName** fElemMap;
- ContentSpecNode::NodeTypes *fElemMapType;
- unsigned int fElemMapSize;
- bool fEmptyOk;
- unsigned int fEOCPos;
- bool* fFinalStateFlags;
- CMStateSet** fFollowList;
- CMNode* fHeadNode;
- unsigned int fLeafCount;
- CMLeaf** fLeafList;
- ContentSpecNode::NodeTypes *fLeafListType;
- unsigned int** fTransTable;
- unsigned int fTransTableSize;
- bool fDTD;
- bool fIsMixed;
- ContentLeafNameTypeVector *fLeafNameTypeVector;
- MemoryManager* fMemoryManager;
+ QName** fElemMap;
+ ContentSpecNode::NodeTypes* fElemMapType;
+ unsigned int fElemMapSize;
+ bool fEmptyOk;
+ unsigned int fEOCPos;
+ bool* fFinalStateFlags;
+ CMStateSet** fFollowList;
+ CMNode* fHeadNode;
+ unsigned int fLeafCount;
+ CMLeaf** fLeafList;
+ ContentSpecNode::NodeTypes* fLeafListType;
+ unsigned int** fTransTable;
+ unsigned int fTransTableSize;
+ bool fDTD;
+ bool fIsMixed;
+ ContentLeafNameTypeVector * fLeafNameTypeVector;
+ MemoryManager* fMemoryManager;
};
inline unsigned int
-DFAContentModel::getNextState(const unsigned int currentState,
- const unsigned int elementIndex) const {
+DFAContentModel::getNextState(unsigned int currentState,
+ unsigned int elementIndex) const {
if (currentState == XMLContentModel::gInvalidTrans) {
return XMLContentModel::gInvalidTrans;
Modified: xerces/c/trunk/src/xercesc/validators/common/MixedContentModel.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/validators/common/MixedContentModel.cpp?rev=675478&r1=675477&r2=675478&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/validators/common/MixedContentModel.cpp (original)
+++ xerces/c/trunk/src/xercesc/validators/common/MixedContentModel.cpp Thu Jul 10 01:50:04 2008
@@ -138,10 +138,11 @@
//must agree with
//the order and number of child elements specified in the model.
//
-int
+bool
MixedContentModel::validateContent( QName** const children
- , const unsigned int childCount
- , const unsigned int
+ , unsigned int childCount
+ , unsigned int
+ , unsigned int* indexFailingChild
, MemoryManager* const) const
{
// must match order
@@ -162,13 +163,15 @@
if (type == ContentSpecNode::Leaf) {
if (fDTD) {
if (!XMLString::equals(inChild->getRawName(), curChild->getRawName())) {
- return outIndex;
+ *indexFailingChild=outIndex;
+ return false;
}
}
else {
if ((inChild->getURI() != curChild->getURI()) ||
(!XMLString::equals(inChild->getLocalPart(), curChild->getLocalPart()))) {
- return outIndex;
+ *indexFailingChild=outIndex;
+ return false;
}
}
}
@@ -176,15 +179,21 @@
}
else if (type == ContentSpecNode::Any_NS) {
if (inChild->getURI() != curChild->getURI())
- return outIndex;
+ {
+ *indexFailingChild=outIndex;
+ return false;
+ }
}
else if (type == ContentSpecNode::Any_Other)
{
// Here we assume that empty string has id 1.
- //
+ //
unsigned int uriId = curChild->getURI();
if (uriId == 1 || uriId == inChild->getURI())
- return outIndex;
+ {
+ *indexFailingChild=outIndex;
+ return false;
+ }
}
// advance index
@@ -231,11 +240,11 @@
}
else if (type == ContentSpecNode::Any_Other)
{
- // Here we assume that empty string has id 1.
- //
- unsigned int uriId = curChild->getURI();
- if (uriId != 1 && uriId != inChild->getURI())
- break;
+ // Here we assume that empty string has id 1.
+ //
+ unsigned int uriId = curChild->getURI();
+ if (uriId != 1 && uriId != inChild->getURI())
+ break;
}
// REVISIT: What about checking for multiple ANY matches?
@@ -245,21 +254,24 @@
}
// We did not find this one, so the validation failed
if (inIndex == fCount)
- return outIndex;
+ {
+ *indexFailingChild=outIndex;
+ return false;
+ }
}
}
// Everything seems to be in order, so return success
- // success
- return -1;
+ return true;
}
-int MixedContentModel::validateContentSpecial(QName** const children
- , const unsigned int childCount
- , const unsigned int
+bool MixedContentModel::validateContentSpecial(QName** const children
+ , unsigned int childCount
+ , unsigned int
, GrammarResolver* const pGrammarResolver
, XMLStringPool* const pStringPool
+ , unsigned int* indexFailingChild
, MemoryManager* const) const
{
@@ -282,21 +294,30 @@
if (type == ContentSpecNode::Leaf) {
if ( !comparator.isEquivalentTo(curChild, inChild))
- return outIndex;
+ {
+ *indexFailingChild=outIndex;
+ return false;
+ }
}
else if (type == ContentSpecNode::Any) {
}
else if (type == ContentSpecNode::Any_NS) {
if (inChild->getURI() != curChild->getURI())
- return outIndex;
+ {
+ *indexFailingChild=outIndex;
+ return false;
+ }
}
else if (type == ContentSpecNode::Any_Other)
{
- // Here we assume that empty string has id 1.
- //
- unsigned int uriId = curChild->getURI();
- if (uriId == 1 || uriId == inChild->getURI())
- return outIndex;
+ // Here we assume that empty string has id 1.
+ //
+ unsigned int uriId = curChild->getURI();
+ if (uriId == 1 || uriId == inChild->getURI())
+ {
+ *indexFailingChild=outIndex;
+ return false;
+ }
}
// advance index
@@ -348,13 +369,15 @@
}
// We did not find this one, so the validation failed
if (inIndex == fCount)
- return outIndex;
+ {
+ *indexFailingChild=outIndex;
+ return false;
+ }
}
}
// Everything seems to be in order, so return success
- // success
- return -1;
+ return true;
}
// ---------------------------------------------------------------------------
Modified: xerces/c/trunk/src/xercesc/validators/common/MixedContentModel.hpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/validators/common/MixedContentModel.hpp?rev=675478&r1=675477&r2=675478&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/validators/common/MixedContentModel.hpp (original)
+++ xerces/c/trunk/src/xercesc/validators/common/MixedContentModel.hpp Thu Jul 10 01:50:04 2008
@@ -68,28 +68,30 @@
// -----------------------------------------------------------------------
// Implementation of the ContentModel virtual interface
// -----------------------------------------------------------------------
- virtual int validateContent
+ virtual bool validateContent
(
QName** const children
- , const unsigned int childCount
- , const unsigned int emptyNamespaceId
+ , unsigned int childCount
+ , unsigned int emptyNamespaceId
+ , unsigned int* indexFailingChild
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
) const;
- virtual int validateContentSpecial
+ virtual bool validateContentSpecial
(
QName** const children
- , const unsigned int childCount
- , const unsigned int emptyNamespaceId
+ , unsigned int childCount
+ , unsigned int emptyNamespaceId
, GrammarResolver* const pGrammarResolver
, XMLStringPool* const pStringPool
+ , unsigned int* indexFailingChild
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
) const;
virtual ContentLeafNameTypeVector* getContentLeafNameTypeVector() const ;
- virtual unsigned int getNextState(const unsigned int currentState,
- const unsigned int elementIndex) const;
+ virtual unsigned int getNextState(unsigned int currentState,
+ unsigned int elementIndex) const;
virtual void checkUniqueParticleAttribution
(
@@ -155,8 +157,8 @@
}
inline unsigned int
-MixedContentModel::getNextState(const unsigned int,
- const unsigned int) const {
+MixedContentModel::getNextState(unsigned int,
+ unsigned int) const {
return XMLContentModel::gInvalidTrans;
}
Modified: xerces/c/trunk/src/xercesc/validators/common/SimpleContentModel.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/validators/common/SimpleContentModel.cpp?rev=675478&r1=675477&r2=675478&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/validators/common/SimpleContentModel.cpp (original)
+++ xerces/c/trunk/src/xercesc/validators/common/SimpleContentModel.cpp Thu Jul 10 01:50:04 2008
@@ -39,10 +39,11 @@
// pretty simple 'bull your way through it' test according to what kind of
// operation it is for.
//
-int
+bool
SimpleContentModel::validateContent(QName** const children
- , const unsigned int childCount
- , const unsigned int
+ , unsigned int childCount
+ , unsigned int
+ , unsigned int* indexFailingChild
, MemoryManager* const) const
{
//
@@ -58,23 +59,31 @@
// element type we stored.
//
if (!childCount)
- return 0;
+ {
+ *indexFailingChild=0;
+ return false;
+ }
// If the 0th child is not the right kind, report an error at 0
if (fDTD) {
if (!XMLString::equals(children[0]->getRawName(), fFirstChild->getRawName())) {
- return 0;
+ *indexFailingChild=0;
+ return false;
}
}
else {
if ((children[0]->getURI() != fFirstChild->getURI()) ||
!XMLString::equals(children[0]->getLocalPart(), fFirstChild->getLocalPart())) {
- return 0;
+ *indexFailingChild=0;
+ return false;
}
}
if (childCount > 1)
- return 1;
+ {
+ *indexFailingChild=1;
+ return false;
+ }
break;
case ContentSpecNode::ZeroOrOne :
@@ -86,20 +95,24 @@
if (childCount == 1) {
if (fDTD) {
if (!XMLString::equals(children[0]->getRawName(), fFirstChild->getRawName())) {
- return 0;
+ *indexFailingChild=0;
+ return false;
}
}
else {
if ((children[0]->getURI() != fFirstChild->getURI()) ||
(!XMLString::equals(children[0]->getLocalPart(), fFirstChild->getLocalPart()))) {
- return 0;
+ *indexFailingChild=0;
+ return false;
}
}
}
-
if (childCount > 1)
- return 1;
+ {
+ *indexFailingChild=1;
+ return false;
+ }
break;
case ContentSpecNode::ZeroOrMore :
@@ -113,7 +126,8 @@
if (fDTD) {
for (index = 0; index < childCount; index++) {
if (!XMLString::equals(children[index]->getRawName(), fFirstChild->getRawName())) {
- return index;
+ *indexFailingChild=index;
+ return false;
}
}
}
@@ -121,7 +135,8 @@
for (index = 0; index < childCount; index++) {
if ((children[index]->getURI() != fFirstChild->getURI()) ||
!XMLString::equals(children[index]->getLocalPart(), fFirstChild->getLocalPart())) {
- return index;
+ *indexFailingChild=index;
+ return false;
}
}
}
@@ -135,12 +150,16 @@
// element type that we stored.
//
if (childCount == 0)
- return 0;
+ {
+ *indexFailingChild=0;
+ return false;
+ }
if (fDTD) {
for (index = 0; index < childCount; index++) {
if (!XMLString::equals(children[index]->getRawName(), fFirstChild->getRawName())) {
- return index;
+ *indexFailingChild=index;
+ return false;
}
}
}
@@ -148,7 +167,8 @@
for (index = 0; index < childCount; index++) {
if ((children[index]->getURI() != fFirstChild->getURI()) ||
!XMLString::equals(children[index]->getLocalPart(), fFirstChild->getLocalPart())) {
- return index;
+ *indexFailingChild=index;
+ return false;
}
}
}
@@ -160,12 +180,16 @@
// two types we stored.
//
if (!childCount)
- return 0;
+ {
+ *indexFailingChild=0;
+ return false;
+ }
if (fDTD) {
if (!XMLString::equals(children[0]->getRawName(), fFirstChild->getRawName()) &&
!XMLString::equals(children[0]->getRawName(), fSecondChild->getRawName())) {
- return 0;
+ *indexFailingChild=0;
+ return false;
}
}
else {
@@ -173,12 +197,16 @@
!XMLString::equals(children[0]->getLocalPart(), fFirstChild->getLocalPart())) &&
((children[0]->getURI() != fSecondChild->getURI()) ||
!XMLString::equals(children[0]->getLocalPart(), fSecondChild->getLocalPart()))) {
- return 0;
+ *indexFailingChild=0;
+ return false;
}
}
if (childCount > 1)
- return 1;
+ {
+ *indexFailingChild=1;
+ return false;
+ }
break;
case ContentSpecNode::Sequence :
@@ -189,35 +217,44 @@
// in this content mode.
//
if (!childCount)
- return 0;
+ {
+ *indexFailingChild=0;
+ return false;
+ }
if (childCount == 2) {
if (fDTD) {
if (!XMLString::equals(children[0]->getRawName(), fFirstChild->getRawName())) {
- return 0;
+ *indexFailingChild=0;
+ return false;
}
if (!XMLString::equals(children[1]->getRawName(), fSecondChild->getRawName())) {
- return 1;
+ *indexFailingChild=1;
+ return false;
}
}
else {
if ((children[0]->getURI() != fFirstChild->getURI()) ||
!XMLString::equals(children[0]->getLocalPart(), fFirstChild->getLocalPart())) {
- return 0;
+ *indexFailingChild=0;
+ return false;
}
if ((children[1]->getURI() != fSecondChild->getURI()) ||
!XMLString::equals(children[1]->getLocalPart(), fSecondChild->getLocalPart())) {
- return 1;
+ *indexFailingChild=1;
+ return false;
}
}
}
else {
if (childCount > 2) {
- return 2;
+ *indexFailingChild=2;
+ return false;
}
- return childCount;
+ *indexFailingChild=childCount;
+ return false;
}
break;
@@ -225,14 +262,15 @@
ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::CM_UnknownCMSpecType, fMemoryManager);
break;
}
- return -1;
+ return true;
}
-int SimpleContentModel::validateContentSpecial(QName** const children
- , const unsigned int childCount
- , const unsigned int
+bool SimpleContentModel::validateContentSpecial(QName** const children
+ , unsigned int childCount
+ , unsigned int
, GrammarResolver* const pGrammarResolver
, XMLStringPool* const pStringPool
+ , unsigned int* indexFailingChild
, MemoryManager* const) const
{
@@ -251,17 +289,26 @@
// element type we stored.
//
if (!childCount)
- return 0;
+ {
+ *indexFailingChild=0;
+ return false;
+ }
if ((children[0]->getURI() != fFirstChild->getURI()) ||
!XMLString::equals(children[0]->getLocalPart(), fFirstChild->getLocalPart()))
{
if (!comparator.isEquivalentTo(children[0], fFirstChild))
- return 0;
+ {
+ *indexFailingChild=0;
+ return false;
+ }
}
if (childCount > 1)
- return 1;
+ {
+ *indexFailingChild=1;
+ return false;
+ }
break;
case ContentSpecNode::ZeroOrOne :
@@ -275,11 +322,17 @@
!XMLString::equals(children[0]->getLocalPart(), fFirstChild->getLocalPart())))
{
if(!comparator.isEquivalentTo(children[0], fFirstChild))
- return 0;
+ {
+ *indexFailingChild=0;
+ return false;
+ }
}
if (childCount > 1)
- return 1;
+ {
+ *indexFailingChild=1;
+ return false;
+ }
break;
case ContentSpecNode::ZeroOrMore :
@@ -295,8 +348,11 @@
if ((children[index]->getURI() != fFirstChild->getURI()) ||
!XMLString::equals(children[index]->getLocalPart(), fFirstChild->getLocalPart()))
{
- if (!comparator.isEquivalentTo(children[index], fFirstChild))
- return index;
+ if (!comparator.isEquivalentTo(children[index], fFirstChild))
+ {
+ *indexFailingChild=index;
+ return false;
+ }
}
}
}
@@ -309,15 +365,21 @@
// element type that we stored.
//
if (childCount == 0)
- return 0;
+ {
+ *indexFailingChild=0;
+ return false;
+ }
for (index = 0; index < childCount; index++)
{
if ((children[index]->getURI() != fFirstChild->getURI()) ||
!XMLString::equals(children[index]->getLocalPart(), fFirstChild->getLocalPart()))
{
- if (!comparator.isEquivalentTo(children[index], fFirstChild))
- return index;
+ if (!comparator.isEquivalentTo(children[index], fFirstChild))
+ {
+ *indexFailingChild=index;
+ return false;
+ }
}
}
break;
@@ -328,7 +390,10 @@
// two types we stored.
//
if (!childCount)
- return 0;
+ {
+ *indexFailingChild=0;
+ return false;
+ }
if (((children[0]->getURI() != fFirstChild->getURI()) ||
!XMLString::equals(children[0]->getLocalPart(), fFirstChild->getLocalPart())) &&
@@ -338,11 +403,17 @@
if (!comparator.isEquivalentTo(children[0], fFirstChild) &&
!comparator.isEquivalentTo(children[0], fSecondChild) )
- return 0;
+ {
+ *indexFailingChild=0;
+ return false;
+ }
}
if (childCount > 1)
- return 1;
+ {
+ *indexFailingChild=1;
+ return false;
+ }
break;
case ContentSpecNode::Sequence :
@@ -353,7 +424,10 @@
// in this content mode.
//
if (!childCount)
- return 0;
+ {
+ *indexFailingChild=0;
+ return false;
+ }
if (childCount == 2)
{
@@ -361,24 +435,32 @@
!XMLString::equals(children[0]->getLocalPart(), fFirstChild->getLocalPart()))
{
if(!comparator.isEquivalentTo(children[0], fFirstChild))
- return 0;
+ {
+ *indexFailingChild=0;
+ return false;
+ }
}
if ((children[1]->getURI() != fSecondChild->getURI()) ||
!XMLString::equals(children[1]->getLocalPart(), fSecondChild->getLocalPart()))
{
if (!comparator.isEquivalentTo(children[1], fSecondChild))
- return 1;
+ {
+ *indexFailingChild=1;
+ return false;
+ }
}
}
else
{
if (childCount > 2)
{
- return 2;
+ *indexFailingChild=2;
+ return false;
}
- return childCount;
+ *indexFailingChild=childCount;
+ return false;
}
break;
@@ -386,7 +468,7 @@
ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::CM_UnknownCMSpecType, fMemoryManager);
break;
}
- return -1;
+ return true;
}
ContentLeafNameTypeVector* SimpleContentModel::getContentLeafNameTypeVector() const
Modified: xerces/c/trunk/src/xercesc/validators/common/SimpleContentModel.hpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/validators/common/SimpleContentModel.hpp?rev=675478&r1=675477&r2=675478&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/validators/common/SimpleContentModel.hpp (original)
+++ xerces/c/trunk/src/xercesc/validators/common/SimpleContentModel.hpp Thu Jul 10 01:50:04 2008
@@ -72,28 +72,30 @@
// -----------------------------------------------------------------------
// Implementation of the ContentModel virtual interface
// -----------------------------------------------------------------------
- virtual int validateContent
+ virtual bool validateContent
(
QName** const children
- , const unsigned int childCount
- , const unsigned int emptyNamespaceId
+ , unsigned int childCount
+ , unsigned int emptyNamespaceId
+ , unsigned int* indexFailingChild
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
) const;
- virtual int validateContentSpecial
+ virtual bool validateContentSpecial
(
QName** const children
- , const unsigned int childCount
- , const unsigned int emptyNamespaceId
+ , unsigned int childCount
+ , unsigned int emptyNamespaceId
, GrammarResolver* const pGrammarResolver
, XMLStringPool* const pStringPool
+ , unsigned int* indexFailingChild
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
) const;
virtual ContentLeafNameTypeVector *getContentLeafNameTypeVector() const;
- virtual unsigned int getNextState(const unsigned int currentState,
- const unsigned int elementIndex) const;
+ virtual unsigned int getNextState(unsigned int currentState,
+ unsigned int elementIndex) const;
virtual void checkUniqueParticleAttribution
(
@@ -154,7 +156,7 @@
: fFirstChild(0)
, fSecondChild(0)
, fOp(cmOp)
- , fDTD(dtd)
+ , fDTD(dtd)
, fMemoryManager(manager)
{
if (firstChild)
@@ -179,8 +181,8 @@
// SimpleContentModel: Virtual methods
// ---------------------------------------------------------------------------
inline unsigned int
-SimpleContentModel::getNextState(const unsigned int,
- const unsigned int) const {
+SimpleContentModel::getNextState(unsigned int,
+ unsigned int) const {
return XMLContentModel::gInvalidTrans;
}
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=675478&r1=675477&r2=675478&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/validators/schema/SchemaValidator.cpp (original)
+++ xerces/c/trunk/src/xercesc/validators/schema/SchemaValidator.cpp Thu Jul 10 01:50:04 2008
@@ -77,9 +77,10 @@
// ---------------------------------------------------------------------------
// SchemaValidator: Implementation of the XMLValidator interface
// ---------------------------------------------------------------------------
-int SchemaValidator::checkContent (XMLElementDecl* const elemDecl
- , QName** const children
- , const unsigned int childCount)
+bool SchemaValidator::checkContent (XMLElementDecl* const elemDecl
+ , QName** const children
+ , unsigned int childCount
+ , unsigned int* indexFailingChild)
{
fErrorOccurred = false;
fElemIsSpecified = false;
@@ -111,7 +112,8 @@
//
if (childCount) {
fErrorOccurred = true;
- return 0;
+ *indexFailingChild=0;
+ return false;
}
}
else if ((modelType == SchemaElementDecl::Mixed_Simple)
@@ -135,17 +137,18 @@
// Ask it to validate and return its return
unsigned int emptyNS = getScanner()->getEmptyNamespaceId();
- int result = elemCM->validateContent(children, childCount, emptyNS, getScanner()->getMemoryManager());
- if (result != -1) {
+ bool result = elemCM->validateContent(children, childCount, emptyNS, indexFailingChild, getScanner()->getMemoryManager());
+ if (!result) {
result = elemCM->validateContentSpecial(children
, childCount
, emptyNS
, fGrammarResolver
, fGrammarResolver->getStringPool()
+ , indexFailingChild
, getScanner()->getMemoryManager());
}
- if(result != -1) {
+ if(!result) {
fErrorOccurred = true;
}
@@ -308,7 +311,7 @@
fCurrentDatatypeValidator = 0;
// Went ok, so return success
- return -1;
+ return true;
}
void SchemaValidator::faultInAttr (XMLAttr& toFill, const XMLAttDef& attDef) const
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=675478&r1=675477&r2=675478&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/validators/schema/SchemaValidator.hpp (original)
+++ xerces/c/trunk/src/xercesc/validators/schema/SchemaValidator.hpp Thu Jul 10 01:50:04 2008
@@ -57,11 +57,12 @@
// -----------------------------------------------------------------------
// Implementation of the XMLValidator interface
// -----------------------------------------------------------------------
- virtual int checkContent
+ virtual bool checkContent
(
XMLElementDecl* const elemDecl
, QName** const children
- , const unsigned int childCount
+ , unsigned int childCount
+ , unsigned int* indexFailingChild
);
virtual void faultInAttr
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org