knoaman 2002/08/26 22:56:19
Modified: c/src/xercesc/validators/schema/identity FieldActivator.cpp
FieldActivator.hpp IC_Selector.cpp IC_Selector.hpp
ValueStoreCache.cpp ValueStoreCache.hpp
XPathMatcher.cpp XPathMatcher.hpp
Log:
Identity Constraint: handle case of recursive elements.
Revision Changes Path
1.2 +10 -6
xml-xerces/c/src/xercesc/validators/schema/identity/FieldActivator.cpp
Index: FieldActivator.cpp
===================================================================
RCS file:
/home/cvs/xml-xerces/c/src/xercesc/validators/schema/identity/FieldActivator.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- FieldActivator.cpp 1 Feb 2002 22:22:50 -0000 1.1
+++ FieldActivator.cpp 27 Aug 2002 05:56:19 -0000 1.2
@@ -56,8 +56,11 @@
/*
* $Log$
- * Revision 1.1 2002/02/01 22:22:50 peiyongz
- * Initial revision
+ * Revision 1.2 2002/08/27 05:56:19 knoaman
+ * Identity Constraint: handle case of recursive elements.
+ *
+ * Revision 1.1.1.1 2002/02/01 22:22:50 peiyongz
+ * sane_include
*
* Revision 1.1 2001/11/02 14:08:40 knoaman
* Add support for identity constraints.
@@ -110,9 +113,9 @@
// ---------------------------------------------------------------------------
// FieldActivator: Operator methods
// ---------------------------------------------------------------------------
-XPathMatcher* FieldActivator::activateField(IC_Field* const field) {
+XPathMatcher* FieldActivator::activateField(IC_Field* const field, const int
initialDepth) {
- ValueStore* valueStore = fValueStoreCache->getValueStoreFor(field);
+ ValueStore* valueStore = fValueStoreCache->getValueStoreFor(field,
initialDepth);
XPathMatcher* matcher = field->createMatcher(valueStore);
field->setMayMatch(true);
@@ -122,22 +125,23 @@
return matcher;
}
-void FieldActivator::startValueScopeFor(const IdentityConstraint* const ic) {
+void FieldActivator::startValueScopeFor(const IdentityConstraint* const ic,
+ const int initialDepth) {
unsigned int fieldCount = ic->getFieldCount();
for(unsigned int i=0; i<fieldCount; i++) {
const IC_Field* field = ic->getFieldAt(i);
- ValueStore* valueStore = fValueStoreCache->getValueStoreFor(field);
+ ValueStore* valueStore = fValueStoreCache->getValueStoreFor(field,
initialDepth);
valueStore->startValueScope();
}
}
-void FieldActivator::endValueScopeFor(const IdentityConstraint* const ic) {
+void FieldActivator::endValueScopeFor(const IdentityConstraint* const ic, const int
initialDepth) {
- ValueStore* valueStore = fValueStoreCache->getValueStoreFor(ic);
+ ValueStore* valueStore = fValueStoreCache->getValueStoreFor(ic, initialDepth);
valueStore->endValueScope();
}
1.2 +4 -4
xml-xerces/c/src/xercesc/validators/schema/identity/FieldActivator.hpp
Index: FieldActivator.hpp
===================================================================
RCS file:
/home/cvs/xml-xerces/c/src/xercesc/validators/schema/identity/FieldActivator.hpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- FieldActivator.hpp 1 Feb 2002 22:22:50 -0000 1.1
+++ FieldActivator.hpp 27 Aug 2002 05:56:19 -0000 1.2
@@ -111,18 +111,18 @@
* method is called when the selector matches in order to initialize
* the value store.
*/
- void startValueScopeFor(const IdentityConstraint* const ic);
+ void startValueScopeFor(const IdentityConstraint* const ic, const int
initialDepth);
/**
* Request to activate the specified field. This method returns the
* matcher for the field.
*/
- XPathMatcher* activateField(IC_Field* const field);
+ XPathMatcher* activateField(IC_Field* const field, const int initialDepth);
/**
* Ends the value scope for the specified identity constraint.
*/
- void endValueScopeFor(const IdentityConstraint* const ic);
+ void endValueScopeFor(const IdentityConstraint* const ic, const int
initialDepth);
private:
// -----------------------------------------------------------------------
1.2 +11 -6
xml-xerces/c/src/xercesc/validators/schema/identity/IC_Selector.cpp
Index: IC_Selector.cpp
===================================================================
RCS file:
/home/cvs/xml-xerces/c/src/xercesc/validators/schema/identity/IC_Selector.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- IC_Selector.cpp 1 Feb 2002 22:22:50 -0000 1.1
+++ IC_Selector.cpp 27 Aug 2002 05:56:19 -0000 1.2
@@ -56,8 +56,11 @@
/*
* $Log$
- * Revision 1.1 2002/02/01 22:22:50 peiyongz
- * Initial revision
+ * Revision 1.2 2002/08/27 05:56:19 knoaman
+ * Identity Constraint: handle case of recursive elements.
+ *
+ * Revision 1.1.1.1 2002/02/01 22:22:50 peiyongz
+ * sane_include
*
* Revision 1.3 2001/11/23 18:35:33 tng
* Eliminate Warning from AIX xlC 3.6:1540-399: (W) "XMLAttr" is undefined. The
delete operator will not call a destructor.
@@ -84,8 +87,10 @@
// ---------------------------------------------------------------------------
SelectorMatcher::SelectorMatcher(XercesXPath* const xpath,
IC_Selector* const selector,
- FieldActivator* const fieldActivator)
+ FieldActivator* const fieldActivator,
+ const int initialDepth)
: XPathMatcher(xpath, false, selector->getIdentityConstraint())
+ , fInitialDepth(initialDepth)
, fElementDepth(0)
, fMatchedDepth(-1)
, fSelector(selector)
@@ -119,12 +124,12 @@
int count = ic->getFieldCount();
fMatchedDepth = fElementDepth;
- fFieldActivator->startValueScopeFor(ic);
+ fFieldActivator->startValueScopeFor(ic, fInitialDepth);
for (int i = 0; i < count; i++) {
IC_Field* field = ic->getFieldAt(i);
- XPathMatcher* matcher = fFieldActivator->activateField(field);
+ XPathMatcher* matcher = fFieldActivator->activateField(field,
fInitialDepth);
matcher->startElement(elemDecl, urlId, elemPrefix, attrList, attrCount);
}
@@ -138,7 +143,7 @@
if (fElementDepth-- == fMatchedDepth) {
fMatchedDepth = -1;
- fFieldActivator->endValueScopeFor(fSelector->getIdentityConstraint());
+ fFieldActivator->endValueScopeFor(fSelector->getIdentityConstraint(),
fInitialDepth);
}
}
@@ -174,9 +179,9 @@
// ---------------------------------------------------------------------------
// IC_Selector: Factory methods
// ---------------------------------------------------------------------------
-XPathMatcher* IC_Selector::createMatcher(FieldActivator* const fieldActivator) {
+XPathMatcher* IC_Selector::createMatcher(FieldActivator* const fieldActivator,
const int initialDepth) {
- return new SelectorMatcher(fXPath, this, fieldActivator);
+ return new SelectorMatcher(fXPath, this, fieldActivator, initialDepth);
}
/**
1.2 +6 -3
xml-xerces/c/src/xercesc/validators/schema/identity/IC_Selector.hpp
Index: IC_Selector.hpp
===================================================================
RCS file:
/home/cvs/xml-xerces/c/src/xercesc/validators/schema/identity/IC_Selector.hpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- IC_Selector.hpp 1 Feb 2002 22:22:50 -0000 1.1
+++ IC_Selector.hpp 27 Aug 2002 05:56:19 -0000 1.2
@@ -98,7 +98,7 @@
// -----------------------------------------------------------------------
// Factory methods
// -----------------------------------------------------------------------
- XPathMatcher* createMatcher(FieldActivator* const fieldActivator);
+ XPathMatcher* createMatcher(FieldActivator* const fieldActivator, const int
initialDepth);
private:
// -----------------------------------------------------------------------
@@ -123,6 +123,8 @@
// -----------------------------------------------------------------------
~SelectorMatcher() {}
+ int getInitialDepth() const { return fInitialDepth; }
+
// -----------------------------------------------------------------------
// XMLDocumentHandler methods
// -----------------------------------------------------------------------
@@ -139,7 +141,7 @@
// Constructors/Destructor
// -----------------------------------------------------------------------
SelectorMatcher(XercesXPath* const anXPath, IC_Selector* const selector,
- FieldActivator* const fieldActivator);
+ FieldActivator* const fieldActivator, const int initialDepth);
// -----------------------------------------------------------------------
// Unimplemented contstructors and operators
@@ -155,6 +157,7 @@
// -----------------------------------------------------------------------
// Data members
// -----------------------------------------------------------------------
+ int fInitialDepth;
int fElementDepth;
int fMatchedDepth;
IC_Selector* fSelector;
1.3 +14 -19
xml-xerces/c/src/xercesc/validators/schema/identity/ValueStoreCache.cpp
Index: ValueStoreCache.cpp
===================================================================
RCS file:
/home/cvs/xml-xerces/c/src/xercesc/validators/schema/identity/ValueStoreCache.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ValueStoreCache.cpp 26 Aug 2002 23:48:09 -0000 1.2
+++ ValueStoreCache.cpp 27 Aug 2002 05:56:19 -0000 1.3
@@ -56,6 +56,9 @@
/*
* $Log$
+ * Revision 1.3 2002/08/27 05:56:19 knoaman
+ * Identity Constraint: handle case of recursive elements.
+ *
* Revision 1.2 2002/08/26 23:48:09 knoaman
* Fix for ValueStore's null pointer.
*
@@ -157,11 +160,12 @@
fValueStores = new RefVectorOf<ValueStore>(8);
fGlobalICMap = new RefHashTableOf<ValueStore>(13, false, new HashPtr());
- fIC2ValueStoreMap = new RefHashTableOf<ValueStore>(13, false, new HashPtr());
+ fIC2ValueStoreMap = new RefHash2KeysTableOf<ValueStore>(13, false, new
HashPtr());
fGlobalMapStack = new RefStackOf<RefHashTableOf<ValueStore> >(8);
}
-void ValueStoreCache::initValueStoresFor(SchemaElementDecl* const elemDecl) {
+void ValueStoreCache::initValueStoresFor(SchemaElementDecl* const elemDecl,
+ const int initialDepth) {
// initialize value stores for unique fields
unsigned int icCount = elemDecl->getIdentityConstraintCount();
@@ -169,38 +173,29 @@
for (unsigned int i=0; i<icCount; i++) {
IdentityConstraint* ic = elemDecl->getIdentityConstraintAt(i);
- ValueStore* valueStore = fIC2ValueStoreMap->get(ic);
-
- if (valueStore && ic->getType() != IdentityConstraint::KEYREF) {
- continue;
- }
-
- valueStore = new ValueStore(ic, fScanner);
+ ValueStore* valueStore = valueStore = new ValueStore(ic, fScanner);
fValueStores->addElement(valueStore);
- fIC2ValueStoreMap->put(ic, valueStore);
+ fIC2ValueStoreMap->put(ic, initialDepth, valueStore);
}
}
-void ValueStoreCache::transplant(IdentityConstraint* const ic) {
+void ValueStoreCache::transplant(IdentityConstraint* const ic, const initialDepth) {
if (ic->getType() == IdentityConstraint::KEYREF) {
return;
}
- ValueStore* newVals = fIC2ValueStoreMap->get(ic);
+ ValueStore* newVals = fIC2ValueStoreMap->get(ic, initialDepth);
ValueStore* currVals = fGlobalICMap->get(ic);
- fIC2ValueStoreMap->removeKey(ic);
-
if (currVals) {
currVals->append(newVals);
} else {
- fGlobalICMap->put(ic, newVals);
+ ValueStore* valueStore = new ValueStore(ic, fScanner);
+ fValueStores->addElement(valueStore);
+ valueStore->append(newVals);
+ fGlobalICMap->put(ic, valueStore);
}
-
- ValueStore* valueStore = new ValueStore(ic, fScanner);
- fValueStores->addElement(valueStore);
- fIC2ValueStoreMap->put(ic, valueStore);
}
/**
1.2 +11 -10
xml-xerces/c/src/xercesc/validators/schema/identity/ValueStoreCache.hpp
Index: ValueStoreCache.hpp
===================================================================
RCS file:
/home/cvs/xml-xerces/c/src/xercesc/validators/schema/identity/ValueStoreCache.hpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ValueStoreCache.hpp 1 Feb 2002 22:22:51 -0000 1.1
+++ ValueStoreCache.hpp 27 Aug 2002 05:56:19 -0000 1.2
@@ -84,6 +84,7 @@
// ---------------------------------------------------------------------------
#include <xercesc/util/RefVectorOf.hpp>
#include <xercesc/util/RefHashTableOf.hpp>
+#include <xercesc/util/RefHash2KeysTableOf.hpp>
#include <xercesc/util/RefStackOf.hpp>
#include <xercesc/validators/schema/identity/IdentityConstraint.hpp>
#include <xercesc/validators/schema/identity/IC_Field.hpp>
@@ -121,14 +122,14 @@
// -----------------------------------------------------------------------
// Initialization methods
// -----------------------------------------------------------------------
- void initValueStoresFor(SchemaElementDecl* const elemDecl);
+ void initValueStoresFor(SchemaElementDecl* const elemDecl, const int
initialDepth);
// -----------------------------------------------------------------------
// Access methods
// -----------------------------------------------------------------------
- ValueStore* getValueStoreFor(const IC_Field* const field);
- ValueStore* getValueStoreFor(const IdentityConstraint* const ic);
+ ValueStore* getValueStoreFor(const IC_Field* const field, const initialDepth);
+ ValueStore* getValueStoreFor(const IdentityConstraint* const ic, const int
intialDepth);
ValueStore* getGlobalValueStoreFor(const IdentityConstraint* const ic);
// -----------------------------------------------------------------------
@@ -138,7 +139,7 @@
* with ic and moves them into the global hashtable, if ic is a <unique>
* or a <key>. If it's a <keyRef>, then we leave it for later.
*/
- void transplant(IdentityConstraint* const ic);
+ void transplant(IdentityConstraint* const ic, const int initialDepth);
private:
// -----------------------------------------------------------------------
@@ -158,7 +159,7 @@
// -----------------------------------------------------------------------
RefVectorOf<ValueStore>* fValueStores;
RefHashTableOf<ValueStore>* fGlobalICMap;
- RefHashTableOf<ValueStore>* fIC2ValueStoreMap;
+ RefHash2KeysTableOf<ValueStore>* fIC2ValueStoreMap;
RefStackOf<RefHashTableOf<ValueStore> >* fGlobalMapStack;
XMLScanner* fScanner;
};
@@ -175,15 +176,15 @@
// ValueStoreCache: Access methods
// ---------------------------------------------------------------------------
inline ValueStore*
-ValueStoreCache::getValueStoreFor(const IC_Field* const field) {
+ValueStoreCache::getValueStoreFor(const IC_Field* const field, const int
initialDepth) {
- return fIC2ValueStoreMap->get(field->getIdentityConstraint());
+ return fIC2ValueStoreMap->get(field->getIdentityConstraint(), initialDepth);
}
inline ValueStore*
-ValueStoreCache::getValueStoreFor(const IdentityConstraint* const ic) {
+ValueStoreCache::getValueStoreFor(const IdentityConstraint* const ic, const int
initialDepth) {
- return fIC2ValueStoreMap->get(ic);
+ return fIC2ValueStoreMap->get(ic, initialDepth);
}
inline ValueStore*
1.3 +13 -0
xml-xerces/c/src/xercesc/validators/schema/identity/XPathMatcher.cpp
Index: XPathMatcher.cpp
===================================================================
RCS file:
/home/cvs/xml-xerces/c/src/xercesc/validators/schema/identity/XPathMatcher.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- XPathMatcher.cpp 18 Feb 2002 06:26:50 -0000 1.2
+++ XPathMatcher.cpp 27 Aug 2002 05:56:19 -0000 1.3
@@ -56,6 +56,9 @@
/*
* $Log$
+ * Revision 1.3 2002/08/27 05:56:19 knoaman
+ * Identity Constraint: handle case of recursive elements.
+ *
* Revision 1.2 2002/02/18 06:26:50 jberry
* Quiet codewarrior compiler warnings
*
@@ -78,6 +81,7 @@
#include <xercesc/validators/schema/SchemaElementDecl.hpp>
#include <xercesc/validators/schema/SchemaAttDef.hpp>
#include <xercesc/validators/schema/SchemaSymbols.hpp>
+#include <xercesc/util/RuntimeException.hpp>
// ---------------------------------------------------------------------------
// XPathMatcher: Constructors and Destructor
@@ -406,6 +410,15 @@
return;
}
+
+// ---------------------------------------------------------------------------
+// XPathMatcher: Match methods
+// ---------------------------------------------------------------------------
+int XPathMatcher::getInitialDepth() const
+{
+ ThrowXML(RuntimeException, XMLExcepts::Regex_NotSupported);
+ return 0; // to make some compilers happy
+}
/**
* End of file XPathMatcher.cpp
1.2 +2 -1
xml-xerces/c/src/xercesc/validators/schema/identity/XPathMatcher.hpp
Index: XPathMatcher.hpp
===================================================================
RCS file:
/home/cvs/xml-xerces/c/src/xercesc/validators/schema/identity/XPathMatcher.hpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- XPathMatcher.hpp 1 Feb 2002 22:22:51 -0000 1.1
+++ XPathMatcher.hpp 27 Aug 2002 05:56:19 -0000 1.2
@@ -103,6 +103,7 @@
* Returns true if XPath has been matched.
*/
bool isMatched();
+ virtual int getInitialDepth() const;
// -----------------------------------------------------------------------
// XMLDocumentHandler methods
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]