Skip to content
Snippets Groups Projects
Commit fa31a490 authored by Khaled Noaman's avatar Khaled Noaman
Browse files

Eliminate the need to create a temporary content model when performing UPA checking

git-svn-id: https://svn.apache.org/repos/asf/xerces/c/trunk@175962 13f79535-47bb-0310-9956-ffa450edef68
parent 3552d571
No related branches found
No related tags found
No related merge requests found
...@@ -56,6 +56,9 @@ ...@@ -56,6 +56,9 @@
/* /*
* $Log$ * $Log$
* Revision 1.27 2004/07/22 15:00:54 knoaman
* Eliminate the need to create a temporary content model when performing UPA checking
*
* Revision 1.26 2004/01/29 11:52:31 cargilld * Revision 1.26 2004/01/29 11:52:31 cargilld
* Code cleanup changes to get rid of various compiler diagnostic messages. * Code cleanup changes to get rid of various compiler diagnostic messages.
* *
...@@ -396,7 +399,7 @@ ComplexTypeInfo::~ComplexTypeInfo() ...@@ -396,7 +399,7 @@ ComplexTypeInfo::~ComplexTypeInfo()
delete fAttDefs; delete fAttDefs;
delete fAttList; delete fAttList;
delete fElements; delete fElements;
delete fSpecNodesToDelete; //delete fSpecNodesToDelete;
delete fLocator; delete fLocator;
delete fContentModel; delete fContentModel;
...@@ -554,16 +557,12 @@ void ComplexTypeInfo::checkUniqueParticleAttribution (SchemaGrammar* const pG ...@@ -554,16 +557,12 @@ void ComplexTypeInfo::checkUniqueParticleAttribution (SchemaGrammar* const pG
XMLStringPool* const pStringPool, XMLStringPool* const pStringPool,
XMLValidator* const pValidator) XMLValidator* const pValidator)
{ {
if (fContentSpec) { if (fContentSpec && !fContentModel)
ContentSpecNode* specNode = new (fMemoryManager) ContentSpecNode(*fContentSpec); {
XMLContentModel* cm = makeContentModel(true, specNode); fContentModel = makeContentModel(true);
if (fContentModel) {
if (cm) { fContentModel->checkUniqueParticleAttribution(pGrammar, pGrammarResolver, pStringPool, pValidator, fContentSpecOrgURI);
cm->checkUniqueParticleAttribution(pGrammar, pGrammarResolver, pStringPool, pValidator, fContentSpecOrgURI);
delete cm;
} }
fSpecNodesToDelete->removeAllElements();
} }
} }
...@@ -613,31 +612,20 @@ XMLCh* ComplexTypeInfo::formatContentModel() const ...@@ -613,31 +612,20 @@ XMLCh* ComplexTypeInfo::formatContentModel() const
XMLContentModel* ComplexTypeInfo::makeContentModel(const bool checkUPA, ContentSpecNode* const specNode) XMLContentModel* ComplexTypeInfo::makeContentModel(const bool checkUPA, ContentSpecNode* const specNode)
{ {
if ((specNode || fContentSpec) && !fSpecNodesToDelete) { ContentSpecNode* aSpecNode = new (fMemoryManager) ContentSpecNode(*fContentSpec);
fSpecNodesToDelete = new (fMemoryManager) RefVectorOf<ContentSpecNode>(8, true, fMemoryManager);
}
// expand the content spec first
ContentSpecNode* aSpecNode = specNode;
XMLContentModel* retModel = 0; XMLContentModel* retModel = 0;
if (aSpecNode) {
if (checkUPA) {
fContentSpecOrgURI = (unsigned int*) fMemoryManager->allocate fContentSpecOrgURI = (unsigned int*) fMemoryManager->allocate
( (
fContentSpecOrgURISize * sizeof(unsigned int) fContentSpecOrgURISize * sizeof(unsigned int)
); //new unsigned int[fContentSpecOrgURISize]; ); //new unsigned int[fContentSpecOrgURISize];
aSpecNode = convertContentSpecTree(aSpecNode, checkUPA);
retModel = buildContentModel(aSpecNode);
fSpecNodesToDelete->addElement(aSpecNode);
}
else {
// building content model for the complex type
aSpecNode = new (fMemoryManager) ContentSpecNode(*fContentSpec);
aSpecNode = convertContentSpecTree(aSpecNode, checkUPA);
retModel = buildContentModel(aSpecNode);
delete aSpecNode;
} }
aSpecNode = convertContentSpecTree(aSpecNode, checkUPA);
retModel = buildContentModel(aSpecNode);
delete aSpecNode;
return retModel; return retModel;
} }
...@@ -803,12 +791,14 @@ ComplexTypeInfo::convertContentSpecTree(ContentSpecNode* const curNode, ...@@ -803,12 +791,14 @@ ComplexTypeInfo::convertContentSpecTree(ContentSpecNode* const curNode,
// When checking Unique Particle Attribution, rename leaf elements // When checking Unique Particle Attribution, rename leaf elements
if (checkUPA) { if (checkUPA) {
if (curNode->getElement()) { if (curNode->getElement()) {
if (fUniqueURI == fContentSpecOrgURISize) {
resizeContentSpecOrgURI();
}
fContentSpecOrgURI[fUniqueURI] = curNode->getElement()->getURI(); fContentSpecOrgURI[fUniqueURI] = curNode->getElement()->getURI();
curNode->getElement()->setURI(fUniqueURI); curNode->getElement()->setURI(fUniqueURI);
fUniqueURI++; fUniqueURI++;
} }
if (fUniqueURI == fContentSpecOrgURISize)
resizeContentSpecOrgURI();
} }
// Get the spec type of the passed node // Get the spec type of the passed node
......
...@@ -403,7 +403,7 @@ ComplexTypeInfo::elementAt(const unsigned int index) const { ...@@ -403,7 +403,7 @@ ComplexTypeInfo::elementAt(const unsigned int index) const {
inline XMLContentModel* ComplexTypeInfo::getContentModel(const bool checkUPA) inline XMLContentModel* ComplexTypeInfo::getContentModel(const bool checkUPA)
{ {
if (!fContentModel) if (!fContentModel && fContentSpec)
fContentModel = makeContentModel(checkUPA); fContentModel = makeContentModel(checkUPA);
return fContentModel; return fContentModel;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment