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/05/27 21:54:58 UTC
cvs commit: xml-xerces/c/src/xercesc/validators/schema GeneralAttributeCheck.hpp TraverseSchema.cpp TraverseSchema.hpp
knoaman 02/05/27 12:54:58
Modified: c/src/xercesc/validators/schema GeneralAttributeCheck.hpp
TraverseSchema.cpp TraverseSchema.hpp
Log:
Performance: use pre-built element-attribute map table.
Revision Changes Path
1.5 +149 -168 xml-xerces/c/src/xercesc/validators/schema/GeneralAttributeCheck.hpp
Index: GeneralAttributeCheck.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/schema/GeneralAttributeCheck.hpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- GeneralAttributeCheck.hpp 21 May 2002 19:30:10 -0000 1.4
+++ GeneralAttributeCheck.hpp 27 May 2002 19:54:57 -0000 1.5
@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * Copyright (c) 2001-2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -55,7 +55,7 @@
*/
/*
- * $Id: GeneralAttributeCheck.hpp,v 1.4 2002/05/21 19:30:10 tng Exp $
+ * $Id: GeneralAttributeCheck.hpp,v 1.5 2002/05/27 19:54:57 knoaman Exp $
*/
#if !defined(GENERALATTRIBUTECHECK_HPP)
@@ -74,6 +74,7 @@
#include <xercesc/util/RefHashTableOf.hpp>
#include <xercesc/util/RefHash2KeysTableOf.hpp>
#include <xercesc/validators/datatype/IDDatatypeValidator.hpp>
+#include <xercesc/util/ValueHashTableOf.hpp>
// ---------------------------------------------------------------------------
// Forward declaration
@@ -82,49 +83,138 @@
class DOMElement;
-class AttributeInfo {
+class VALIDATORS_EXPORT GeneralAttributeCheck
+{
public:
// -----------------------------------------------------------------------
- // Constructor/Destructor
- // -----------------------------------------------------------------------
- AttributeInfo(const XMLCh* const name, const short defaultOption,
- const XMLCh* const defaultValue, const short dvIndex);
- ~AttributeInfo();
-
- // -----------------------------------------------------------------------
- // Getter methods
- // -----------------------------------------------------------------------
- short getDefaultOption() const;
- short getValidatorIndex() const;
- XMLCh* getName() const;
- XMLCh* getDefaultValue() const;
-
-
-private:
+ // Constants
// -----------------------------------------------------------------------
- // CleanUp methods
- // -----------------------------------------------------------------------
- void cleanUp();
+ //Elements
+ enum
+ {
+ E_All,
+ E_Annotation,
+ E_Any,
+ E_AnyAttribute,
+ E_Appinfo,
+ E_AttributeGlobal,
+ E_AttributeLocal,
+ E_AttributeRef,
+ E_AttributeGroupGlobal,
+ E_AttributeGroupRef,
+ E_Choice,
+ E_ComplexContent,
+ E_ComplexTypeGlobal,
+ E_ComplexTypeLocal,
+ E_Documentation,
+ E_ElementGlobal,
+ E_ElementLocal,
+ E_ElementRef,
+ E_Enumeration,
+ E_Extension,
+ E_Field,
+ E_FractionDigits,
+ E_GroupGlobal,
+ E_GroupRef,
+ E_Import,
+ E_Include,
+ E_Key,
+ E_KeyRef,
+ E_Length,
+ E_List,
+ E_MaxExclusive,
+ E_MaxInclusive,
+ E_MaxLength,
+ E_MinExclusive,
+ E_MinInclusive,
+ E_MinLength,
+ E_Notation,
+ E_Pattern,
+ E_Redefine,
+ E_Restriction,
+ E_Schema,
+ E_Selector,
+ E_Sequence,
+ E_SimpleContent,
+ E_SimpleTypeGlobal,
+ E_SimpleTypeLocal,
+ E_TotalDigits,
+ E_Union,
+ E_Unique,
+ E_WhiteSpace,
- // -----------------------------------------------------------------------
- // Private data members
- // -----------------------------------------------------------------------
- short fDefaultOption;
- short fValidatorIndex;
- XMLCh* fName;
- XMLCh* fDefaultValue;
-};
+ E_Count,
+ E_Invalid = -1
+ };
+ //Attributes
+ enum
+ {
+ A_Abstract,
+ A_AttributeFormDefault,
+ A_Base,
+ A_Block,
+ A_BlockDefault,
+ A_Default,
+ A_ElementFormDefault,
+ A_Final,
+ A_FinalDefault,
+ A_Fixed,
+ A_Form,
+ A_ID,
+ A_ItemType,
+ A_MaxOccurs,
+ A_MemberTypes,
+ A_MinOccurs,
+ A_Mixed,
+ A_Name,
+ A_Namespace,
+ A_Nillable,
+ A_ProcessContents,
+ A_Public,
+ A_Ref,
+ A_Refer,
+ A_SchemaLocation,
+ A_Source,
+ A_SubstitutionGroup,
+ A_System,
+ A_TargetNamespace,
+ A_Type,
+ A_Use,
+ A_Value,
+ A_Version,
+ A_XPath,
+
+ A_Count,
+ A_Invalid = -1
+ };
-// ---------------------------------------------------------------------------
-// local type declaration
-// ---------------------------------------------------------------------------
-typedef RefVectorOf<AttributeInfo> RefVectorOfAttributeInfo;
+ //Validators
+ enum {
+
+ DV_String = 0,
+ DV_AnyURI = 4,
+ DV_NonNegInt = 8,
+ DV_Boolean = 16,
+ DV_ID = 32,
+ DV_Form = 64,
+ DV_MaxOccurs = 128,
+ DV_MaxOccurs1 = 256,
+ DV_MinOccurs1 = 512,
+ DV_ProcessContents = 1024,
+ DV_Use = 2048,
+ DV_WhiteSpace = 4096,
+
+ DV_Mask = (DV_AnyURI | DV_NonNegInt | DV_Boolean | DV_ID | DV_Form |
+ DV_MaxOccurs | DV_MaxOccurs1 | DV_MinOccurs1 |
+ DV_ProcessContents | DV_Use | DV_WhiteSpace)
+ };
+ // generate element-attributes map table
+#if defined(NEED_TO_GEN_ELEM_ATT_MAP_TABLE)
+ static void initCharFlagTable();
+#endif
-class VALIDATORS_EXPORT GeneralAttributeCheck
-{
-public:
// -----------------------------------------------------------------------
// Constructor/Destructor
// -----------------------------------------------------------------------
@@ -132,10 +222,9 @@
~GeneralAttributeCheck();
// -----------------------------------------------------------------------
- // Public Constants
+ // Getter methods
// -----------------------------------------------------------------------
- static const unsigned short GlobalContext;
- static const unsigned short LocalContext;
+ unsigned short getFacetId(const XMLCh* const facetName);
// -----------------------------------------------------------------------
// Setter methods
@@ -147,7 +236,8 @@
// -----------------------------------------------------------------------
void checkAttributes(const DOMElement* const elem,
const unsigned short elemContext,
- TraverseSchema* const schema);
+ TraverseSchema* const schema,
+ const bool isTopLevel = false);
// -----------------------------------------------------------------------
// Notification that lazy data has been deleted
@@ -164,9 +254,9 @@
// -----------------------------------------------------------------------
// Setup methods
// -----------------------------------------------------------------------
- void setUpAttributes();
void setUpValidators();
void mapElements();
+ void mapAttributes();
// -----------------------------------------------------------------------
// Validation methods
@@ -177,145 +267,35 @@
// -----------------------------------------------------------------------
// Private Constants
// -----------------------------------------------------------------------
- // attributes
- enum {
- Att_Abstract_D, // starts with 0
- Att_Attribute_FD_D,
- Att_Base_R,
- Att_Base_N,
- Att_Block_N,
- Att_Block1_N,
- Att_Block_D_D,
- Att_Default_N,
- Att_Element_FD_D,
- Att_Final_N,
- Att_Final1_N,
- Att_Final_D_D,
- Att_Fixed_N,
- Att_Fixed_D,
- Att_Form_N,
- Att_ID_N,
- Att_ItemType_N,
- Att_MaxOccurs_D,
- Att_MaxOccurs1_D,
- Att_Member_T_N,
- Att_MinOccurs_D,
- Att_MinOccurs1_D,
- Att_Mixed_D,
- Att_Mixed_N,
- Att_Name_R,
- Att_Namespace_D,
- Att_Namespace_N,
- Att_Nillable_D,
- Att_Process_C_D,
- Att_Public_R,
- Att_Ref_R,
- Att_Refer_R,
- Att_Schema_L_R,
- Att_Schema_L_N,
- Att_Source_N,
- Att_Substitution_G_N,
- Att_System_N,
- Att_Target_N_N,
- Att_Type_N,
- Att_Use_D,
- Att_Value_NNI_N,
- Att_Value_STR_N,
- Att_Value_WS_N,
- Att_Version_N,
- Att_XPath_R,
- Att_XPath1_R,
-
- Att_Count
- };
-
- // direct value compare
- enum {
- DT_Block = -1,
- DT_Block1 = -2,
- DT_Final = -3,
- DT_Final1 = -4,
- DT_Form = -5,
- DT_MaxOccurs = -6,
- DT_MaxOccurs1 = -7,
- DT_MemberTypes = -8,
- DT_MinOccurs1 = -9,
- DT_Namespace = -10,
- DT_ProcessContents = -11,
- DT_Public = -12,
- DT_Use = -13,
- DT_WhiteSpace = -14,
- DT_ID = -15
- };
-
- // datatype validators
- enum {
- DT_String,
- DT_Token,
- DT_AnyURI,
- DT_NonNegInt,
- DT_QName,
- DT_Boolean,
-
- // add XPath
- DT_Count
- };
-
- // element context prefixes
- enum {
- globalPrefix,
- localNamePrefix,
- localRefPrefix
- };
-
// optional vs. required attribute
enum {
- Att_Required,
- Att_Optional_Default,
- Att_Optional_NoDefault
+ Att_Required = 1,
+ Att_Optional = 2,
+ Att_Mask = 3
};
// -----------------------------------------------------------------------
// Private data members
// -----------------------------------------------------------------------
- static AttributeInfo** fAttributes;
- static DatatypeValidator** fValidators;
- static RefHash2KeysTableOf<RefVectorOfAttributeInfo>* fElementMap;
- IDDatatypeValidator fIDValidator;
- RefHashTableOf<XMLRefInfo>* fIDRefList;
+ static ValueHashTableOf<unsigned short>* fAttMap;
+ static ValueHashTableOf<unsigned short>* fFacetsMap;
+ static DatatypeValidator* fNonNegIntDV;
+ static DatatypeValidator* fBooleanDV;
+ static DatatypeValidator* fAnyURIDV;
+ static unsigned short fgElemAttTable[E_Count][A_Count];
+ static const XMLCh* fAttNames[A_Count];
+ IDDatatypeValidator fIDValidator;
+ RefHashTableOf<XMLRefInfo>* fIDRefList;
};
// ---------------------------------------------------------------------------
-// AttributeInfo: Getter methods
+// GeneralAttributeCheck: Getter methods
// ---------------------------------------------------------------------------
-inline short AttributeInfo::getDefaultOption() const {
+inline unsigned short
+GeneralAttributeCheck::getFacetId(const XMLCh* const facetName) {
- return fDefaultOption;
-}
-
-inline short AttributeInfo::getValidatorIndex() const {
-
- return fValidatorIndex;
-}
-
-inline XMLCh* AttributeInfo::getName() const {
-
- return fName;
-}
-
-inline XMLCh* AttributeInfo::getDefaultValue() const {
-
- return fDefaultValue;
-}
-
-// ---------------------------------------------------------------------------
-// AttributeInfo: CleanUp methods
-// ---------------------------------------------------------------------------
-inline void AttributeInfo::cleanUp() {
-
- delete [] fName;
- delete [] fDefaultValue;
+ return fFacetsMap->get(facetName);
}
// ---------------------------------------------------------------------------
@@ -326,6 +306,7 @@
fIDRefList = refList;
}
+
#endif
1.17 +72 -95 xml-xerces/c/src/xercesc/validators/schema/TraverseSchema.cpp
Index: TraverseSchema.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/schema/TraverseSchema.cpp,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- TraverseSchema.cpp 22 May 2002 20:54:14 -0000 1.16
+++ TraverseSchema.cpp 27 May 2002 19:54:57 -0000 1.17
@@ -55,7 +55,7 @@
*/
/*
- * $Id: TraverseSchema.cpp,v 1.16 2002/05/22 20:54:14 knoaman Exp $
+ * $Id: TraverseSchema.cpp,v 1.17 2002/05/27 19:54:57 knoaman Exp $
*/
// ---------------------------------------------------------------------------
@@ -394,8 +394,7 @@
// -----------------------------------------------------------------------
// Check Attributes
// -----------------------------------------------------------------------
- unsigned short scope = GeneralAttributeCheck::GlobalContext;
- fAttributeCheck.checkAttributes(schemaRoot, scope, this);
+ fAttributeCheck.checkAttributes(schemaRoot, GeneralAttributeCheck::E_Schema, this, true);
retrieveNamespaceMapping(schemaRoot);
unsigned short elemAttrDefaultQualified = 0;
@@ -422,10 +421,7 @@
// -----------------------------------------------------------------------
// Check Attributes
// -----------------------------------------------------------------------
- int scope = (topLevel) ? GeneralAttributeCheck::GlobalContext
- : GeneralAttributeCheck::LocalContext;
-
- fAttributeCheck.checkAttributes(annotationElem, scope, this);
+ fAttributeCheck.checkAttributes(annotationElem, GeneralAttributeCheck::E_Annotation, this, topLevel);
for (DOMElement* child = XUtil::getFirstChildElement(annotationElem);
child != 0;
@@ -433,13 +429,15 @@
const XMLCh* name = child->getLocalName();
- if (XMLString::compareString(name, SchemaSymbols::fgELT_APPINFO) &&
- XMLString::compareString(name, SchemaSymbols::fgELT_DOCUMENTATION)) {
+ if (XMLString::compareString(name, SchemaSymbols::fgELT_APPINFO)) {
+ fAttributeCheck.checkAttributes(child, GeneralAttributeCheck::E_Appinfo, this);
+ }
+ else if (XMLString::compareString(name, SchemaSymbols::fgELT_DOCUMENTATION)) {
+ fAttributeCheck.checkAttributes(child, GeneralAttributeCheck::E_Documentation, this);
+ }
+ else {
// reportSchemaError(XMLUni::fgXMLErrDomain, 0, 0); //"an <annotation> can only contain <appinfo> and <documentation> elements"
}
-
- // General Attribute Checking
- fAttributeCheck.checkAttributes(child, GeneralAttributeCheck::LocalContext, this);
}
}
@@ -459,8 +457,7 @@
// ------------------------------------------------------------------
// Check attributes
// ------------------------------------------------------------------
- unsigned short scope = GeneralAttributeCheck::GlobalContext;
- fAttributeCheck.checkAttributes(elem, scope, this);
+ fAttributeCheck.checkAttributes(elem, GeneralAttributeCheck::E_Include, this, true);
// ------------------------------------------------------------------
// First, handle any ANNOTATION declaration
@@ -604,8 +601,7 @@
// ------------------------------------------------------------------
// Check attributes
// ------------------------------------------------------------------
- unsigned short scope = GeneralAttributeCheck::GlobalContext;
- fAttributeCheck.checkAttributes(elem, scope, this);
+ fAttributeCheck.checkAttributes(elem, GeneralAttributeCheck::E_Import, this, true);
// ------------------------------------------------------------------
// First, handle any ANNOTATION declaration
@@ -777,8 +773,7 @@
// ------------------------------------------------------------------
// Check attributes
// ------------------------------------------------------------------
- unsigned short scope = GeneralAttributeCheck::GlobalContext;
- fAttributeCheck.checkAttributes(redefineElem, scope, this);
+ fAttributeCheck.checkAttributes(redefineElem, GeneralAttributeCheck::E_Redefine, this, true);
// First, we look through the children of redefineElem. Each one will
// correspond to an element of the redefined schema that we need to
@@ -851,8 +846,7 @@
// ------------------------------------------------------------------
// Check attributes
// ------------------------------------------------------------------
- unsigned short scope = GeneralAttributeCheck::LocalContext;
- fAttributeCheck.checkAttributes(elem, scope, this);
+ fAttributeCheck.checkAttributes(elem, GeneralAttributeCheck::E_Sequence, this);
// ------------------------------------------------------------------
// Process contents
@@ -998,10 +992,10 @@
// ------------------------------------------------------------------
// Check attributes
// ------------------------------------------------------------------
- unsigned short scope = (topLevel) ? GeneralAttributeCheck::GlobalContext
- : GeneralAttributeCheck::LocalContext;
+ unsigned short scope = (topLevel) ? GeneralAttributeCheck::E_SimpleTypeGlobal
+ : GeneralAttributeCheck::E_SimpleTypeLocal;
- fAttributeCheck.checkAttributes(childElem, scope, this);
+ fAttributeCheck.checkAttributes(childElem, scope, this, topLevel);
// Circular constraint checking
if (fCurrentTypeNameStack->containsElement(fullTypeNameId)){
@@ -1029,11 +1023,6 @@
const XMLCh* varietyName = content->getLocalName();
int newSimpleTypeName = fStringPool->addOrFind(name);
- // -----------------------------------------------------------------------
- // Check Attributes
- // -----------------------------------------------------------------------
- fAttributeCheck.checkAttributes(content, GeneralAttributeCheck::LocalContext, this);
-
// Remark: some code will be repeated in list|restriction| union but it
// is cleaner that way
if (!XMLString::compareString(varietyName, SchemaSymbols::fgELT_LIST)) { //traverse List
@@ -1125,9 +1114,9 @@
// -----------------------------------------------------------------------
// Check Attributes
// -----------------------------------------------------------------------
- unsigned short scope = (topLevel) ? GeneralAttributeCheck::GlobalContext
- : GeneralAttributeCheck::LocalContext;
- fAttributeCheck.checkAttributes(elem, scope, this);
+ unsigned short scope = (topLevel) ? GeneralAttributeCheck::E_ComplexTypeGlobal
+ : GeneralAttributeCheck::E_ComplexTypeLocal;
+ fAttributeCheck.checkAttributes(elem, scope, this, topLevel);
// -----------------------------------------------------------------------
// Create a new instance
@@ -1296,9 +1285,9 @@
// ------------------------------------------------------------------
// Check attributes
// ------------------------------------------------------------------
- unsigned short scope = (topLevel) ? GeneralAttributeCheck::GlobalContext
- : GeneralAttributeCheck::LocalContext;
- fAttributeCheck.checkAttributes(elem, scope, this);
+ unsigned short scope = (topLevel) ? GeneralAttributeCheck::E_GroupGlobal
+ : GeneralAttributeCheck::E_GroupRef;
+ fAttributeCheck.checkAttributes(elem, scope, this, topLevel);
// ------------------------------------------------------------------
// Check for annotations
@@ -1454,9 +1443,9 @@
// ------------------------------------------------------------------
// Check attributes
// ------------------------------------------------------------------
- unsigned short scope = (topLevel) ? GeneralAttributeCheck::GlobalContext
- : GeneralAttributeCheck::LocalContext;
- fAttributeCheck.checkAttributes(elem, scope, this);
+ unsigned short scope = (topLevel) ? GeneralAttributeCheck::E_AttributeGroupGlobal
+ : GeneralAttributeCheck::E_AttributeGroupRef;
+ fAttributeCheck.checkAttributes(elem, scope, this, topLevel);
// ------------------------------------------------------------------
// Handle "ref="
@@ -1596,8 +1585,7 @@
// -----------------------------------------------------------------------
// Check Attributes
// -----------------------------------------------------------------------
- unsigned short scope = GeneralAttributeCheck::LocalContext;
- fAttributeCheck.checkAttributes(elem, scope, this);
+ fAttributeCheck.checkAttributes(elem, GeneralAttributeCheck::E_Any, this);
// ------------------------------------------------------------------
// First, handle any ANNOTATION declaration
@@ -1724,8 +1712,7 @@
// ------------------------------------------------------------------
// Check attributes
// ------------------------------------------------------------------
- unsigned short scope = GeneralAttributeCheck::LocalContext;
- fAttributeCheck.checkAttributes(elem, scope, this);
+ fAttributeCheck.checkAttributes(elem, GeneralAttributeCheck::E_All, this);
// ------------------------------------------------------------------
// Process contents
@@ -1828,9 +1815,10 @@
// ------------------------------------------------------------------
// Check attributes
// ------------------------------------------------------------------
- unsigned short scope = (topLevel) ? GeneralAttributeCheck::GlobalContext
- : GeneralAttributeCheck::LocalContext;
- fAttributeCheck.checkAttributes(elem, scope, this);
+ unsigned short scope = (topLevel) ? GeneralAttributeCheck::E_AttributeGlobal
+ : (refEmpty) ? GeneralAttributeCheck::E_AttributeLocal
+ : GeneralAttributeCheck::E_AttributeRef;
+ fAttributeCheck.checkAttributes(elem, scope, this, topLevel);
const XMLCh* defaultVal = getElementAttValue(elem, SchemaSymbols::fgATT_DEFAULT);
const XMLCh* fixedVal = getElementAttValue(elem, SchemaSymbols::fgATT_FIXED);
@@ -2186,9 +2174,10 @@
// ------------------------------------------------------------------
// Check attributes
// ------------------------------------------------------------------
- unsigned short scope = (topLevel) ? GeneralAttributeCheck::GlobalContext
- : GeneralAttributeCheck::LocalContext;
- fAttributeCheck.checkAttributes(elem, scope, this);
+ unsigned short scope = (topLevel) ? GeneralAttributeCheck::E_ElementGlobal
+ : (refEmpty) ? GeneralAttributeCheck::E_ElementLocal
+ : GeneralAttributeCheck::E_ElementRef;
+ fAttributeCheck.checkAttributes(elem, scope, this, topLevel);
// ------------------------------------------------------------------
// Process contents
@@ -2626,7 +2615,7 @@
// ------------------------------------------------------------------
// Check attributes
// ------------------------------------------------------------------
- fAttributeCheck.checkAttributes(elem, GeneralAttributeCheck::GlobalContext, this);
+ fAttributeCheck.checkAttributes(elem, GeneralAttributeCheck::E_Notation, this, true);
// ------------------------------------------------------------------
// Process notation attributes/elements
@@ -2725,6 +2714,8 @@
const XMLCh* typeName = fStringPool->getValueForId(typeNameIndex);
const XMLCh* baseTypeName = getElementAttValue(contentElem, SchemaSymbols::fgATT_ITEMTYPE);
+ fAttributeCheck.checkAttributes(contentElem, GeneralAttributeCheck::E_List, this);
+
if (XUtil::getNextSiblingElement(contentElem) != 0) {
reportSchemaError(contentElem, XMLUni::fgXMLErrDomain, XMLErrs::SimpleTypeContentError);
}
@@ -2811,6 +2802,8 @@
const XMLCh* typeName = fStringPool->getValueForId(typeNameIndex);
const XMLCh* baseTypeName = getElementAttValue(contentElem, SchemaSymbols::fgATT_BASE);
+ fAttributeCheck.checkAttributes(contentElem, GeneralAttributeCheck::E_Restriction, this);
+
if (XUtil::getNextSiblingElement(contentElem) != 0) {
reportSchemaError(contentElem, XMLUni::fgXMLErrDomain, XMLErrs::SimpleTypeContentError);
}
@@ -2853,7 +2846,7 @@
XMLBuffer pattern(128);
XMLCh fixedFlagStr[16];
unsigned int fixedFlag = 0;
- unsigned int scope = GeneralAttributeCheck::LocalContext;
+ unsigned short scope = 0;
bool isFirstPattern = true;
while (content != 0) {
@@ -2861,8 +2854,18 @@
if (content->getNodeType() == DOMNode::ELEMENT_NODE) {
const XMLCh* facetName = content->getLocalName();
- const XMLCh* attValue = content->getAttribute(SchemaSymbols::fgATT_VALUE);
+ try {
+ scope = fAttributeCheck.getFacetId(facetName);
+ }
+ catch (...) {
+
+ reportSchemaError(content, XMLUni::fgXMLErrDomain, XMLErrs::ListUnionRestrictionError, typeName);
+ content = XUtil::getNextSiblingElement(content);
+ continue;
+ }
+
+ const XMLCh* attValue = content->getAttribute(SchemaSymbols::fgATT_VALUE);
fAttributeCheck.checkAttributes(content, scope, this);
if (facets == 0) {
@@ -2912,10 +2915,6 @@
pattern.append(attValue);
}
}
- else if (XMLString::compareString(facetName, SchemaSymbols::fgELT_ANNOTATION) == 0
- || XMLString::compareString(facetName, SchemaSymbols::fgELT_SIMPLETYPE) == 0) {
- reportSchemaError(content, XMLUni::fgXMLErrDomain, XMLErrs::ListUnionRestrictionError, typeName);
- }
else {
if (facets->containsKey(facetName)) {
@@ -2988,6 +2987,8 @@
const int finalSet,
int baseRefContext) {
+ fAttributeCheck.checkAttributes(contentElem, GeneralAttributeCheck::E_Union, this);
+
if (XUtil::getNextSiblingElement(contentElem) != 0) {
reportSchemaError(contentElem, XMLUni::fgXMLErrDomain, XMLErrs::SimpleTypeContentError);
}
@@ -3123,8 +3124,7 @@
// -----------------------------------------------------------------------
// Check Attributes
// -----------------------------------------------------------------------
- unsigned short scope = GeneralAttributeCheck::LocalContext;
- fAttributeCheck.checkAttributes(contentDecl, scope, this);
+ fAttributeCheck.checkAttributes(contentDecl, GeneralAttributeCheck::E_SimpleContent, this);
// -----------------------------------------------------------------------
// Set the content type to be simple, and initialize content spec handle
@@ -3140,17 +3140,19 @@
throw TraverseSchema::InvalidComplexTypeInfo;
}
- fAttributeCheck.checkAttributes(simpleContent, scope, this);
-
// -----------------------------------------------------------------------
// The content should be either "restriction" or "extension"
// -----------------------------------------------------------------------
const XMLCh* const contentName = simpleContent->getLocalName();
if (!XMLString::compareString(contentName, SchemaSymbols::fgATTVAL_RESTRICTION)) {
+
+ fAttributeCheck.checkAttributes(simpleContent, GeneralAttributeCheck::E_Restriction, this);
typeInfo->setDerivedBy(SchemaSymbols::RESTRICTION);
}
else if (!XMLString::compareString(contentName, SchemaSymbols::fgATTVAL_EXTENSION)) {
+
+ fAttributeCheck.checkAttributes(simpleContent, GeneralAttributeCheck::E_Extension, this);
typeInfo->setDerivedBy(SchemaSymbols::EXTENSION);
}
else {
@@ -3277,6 +3279,7 @@
XMLBuffer pattern(128);
XMLCh fixedFlagStr[16];
unsigned int fixedFlag = 0;
+ unsigned short scope = 0;
bool isFirstPattern = true;
while (content != 0) {
@@ -3284,7 +3287,10 @@
const XMLCh* facetName = content->getLocalName();
// if not a valid facet, break from the loop
- if (!isValidFacet(SchemaSymbols::fgELT_SIMPLECONTENT, facetName)) {
+ try {
+ scope = fAttributeCheck.getFacetId(facetName);
+ }
+ catch(...) {
break;
}
@@ -3448,8 +3454,7 @@
// ------------------------------------------------------------------
// Check attributes
// ------------------------------------------------------------------
- unsigned short scope = GeneralAttributeCheck::LocalContext;
- fAttributeCheck.checkAttributes(contentDecl, scope, this);
+ fAttributeCheck.checkAttributes(contentDecl, GeneralAttributeCheck::E_ComplexContent, this);
// -----------------------------------------------------------------------
// Determine whether the content is mixed, or element-only
@@ -3566,8 +3571,7 @@
// -----------------------------------------------------------------------
// Check Attributes
// -----------------------------------------------------------------------
- unsigned short scope = GeneralAttributeCheck::LocalContext;
- fAttributeCheck.checkAttributes(elem, scope, this);
+ fAttributeCheck.checkAttributes(elem, GeneralAttributeCheck::E_AnyAttribute, this);
// ------------------------------------------------------------------
// First, handle any ANNOTATION declaration
@@ -3674,8 +3678,7 @@
// -----------------------------------------------------------------------
// Check Attributes
// -----------------------------------------------------------------------
- unsigned short scope = GeneralAttributeCheck::LocalContext;
- fAttributeCheck.checkAttributes(icElem, scope, this);
+ fAttributeCheck.checkAttributes(icElem, GeneralAttributeCheck::E_Key, this);
// -----------------------------------------------------------------------
// Create identity constraint
@@ -3737,8 +3740,7 @@
// -----------------------------------------------------------------------
// Check Attributes
// -----------------------------------------------------------------------
- unsigned short scope = GeneralAttributeCheck::LocalContext;
- fAttributeCheck.checkAttributes(icElem, scope, this);
+ fAttributeCheck.checkAttributes(icElem, GeneralAttributeCheck::E_Unique, this);
// -----------------------------------------------------------------------
// Create identity constraint
@@ -3801,8 +3803,7 @@
// -----------------------------------------------------------------------
// Check Attributes
// -----------------------------------------------------------------------
- unsigned short scope = GeneralAttributeCheck::LocalContext;
- fAttributeCheck.checkAttributes(icElem, scope, this);
+ fAttributeCheck.checkAttributes(icElem, GeneralAttributeCheck::E_KeyRef, this);
// -----------------------------------------------------------------------
// Verify that key reference "refer" attribute is valid
@@ -3877,7 +3878,6 @@
// ------------------------------------------------------------------
// First, handle any ANNOTATION declaration
// ------------------------------------------------------------------
- unsigned short scope = GeneralAttributeCheck::LocalContext;
DOMElement* elem = checkContent(icElem, XUtil::getFirstChildElement(icElem), false);
// ------------------------------------------------------------------
@@ -3895,7 +3895,7 @@
return false;
}
- fAttributeCheck.checkAttributes(elem, scope, this);
+ fAttributeCheck.checkAttributes(elem, GeneralAttributeCheck::E_Selector, this);
checkContent(icElem, XUtil::getFirstChildElement(elem), true);
// ------------------------------------------------------------------
@@ -3966,7 +3966,7 @@
}
else {
// General Attribute Checking
- fAttributeCheck.checkAttributes(elem, scope, this);
+ fAttributeCheck.checkAttributes(elem, GeneralAttributeCheck::E_Field, this);
checkContent(icElem, XUtil::getFirstChildElement(elem), true);
// xpath expression parsing
@@ -5822,29 +5822,6 @@
}
return 0;
-}
-
-
-bool TraverseSchema::isValidFacet(const XMLCh* const component,
- const XMLCh* const name) {
-
- if (!XMLString::compareString(name, SchemaSymbols::fgELT_MINEXCLUSIVE) ||
- !XMLString::compareString(name, SchemaSymbols::fgELT_MININCLUSIVE) ||
- !XMLString::compareString(name, SchemaSymbols::fgELT_MAXEXCLUSIVE) ||
- !XMLString::compareString(name, SchemaSymbols::fgELT_MAXINCLUSIVE) ||
- !XMLString::compareString(name, SchemaSymbols::fgELT_TOTALDIGITS) ||
- !XMLString::compareString(name, SchemaSymbols::fgELT_FRACTIONDIGITS) ||
- !XMLString::compareString(name, SchemaSymbols::fgELT_LENGTH) ||
- !XMLString::compareString(name, SchemaSymbols::fgELT_MINLENGTH) ||
- !XMLString::compareString(name, SchemaSymbols::fgELT_MAXLENGTH) ||
- !XMLString::compareString(name, SchemaSymbols::fgELT_ENUMERATION) ||
- !XMLString::compareString(name, SchemaSymbols::fgELT_WHITESPACE) ||
- !XMLString::compareString(name, SchemaSymbols::fgELT_PATTERN) ||
- !XMLString::compareString(name, SchemaSymbols::fgELT_ANNOTATION)) {
- return true;
- }
-
- return false;
}
1.10 +12 -15 xml-xerces/c/src/xercesc/validators/schema/TraverseSchema.hpp
Index: TraverseSchema.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/schema/TraverseSchema.hpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- TraverseSchema.hpp 22 May 2002 20:54:14 -0000 1.9
+++ TraverseSchema.hpp 27 May 2002 19:54:57 -0000 1.10
@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * Copyright (c) 2001-2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -55,7 +55,7 @@
*/
/*
- * $Id: TraverseSchema.hpp,v 1.9 2002/05/22 20:54:14 knoaman Exp $
+ * $Id: TraverseSchema.hpp,v 1.10 2002/05/27 19:54:57 knoaman Exp $
*/
#if !defined(TRAVERSESCHEMA_HPP)
@@ -114,15 +114,15 @@
// -----------------------------------------------------------------------
TraverseSchema
(
- DOMElement* const schemaRoot
- , XMLStringPool* const uriStringPool
- , SchemaGrammar* const schemaGrammar
- , GrammarResolver* const grammarResolver
- , XMLScanner* const xmlScanner
- , XMLValidator* const xmlValidator
- , const XMLCh* const schemaURL
- , XMLEntityHandler* const entityHandler
- , XMLErrorReporter* const errorReporter
+ DOMElement* const schemaRoot
+ , XMLStringPool* const uriStringPool
+ , SchemaGrammar* const schemaGrammar
+ , GrammarResolver* const grammarResolver
+ , XMLScanner* const xmlScanner
+ , XMLValidator* const xmlValidator
+ , const XMLCh* const schemaURL
+ , XMLEntityHandler* const entityHandler
+ , XMLErrorReporter* const errorReporter
);
~TraverseSchema();
@@ -495,11 +495,8 @@
const XMLCh* const localPart);
/**
- * Returns true if 'name' is a valid facet for a given 'component',
- * otherwise false
+ * Returns true if a DOM Element is an attribute or attribute group
*/
- bool isValidFacet(const XMLCh* const component, const XMLCh* const name);
-
bool isAttrOrAttrGroup(const DOMElement* const elem);
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org