You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by kn...@apache.org on 2002/02/06 23:24:59 UTC
cvs commit: xml-xerces/c/src/xercesc/validators/schema SchemaInfo.hpp SchemaInfo.cpp
knoaman 02/02/06 14:24:59
Modified: c/src/xercesc/validators/schema SchemaInfo.hpp
SchemaInfo.cpp
Log:
Use IDOM for schema processing.
Revision Changes Path
1.2 +92 -66 xml-xerces/c/src/xercesc/validators/schema/SchemaInfo.hpp
Index: SchemaInfo.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/schema/SchemaInfo.hpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- SchemaInfo.hpp 1 Feb 2002 22:22:46 -0000 1.1
+++ SchemaInfo.hpp 6 Feb 2002 22:24:59 -0000 1.2
@@ -55,7 +55,7 @@
*/
/*
- * $Id: SchemaInfo.hpp,v 1.1 2002/02/01 22:22:46 peiyongz Exp $
+ * $Id: SchemaInfo.hpp,v 1.2 2002/02/06 22:24:59 knoaman Exp $
*/
#if !defined(SCHEMAINFO_HPP)
@@ -77,9 +77,9 @@
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
-#include <xercesc/dom/DOM_Element.hpp>
+#include <xercesc/idom/IDOM_Element.hpp>
#include <xercesc/util/RefVectorOf.hpp>
-#include <xercesc/util/RefHash2KeysTableOf.hpp>
+#include <xercesc/util/ValueVectorOf.hpp>
#include <xercesc/util/StringPool.hpp>
class SchemaInfo
@@ -105,7 +105,7 @@
XMLCh* const schemaURL,
const XMLCh* const targetNSURIString,
XMLStringPool* const stringPool,
- const DOM_Element& root);
+ const IDOM_Element* const root);
~SchemaInfo();
@@ -114,7 +114,7 @@
// -----------------------------------------------------------------------
XMLCh* getCurrentSchemaURL() const;
const XMLCh* const getTargetNSURIString() const;
- DOM_Element getRoot() const;
+ const IDOM_Element* getRoot() const;
int getBlockDefault() const;
int getFinalDefault() const;
int getTargetNSURI() const;
@@ -134,39 +134,41 @@
// Access methods
// -----------------------------------------------------------------------
void addSchemaInfo(SchemaInfo* const toAdd, const ListType aListType);
- void addRedefineInfo(const XMLCh* const categName, const XMLCh* const typeName,
- SchemaInfo* const toAdd);
bool containsInfo(const SchemaInfo* const toCheck, const ListType aListType) const;
SchemaInfo* getImportInfo(const unsigned int namespaceURI) const;
- SchemaInfo* getRedefInfo(const XMLCh* const categName,
- const XMLCh* const typeName);
- DOM_Element getTopLevelComponent(const XMLCh* const compCategory,
- const XMLCh* const name);
- DOM_Element getTopLevelComponent(const XMLCh* const compCategory,
- const XMLCh* const name,
- SchemaInfo** enclosingSchema);
+ IDOM_Element* getTopLevelComponent(const XMLCh* const compCategory,
+ const XMLCh* const name);
+ IDOM_Element* getTopLevelComponent(const XMLCh* const compCategory,
+ const XMLCh* const name,
+ SchemaInfo** enclosingSchema);
void updateImportingInfo(SchemaInfo* const importingInfo);
bool circularImportExist(const unsigned int nameSpaceURI);
+ bool isFailedRedefine(const IDOM_Element* const anElem);
+ void addFailedRedefine(const IDOM_Element* const anElem);
+ bool isImportingNS(const int namespaceURI);
+ void addImportedNS(const int namespaceURI);
private:
// -----------------------------------------------------------------------
// Private data members
// -----------------------------------------------------------------------
- unsigned short fElemAttrDefaultQualified;
- int fBlockDefault;
- int fFinalDefault;
- int fTargetNSURI;
- int fCurrentScope;
- int fScopeCount;
- unsigned int fNamespaceScopeLevel;
- XMLCh* fCurrentSchemaURL;
- const XMLCh* fTargetNSURIString;
- XMLStringPool* fStringPool;
- DOM_Element fSchemaRootElement;
- RefVectorOf<SchemaInfo>* fIncludeList;
- RefVectorOf<SchemaInfo>* fImportList;
- RefVectorOf<SchemaInfo>* fImportingList;
- RefHash2KeysTableOf<SchemaInfo>* fRedefineList;
+ bool fAdoptInclude;
+ unsigned short fElemAttrDefaultQualified;
+ int fBlockDefault;
+ int fFinalDefault;
+ int fTargetNSURI;
+ int fCurrentScope;
+ int fScopeCount;
+ unsigned int fNamespaceScopeLevel;
+ XMLCh* fCurrentSchemaURL;
+ const XMLCh* fTargetNSURIString;
+ XMLStringPool* fStringPool;
+ const IDOM_Element* fSchemaRootElement;
+ RefVectorOf<SchemaInfo>* fIncludeInfoList;
+ RefVectorOf<SchemaInfo>* fImportedInfoList;
+ RefVectorOf<SchemaInfo>* fImportingInfoList;
+ ValueVectorOf<const IDOM_Element*>* fFailedRedefineList;
+ ValueVectorOf<int>* fImportedNSList;
};
// ---------------------------------------------------------------------------
@@ -201,7 +203,7 @@
return fTargetNSURIString;
}
-inline DOM_Element SchemaInfo::getRoot() const {
+inline const IDOM_Element* SchemaInfo::getRoot() const {
return fSchemaRootElement;
}
@@ -224,7 +226,7 @@
inline RefVectorEnumerator<SchemaInfo>
SchemaInfo::getImportingListEnumerator() const {
- return RefVectorEnumerator<SchemaInfo>(fImportingList);
+ return RefVectorEnumerator<SchemaInfo>(fImportingInfoList);
}
// ---------------------------------------------------------------------------
@@ -240,6 +242,7 @@
fScopeCount = aValue;
}
+
// ---------------------------------------------------------------------------
// SchemaInfo: Access methods
// ---------------------------------------------------------------------------
@@ -248,43 +251,40 @@
if (aListType == IMPORT) {
- if (!fImportList)
- fImportList = new RefVectorOf<SchemaInfo>(8, false);
+ if (!fImportedInfoList)
+ fImportedInfoList = new RefVectorOf<SchemaInfo>(4, false);
+
+ if (!fImportedInfoList->containsElement(toAdd)) {
- if (!fImportList->containsElement(toAdd)) {
- fImportList->addElement(toAdd);
+ fImportedInfoList->addElement(toAdd);
+ addImportedNS(toAdd->getTargetNSURI());
toAdd->updateImportingInfo(this);
}
}
else {
- if (!fIncludeList)
- fIncludeList = new RefVectorOf<SchemaInfo>(8, false);
+ if (!fIncludeInfoList) {
- if (!fIncludeList->containsElement(toAdd))
- fIncludeList->addElement(toAdd);
- }
-}
+ fIncludeInfoList = new RefVectorOf<SchemaInfo>(8, false);
+ fAdoptInclude = true;
+ }
-inline void SchemaInfo::addRedefineInfo(const XMLCh* const categName,
- const XMLCh* const typeName,
- SchemaInfo* const toAdd) {
+ if (!fIncludeInfoList->containsElement(toAdd)) {
- if (!fRedefineList) {
- fRedefineList = new RefHash2KeysTableOf<SchemaInfo>(8, false);
+ fIncludeInfoList->addElement(toAdd);
+ toAdd->fIncludeInfoList = fIncludeInfoList;
+ }
}
-
- fRedefineList->put((void*) categName, fStringPool->addOrFind(typeName), toAdd);
}
inline SchemaInfo* SchemaInfo::getImportInfo(const unsigned int namespaceURI) const {
- unsigned int importSize = (fImportList) ? fImportList->size() : 0;
+ unsigned int importSize = (fImportedInfoList) ? fImportedInfoList->size() : 0;
SchemaInfo* currInfo = 0;
for (unsigned int i=0; i < importSize; i++) {
- currInfo = fImportList->elementAt(i);
+ currInfo = fImportedInfoList->elementAt(i);
if (currInfo->getTargetNSURI() == (int) namespaceURI)
break;
@@ -293,24 +293,14 @@
return currInfo;
}
-inline SchemaInfo* SchemaInfo::getRedefInfo(const XMLCh* const categName,
- const XMLCh* const typeName) {
-
- if (fRedefineList) {
- return fRedefineList->get(categName, fStringPool->addOrFind(typeName));
- }
-
- return 0;
-}
-
inline bool SchemaInfo::containsInfo(const SchemaInfo* const toCheck,
const ListType aListType) const {
- if ((aListType == INCLUDE) && fIncludeList) {
- return fIncludeList->containsElement(toCheck);
+ if ((aListType == INCLUDE) && fIncludeInfoList) {
+ return fIncludeInfoList->containsElement(toCheck);
}
- else if ((aListType == IMPORT) && fImportList) {
- return fImportList->containsElement(toCheck);
+ else if ((aListType == IMPORT) && fImportedInfoList) {
+ return fImportedInfoList->containsElement(toCheck);
}
return false;
@@ -318,16 +308,52 @@
inline bool SchemaInfo::circularImportExist(const unsigned int namespaceURI) {
- unsigned int importSize = fImportingList->size();
+ unsigned int importSize = fImportingInfoList->size();
for (unsigned int i=0; i < importSize; i++) {
- if (fImportingList->elementAt(i)->getTargetNSURI() == (int) namespaceURI) {
+ if (fImportingInfoList->elementAt(i)->getTargetNSURI() == (int) namespaceURI) {
return true;
}
}
return false;
}
+
+inline bool SchemaInfo::isFailedRedefine(const IDOM_Element* const anElem) {
+
+ if (fFailedRedefineList)
+ return (fFailedRedefineList->containsElement(anElem));
+
+ return false;
+}
+
+inline void SchemaInfo::addFailedRedefine(const IDOM_Element* const anElem) {
+
+ if (!fFailedRedefineList) {
+ fFailedRedefineList = new ValueVectorOf<const IDOM_Element*>(4);
+ }
+
+ fFailedRedefineList->addElement(anElem);
+}
+
+inline void SchemaInfo::addImportedNS(const int namespaceURI) {
+
+ if (!fImportedNSList) {
+ fImportedNSList = new ValueVectorOf<int>(4);
+ }
+
+ if (!fImportedNSList->containsElement(namespaceURI))
+ fImportedNSList->addElement(namespaceURI);
+}
+
+inline bool SchemaInfo::isImportingNS(const int namespaceURI) {
+
+ if (!fImportedNSList)
+ return false;
+
+ return (fImportedNSList->containsElement(namespaceURI));
+}
+
#endif
1.2 +48 -48 xml-xerces/c/src/xercesc/validators/schema/SchemaInfo.cpp
Index: SchemaInfo.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/schema/SchemaInfo.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- SchemaInfo.cpp 1 Feb 2002 22:22:46 -0000 1.1
+++ SchemaInfo.cpp 6 Feb 2002 22:24:59 -0000 1.2
@@ -56,8 +56,11 @@
/*
* $Log: SchemaInfo.cpp,v $
- * Revision 1.1 2002/02/01 22:22:46 peiyongz
- * Initial revision
+ * Revision 1.2 2002/02/06 22:24:59 knoaman
+ * Use IDOM for schema processing.
+ *
+ * Revision 1.1.1.1 2002/02/01 22:22:46 peiyongz
+ * sane_include
*
* Revision 1.6 2001/12/12 20:52:19 peiyongz
* memory leak: fRedefineList
@@ -100,8 +103,9 @@
XMLCh* const schemaURL,
const XMLCh* const targetNSURIString,
XMLStringPool* const stringPool,
- const DOM_Element& root)
- : fElemAttrDefaultQualified(elemAttrDefaultQualified)
+ const IDOM_Element* const root)
+ : fAdoptInclude(false)
+ , fElemAttrDefaultQualified(elemAttrDefaultQualified)
, fBlockDefault(blockDefault)
, fFinalDefault(finalDefault)
, fTargetNSURI(targetNSURI)
@@ -112,46 +116,56 @@
, fTargetNSURIString(targetNSURIString)
, fStringPool(stringPool)
, fSchemaRootElement(root)
- , fIncludeList(0)
- , fImportList(0)
- , fImportingList(0)
- , fRedefineList(0)
+ , fIncludeInfoList(0)
+ , fImportedInfoList(0)
+ , fImportingInfoList(0)
+ , fFailedRedefineList(0)
+ , fImportedNSList(0)
{
- fImportingList = new RefVectorOf<SchemaInfo>(4, false);
+ fImportingInfoList = new RefVectorOf<SchemaInfo>(4, false);
}
SchemaInfo::~SchemaInfo()
{
delete [] fCurrentSchemaURL;
- delete fImportList;
- delete fIncludeList;
- delete fImportingList;
+ delete fImportedInfoList;
+
+ if (fAdoptInclude)
+ delete fIncludeInfoList;
+
+ delete fImportingInfoList;
+
+ fImportedInfoList = fIncludeInfoList = fImportingInfoList = 0;
- fImportList = fIncludeList = fImportingList = 0;
+ delete fImportedNSList;
+ fImportedNSList = 0;
- delete fRedefineList;
- fRedefineList = 0;
+ delete fFailedRedefineList;
+ fFailedRedefineList = 0;
}
// ---------------------------------------------------------------------------
// SchemaInfo:
// ---------------------------------------------------------------------------
-DOM_Element
+IDOM_Element*
SchemaInfo::getTopLevelComponent(const XMLCh* const compCategory,
const XMLCh* const name,
SchemaInfo** enclosingSchema) {
SchemaInfo* currentInfo = this;
- DOM_Element child = getTopLevelComponent(compCategory, name);
+ IDOM_Element* child = getTopLevelComponent(compCategory, name);
if (child == 0) {
- unsigned int listSize = (fIncludeList) ? fIncludeList->size() : 0;
+ unsigned int listSize = (fIncludeInfoList) ? fIncludeInfoList->size() : 0;
for (unsigned int i=0; i < listSize; i++) {
- currentInfo = fIncludeList->elementAt(i);
+ currentInfo = fIncludeInfoList->elementAt(i);
+
+ if (currentInfo == this)
+ continue;
child = currentInfo->getTopLevelComponent(compCategory, name);
@@ -161,50 +175,36 @@
break;
}
}
-
- if (child == 0 && fRedefineList) { // try redefine list
-
- currentInfo = fRedefineList->get(compCategory, fStringPool->addOrFind(name));
-
- if (currentInfo) {
- child = currentInfo->getTopLevelComponent(compCategory, name);
-
- if (child != 0) {
- *enclosingSchema = currentInfo;
- }
- }
- }
}
return child;
}
-DOM_Element
+IDOM_Element*
SchemaInfo::getTopLevelComponent(const XMLCh* const compCategory,
- const XMLCh* const name) {
+ const XMLCh* const name) {
- DOM_Element child = XUtil::getFirstChildElement(fSchemaRootElement);
+ IDOM_Element* child = XUtil::getFirstChildElement(fSchemaRootElement);
while (child != 0) {
- if (child.getLocalName().equals(compCategory)) {
+ if (!XMLString::compareString(child->getLocalName(), compCategory)) {
- if (child.getAttribute(SchemaSymbols::fgATT_NAME).equals(name)) {
+ if (!XMLString::compareString(child->getAttribute(SchemaSymbols::fgATT_NAME), name))
break;
- }
}
- else if (child.getLocalName().equals(SchemaSymbols::fgELT_REDEFINE)) { // if redefine
+ else if (!XMLString::compareString(child->getLocalName(),SchemaSymbols::fgELT_REDEFINE)
+ && (!fFailedRedefineList || !fFailedRedefineList->containsElement(child))) { // if redefine
- DOM_Element redefineChild = XUtil::getFirstChildElement(child);
+ IDOM_Element* redefineChild = XUtil::getFirstChildElement(child);
while (redefineChild != 0) {
- if (redefineChild.getLocalName().equals(compCategory)) {
-
- if (redefineChild.getAttribute(SchemaSymbols::fgATT_NAME).equals(name)) {
+ if ((!fFailedRedefineList || !fFailedRedefineList->containsElement(redefineChild))
+ && !XMLString::compareString(redefineChild->getLocalName(), compCategory)
+ && !XMLString::compareString(redefineChild->getAttribute(SchemaSymbols::fgATT_NAME), name)) {
break;
- }
}
redefineChild = XUtil::getNextSiblingElement(redefineChild);
@@ -225,18 +225,18 @@
void SchemaInfo::updateImportingInfo(SchemaInfo* const importingInfo) {
- if (!fImportingList->containsElement(importingInfo)) {
- fImportingList->addElement(importingInfo);
+ if (!fImportingInfoList->containsElement(importingInfo)) {
+ fImportingInfoList->addElement(importingInfo);
}
- unsigned int listSize = importingInfo->fImportingList->size();
+ unsigned int listSize = importingInfo->fImportingInfoList->size();
for (unsigned int i=0; i < listSize; i++) {
- SchemaInfo* tmpInfo = importingInfo->fImportingList->elementAt(i);
+ SchemaInfo* tmpInfo = importingInfo->fImportingInfoList->elementAt(i);
- if (tmpInfo != this && !fImportingList->containsElement(tmpInfo)) {
- fImportingList->addElement(tmpInfo);
+ if (tmpInfo != this && !fImportingInfoList->containsElement(tmpInfo)) {
+ fImportingInfoList->addElement(tmpInfo);
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org