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 2001/11/16 16:03:38 UTC
cvs commit: xml-xerces/c/src/validators/schema GeneralAttributeCheck.cpp GeneralAttributeCheck.hpp TraverseSchema.cpp TraverseSchema.hpp
knoaman 01/11/16 07:03:38
Modified: c/src/validators/schema GeneralAttributeCheck.cpp
GeneralAttributeCheck.hpp TraverseSchema.cpp
TraverseSchema.hpp
Log:
Design change: GeneralAttributeCheck is not longer a singleton class.
Revision Changes Path
1.12 +442 -426 xml-xerces/c/src/validators/schema/GeneralAttributeCheck.cpp
Index: GeneralAttributeCheck.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/validators/schema/GeneralAttributeCheck.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- GeneralAttributeCheck.cpp 2001/11/02 14:13:45 1.11
+++ GeneralAttributeCheck.cpp 2001/11/16 15:03:37 1.12
@@ -56,6 +56,9 @@
/*
* $Log: GeneralAttributeCheck.cpp,v $
+ * Revision 1.12 2001/11/16 15:03:37 knoaman
+ * Design change: GeneralAttributeCheck is not longer a singleton class.
+ *
* Revision 1.11 2001/11/02 14:13:45 knoaman
* Add support for identity constraints.
*
@@ -141,9 +144,17 @@
// ---------------------------------------------------------------------------
// Static member data initialization
// ---------------------------------------------------------------------------
-GeneralAttributeCheck* GeneralAttributeCheck::fInstance = 0;
const unsigned short GeneralAttributeCheck::GlobalContext = 0;
const unsigned short GeneralAttributeCheck::LocalContext = 1;
+AttributeInfo** GeneralAttributeCheck::fAttributes = 0;
+DatatypeValidator** GeneralAttributeCheck::fValidators = 0;
+RefHash2KeysTableOf<RefVectorOfAttributeInfo>* GeneralAttributeCheck::fElementMap = 0;
+
+// ---------------------------------------------------------------------------
+// Static local data
+// ---------------------------------------------------------------------------
+static XMLMutex* sGeneralAttCheckMutex = 0;
+static XMLRegisterCleanup GeneralAttCheckCleanup;
// ---------------------------------------------------------------------------
@@ -180,23 +191,14 @@
// GeneralAttributeCheck: Constructors and Destructor
// ---------------------------------------------------------------------------
GeneralAttributeCheck::GeneralAttributeCheck()
- : fAttributes(0)
- , fValidators(0)
- , fElementMap(0)
+ : fIDRefList(0)
{
- try {
- mapElements();
- }
- catch(...) {
-
- cleanUp();
- throw;
- }
+ mapElements();
}
GeneralAttributeCheck::~GeneralAttributeCheck()
{
- cleanUp();
+ delete fIDRefList;
}
@@ -269,7 +271,7 @@
fAttributes[Att_ID_N] =
new AttributeInfo(SchemaSymbols::fgATT_ID, Att_Optional_NoDefault,
- 0, 0);
+ 0, DT_ID);
fAttributes[Att_ItemType_N] =
new AttributeInfo(SchemaSymbols::fgATT_ITEMTYPE, Att_Optional_NoDefault,
@@ -407,435 +409,434 @@
fValidators[DT_Boolean] =
dvFactory.getDatatypeValidator(SchemaSymbols::fgDT_BOOLEAN);
+ fValidators[DT_AnyURI] =
+ dvFactory.getDatatypeValidator(SchemaSymbols::fgDT_ANYURI);
+
+ fValidators[DT_ID] = &fIDValidator;
+
// TO DO - add remaining valdiators
}
void GeneralAttributeCheck::mapElements() {
- if (fElementMap) {
- return;
- }
+ if (!sGeneralAttCheckMutex)
+ {
+ XMLMutex* tmpMutex = new XMLMutex;
+ if (XMLPlatformUtils::compareAndSwap((void**)&sGeneralAttCheckMutex, tmpMutex, 0))
+ {
+ // Some other thread beat us to it, so let's clean up ours.
+ delete tmpMutex;
+ }
+ else
+ {
+ //
+ // the thread who creates the mutex succesfully, to
+ // initialize the followings
+ //
+ setUpAttributes();
+ setUpValidators();
+
+ RefVectorOf<AttributeInfo>* attList = 0;
+ int prefixContext = globalPrefix;
+
+ fElementMap = new RefHash2KeysTableOf<RefVectorOfAttributeInfo>(25);
+
+ // element "attribute" - global
+ attList = new RefVectorOf<AttributeInfo>(5, false);
+ attList->addElement(fAttributes[Att_Default_N]);
+ attList->addElement(fAttributes[Att_Fixed_N]);
+ attList->addElement(fAttributes[Att_ID_N]);
+ attList->addElement(fAttributes[Att_Name_R]);
+ attList->addElement(fAttributes[Att_Type_N]);
+ fElementMap->put((void*) SchemaSymbols::fgELT_ATTRIBUTE, prefixContext, attList);
+
+ // element "element" - global
+ attList = new RefVectorOf<AttributeInfo>(10, false);
+ attList->addElement(fAttributes[Att_Abstract_D]);
+ attList->addElement(fAttributes[Att_Block_N]);
+ attList->addElement(fAttributes[Att_Default_N]);
+ attList->addElement(fAttributes[Att_Final_N]);
+ attList->addElement(fAttributes[Att_Fixed_N]);
+ attList->addElement(fAttributes[Att_ID_N]);
+ attList->addElement(fAttributes[Att_Name_R]);
+ attList->addElement(fAttributes[Att_Nillable_D]);
+ attList->addElement(fAttributes[Att_Substitution_G_N]);
+ attList->addElement(fAttributes[Att_Type_N]);
+ fElementMap->put((void*) SchemaSymbols::fgELT_ELEMENT, prefixContext, attList);
+
+ // element "complexType" - global
+ attList = new RefVectorOf<AttributeInfo>(6, false);
+ attList->addElement(fAttributes[Att_Abstract_D]);
+ attList->addElement(fAttributes[Att_Block1_N]);
+ attList->addElement(fAttributes[Att_Final_N]);
+ attList->addElement(fAttributes[Att_ID_N]);
+ attList->addElement(fAttributes[Att_Mixed_D]);
+ attList->addElement(fAttributes[Att_Name_R]);
+ fElementMap->put((void*) SchemaSymbols::fgELT_COMPLEXTYPE, prefixContext, attList);
+
+ // element "simpleType" - global
+ attList = new RefVectorOf<AttributeInfo>(3, false);
+ attList->addElement(fAttributes[Att_Final1_N]);
+ attList->addElement(fAttributes[Att_ID_N]);
+ attList->addElement(fAttributes[Att_Name_R]);
+ fElementMap->put((void*) SchemaSymbols::fgELT_SIMPLETYPE, prefixContext, attList);
+
+ // element "schema" - global
+ attList = new RefVectorOf<AttributeInfo>(7, false);
+ attList->addElement(fAttributes[Att_Attribute_FD_D]);
+ attList->addElement(fAttributes[Att_Block_D_D]);
+ attList->addElement(fAttributes[Att_Element_FD_D]);
+ attList->addElement(fAttributes[Att_Final_D_D]);
+ attList->addElement(fAttributes[Att_ID_N]);
+ attList->addElement(fAttributes[Att_Target_N_N]);
+ attList->addElement(fAttributes[Att_Version_N]);
+ // xml:lang = language ???
+ fElementMap->put((void*) SchemaSymbols::fgELT_SCHEMA, prefixContext, attList);
+
+ // element "include" - global
+ attList = new RefVectorOf<AttributeInfo>(2, false);
+ attList->addElement(fAttributes[Att_ID_N]);
+ attList->addElement(fAttributes[Att_Schema_L_R]);
+ fElementMap->put((void*) SchemaSymbols::fgELT_INCLUDE, prefixContext, attList);
+
+ // element "import" - global
+ attList = new RefVectorOf<AttributeInfo>(3, false);
+ attList->addElement(fAttributes[Att_ID_N]);
+ attList->addElement(fAttributes[Att_Namespace_N]);
+ attList->addElement(fAttributes[Att_Schema_L_N]);
+ fElementMap->put((void*) SchemaSymbols::fgELT_IMPORT, prefixContext, attList);
+
+ // for element "redefine" - global (same as include)
+ attList = new RefVectorOf<AttributeInfo>(2, false);
+ attList->addElement(fAttributes[Att_ID_N]);
+ attList->addElement(fAttributes[Att_Schema_L_R]);
+ fElementMap->put((void*) SchemaSymbols::fgELT_REDEFINE, prefixContext, attList);
+
+
+ // element "attributeGroup" - global
+ attList = new RefVectorOf<AttributeInfo>(2, false);
+ attList->addElement(fAttributes[Att_ID_N]);
+ attList->addElement(fAttributes[Att_Name_R]);
+ fElementMap->put((void*) SchemaSymbols::fgELT_ATTRIBUTEGROUP, prefixContext, attList);
+
+ // element "group" - global
+ attList = new RefVectorOf<AttributeInfo>(2, false);
+ attList->addElement(fAttributes[Att_ID_N]);
+ attList->addElement(fAttributes[Att_Name_R]);
+ fElementMap->put((void*) SchemaSymbols::fgELT_GROUP, prefixContext, attList);
+
+ // element "annotation" - global
+ attList = new RefVectorOf<AttributeInfo>(1, false);
+ attList->addElement(fAttributes[Att_ID_N]);
+ fElementMap->put((void*) SchemaSymbols::fgELT_ANNOTATION, prefixContext, attList);
+
+ // element "notation" - global
+ attList = new RefVectorOf<AttributeInfo>(4, false);
+ attList->addElement(fAttributes[Att_ID_N]);
+ attList->addElement(fAttributes[Att_Name_R]);
+ attList->addElement(fAttributes[Att_Public_R]);
+ attList->addElement(fAttributes[Att_System_N]);
+ fElementMap->put((void*) SchemaSymbols::fgELT_NOTATION, prefixContext, attList);
- setUpAttributes();
- setUpValidators();
+ // element "attribute" - local ref
+ prefixContext = localRefPrefix;
+ attList = new RefVectorOf<AttributeInfo>(5, false);
+ attList->addElement(fAttributes[Att_Default_N]);
+ attList->addElement(fAttributes[Att_Fixed_N]);
+ attList->addElement(fAttributes[Att_ID_N]);
+ attList->addElement(fAttributes[Att_Ref_R]);
+ attList->addElement(fAttributes[Att_Use_D]);
+ fElementMap->put((void*) SchemaSymbols::fgELT_ATTRIBUTE, prefixContext, attList);
+
+ // element "element" - local ref
+ attList = new RefVectorOf<AttributeInfo>(4, false);
+ attList->addElement(fAttributes[Att_ID_N]);
+ attList->addElement(fAttributes[Att_MaxOccurs_D]);
+ attList->addElement(fAttributes[Att_MinOccurs_D]);
+ attList->addElement(fAttributes[Att_Ref_R]);
+ fElementMap->put((void*) SchemaSymbols::fgELT_ELEMENT, prefixContext, attList);
+
+ // element "attributeGroup" - local ref
+ attList = new RefVectorOf<AttributeInfo>(2, false);
+ attList->addElement(fAttributes[Att_ID_N]);
+ attList->addElement(fAttributes[Att_Ref_R]);
+ fElementMap->put((void*) SchemaSymbols::fgELT_ATTRIBUTEGROUP, prefixContext, attList);
+
+ // element "group" - local ref
+ attList = new RefVectorOf<AttributeInfo>(4, false);
+ attList->addElement(fAttributes[Att_ID_N]);
+ attList->addElement(fAttributes[Att_MaxOccurs_D]);
+ attList->addElement(fAttributes[Att_MinOccurs_D]);
+ attList->addElement(fAttributes[Att_Ref_R]);
+ fElementMap->put((void*) SchemaSymbols::fgELT_GROUP, prefixContext, attList);
- RefVectorOf<AttributeInfo>* attList = 0;
- int prefixContext = globalPrefix;
+ // element "attribute" - local name
+ prefixContext = localNamePrefix;
+ attList = new RefVectorOf<AttributeInfo>(7, false);
+ attList->addElement(fAttributes[Att_Default_N]);
+ attList->addElement(fAttributes[Att_Fixed_N]);
+ attList->addElement(fAttributes[Att_Form_N]);
+ attList->addElement(fAttributes[Att_ID_N]);
+ attList->addElement(fAttributes[Att_Name_R]);
+ attList->addElement(fAttributes[Att_Type_N]);
+ attList->addElement(fAttributes[Att_Use_D]);
+ fElementMap->put((void*) SchemaSymbols::fgELT_ATTRIBUTE, prefixContext, attList);
+
+ // for element "element" - local name
+ attList = new RefVectorOf<AttributeInfo>(10, false);
+ attList->addElement(fAttributes[Att_Block_N]);
+ attList->addElement(fAttributes[Att_Default_N]);
+ attList->addElement(fAttributes[Att_Fixed_N]);
+ attList->addElement(fAttributes[Att_Form_N]);
+ attList->addElement(fAttributes[Att_ID_N]);
+ attList->addElement(fAttributes[Att_MaxOccurs_D]);
+ attList->addElement(fAttributes[Att_MinOccurs_D]);
+ attList->addElement(fAttributes[Att_Name_R]);
+ attList->addElement(fAttributes[Att_Nillable_D]);
+ attList->addElement(fAttributes[Att_Type_N]);
+ fElementMap->put((void*) SchemaSymbols::fgELT_ELEMENT, prefixContext, attList);
- fElementMap = new RefHash2KeysTableOf<RefVectorOfAttributeInfo>(25);
+ // element "complexType" - local name
+ prefixContext = localNamePrefix;
+ attList = new RefVectorOf<AttributeInfo>(2, false);
+ attList->addElement(fAttributes[Att_ID_N]);
+ attList->addElement(fAttributes[Att_Mixed_D]);
+ fElementMap->put((void*) SchemaSymbols::fgELT_COMPLEXTYPE, prefixContext, attList);
+
+ // element "simpleContent" - local name
+ attList = new RefVectorOf<AttributeInfo>(1, false);
+ attList->addElement(fAttributes[Att_ID_N]);
+ fElementMap->put((void*) SchemaSymbols::fgELT_SIMPLECONTENT, prefixContext, attList);
+
+ // element "restriction" - local name
+ attList = new RefVectorOf<AttributeInfo>(2, false);
+ attList->addElement(fAttributes[Att_Base_N]);
+ attList->addElement(fAttributes[Att_ID_N]);
+ fElementMap->put((void*) SchemaSymbols::fgELT_RESTRICTION, prefixContext, attList);
+
+ // element "extension" - local name
+ attList = new RefVectorOf<AttributeInfo>(2, false);
+ attList->addElement(fAttributes[Att_Base_R]);
+ attList->addElement(fAttributes[Att_ID_N]);
+ fElementMap->put((void*) SchemaSymbols::fgELT_EXTENSION, prefixContext, attList);
+
+ // element "anyAttribute" - local name
+ attList = new RefVectorOf<AttributeInfo>(3, false);
+ attList->addElement(fAttributes[Att_ID_N]);
+ attList->addElement(fAttributes[Att_Namespace_D]);
+ attList->addElement(fAttributes[Att_Process_C_D]);
+ fElementMap->put((void*) SchemaSymbols::fgELT_ANYATTRIBUTE, prefixContext, attList);
+
+ // element "complexContent" - local name
+ attList = new RefVectorOf<AttributeInfo>(2, false);
+ attList->addElement(fAttributes[Att_ID_N]);
+ attList->addElement(fAttributes[Att_Mixed_N]);
+ fElementMap->put((void*) SchemaSymbols::fgELT_COMPLEXCONTENT, prefixContext, attList);
+
+ // element "choice" - local name
+ attList = new RefVectorOf<AttributeInfo>(3, false);
+ attList->addElement(fAttributes[Att_ID_N]);
+ attList->addElement(fAttributes[Att_MaxOccurs_D]);
+ attList->addElement(fAttributes[Att_MinOccurs_D]);
+ fElementMap->put((void*) SchemaSymbols::fgELT_CHOICE, prefixContext, attList);
+
+ // element "sequence" - local name
+ attList = new RefVectorOf<AttributeInfo>(3, false);
+ attList->addElement(fAttributes[Att_ID_N]);
+ attList->addElement(fAttributes[Att_MaxOccurs_D]);
+ attList->addElement(fAttributes[Att_MinOccurs_D]);
+ fElementMap->put((void*) SchemaSymbols::fgELT_SEQUENCE, prefixContext, attList);
+
+ // for element "any" - local name
+ attList = new RefVectorOf<AttributeInfo>(5, false);
+ attList->addElement(fAttributes[Att_ID_N]);
+ attList->addElement(fAttributes[Att_MaxOccurs_D]);
+ attList->addElement(fAttributes[Att_MinOccurs_D]);
+ attList->addElement(fAttributes[Att_Namespace_D]);
+ attList->addElement(fAttributes[Att_Process_C_D]);
+ fElementMap->put((void*) SchemaSymbols::fgELT_ANY, prefixContext, attList);
+
+ // element "simpleType" - local name
+ attList = new RefVectorOf<AttributeInfo>(2, false);
+ attList->addElement(fAttributes[Att_Final1_N]);
+ attList->addElement(fAttributes[Att_ID_N]);
+ fElementMap->put((void*) SchemaSymbols::fgELT_SIMPLETYPE, prefixContext, attList);
+
+ // element "list" - local name
+ attList = new RefVectorOf<AttributeInfo>(2, false);
+ attList->addElement(fAttributes[Att_ID_N]);
+ attList->addElement(fAttributes[Att_ItemType_N]);
+ fElementMap->put((void*) SchemaSymbols::fgELT_LIST, prefixContext, attList);
+
+ // element "union" - local name
+ attList = new RefVectorOf<AttributeInfo>(2, false);
+ attList->addElement(fAttributes[Att_ID_N]);
+ attList->addElement(fAttributes[Att_Member_T_N]);
+ fElementMap->put((void*) SchemaSymbols::fgELT_UNION, prefixContext, attList);
+
+ // element "length" - local name
+ attList = new RefVectorOf<AttributeInfo>(3, false);
+ attList->addElement(fAttributes[Att_ID_N]);
+ attList->addElement(fAttributes[Att_Value_NNI_N]);
+ attList->addElement(fAttributes[Att_Fixed_D]);
+ fElementMap->put((void*) SchemaSymbols::fgELT_LENGTH, prefixContext, attList);
+
+ // element "minLength" - local name
+ attList = new RefVectorOf<AttributeInfo>(3, false);
+ attList->addElement(fAttributes[Att_ID_N]);
+ attList->addElement(fAttributes[Att_Value_NNI_N]);
+ attList->addElement(fAttributes[Att_Fixed_D]);
+ fElementMap->put((void*) SchemaSymbols::fgELT_MINLENGTH, prefixContext, attList);
+
+ // element "maxLength" - local name
+ attList = new RefVectorOf<AttributeInfo>(3, false);
+ attList->addElement(fAttributes[Att_ID_N]);
+ attList->addElement(fAttributes[Att_Value_NNI_N]);
+ attList->addElement(fAttributes[Att_Fixed_D]);
+ fElementMap->put((void*) SchemaSymbols::fgELT_MAXLENGTH, prefixContext, attList);
+
+ // element "totalDigits" - local name
+ attList = new RefVectorOf<AttributeInfo>(3, false);
+ attList->addElement(fAttributes[Att_ID_N]);
+ attList->addElement(fAttributes[Att_Value_NNI_N]);
+ attList->addElement(fAttributes[Att_Fixed_D]);
+ fElementMap->put((void*) SchemaSymbols::fgELT_TOTALDIGITS, prefixContext, attList);
+
+ // element "fractionDigits" - local name
+ attList = new RefVectorOf<AttributeInfo>(3, false);
+ attList->addElement(fAttributes[Att_ID_N]);
+ attList->addElement(fAttributes[Att_Value_NNI_N]);
+ attList->addElement(fAttributes[Att_Fixed_D]);
+ fElementMap->put((void*) SchemaSymbols::fgELT_FRACTIONDIGITS, prefixContext, attList);
+
+ // element "pattern" - local name
+ attList = new RefVectorOf<AttributeInfo>(2, false);
+ attList->addElement(fAttributes[Att_ID_N]);
+ attList->addElement(fAttributes[Att_Value_STR_N]);
+ fElementMap->put((void*) SchemaSymbols::fgELT_PATTERN, prefixContext, attList);
+
+ // element "enumeration" - local name
+ attList = new RefVectorOf<AttributeInfo>(2, false);
+ attList->addElement(fAttributes[Att_ID_N]);
+ attList->addElement(fAttributes[Att_Value_STR_N]);
+ fElementMap->put((void*) SchemaSymbols::fgELT_ENUMERATION, prefixContext, attList);
+
+ // element "whiteSpace" - local name
+ attList = new RefVectorOf<AttributeInfo>(3, false);
+ attList->addElement(fAttributes[Att_ID_N]);
+ attList->addElement(fAttributes[Att_Value_WS_N]);
+ attList->addElement(fAttributes[Att_Fixed_D]);
+ fElementMap->put((void*) SchemaSymbols::fgELT_WHITESPACE, prefixContext, attList);
+
+ // element "maxInclusive" - local name
+ attList = new RefVectorOf<AttributeInfo>(3, false);
+ attList->addElement(fAttributes[Att_ID_N]);
+ attList->addElement(fAttributes[Att_Value_STR_N]);
+ attList->addElement(fAttributes[Att_Fixed_D]);
+ fElementMap->put((void*) SchemaSymbols::fgELT_MAXINCLUSIVE, prefixContext, attList);
+
+ // element "maxExclusive" - local name
+ attList = new RefVectorOf<AttributeInfo>(3, false);
+ attList->addElement(fAttributes[Att_ID_N]);
+ attList->addElement(fAttributes[Att_Value_STR_N]);
+ attList->addElement(fAttributes[Att_Fixed_D]);
+ fElementMap->put((void*) SchemaSymbols::fgELT_MAXEXCLUSIVE, prefixContext, attList);
+
+ // for element "minInclusive" - local name
+ attList = new RefVectorOf<AttributeInfo>(3, false);
+ attList->addElement(fAttributes[Att_ID_N]);
+ attList->addElement(fAttributes[Att_Value_STR_N]);
+ attList->addElement(fAttributes[Att_Fixed_D]);
+ fElementMap->put((void*) SchemaSymbols::fgELT_MININCLUSIVE, prefixContext, attList);
+
+ // for element "minExclusive" - local name
+ attList = new RefVectorOf<AttributeInfo>(3, false);
+ attList->addElement(fAttributes[Att_ID_N]);
+ attList->addElement(fAttributes[Att_Value_STR_N]);
+ attList->addElement(fAttributes[Att_Fixed_D]);
+ fElementMap->put((void*) SchemaSymbols::fgELT_MINEXCLUSIVE, prefixContext, attList);
+
+ // element "all" - local name
+ attList = new RefVectorOf<AttributeInfo>(3, false);
+ attList->addElement(fAttributes[Att_ID_N]);
+ attList->addElement(fAttributes[Att_MaxOccurs1_D]);
+ attList->addElement(fAttributes[Att_MinOccurs1_D]);
+ fElementMap->put((void*) SchemaSymbols::fgELT_ALL, prefixContext, attList);
+
+ // element "annotation" - local name
+ attList = new RefVectorOf<AttributeInfo>(1, false);
+ attList->addElement(fAttributes[Att_ID_N]);
+ fElementMap->put((void*) SchemaSymbols::fgELT_ANNOTATION, prefixContext, attList);
+
+ // element "appinfo" - local name
+ attList = new RefVectorOf<AttributeInfo>(1, false);
+ attList->addElement(fAttributes[Att_Source_N]);
+ fElementMap->put((void*) SchemaSymbols::fgELT_APPINFO, prefixContext, attList);
+
+ // element "documentation" - local name
+ attList = new RefVectorOf<AttributeInfo>(1, false);
+ attList->addElement(fAttributes[Att_Source_N]);
+ // xml:lang = language ???
+ fElementMap->put((void*) SchemaSymbols::fgELT_DOCUMENTATION, prefixContext, attList);
+
+ // element "unique" - local name
+ attList = new RefVectorOf<AttributeInfo>(2, false);
+ attList->addElement(fAttributes[Att_ID_N]);
+ attList->addElement(fAttributes[Att_Name_R]);
+ fElementMap->put((void*) SchemaSymbols::fgELT_UNIQUE, prefixContext, attList);
+
+ // element "key" - local name
+ attList = new RefVectorOf<AttributeInfo>(2, false);
+ attList->addElement(fAttributes[Att_ID_N]);
+ attList->addElement(fAttributes[Att_Name_R]);
+ fElementMap->put((void*) SchemaSymbols::fgELT_KEY, prefixContext, attList);
+
+ // element "keyref" - local name
+ attList = new RefVectorOf<AttributeInfo>(3, false);
+ attList->addElement(fAttributes[Att_ID_N]);
+ attList->addElement(fAttributes[Att_Name_R]);
+ attList->addElement(fAttributes[Att_Refer_R]);
+ fElementMap->put((void*) SchemaSymbols::fgELT_KEYREF, prefixContext, attList);
+
+ // element "selector" - local name
+ attList = new RefVectorOf<AttributeInfo>(2, false);
+ attList->addElement(fAttributes[Att_ID_N]);
+ attList->addElement(fAttributes[Att_XPath_R]);
+ fElementMap->put((void*) SchemaSymbols::fgELT_SELECTOR, prefixContext, attList);
+
+ // element "field" - local name
+ attList = new RefVectorOf<AttributeInfo>(2, false);
+ attList->addElement(fAttributes[Att_ID_N]);
+ attList->addElement(fAttributes[Att_XPath1_R]);
+ fElementMap->put((void*) SchemaSymbols::fgELT_FIELD, prefixContext, attList);
- // element "attribute" - global
- attList = new RefVectorOf<AttributeInfo>(5, false);
- attList->addElement(fAttributes[Att_Default_N]);
- attList->addElement(fAttributes[Att_Fixed_N]);
- attList->addElement(fAttributes[Att_ID_N]);
- attList->addElement(fAttributes[Att_Name_R]);
- attList->addElement(fAttributes[Att_Type_N]);
- fElementMap->put((void*) SchemaSymbols::fgELT_ATTRIBUTE, prefixContext, attList);
-
- // element "element" - global
- attList = new RefVectorOf<AttributeInfo>(10, false);
- attList->addElement(fAttributes[Att_Abstract_D]);
- attList->addElement(fAttributes[Att_Block_N]);
- attList->addElement(fAttributes[Att_Default_N]);
- attList->addElement(fAttributes[Att_Final_N]);
- attList->addElement(fAttributes[Att_Fixed_N]);
- attList->addElement(fAttributes[Att_ID_N]);
- attList->addElement(fAttributes[Att_Name_R]);
- attList->addElement(fAttributes[Att_Nillable_D]);
- attList->addElement(fAttributes[Att_Substitution_G_N]);
- attList->addElement(fAttributes[Att_Type_N]);
- fElementMap->put((void*) SchemaSymbols::fgELT_ELEMENT, prefixContext, attList);
-
- // element "complexType" - global
- attList = new RefVectorOf<AttributeInfo>(6, false);
- attList->addElement(fAttributes[Att_Abstract_D]);
- attList->addElement(fAttributes[Att_Block1_N]);
- attList->addElement(fAttributes[Att_Final_N]);
- attList->addElement(fAttributes[Att_ID_N]);
- attList->addElement(fAttributes[Att_Mixed_D]);
- attList->addElement(fAttributes[Att_Name_R]);
- fElementMap->put((void*) SchemaSymbols::fgELT_COMPLEXTYPE, prefixContext, attList);
-
- // element "simpleType" - global
- attList = new RefVectorOf<AttributeInfo>(3, false);
- attList->addElement(fAttributes[Att_Final1_N]);
- attList->addElement(fAttributes[Att_ID_N]);
- attList->addElement(fAttributes[Att_Name_R]);
- fElementMap->put((void*) SchemaSymbols::fgELT_SIMPLETYPE, prefixContext, attList);
-
- // element "schema" - global
- attList = new RefVectorOf<AttributeInfo>(7, false);
- attList->addElement(fAttributes[Att_Attribute_FD_D]);
- attList->addElement(fAttributes[Att_Block_D_D]);
- attList->addElement(fAttributes[Att_Element_FD_D]);
- attList->addElement(fAttributes[Att_Final_D_D]);
- attList->addElement(fAttributes[Att_ID_N]);
- attList->addElement(fAttributes[Att_Target_N_N]);
- attList->addElement(fAttributes[Att_Version_N]);
- // xml:lang = language ???
- fElementMap->put((void*) SchemaSymbols::fgELT_SCHEMA, prefixContext, attList);
-
- // element "include" - global
- attList = new RefVectorOf<AttributeInfo>(2, false);
- attList->addElement(fAttributes[Att_ID_N]);
- attList->addElement(fAttributes[Att_Schema_L_R]);
- fElementMap->put((void*) SchemaSymbols::fgELT_INCLUDE, prefixContext, attList);
-
- // element "import" - global
- attList = new RefVectorOf<AttributeInfo>(3, false);
- attList->addElement(fAttributes[Att_ID_N]);
- attList->addElement(fAttributes[Att_Namespace_N]);
- attList->addElement(fAttributes[Att_Schema_L_N]);
- fElementMap->put((void*) SchemaSymbols::fgELT_IMPORT, prefixContext, attList);
-
- // for element "redefine" - global (same as include)
- attList = new RefVectorOf<AttributeInfo>(2, false);
- attList->addElement(fAttributes[Att_ID_N]);
- attList->addElement(fAttributes[Att_Schema_L_R]);
- fElementMap->put((void*) SchemaSymbols::fgELT_REDEFINE, prefixContext, attList);
-
-
- // element "attributeGroup" - global
- attList = new RefVectorOf<AttributeInfo>(2, false);
- attList->addElement(fAttributes[Att_ID_N]);
- attList->addElement(fAttributes[Att_Name_R]);
- fElementMap->put((void*) SchemaSymbols::fgELT_ATTRIBUTEGROUP, prefixContext, attList);
-
- // element "group" - global
- attList = new RefVectorOf<AttributeInfo>(2, false);
- attList->addElement(fAttributes[Att_ID_N]);
- attList->addElement(fAttributes[Att_Name_R]);
- fElementMap->put((void*) SchemaSymbols::fgELT_GROUP, prefixContext, attList);
-
- // element "annotation" - global
- attList = new RefVectorOf<AttributeInfo>(1, false);
- attList->addElement(fAttributes[Att_ID_N]);
- fElementMap->put((void*) SchemaSymbols::fgELT_ANNOTATION, prefixContext, attList);
-
- // element "notation" - global
- attList = new RefVectorOf<AttributeInfo>(4, false);
- attList->addElement(fAttributes[Att_ID_N]);
- attList->addElement(fAttributes[Att_Name_R]);
- attList->addElement(fAttributes[Att_Public_R]);
- attList->addElement(fAttributes[Att_System_N]);
- fElementMap->put((void*) SchemaSymbols::fgELT_NOTATION, prefixContext, attList);
-
- // element "attribute" - local ref
- prefixContext = localRefPrefix;
- attList = new RefVectorOf<AttributeInfo>(5, false);
- attList->addElement(fAttributes[Att_Default_N]);
- attList->addElement(fAttributes[Att_Fixed_N]);
- attList->addElement(fAttributes[Att_ID_N]);
- attList->addElement(fAttributes[Att_Ref_R]);
- attList->addElement(fAttributes[Att_Use_D]);
- fElementMap->put((void*) SchemaSymbols::fgELT_ATTRIBUTE, prefixContext, attList);
-
- // element "element" - local ref
- attList = new RefVectorOf<AttributeInfo>(4, false);
- attList->addElement(fAttributes[Att_ID_N]);
- attList->addElement(fAttributes[Att_MaxOccurs_D]);
- attList->addElement(fAttributes[Att_MinOccurs_D]);
- attList->addElement(fAttributes[Att_Ref_R]);
- fElementMap->put((void*) SchemaSymbols::fgELT_ELEMENT, prefixContext, attList);
-
- // element "attributeGroup" - local ref
- attList = new RefVectorOf<AttributeInfo>(2, false);
- attList->addElement(fAttributes[Att_ID_N]);
- attList->addElement(fAttributes[Att_Ref_R]);
- fElementMap->put((void*) SchemaSymbols::fgELT_ATTRIBUTEGROUP, prefixContext, attList);
-
- // element "group" - local ref
- attList = new RefVectorOf<AttributeInfo>(4, false);
- attList->addElement(fAttributes[Att_ID_N]);
- attList->addElement(fAttributes[Att_MaxOccurs_D]);
- attList->addElement(fAttributes[Att_MinOccurs_D]);
- attList->addElement(fAttributes[Att_Ref_R]);
- fElementMap->put((void*) SchemaSymbols::fgELT_GROUP, prefixContext, attList);
-
- // element "attribute" - local name
- prefixContext = localNamePrefix;
- attList = new RefVectorOf<AttributeInfo>(7, false);
- attList->addElement(fAttributes[Att_Default_N]);
- attList->addElement(fAttributes[Att_Fixed_N]);
- attList->addElement(fAttributes[Att_Form_N]);
- attList->addElement(fAttributes[Att_ID_N]);
- attList->addElement(fAttributes[Att_Name_R]);
- attList->addElement(fAttributes[Att_Type_N]);
- attList->addElement(fAttributes[Att_Use_D]);
- fElementMap->put((void*) SchemaSymbols::fgELT_ATTRIBUTE, prefixContext, attList);
-
- // for element "element" - local name
- attList = new RefVectorOf<AttributeInfo>(10, false);
- attList->addElement(fAttributes[Att_Block_N]);
- attList->addElement(fAttributes[Att_Default_N]);
- attList->addElement(fAttributes[Att_Fixed_N]);
- attList->addElement(fAttributes[Att_Form_N]);
- attList->addElement(fAttributes[Att_ID_N]);
- attList->addElement(fAttributes[Att_MaxOccurs_D]);
- attList->addElement(fAttributes[Att_MinOccurs_D]);
- attList->addElement(fAttributes[Att_Name_R]);
- attList->addElement(fAttributes[Att_Nillable_D]);
- attList->addElement(fAttributes[Att_Type_N]);
- fElementMap->put((void*) SchemaSymbols::fgELT_ELEMENT, prefixContext, attList);
-
- // element "complexType" - local name
- prefixContext = localNamePrefix;
- attList = new RefVectorOf<AttributeInfo>(2, false);
- attList->addElement(fAttributes[Att_ID_N]);
- attList->addElement(fAttributes[Att_Mixed_D]);
- fElementMap->put((void*) SchemaSymbols::fgELT_COMPLEXTYPE, prefixContext, attList);
-
- // element "simpleContent" - local name
- attList = new RefVectorOf<AttributeInfo>(1, false);
- attList->addElement(fAttributes[Att_ID_N]);
- fElementMap->put((void*) SchemaSymbols::fgELT_SIMPLECONTENT, prefixContext, attList);
-
- // element "restriction" - local name
- attList = new RefVectorOf<AttributeInfo>(2, false);
- attList->addElement(fAttributes[Att_Base_N]);
- attList->addElement(fAttributes[Att_ID_N]);
- fElementMap->put((void*) SchemaSymbols::fgELT_RESTRICTION, prefixContext, attList);
-
- // element "extension" - local name
- attList = new RefVectorOf<AttributeInfo>(2, false);
- attList->addElement(fAttributes[Att_Base_R]);
- attList->addElement(fAttributes[Att_ID_N]);
- fElementMap->put((void*) SchemaSymbols::fgELT_EXTENSION, prefixContext, attList);
-
- // element "anyAttribute" - local name
- attList = new RefVectorOf<AttributeInfo>(3, false);
- attList->addElement(fAttributes[Att_ID_N]);
- attList->addElement(fAttributes[Att_Namespace_D]);
- attList->addElement(fAttributes[Att_Process_C_D]);
- fElementMap->put((void*) SchemaSymbols::fgELT_ANYATTRIBUTE, prefixContext, attList);
-
- // element "complexContent" - local name
- attList = new RefVectorOf<AttributeInfo>(2, false);
- attList->addElement(fAttributes[Att_ID_N]);
- attList->addElement(fAttributes[Att_Mixed_N]);
- fElementMap->put((void*) SchemaSymbols::fgELT_COMPLEXCONTENT, prefixContext, attList);
-
- // element "choice" - local name
- attList = new RefVectorOf<AttributeInfo>(3, false);
- attList->addElement(fAttributes[Att_ID_N]);
- attList->addElement(fAttributes[Att_MaxOccurs_D]);
- attList->addElement(fAttributes[Att_MinOccurs_D]);
- fElementMap->put((void*) SchemaSymbols::fgELT_CHOICE, prefixContext, attList);
-
- // element "sequence" - local name
- attList = new RefVectorOf<AttributeInfo>(3, false);
- attList->addElement(fAttributes[Att_ID_N]);
- attList->addElement(fAttributes[Att_MaxOccurs_D]);
- attList->addElement(fAttributes[Att_MinOccurs_D]);
- fElementMap->put((void*) SchemaSymbols::fgELT_SEQUENCE, prefixContext, attList);
-
- // for element "any" - local name
- attList = new RefVectorOf<AttributeInfo>(5, false);
- attList->addElement(fAttributes[Att_ID_N]);
- attList->addElement(fAttributes[Att_MaxOccurs_D]);
- attList->addElement(fAttributes[Att_MinOccurs_D]);
- attList->addElement(fAttributes[Att_Namespace_D]);
- attList->addElement(fAttributes[Att_Process_C_D]);
- fElementMap->put((void*) SchemaSymbols::fgELT_ANY, prefixContext, attList);
-
- // element "simpleType" - local name
- attList = new RefVectorOf<AttributeInfo>(2, false);
- attList->addElement(fAttributes[Att_Final1_N]);
- attList->addElement(fAttributes[Att_ID_N]);
- fElementMap->put((void*) SchemaSymbols::fgELT_SIMPLETYPE, prefixContext, attList);
-
- // element "list" - local name
- attList = new RefVectorOf<AttributeInfo>(2, false);
- attList->addElement(fAttributes[Att_ID_N]);
- attList->addElement(fAttributes[Att_ItemType_N]);
- fElementMap->put((void*) SchemaSymbols::fgELT_LIST, prefixContext, attList);
-
- // element "union" - local name
- attList = new RefVectorOf<AttributeInfo>(2, false);
- attList->addElement(fAttributes[Att_ID_N]);
- attList->addElement(fAttributes[Att_Member_T_N]);
- fElementMap->put((void*) SchemaSymbols::fgELT_UNION, prefixContext, attList);
-
- // element "length" - local name
- attList = new RefVectorOf<AttributeInfo>(3, false);
- attList->addElement(fAttributes[Att_ID_N]);
- attList->addElement(fAttributes[Att_Value_NNI_N]);
- attList->addElement(fAttributes[Att_Fixed_D]);
- fElementMap->put((void*) SchemaSymbols::fgELT_LENGTH, prefixContext, attList);
-
- // element "minLength" - local name
- attList = new RefVectorOf<AttributeInfo>(3, false);
- attList->addElement(fAttributes[Att_ID_N]);
- attList->addElement(fAttributes[Att_Value_NNI_N]);
- attList->addElement(fAttributes[Att_Fixed_D]);
- fElementMap->put((void*) SchemaSymbols::fgELT_MINLENGTH, prefixContext, attList);
-
- // element "maxLength" - local name
- attList = new RefVectorOf<AttributeInfo>(3, false);
- attList->addElement(fAttributes[Att_ID_N]);
- attList->addElement(fAttributes[Att_Value_NNI_N]);
- attList->addElement(fAttributes[Att_Fixed_D]);
- fElementMap->put((void*) SchemaSymbols::fgELT_MAXLENGTH, prefixContext, attList);
-
- // element "totalDigits" - local name
- attList = new RefVectorOf<AttributeInfo>(3, false);
- attList->addElement(fAttributes[Att_ID_N]);
- attList->addElement(fAttributes[Att_Value_NNI_N]);
- attList->addElement(fAttributes[Att_Fixed_D]);
- fElementMap->put((void*) SchemaSymbols::fgELT_TOTALDIGITS, prefixContext, attList);
-
- // element "fractionDigits" - local name
- attList = new RefVectorOf<AttributeInfo>(3, false);
- attList->addElement(fAttributes[Att_ID_N]);
- attList->addElement(fAttributes[Att_Value_NNI_N]);
- attList->addElement(fAttributes[Att_Fixed_D]);
- fElementMap->put((void*) SchemaSymbols::fgELT_FRACTIONDIGITS, prefixContext, attList);
-
- // element "pattern" - local name
- attList = new RefVectorOf<AttributeInfo>(2, false);
- attList->addElement(fAttributes[Att_ID_N]);
- attList->addElement(fAttributes[Att_Value_STR_N]);
- fElementMap->put((void*) SchemaSymbols::fgELT_PATTERN, prefixContext, attList);
-
- // element "enumeration" - local name
- attList = new RefVectorOf<AttributeInfo>(2, false);
- attList->addElement(fAttributes[Att_ID_N]);
- attList->addElement(fAttributes[Att_Value_STR_N]);
- fElementMap->put((void*) SchemaSymbols::fgELT_ENUMERATION, prefixContext, attList);
-
- // element "whiteSpace" - local name
- attList = new RefVectorOf<AttributeInfo>(3, false);
- attList->addElement(fAttributes[Att_ID_N]);
- attList->addElement(fAttributes[Att_Value_WS_N]);
- attList->addElement(fAttributes[Att_Fixed_D]);
- fElementMap->put((void*) SchemaSymbols::fgELT_WHITESPACE, prefixContext, attList);
-
- // element "maxInclusive" - local name
- attList = new RefVectorOf<AttributeInfo>(3, false);
- attList->addElement(fAttributes[Att_ID_N]);
- attList->addElement(fAttributes[Att_Value_STR_N]);
- attList->addElement(fAttributes[Att_Fixed_D]);
- fElementMap->put((void*) SchemaSymbols::fgELT_MAXINCLUSIVE, prefixContext, attList);
-
- // element "maxExclusive" - local name
- attList = new RefVectorOf<AttributeInfo>(3, false);
- attList->addElement(fAttributes[Att_ID_N]);
- attList->addElement(fAttributes[Att_Value_STR_N]);
- attList->addElement(fAttributes[Att_Fixed_D]);
- fElementMap->put((void*) SchemaSymbols::fgELT_MAXEXCLUSIVE, prefixContext, attList);
-
- // for element "minInclusive" - local name
- attList = new RefVectorOf<AttributeInfo>(3, false);
- attList->addElement(fAttributes[Att_ID_N]);
- attList->addElement(fAttributes[Att_Value_STR_N]);
- attList->addElement(fAttributes[Att_Fixed_D]);
- fElementMap->put((void*) SchemaSymbols::fgELT_MININCLUSIVE, prefixContext, attList);
-
- // for element "minExclusive" - local name
- attList = new RefVectorOf<AttributeInfo>(3, false);
- attList->addElement(fAttributes[Att_ID_N]);
- attList->addElement(fAttributes[Att_Value_STR_N]);
- attList->addElement(fAttributes[Att_Fixed_D]);
- fElementMap->put((void*) SchemaSymbols::fgELT_MINEXCLUSIVE, prefixContext, attList);
-
- // element "all" - local name
- attList = new RefVectorOf<AttributeInfo>(3, false);
- attList->addElement(fAttributes[Att_ID_N]);
- attList->addElement(fAttributes[Att_MaxOccurs1_D]);
- attList->addElement(fAttributes[Att_MinOccurs1_D]);
- fElementMap->put((void*) SchemaSymbols::fgELT_ALL, prefixContext, attList);
-
- // element "annotation" - local name
- attList = new RefVectorOf<AttributeInfo>(1, false);
- attList->addElement(fAttributes[Att_ID_N]);
- fElementMap->put((void*) SchemaSymbols::fgELT_ANNOTATION, prefixContext, attList);
-
- // element "appinfo" - local name
- attList = new RefVectorOf<AttributeInfo>(1, false);
- attList->addElement(fAttributes[Att_Source_N]);
- fElementMap->put((void*) SchemaSymbols::fgELT_APPINFO, prefixContext, attList);
-
- // element "documentation" - local name
- attList = new RefVectorOf<AttributeInfo>(1, false);
- attList->addElement(fAttributes[Att_Source_N]);
- // xml:lang = language ???
- fElementMap->put((void*) SchemaSymbols::fgELT_DOCUMENTATION, prefixContext, attList);
-
- // element "unique" - local name
- attList = new RefVectorOf<AttributeInfo>(2, false);
- attList->addElement(fAttributes[Att_ID_N]);
- attList->addElement(fAttributes[Att_Name_R]);
- fElementMap->put((void*) SchemaSymbols::fgELT_UNIQUE, prefixContext, attList);
-
- // element "key" - local name
- attList = new RefVectorOf<AttributeInfo>(2, false);
- attList->addElement(fAttributes[Att_ID_N]);
- attList->addElement(fAttributes[Att_Name_R]);
- fElementMap->put((void*) SchemaSymbols::fgELT_KEY, prefixContext, attList);
-
- // element "keyref" - local name
- attList = new RefVectorOf<AttributeInfo>(3, false);
- attList->addElement(fAttributes[Att_ID_N]);
- attList->addElement(fAttributes[Att_Name_R]);
- attList->addElement(fAttributes[Att_Refer_R]);
- fElementMap->put((void*) SchemaSymbols::fgELT_KEYREF, prefixContext, attList);
-
- // element "selector" - local name
- attList = new RefVectorOf<AttributeInfo>(2, false);
- attList->addElement(fAttributes[Att_ID_N]);
- attList->addElement(fAttributes[Att_XPath_R]);
- fElementMap->put((void*) SchemaSymbols::fgELT_SELECTOR, prefixContext, attList);
-
- // element "field" - local name
- attList = new RefVectorOf<AttributeInfo>(2, false);
- attList->addElement(fAttributes[Att_ID_N]);
- attList->addElement(fAttributes[Att_XPath1_R]);
- fElementMap->put((void*) SchemaSymbols::fgELT_FIELD, prefixContext, attList);
+ // This is the real mutex. Register it for cleanup at Termination.
+ GeneralAttCheckCleanup.registerCleanup(reinitGeneralAttCheck);
+ }
+ }
}
-// ---------------------------------------------------------------------------
-// GeneralAttributeCheck: CleanUp methods
-// ---------------------------------------------------------------------------
-void GeneralAttributeCheck::cleanUp() {
+// -----------------------------------------------------------------------
+// Notification that lazy data has been deleted
+// -----------------------------------------------------------------------
+void
+GeneralAttributeCheck::reinitGeneralAttCheck() {
+
+ delete sGeneralAttCheckMutex;
+ sGeneralAttCheckMutex = 0;
+
for (unsigned int index = 0; index < Att_Count; index++) {
- delete fAttributes[index];
+ delete fAttributes[index];
}
delete [] fAttributes;
delete [] fValidators;
delete fElementMap;
-}
-
-// ---------------------------------------------------------------------------
-// GeneralAttributeCheck: Instance methods
-// ---------------------------------------------------------------------------
-GeneralAttributeCheck* GeneralAttributeCheck::instance() {
- static XMLRegisterCleanup instanceCleanup;
-
- if (!fInstance) {
- GeneralAttributeCheck* t = new GeneralAttributeCheck();
- if (XMLPlatformUtils::compareAndSwap((void **)&fInstance, t, 0) != 0)
- {
- delete t;
- }
- else
- {
- instanceCleanup.registerCleanup(reinitInstance);
- }
-
- }
- return fInstance;
-}
-
-// -----------------------------------------------------------------------
-// Notification that lazy data has been deleted
-// -----------------------------------------------------------------------
-void
-GeneralAttributeCheck::reinitInstance() {
- delete fInstance;
- fInstance = 0;
+
+ fAttributes = 0;
+ fValidators = 0;
+ fElementMap = 0;
}
// ---------------------------------------------------------------------------
@@ -846,7 +847,7 @@
const unsigned short elemContext,
TraverseSchema* const schema) {
- if (elem == 0) {
+ if (elem == 0 || !fElementMap) {
return;
}
@@ -1024,11 +1025,26 @@
case DT_NonNegInt:
dv = fValidators[DT_NonNegInt];
break;
+ case DT_AnyURI:
+ dv = fValidators[DT_AnyURI];
+ break;
+ case DT_ID:
+ dv = fValidators[DT_ID];
+
+ if (!fIDRefList) {
+
+ fIDRefList = new RefHashTableOf<XMLRefInfo>(29);
+ ((IDDatatypeValidator*) dv)->setIDRefList(fIDRefList);
+ }
+ break;
}
if (dv) {
try {
dv->validate(attValue);
+ }
+ catch(const XMLException& excep) {
+ schema->reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::DisplayErrorMessage, excep.getMessage());
}
catch(...) {
isInvalid = true;
1.7 +12 -24 xml-xerces/c/src/validators/schema/GeneralAttributeCheck.hpp
Index: GeneralAttributeCheck.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/validators/schema/GeneralAttributeCheck.hpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- GeneralAttributeCheck.hpp 2001/11/02 14:13:45 1.6
+++ GeneralAttributeCheck.hpp 2001/11/16 15:03:37 1.7
@@ -55,7 +55,7 @@
*/
/*
- * $Id: GeneralAttributeCheck.hpp,v 1.6 2001/11/02 14:13:45 knoaman Exp $
+ * $Id: GeneralAttributeCheck.hpp,v 1.7 2001/11/16 15:03:37 knoaman Exp $
*/
#if !defined(GENERALATTRIBUTECHECK_HPP)
@@ -74,13 +74,14 @@
#include <util/RefHashTableOf.hpp>
#include <util/RefHash2KeysTableOf.hpp>
#include <dom/DOM_Element.hpp>
+#include <validators/datatype/IDDatatypeValidator.hpp>
// ---------------------------------------------------------------------------
// Forward declaration
// ---------------------------------------------------------------------------
class TraverseSchema;
-class DatatypeValidator;
+
class AttributeInfo {
public:
// -----------------------------------------------------------------------
@@ -121,20 +122,16 @@
typedef RefVectorOf<AttributeInfo> RefVectorOfAttributeInfo;
-class GeneralAttributeCheck
+class VALIDATORS_EXPORT GeneralAttributeCheck
{
public:
// -----------------------------------------------------------------------
// Constructor/Destructor
// -----------------------------------------------------------------------
+ GeneralAttributeCheck();
~GeneralAttributeCheck();
// -----------------------------------------------------------------------
- // Instance methods
- // -----------------------------------------------------------------------
- static GeneralAttributeCheck* instance();
-
- // -----------------------------------------------------------------------
// Public Constants
// -----------------------------------------------------------------------
static const unsigned short GlobalContext;
@@ -147,18 +144,13 @@
const unsigned short elemContext,
TraverseSchema* const schema);
- // -----------------------------------------------------------------------
+ // -----------------------------------------------------------------------
// Notification that lazy data has been deleted
// -----------------------------------------------------------------------
- static void reinitInstance();
+ static void reinitGeneralAttCheck();
private:
// -----------------------------------------------------------------------
- // Constructor and destructors
- // -----------------------------------------------------------------------
- GeneralAttributeCheck();
-
- // -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
GeneralAttributeCheck(const GeneralAttributeCheck&);
@@ -172,11 +164,6 @@
void mapElements();
// -----------------------------------------------------------------------
- // CleanUp methods
- // -----------------------------------------------------------------------
- void cleanUp();
-
- // -----------------------------------------------------------------------
// Validation methods
// -----------------------------------------------------------------------
void validate(const XMLCh* const attName, const XMLCh* const attValue,
@@ -286,10 +273,11 @@
// -----------------------------------------------------------------------
// Private data members
// -----------------------------------------------------------------------
- AttributeInfo** fAttributes;
- DatatypeValidator** fValidators;
- RefHash2KeysTableOf<RefVectorOfAttributeInfo>* fElementMap;
- static GeneralAttributeCheck* fInstance;
+ static AttributeInfo** fAttributes;
+ static DatatypeValidator** fValidators;
+ static RefHash2KeysTableOf<RefVectorOfAttributeInfo>* fElementMap;
+ IDDatatypeValidator fIDValidator;
+ RefHashTableOf<XMLRefInfo>* fIDRefList;
};
1.60 +40 -43 xml-xerces/c/src/validators/schema/TraverseSchema.cpp
Index: TraverseSchema.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/validators/schema/TraverseSchema.cpp,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -r1.59 -r1.60
--- TraverseSchema.cpp 2001/11/15 17:10:19 1.59
+++ TraverseSchema.cpp 2001/11/16 15:03:37 1.60
@@ -55,7 +55,7 @@
*/
/*
- * $Id: TraverseSchema.cpp,v 1.59 2001/11/15 17:10:19 knoaman Exp $
+ * $Id: TraverseSchema.cpp,v 1.60 2001/11/16 15:03:37 knoaman Exp $
*/
// ---------------------------------------------------------------------------
@@ -217,7 +217,6 @@
, fCurrentGroupStack(0)
, fIC_NamespaceDepth(0)
, fIC_Elements(0)
- , fAttributeCheck(0)
, fGlobalDeclarations(0)
, fNotationRegistry(0)
, fRedefineComponents(0)
@@ -405,7 +404,7 @@
// Check Attributes
// -----------------------------------------------------------------------
unsigned short scope = GeneralAttributeCheck::GlobalContext;
- fAttributeCheck->checkAttributes(schemaRoot, scope, this);
+ fAttributeCheck.checkAttributes(schemaRoot, scope, this);
retrieveNamespaceMapping(schemaRoot);
fElemAttrDefaultQualified = 0;
@@ -436,7 +435,7 @@
int scope = (topLevel) ? GeneralAttributeCheck::GlobalContext
: GeneralAttributeCheck::LocalContext;
- fAttributeCheck->checkAttributes(annotationElem, scope, this);
+ fAttributeCheck.checkAttributes(annotationElem, scope, this);
for (DOM_Element child = XUtil::getFirstChildElement(annotationElem);
child != 0;
@@ -450,7 +449,7 @@
}
// General Attribute Checking
- fAttributeCheck->checkAttributes(child, GeneralAttributeCheck::LocalContext, this);
+ fAttributeCheck.checkAttributes(child, GeneralAttributeCheck::LocalContext, this);
}
}
@@ -471,7 +470,7 @@
// Check attributes
// ------------------------------------------------------------------
unsigned short scope = GeneralAttributeCheck::GlobalContext;
- fAttributeCheck->checkAttributes(elem, scope, this);
+ fAttributeCheck.checkAttributes(elem, scope, this);
// ------------------------------------------------------------------
// First, handle any ANNOTATION declaration
@@ -599,7 +598,7 @@
// Check attributes
// ------------------------------------------------------------------
unsigned short scope = GeneralAttributeCheck::GlobalContext;
- fAttributeCheck->checkAttributes(elem, scope, this);
+ fAttributeCheck.checkAttributes(elem, scope, this);
// ------------------------------------------------------------------
// First, handle any ANNOTATION declaration
@@ -760,7 +759,7 @@
// Check attributes
// ------------------------------------------------------------------
unsigned short scope = GeneralAttributeCheck::GlobalContext;
- fAttributeCheck->checkAttributes(redefineElem, scope, this);
+ fAttributeCheck.checkAttributes(redefineElem, scope, this);
// First, we look through the children of redefineElem. Each one will
// correspond to an element of the redefined schema that we need to
@@ -814,7 +813,7 @@
// Check attributes
// ------------------------------------------------------------------
unsigned short scope = GeneralAttributeCheck::LocalContext;
- fAttributeCheck->checkAttributes(elem, scope, this);
+ fAttributeCheck.checkAttributes(elem, scope, this);
// ------------------------------------------------------------------
// Process contents
@@ -937,7 +936,7 @@
unsigned short scope = (topLevel) ? GeneralAttributeCheck::GlobalContext
: GeneralAttributeCheck::LocalContext;
- fAttributeCheck->checkAttributes(childElem, scope, this);
+ fAttributeCheck.checkAttributes(childElem, scope, this);
// ------------------------------------------------------------------
// Process contents
@@ -1002,7 +1001,7 @@
// -----------------------------------------------------------------------
// Check Attributes
// -----------------------------------------------------------------------
- fAttributeCheck->checkAttributes(content, GeneralAttributeCheck::LocalContext, this);
+ fAttributeCheck.checkAttributes(content, GeneralAttributeCheck::LocalContext, this);
// Remark: some code will be repeated in list|restriction| union but it
// is cleaner that way
@@ -1075,7 +1074,7 @@
// -----------------------------------------------------------------------
unsigned short scope = (topLevel) ? GeneralAttributeCheck::GlobalContext
: GeneralAttributeCheck::LocalContext;
- fAttributeCheck->checkAttributes(elem, scope, this);
+ fAttributeCheck.checkAttributes(elem, scope, this);
// ------------------------------------------------------------------
// Check if the type has already been registered
@@ -1237,7 +1236,7 @@
// ------------------------------------------------------------------
unsigned short scope = (topLevel) ? GeneralAttributeCheck::GlobalContext
: GeneralAttributeCheck::LocalContext;
- fAttributeCheck->checkAttributes(elem, scope, this);
+ fAttributeCheck.checkAttributes(elem, scope, this);
// ------------------------------------------------------------------
// Check for annotations
@@ -1394,7 +1393,7 @@
// ------------------------------------------------------------------
unsigned short scope = (topLevel) ? GeneralAttributeCheck::GlobalContext
: GeneralAttributeCheck::LocalContext;
- fAttributeCheck->checkAttributes(elem, scope, this);
+ fAttributeCheck.checkAttributes(elem, scope, this);
// ------------------------------------------------------------------
// Handle "ref="
@@ -1515,7 +1514,7 @@
// Check Attributes
// -----------------------------------------------------------------------
unsigned short scope = GeneralAttributeCheck::LocalContext;
- fAttributeCheck->checkAttributes(elem, scope, this);
+ fAttributeCheck.checkAttributes(elem, scope, this);
// ------------------------------------------------------------------
// First, handle any ANNOTATION declaration
@@ -1641,7 +1640,7 @@
// Check attributes
// ------------------------------------------------------------------
unsigned short scope = GeneralAttributeCheck::LocalContext;
- fAttributeCheck->checkAttributes(elem, scope, this);
+ fAttributeCheck.checkAttributes(elem, scope, this);
// ------------------------------------------------------------------
// Process contents
@@ -1767,7 +1766,7 @@
// ------------------------------------------------------------------
unsigned short scope = (topLevel) ? GeneralAttributeCheck::GlobalContext
: GeneralAttributeCheck::LocalContext;
- fAttributeCheck->checkAttributes(elem, scope, this);
+ fAttributeCheck.checkAttributes(elem, scope, this);
const XMLCh* defaultVal = getElementAttValue(elem, SchemaSymbols::fgATT_DEFAULT);
const XMLCh* fixedVal = getElementAttValue(elem, SchemaSymbols::fgATT_FIXED);
@@ -2121,7 +2120,7 @@
// ------------------------------------------------------------------
unsigned short scope = (topLevel) ? GeneralAttributeCheck::GlobalContext
: GeneralAttributeCheck::LocalContext;
- fAttributeCheck->checkAttributes(elem, scope, this);
+ fAttributeCheck.checkAttributes(elem, scope, this);
// ------------------------------------------------------------------
// Process contents
@@ -2548,7 +2547,7 @@
// ------------------------------------------------------------------
// Check attributes
// ------------------------------------------------------------------
- fAttributeCheck->checkAttributes(elem, GeneralAttributeCheck::GlobalContext, this);
+ fAttributeCheck.checkAttributes(elem, GeneralAttributeCheck::GlobalContext, this);
// ------------------------------------------------------------------
// Process notation attributes/elements
@@ -2772,7 +2771,7 @@
if (content.getNodeType() == DOM_Node::ELEMENT_NODE) {
- fAttributeCheck->checkAttributes(content, scope, this);
+ fAttributeCheck.checkAttributes(content, scope, this);
facetName = content.getLocalName();
fBuffer.set(facetName.rawBuffer(), facetName.length());
@@ -3055,7 +3054,7 @@
// Check Attributes
// -----------------------------------------------------------------------
unsigned short scope = GeneralAttributeCheck::LocalContext;
- fAttributeCheck->checkAttributes(contentDecl, scope, this);
+ fAttributeCheck.checkAttributes(contentDecl, scope, this);
// -----------------------------------------------------------------------
// Set the content type to be simple, and initialize content spec handle
@@ -3072,7 +3071,7 @@
throw TraverseSchema::InvalidComplexTypeInfo;
}
- fAttributeCheck->checkAttributes(simpleContent, scope, this);
+ fAttributeCheck.checkAttributes(simpleContent, scope, this);
// -----------------------------------------------------------------------
// The content should be either "restriction" or "extension"
@@ -3228,7 +3227,7 @@
if (content.getNodeType() == DOM_Node::ELEMENT_NODE) {
- fAttributeCheck->checkAttributes(content, scope, this);
+ fAttributeCheck.checkAttributes(content, scope, this);
DOMString attValue =
content.getAttribute(SchemaSymbols::fgATT_VALUE);
@@ -3393,7 +3392,7 @@
// Check attributes
// ------------------------------------------------------------------
unsigned short scope = GeneralAttributeCheck::LocalContext;
- fAttributeCheck->checkAttributes(contentDecl, scope, this);
+ fAttributeCheck.checkAttributes(contentDecl, scope, this);
// -----------------------------------------------------------------------
// Determine whether the content is mixed, or element-only
@@ -3510,7 +3509,7 @@
// Check Attributes
// -----------------------------------------------------------------------
unsigned short scope = GeneralAttributeCheck::LocalContext;
- fAttributeCheck->checkAttributes(elem, scope, this);
+ fAttributeCheck.checkAttributes(elem, scope, this);
// ------------------------------------------------------------------
// First, handle any ANNOTATION declaration
@@ -3619,7 +3618,7 @@
// Check Attributes
// -----------------------------------------------------------------------
unsigned short scope = GeneralAttributeCheck::LocalContext;
- fAttributeCheck->checkAttributes(icElem, scope, this);
+ fAttributeCheck.checkAttributes(icElem, scope, this);
// -----------------------------------------------------------------------
// Create identity constraint
@@ -3682,7 +3681,7 @@
// Check Attributes
// -----------------------------------------------------------------------
unsigned short scope = GeneralAttributeCheck::LocalContext;
- fAttributeCheck->checkAttributes(icElem, scope, this);
+ fAttributeCheck.checkAttributes(icElem, scope, this);
// -----------------------------------------------------------------------
// Create identity constraint
@@ -3746,7 +3745,7 @@
// Check Attributes
// -----------------------------------------------------------------------
unsigned short scope = GeneralAttributeCheck::LocalContext;
- fAttributeCheck->checkAttributes(icElem, scope, this);
+ fAttributeCheck.checkAttributes(icElem, scope, this);
// -----------------------------------------------------------------------
// Verify that key reference "refer" attribute is valid
@@ -3818,15 +3817,10 @@
bool TraverseSchema::traverseIdentityConstraint(IdentityConstraint* const ic,
const DOM_Element& icElem) {
- // -----------------------------------------------------------------------
- // Check Attributes
- // -----------------------------------------------------------------------
- unsigned short scope = GeneralAttributeCheck::LocalContext;
- fAttributeCheck->checkAttributes(icElem, scope, this);
-
// ------------------------------------------------------------------
// First, handle any ANNOTATION declaration
// ------------------------------------------------------------------
+ unsigned short scope = GeneralAttributeCheck::LocalContext;
DOM_Element elem = XUtil::getFirstChildElement(icElem);
if (elem == 0) {
@@ -3846,7 +3840,7 @@
return false;
}
- fAttributeCheck->checkAttributes(elem, scope, this);
+ fAttributeCheck.checkAttributes(elem, scope, this);
checkContent(icElem, XUtil::getFirstChildElement(elem), true);
// ------------------------------------------------------------------
@@ -3902,7 +3896,7 @@
}
else {
// General Attribute Checking
- fAttributeCheck->checkAttributes(elem, scope, this);
+ fAttributeCheck.checkAttributes(elem, scope, this);
checkContent(icElem, XUtil::getFirstChildElement(elem), true);
// xpath expression parsing
@@ -4138,7 +4132,9 @@
}
}
- traverseGroupDecl(child);
+ if (!typeName || !fGroupRegistry->containsKey(fBuffer.getRawBuffer())) {
+ traverseGroupDecl(child);
+ }
}
else if (name.equals(SchemaSymbols::fgELT_NOTATION)) {
traverseNotationDecl(child);
@@ -5173,10 +5169,6 @@
}
}
- if (minOccurs == 0 && maxOccurs == 0){
- return;
- }
-
// Constraint checking for min/max value
if (!isMaxUnbounded) {
@@ -5201,6 +5193,10 @@
}
}
+ if (minOccurs == 0 && maxOccurs == 0){
+ return;
+ }
+
// Constraint checking for 'all' content
bool isAllElement = (allContextFlag == All_Element);
bool isAllGroup = (allContextFlag == All_Group);
@@ -7638,12 +7634,14 @@
ValueVectorOf<ContentSpecNode*>* const nodes) {
ContentSpecNode* rightNode = specNode->getSecond();
+ int min = specNode->getMinOccurs();
+ int max = specNode->getMaxOccurs();
if (!rightNode) {
gatherChildren(nodeType, specNode->getFirst(), nodes);
- if (nodes->size() == 1) {
+ if (nodes->size() == 1 && min == 1 && max == 1) {
return nodes->elementAt(0);
}
@@ -8240,7 +8238,6 @@
fDatatypeRegistry->expandRegistryToFullSchemaSet();
fStringPool = fGrammarResolver->getStringPool();
fEmptyNamespaceURI = fScanner->getEmptyNamespaceId();
- fAttributeCheck = GeneralAttributeCheck::instance();
fCurrentTypeNameStack = new ValueVectorOf<unsigned int>(8);
fCurrentGroupStack = new ValueVectorOf<unsigned int>(8);
fGlobalDeclarations = new RefHash2KeysTableOf<XMLCh>(29, false);
1.27 +3 -3 xml-xerces/c/src/validators/schema/TraverseSchema.hpp
Index: TraverseSchema.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/validators/schema/TraverseSchema.hpp,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- TraverseSchema.hpp 2001/11/15 17:10:19 1.26
+++ TraverseSchema.hpp 2001/11/16 15:03:37 1.27
@@ -55,7 +55,7 @@
*/
/*
- * $Id: TraverseSchema.hpp,v 1.26 2001/11/15 17:10:19 knoaman Exp $
+ * $Id: TraverseSchema.hpp,v 1.27 2001/11/16 15:03:37 knoaman Exp $
*/
#if !defined(TRAVERSESCHEMA_HPP)
@@ -80,6 +80,7 @@
#include <validators/common/ContentSpecNode.hpp>
#include <validators/schema/SchemaGrammar.hpp>
#include <validators/schema/SchemaInfo.hpp>
+#include <validators/schema/GeneralAttributeCheck.hpp>
// ---------------------------------------------------------------------------
// Forward Declarations
@@ -98,7 +99,6 @@
class SchemaAttDef;
class InputSource;
class ErrorHandler;
-class GeneralAttributeCheck;
class XercesGroupInfo;
class XercesAttGroupInfo;
class IdentityConstraint;
@@ -801,7 +801,7 @@
ValueVectorOf<unsigned int>* fCurrentGroupStack;
ValueVectorOf<unsigned int>* fIC_NamespaceDepth;
ValueVectorOf<SchemaElementDecl*>* fIC_Elements;
- GeneralAttributeCheck* fAttributeCheck;
+ GeneralAttributeCheck fAttributeCheck;
RefHash2KeysTableOf<XMLCh>* fGlobalDeclarations;
RefHash2KeysTableOf<XMLCh>* fNotationRegistry;
RefHash2KeysTableOf<XMLCh>* fRedefineComponents;
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org