Reordered files in all libs - now all includes are in "libname/include" dir - logical, isn't it? This should break compilation however.

This commit is contained in:
pelya
2010-10-26 14:43:54 +03:00
parent fc58bc53c0
commit 6b9b163689
520 changed files with 41 additions and 43205 deletions

View File

@@ -0,0 +1,531 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* $Id: ComplexTypeInfo.hpp 932887 2010-04-11 13:04:59Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_COMPLEXTYPEINFO_HPP)
#define XERCESC_INCLUDE_GUARD_COMPLEXTYPEINFO_HPP
/**
* The class act as a place holder to store complex type information.
*
* The class is intended for internal use.
*/
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <xercesc/util/XMLString.hpp>
#include <xercesc/util/RefHash2KeysTableOf.hpp>
#include <xercesc/util/RefVectorOf.hpp>
#include <xercesc/framework/XMLElementDecl.hpp>
#include <xercesc/framework/XMLContentModel.hpp>
#include <xercesc/validators/schema/SchemaAttDef.hpp>
#include <xercesc/internal/XSerializable.hpp>
XERCES_CPP_NAMESPACE_BEGIN
// ---------------------------------------------------------------------------
// Forward Declarations
// ---------------------------------------------------------------------------
class DatatypeValidator;
class ContentSpecNode;
class SchemaAttDefList;
class SchemaElementDecl;
class XSDLocator;
class VALIDATORS_EXPORT ComplexTypeInfo : public XSerializable, public XMemory
{
public:
// -----------------------------------------------------------------------
// Public Constructors/Destructor
// -----------------------------------------------------------------------
ComplexTypeInfo(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
~ComplexTypeInfo();
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
bool getAbstract() const;
bool getAdoptContentSpec() const;
bool containsAttWithTypeId() const;
bool getPreprocessed() const;
int getDerivedBy() const;
int getBlockSet() const;
int getFinalSet() const;
unsigned int getScopeDefined() const;
unsigned int getElementId() const;
int getContentType() const;
XMLSize_t elementCount() const;
XMLCh* getTypeName() const;
DatatypeValidator* getBaseDatatypeValidator() const;
DatatypeValidator* getDatatypeValidator() const;
ComplexTypeInfo* getBaseComplexTypeInfo() const;
ContentSpecNode* getContentSpec() const;
const SchemaAttDef* getAttWildCard() const;
SchemaAttDef* getAttWildCard();
const SchemaAttDef* getAttDef(const XMLCh* const baseName,
const int uriId) const;
SchemaAttDef* getAttDef(const XMLCh* const baseName,
const int uriId);
XMLAttDefList& getAttDefList() const;
const SchemaElementDecl* elementAt(const XMLSize_t index) const;
SchemaElementDecl* elementAt(const XMLSize_t index);
XMLContentModel* getContentModel(const bool checkUPA = false);
const XMLCh* getFormattedContentModel () const;
XSDLocator* getLocator() const;
const XMLCh* getTypeLocalName() const;
const XMLCh* getTypeUri() const;
/**
* returns true if this type is anonymous
**/
bool getAnonymous() const;
// -----------------------------------------------------------------------
// Setter methods
// -----------------------------------------------------------------------
void setAbstract(const bool isAbstract);
void setAdoptContentSpec(const bool toAdopt);
void setAttWithTypeId(const bool value);
void setPreprocessed(const bool aValue = true);
void setDerivedBy(const int derivedBy);
void setBlockSet(const int blockSet);
void setFinalSet(const int finalSet);
void setScopeDefined(const unsigned int scopeDefined);
void setElementId(const unsigned int elemId);
void setTypeName(const XMLCh* const typeName);
void setContentType(const int contentType);
void setBaseDatatypeValidator(DatatypeValidator* const baseValidator);
void setDatatypeValidator(DatatypeValidator* const validator);
void setBaseComplexTypeInfo(ComplexTypeInfo* const typeInfo);
void setContentSpec(ContentSpecNode* const toAdopt);
void setAttWildCard(SchemaAttDef* const toAdopt);
void addAttDef(SchemaAttDef* const toAdd);
void addElement(SchemaElementDecl* const toAdd);
void setLocator(XSDLocator* const aLocator);
/**
* sets this type to be anonymous
**/
void setAnonymous();
// -----------------------------------------------------------------------
// Helper methods
// -----------------------------------------------------------------------
bool hasAttDefs() const;
bool contains(const XMLCh* const attName);
void checkUniqueParticleAttribution
(
SchemaGrammar* const pGrammar
, GrammarResolver* const pGrammarResolver
, XMLStringPool* const pStringPool
, XMLValidator* const pValidator
) ;
/**
* Return a singleton that represents 'anyType'
*
* @param emptyNSId the uri id of the empty namespace
*/
static ComplexTypeInfo* getAnyType(unsigned int emptyNSId);
/**
* Notification that lazy data has been deleted
*/
static void reinitAnyType();
/***
* Support for Serialization/De-serialization
***/
DECL_XSERIALIZABLE(ComplexTypeInfo)
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
ComplexTypeInfo(const ComplexTypeInfo& elemInfo);
ComplexTypeInfo& operator= (const ComplexTypeInfo& other);
// -----------------------------------------------------------------------
// Private helper methods
// -----------------------------------------------------------------------
void faultInAttDefList() const;
bool useRepeatingLeafNodes(ContentSpecNode* particle);
XMLContentModel* makeContentModel(bool checkUPA = false);
XMLCh* formatContentModel () const ;
ContentSpecNode* expandContentModel(ContentSpecNode* const curNode, int minOccurs, int maxOccurs, bool bAllowCompactSyntax);
ContentSpecNode* convertContentSpecTree(ContentSpecNode* const curNode, bool checkUPA, bool bAllowCompactSyntax);
void resizeContentSpecOrgURI();
// -----------------------------------------------------------------------
// Private data members
// -----------------------------------------------------------------------
bool fAnonymous;
bool fAbstract;
bool fAdoptContentSpec;
bool fAttWithTypeId;
bool fPreprocessed;
int fDerivedBy;
int fBlockSet;
int fFinalSet;
unsigned int fScopeDefined;
int fContentType;
unsigned int fElementId;
unsigned int fUniqueURI;
unsigned int fContentSpecOrgURISize;
XMLCh* fTypeName;
XMLCh* fTypeLocalName;
XMLCh* fTypeUri;
DatatypeValidator* fBaseDatatypeValidator;
DatatypeValidator* fDatatypeValidator;
ComplexTypeInfo* fBaseComplexTypeInfo;
ContentSpecNode* fContentSpec;
SchemaAttDef* fAttWildCard;
SchemaAttDefList* fAttList;
RefVectorOf<SchemaElementDecl>* fElements;
RefHash2KeysTableOf<SchemaAttDef>* fAttDefs;
XMLContentModel* fContentModel;
XMLCh* fFormattedModel;
unsigned int* fContentSpecOrgURI;
XSDLocator* fLocator;
MemoryManager* fMemoryManager;
static ComplexTypeInfo* fAnyType;
friend class XMLInitializer;
};
// ---------------------------------------------------------------------------
// ComplexTypeInfo: Getter methods
// ---------------------------------------------------------------------------
inline bool ComplexTypeInfo::getAbstract() const {
return fAbstract;
}
inline bool ComplexTypeInfo::getAdoptContentSpec() const {
return fAdoptContentSpec;
}
inline bool ComplexTypeInfo::containsAttWithTypeId() const {
return fAttWithTypeId;
}
inline bool ComplexTypeInfo::getPreprocessed() const {
return fPreprocessed;
}
inline int ComplexTypeInfo::getDerivedBy() const {
return fDerivedBy;
}
inline int ComplexTypeInfo::getBlockSet() const {
return fBlockSet;
}
inline int ComplexTypeInfo::getFinalSet() const {
return fFinalSet;
}
inline unsigned int ComplexTypeInfo::getScopeDefined() const {
return fScopeDefined;
}
inline unsigned int ComplexTypeInfo::getElementId() const {
return fElementId;
}
inline int ComplexTypeInfo::getContentType() const {
return fContentType;
}
inline XMLSize_t ComplexTypeInfo::elementCount() const {
if (fElements) {
return fElements->size();
}
return 0;
}
inline XMLCh* ComplexTypeInfo::getTypeName() const {
return fTypeName;
}
inline DatatypeValidator* ComplexTypeInfo::getBaseDatatypeValidator() const {
return fBaseDatatypeValidator;
}
inline DatatypeValidator* ComplexTypeInfo::getDatatypeValidator() const {
return fDatatypeValidator;
}
inline ComplexTypeInfo* ComplexTypeInfo::getBaseComplexTypeInfo() const {
return fBaseComplexTypeInfo;
}
inline ContentSpecNode* ComplexTypeInfo::getContentSpec() const {
return fContentSpec;
}
inline const SchemaAttDef* ComplexTypeInfo::getAttWildCard() const {
return fAttWildCard;
}
inline SchemaAttDef* ComplexTypeInfo::getAttWildCard() {
return fAttWildCard;
}
inline const SchemaAttDef* ComplexTypeInfo::getAttDef(const XMLCh* const baseName,
const int uriId) const {
return fAttDefs->get(baseName, uriId);
}
inline SchemaAttDef* ComplexTypeInfo::getAttDef(const XMLCh* const baseName,
const int uriId)
{
return fAttDefs->get(baseName, uriId);
}
inline SchemaElementDecl*
ComplexTypeInfo::elementAt(const XMLSize_t index) {
if (!fElements) {
return 0; // REVISIT - need to throw an exception
}
return fElements->elementAt(index);
}
inline const SchemaElementDecl*
ComplexTypeInfo::elementAt(const XMLSize_t index) const {
if (!fElements) {
return 0; // REVISIT - need to throw an exception
}
return fElements->elementAt(index);
}
inline XMLContentModel* ComplexTypeInfo::getContentModel(const bool checkUPA)
{
if (!fContentModel && fContentSpec)
fContentModel = makeContentModel(checkUPA);
return fContentModel;
}
inline XSDLocator* ComplexTypeInfo::getLocator() const
{
return fLocator;
}
inline bool ComplexTypeInfo::getAnonymous() const {
return fAnonymous;
}
inline const XMLCh* ComplexTypeInfo::getTypeLocalName() const
{
return fTypeLocalName;
}
inline const XMLCh* ComplexTypeInfo::getTypeUri() const
{
return fTypeUri;
}
// ---------------------------------------------------------------------------
// ComplexTypeInfo: Setter methods
// ---------------------------------------------------------------------------
inline void ComplexTypeInfo::setAbstract(const bool isAbstract) {
fAbstract = isAbstract;
}
inline void ComplexTypeInfo::setAdoptContentSpec(const bool toAdopt) {
fAdoptContentSpec = toAdopt;
}
inline void ComplexTypeInfo::setAttWithTypeId(const bool value) {
fAttWithTypeId = value;
}
inline void ComplexTypeInfo::setPreprocessed(const bool aValue) {
fPreprocessed = aValue;
}
inline void ComplexTypeInfo::setDerivedBy(const int derivedBy) {
fDerivedBy = derivedBy;
}
inline void ComplexTypeInfo::setBlockSet(const int blockSet) {
fBlockSet = blockSet;
}
inline void ComplexTypeInfo::setFinalSet(const int finalSet) {
fFinalSet = finalSet;
}
inline void ComplexTypeInfo::setScopeDefined(const unsigned int scopeDefined) {
fScopeDefined = scopeDefined;
}
inline void ComplexTypeInfo::setElementId(const unsigned int elemId) {
fElementId = elemId;
}
inline void
ComplexTypeInfo::setContentType(const int contentType) {
fContentType = contentType;
}
inline void ComplexTypeInfo::setTypeName(const XMLCh* const typeName) {
fMemoryManager->deallocate(fTypeName);//delete [] fTypeName;
fMemoryManager->deallocate(fTypeLocalName);//delete [] fTypeLocalName;
fMemoryManager->deallocate(fTypeUri);//delete [] fTypeUri;
if (typeName)
{
fTypeName = XMLString::replicate(typeName, fMemoryManager);
int index = XMLString::indexOf(fTypeName, chComma);
XMLSize_t length = XMLString::stringLen(fTypeName);
fTypeLocalName = (XMLCh*) fMemoryManager->allocate
(
(length - index + 1) * sizeof(XMLCh)
); //new XMLCh[length - index + 1];
XMLString::subString(fTypeLocalName, fTypeName, index + 1, length, fMemoryManager);
fTypeUri = (XMLCh*) fMemoryManager->allocate
(
(index + 1) * sizeof(XMLCh)
); //new XMLCh[index + 1];
XMLString::subString(fTypeUri, fTypeName, 0, index, fMemoryManager);
}
else
{
fTypeName = fTypeLocalName = fTypeUri = 0;
}
}
inline void
ComplexTypeInfo::setBaseDatatypeValidator(DatatypeValidator* const validator) {
fBaseDatatypeValidator = validator;
}
inline void
ComplexTypeInfo::setDatatypeValidator(DatatypeValidator* const validator) {
fDatatypeValidator = validator;
}
inline void
ComplexTypeInfo::setBaseComplexTypeInfo(ComplexTypeInfo* const typeInfo) {
fBaseComplexTypeInfo = typeInfo;
}
inline void ComplexTypeInfo::addElement(SchemaElementDecl* const elem) {
if (!fElements) {
fElements = new (fMemoryManager) RefVectorOf<SchemaElementDecl>(8, false, fMemoryManager);
}
else if (fElements->containsElement(elem)) {
return;
}
fElements->addElement(elem);
}
inline void ComplexTypeInfo::setAttWildCard(SchemaAttDef* const toAdopt) {
if (fAttWildCard) {
delete fAttWildCard;
}
fAttWildCard = toAdopt;
}
inline void ComplexTypeInfo::setAnonymous() {
fAnonymous = true;
}
// ---------------------------------------------------------------------------
// ComplexTypeInfo: Helper methods
// ---------------------------------------------------------------------------
inline bool ComplexTypeInfo::hasAttDefs() const
{
return !fAttDefs->isEmpty();
}
inline bool ComplexTypeInfo::contains(const XMLCh* const attName) {
RefHash2KeysTableOfEnumerator<SchemaAttDef> enumDefs(fAttDefs, false, fMemoryManager);
while (enumDefs.hasMoreElements()) {
if (XMLString::equals(attName, enumDefs.nextElement().getAttName()->getLocalPart())) {
return true;
}
}
return false;
}
XERCES_CPP_NAMESPACE_END
#endif
/**
* End of file ComplexTypeInfo.hpp
*/

View File

@@ -0,0 +1,258 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* $Id: GeneralAttributeCheck.hpp 729944 2008-12-29 17:03:32Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_GENERALATTRIBUTECHECK_HPP)
#define XERCESC_INCLUDE_GUARD_GENERALATTRIBUTECHECK_HPP
/**
* A general purpose class to check for valid values of attributes, as well
* as check for proper association with corresponding schema elements.
*/
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <xercesc/util/RefHashTableOf.hpp>
#include <xercesc/util/ValueHashTableOf.hpp>
#include <xercesc/validators/datatype/IDDatatypeValidator.hpp>
#include <xercesc/framework/ValidationContext.hpp>
XERCES_CPP_NAMESPACE_BEGIN
// ---------------------------------------------------------------------------
// Forward declaration
// ---------------------------------------------------------------------------
class TraverseSchema;
class DOMElement;
class DOMNode;
class VALIDATORS_EXPORT GeneralAttributeCheck : public XMemory
{
public:
// -----------------------------------------------------------------------
// Constants
// -----------------------------------------------------------------------
//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,
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
};
//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
// -----------------------------------------------------------------------
// Constructor/Destructor
// -----------------------------------------------------------------------
GeneralAttributeCheck(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
~GeneralAttributeCheck();
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
unsigned short getFacetId(const XMLCh* const facetName, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
// -----------------------------------------------------------------------
// Validation methods
// -----------------------------------------------------------------------
void checkAttributes(const DOMElement* const elem,
const unsigned short elemContext,
TraverseSchema* const schema,
const bool isTopLevel = false,
ValueVectorOf<DOMNode*>* const nonXSAttList = 0);
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
GeneralAttributeCheck(const GeneralAttributeCheck&);
GeneralAttributeCheck& operator=(const GeneralAttributeCheck&);
// -----------------------------------------------------------------------
// Validation methods
// -----------------------------------------------------------------------
void validate(const DOMElement* const elem, const XMLCh* const attName, const XMLCh* const attValue,
const short dvIndex, TraverseSchema* const schema);
// -----------------------------------------------------------------------
// Private Constants
// -----------------------------------------------------------------------
// optional vs. required attribute
enum {
Att_Required = 1,
Att_Optional = 2,
Att_Mask = 3
};
// -----------------------------------------------------------------------
// Private data members
// -----------------------------------------------------------------------
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];
MemoryManager* fMemoryManager;
IDDatatypeValidator fIDValidator;
private:
static void initialize();
friend class XMLInitializer;
};
// ---------------------------------------------------------------------------
// GeneralAttributeCheck: Getter methods
// ---------------------------------------------------------------------------
inline unsigned short
GeneralAttributeCheck::getFacetId(const XMLCh* const facetName, MemoryManager* const manager) {
return fFacetsMap->get(facetName, manager);
}
XERCES_CPP_NAMESPACE_END
#endif
/**
* End of file GeneralAttributeCheck.hpp
*/

View File

@@ -0,0 +1,169 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* $Id: NamespaceScope.hpp 729944 2008-12-29 17:03:32Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_NAMESPACESCOPE_HPP)
#define XERCESC_INCLUDE_GUARD_NAMESPACESCOPE_HPP
#include <xercesc/util/StringPool.hpp>
XERCES_CPP_NAMESPACE_BEGIN
// Define a pure interface to allow XercesXPath to work on both NamespaceScope and DOMXPathNSResolver
class VALIDATORS_EXPORT XercesNamespaceResolver
{
public:
virtual unsigned int getNamespaceForPrefix(const XMLCh* const prefix) const = 0;
};
//
// NamespaceScope provides a data structure for mapping namespace prefixes
// to their URI's. The mapping accurately reflects the scoping of namespaces
// at a particular instant in time.
//
class VALIDATORS_EXPORT NamespaceScope : public XMemory,
public XercesNamespaceResolver
{
public :
// -----------------------------------------------------------------------
// Class specific data types
//
// These really should be private, but some of the compilers we have to
// support are too dumb to deal with that.
//
// PrefMapElem
// fURIId is the id of the URI from the validator's URI map. The
// fPrefId is the id of the prefix from our own prefix pool. The
// namespace stack consists of these elements.
//
// StackElem
// The fMapCapacity is how large fMap has grown so far. fMapCount
// is how many of them are valid right now.
// -----------------------------------------------------------------------
struct PrefMapElem : public XMemory
{
unsigned int fPrefId;
unsigned int fURIId;
};
struct StackElem : public XMemory
{
PrefMapElem* fMap;
unsigned int fMapCapacity;
unsigned int fMapCount;
};
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
NamespaceScope(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
NamespaceScope(const NamespaceScope* const initialize, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
~NamespaceScope();
// -----------------------------------------------------------------------
// Stack access
// -----------------------------------------------------------------------
unsigned int increaseDepth();
unsigned int decreaseDepth();
// -----------------------------------------------------------------------
// Prefix map methods
// -----------------------------------------------------------------------
void addPrefix(const XMLCh* const prefixToAdd,
const unsigned int uriId);
virtual unsigned int getNamespaceForPrefix(const XMLCh* const prefixToMap) const;
// -----------------------------------------------------------------------
// Miscellaneous methods
// -----------------------------------------------------------------------
bool isEmpty() const;
void reset(const unsigned int emptyId);
unsigned int getEmptyNamespaceId() const;
private :
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
NamespaceScope(const NamespaceScope&);
NamespaceScope& operator=(const NamespaceScope&);
// -----------------------------------------------------------------------
// Private helper methods
// -----------------------------------------------------------------------
void expandMap(StackElem* const toExpand);
void expandStack();
// -----------------------------------------------------------------------
// Data members
//
// fEmptyNamespaceId
// This is the special URI id for the "" namespace, which is magic
// because of the xmlns="" operation.
//
// fPrefixPool
// This is the prefix pool where prefixes are hashed and given unique
// ids. These ids are used to track prefixes in the element stack.
//
// fStack
// fStackCapacity
// fStackTop
// This the stack array. Its an array of pointers to StackElem
// structures. The capacity is the current high water mark of the
// stack. The top is the current top of stack (i.e. the part of it
// being used.)
// -----------------------------------------------------------------------
unsigned int fEmptyNamespaceId;
unsigned int fStackCapacity;
unsigned int fStackTop;
XMLStringPool fPrefixPool;
StackElem** fStack;
MemoryManager* fMemoryManager;
};
// ---------------------------------------------------------------------------
// NamespaceScope: Miscellaneous methods
// ---------------------------------------------------------------------------
inline bool NamespaceScope::isEmpty() const
{
return (fStackTop == 0);
}
inline unsigned int NamespaceScope::getEmptyNamespaceId() const
{
return fEmptyNamespaceId;
}
XERCES_CPP_NAMESPACE_END
#endif
/**
* End of file NameSpaceScope.hpp
*/

View File

@@ -0,0 +1,40 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* $Id: PSVIDefs.hpp 932887 2010-04-11 13:04:59Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_PSVIDEFS_HPP)
#define XERCESC_INCLUDE_GUARD_PSVIDEFS_HPP
XERCES_CPP_NAMESPACE_BEGIN
class VALIDATORS_EXPORT PSVIDefs
{
public:
enum PSVIScope
{
SCP_ABSENT // declared in group/attribute group
, SCP_GLOBAL // global declaration or ref
, SCP_LOCAL // local declaration
};
};
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,252 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* $Id: SchemaAttDef.hpp 676911 2008-07-15 13:27:32Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_SCHEMAATTDEF_HPP)
#define XERCESC_INCLUDE_GUARD_SCHEMAATTDEF_HPP
#include <xercesc/util/XMLString.hpp>
#include <xercesc/framework/XMLAttDef.hpp>
#include <xercesc/util/ValueVectorOf.hpp>
#include <xercesc/validators/datatype/DatatypeValidator.hpp>
#include <xercesc/validators/datatype/UnionDatatypeValidator.hpp>
#include <xercesc/validators/schema/PSVIDefs.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class DatatypeValidator;
class QName;
class ComplexTypeInfo;
//
// This class is a derivative of the core XMLAttDef class. This class adds
// any Schema specific data members and provides Schema specific implementations
// of any underlying attribute def virtual methods.
//
class VALIDATORS_EXPORT SchemaAttDef : public XMLAttDef
{
public :
// -----------------------------------------------------------------------
// Constructors and Destructors
// -----------------------------------------------------------------------
SchemaAttDef(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
SchemaAttDef
(
const XMLCh* const prefix
, const XMLCh* const localPart
, const int uriId
, const XMLAttDef::AttTypes type = CData
, const XMLAttDef::DefAttTypes defType = Implied
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
SchemaAttDef
(
const XMLCh* const prefix
, const XMLCh* const localPart
, const int uriId
, const XMLCh* const attValue
, const XMLAttDef::AttTypes type
, const XMLAttDef::DefAttTypes defType
, const XMLCh* const enumValues = 0
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
SchemaAttDef
(
const SchemaAttDef* other
);
virtual ~SchemaAttDef();
// -----------------------------------------------------------------------
// Implementation of the XMLAttDef interface
// -----------------------------------------------------------------------
virtual const XMLCh* getFullName() const;
virtual void reset();
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
XMLSize_t getElemId() const;
QName* getAttName() const;
DatatypeValidator* getDatatypeValidator() const;
ValueVectorOf<unsigned int>* getNamespaceList() const;
const SchemaAttDef* getBaseAttDecl() const;
SchemaAttDef* getBaseAttDecl();
PSVIDefs::PSVIScope getPSVIScope() const;
// -----------------------------------------------------------------------
// Setter methods
// -----------------------------------------------------------------------
void setElemId(const XMLSize_t newId);
void setAttName
(
const XMLCh* const prefix
,const XMLCh* const localPart
,const int uriId = -1
);
void setDatatypeValidator(DatatypeValidator* newDatatypeValidator);
void setBaseAttDecl(SchemaAttDef* const attDef);
void setPSVIScope(const PSVIDefs::PSVIScope toSet);
void setNamespaceList(const ValueVectorOf<unsigned int>* const toSet);
void resetNamespaceList();
void setEnclosingCT(ComplexTypeInfo* complexTypeInfo);
/***
* Support for Serialization/De-serialization
***/
DECL_XSERIALIZABLE(SchemaAttDef)
private :
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
SchemaAttDef(const SchemaAttDef&);
SchemaAttDef& operator=(const SchemaAttDef&);
// -----------------------------------------------------------------------
// Private data members
//
// fElemId
// This is the id of the element (the id is into the element decl
// pool) of the element this attribute def said it belonged to.
// This is used later to link back to the element, mostly for
// validation purposes.
//
// fAttName
// This is the name of the attribute.
//
// fDatatypeValidator
// The DatatypeValidator used to validate this attribute type.
//
// fNamespaceList
// The list of namespace values for a wildcard attribute
//
// fBaseAttDecl
// The base attribute declaration that this attribute is based on
// NOTE: we do not have a notion of attribute use, so in the case
// of ref'd attributes and inherited attributes, we make a copy
// of the actual attribute declaration. The fBaseAttDecl stores that
// declaration, and will be helpful when we build the XSModel (i.e
// easy access the XSAnnotation object).
// -----------------------------------------------------------------------
XMLSize_t fElemId;
PSVIDefs::PSVIScope fPSVIScope;
QName* fAttName;
DatatypeValidator* fDatatypeValidator;
ValueVectorOf<unsigned int>* fNamespaceList;
SchemaAttDef* fBaseAttDecl;
};
// ---------------------------------------------------------------------------
// SchemaAttDef: Getter methods
// ---------------------------------------------------------------------------
inline XMLSize_t SchemaAttDef::getElemId() const
{
return fElemId;
}
inline QName* SchemaAttDef::getAttName() const
{
return fAttName;
}
inline DatatypeValidator* SchemaAttDef::getDatatypeValidator() const
{
return fDatatypeValidator;
}
inline ValueVectorOf<unsigned int>*
SchemaAttDef::getNamespaceList() const {
return fNamespaceList;
}
inline SchemaAttDef* SchemaAttDef::getBaseAttDecl()
{
return fBaseAttDecl;
}
inline const SchemaAttDef* SchemaAttDef::getBaseAttDecl() const
{
return fBaseAttDecl;
}
inline PSVIDefs::PSVIScope SchemaAttDef::getPSVIScope() const
{
return fPSVIScope;
}
// ---------------------------------------------------------------------------
// SchemaAttDef: Setter methods
// ---------------------------------------------------------------------------
inline void SchemaAttDef::setElemId(const XMLSize_t newId)
{
fElemId = newId;
}
inline void SchemaAttDef::setDatatypeValidator(DatatypeValidator* newDatatypeValidator)
{
fDatatypeValidator = newDatatypeValidator;
}
inline void SchemaAttDef::resetNamespaceList() {
if (fNamespaceList && fNamespaceList->size()) {
fNamespaceList->removeAllElements();
}
}
inline void SchemaAttDef::setNamespaceList(const ValueVectorOf<unsigned int>* const toSet) {
if (toSet && toSet->size()) {
if (fNamespaceList) {
*fNamespaceList = *toSet;
}
else {
fNamespaceList = new (getMemoryManager()) ValueVectorOf<unsigned int>(*toSet);
}
}
else {
resetNamespaceList();
}
}
inline void SchemaAttDef::reset() {
}
inline void SchemaAttDef::setEnclosingCT(ComplexTypeInfo*)
{
}
inline void SchemaAttDef::setBaseAttDecl(SchemaAttDef* const attDef)
{
fBaseAttDecl = attDef;
}
inline void SchemaAttDef::setPSVIScope(const PSVIDefs::PSVIScope toSet)
{
fPSVIScope = toSet;
}
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,181 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* $Id: SchemaAttDefList.hpp 673679 2008-07-03 13:50:10Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_SCHEMAATTDEFLIST_HPP)
#define XERCESC_INCLUDE_GUARD_SCHEMAATTDEFLIST_HPP
#include <xercesc/util/RefHash2KeysTableOf.hpp>
#include <xercesc/validators/schema/SchemaElementDecl.hpp>
XERCES_CPP_NAMESPACE_BEGIN
//
// This is a derivative of the framework abstract class which defines the
// interface to a list of attribute defs that belong to a particular
// element. The scanner needs to be able to get a list of the attributes
// that an element supports, for use during the validation process and for
// fixed/default attribute processing.
//
// For us, we just wrap the RefHash2KeysTableOf collection that the SchemaElementDecl
// class uses to store the attributes that belong to it.
//
// This class does not adopt the hash table, it just references it. The
// hash table is owned by the element decl it is a member of.
//
class VALIDATORS_EXPORT SchemaAttDefList : public XMLAttDefList
{
public :
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
SchemaAttDefList
(
RefHash2KeysTableOf<SchemaAttDef>* const listToUse,
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
~SchemaAttDefList();
// -----------------------------------------------------------------------
// Implementation of the virtual interface
// -----------------------------------------------------------------------
virtual bool isEmpty() const;
virtual XMLAttDef* findAttDef
(
const unsigned int uriID
, const XMLCh* const attName
);
virtual const XMLAttDef* findAttDef
(
const unsigned int uriID
, const XMLCh* const attName
) const;
virtual XMLAttDef* findAttDef
(
const XMLCh* const attURI
, const XMLCh* const attName
);
virtual const XMLAttDef* findAttDef
(
const XMLCh* const attURI
, const XMLCh* const attName
) const;
XMLAttDef* findAttDefLocalPart
(
const unsigned int uriID
, const XMLCh* const attLocalPart
);
const XMLAttDef* findAttDefLocalPart
(
const unsigned int uriID
, const XMLCh* const attLocalPart
) const;
/**
* return total number of attributes in this list
*/
virtual XMLSize_t getAttDefCount() const ;
/**
* return attribute at the index-th position in the list.
*/
virtual XMLAttDef &getAttDef(XMLSize_t index) ;
/**
* return attribute at the index-th position in the list.
*/
virtual const XMLAttDef &getAttDef(XMLSize_t index) const ;
/***
* Support for Serialization/De-serialization
***/
DECL_XSERIALIZABLE(SchemaAttDefList)
SchemaAttDefList(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
private :
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
SchemaAttDefList(const SchemaAttDefList&);
SchemaAttDefList& operator=(const SchemaAttDefList&);
void addAttDef(SchemaAttDef *toAdd);
// -----------------------------------------------------------------------
// Private data members
//
// fEnum
// This is an enumerator for the list that we use to do the enumerator
// type methods of this class.
//
// fList
// The list of SchemaAttDef objects that represent the attributes that
// a particular element supports.
// fArray
// vector of pointers to the DTDAttDef objects contained in this list
// fSize
// size of fArray
// fCount
// number of DTDAttDef objects currently stored in this list
// -----------------------------------------------------------------------
RefHash2KeysTableOfEnumerator<SchemaAttDef>* fEnum;
RefHash2KeysTableOf<SchemaAttDef>* fList;
SchemaAttDef** fArray;
XMLSize_t fSize;
XMLSize_t fCount;
friend class ComplexTypeInfo;
};
inline void SchemaAttDefList::addAttDef(SchemaAttDef *toAdd)
{
if(fCount == fSize)
{
// need to grow fArray
fSize <<= 1;
SchemaAttDef** newArray = (SchemaAttDef **)((getMemoryManager())->allocate( sizeof(SchemaAttDef*) * fSize ));
memcpy(newArray, fArray, fCount * sizeof(SchemaAttDef *));
(getMemoryManager())->deallocate(fArray);
fArray = newArray;
}
fArray[fCount++] = toAdd;
}
inline XMLAttDef* SchemaAttDefList::findAttDefLocalPart(const unsigned int uriID
, const XMLCh* const attLocalPart)
{
return fList->get((void*)attLocalPart, uriID);
}
inline const XMLAttDef* SchemaAttDefList::findAttDefLocalPart(const unsigned int uriID
, const XMLCh* const attLocalPart) const
{
return fList->get((void*)attLocalPart, uriID);
}
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,438 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* $Id: SchemaElementDecl.hpp 932887 2010-04-11 13:04:59Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_SCHEMAELEMENTDECL_HPP)
#define XERCESC_INCLUDE_GUARD_SCHEMAELEMENTDECL_HPP
#include <xercesc/util/QName.hpp>
#include <xercesc/validators/common/Grammar.hpp>
#include <xercesc/validators/schema/ComplexTypeInfo.hpp>
#include <xercesc/validators/schema/identity/IdentityConstraint.hpp>
#include <xercesc/validators/datatype/DatatypeValidator.hpp>
#include <xercesc/validators/schema/PSVIDefs.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class ContentSpecNode;
class SchemaAttDefList;
//
// This class is a derivative of the basic element decl. This one implements
// the virtuals so that they work for a Schema.
//
class VALIDATORS_EXPORT SchemaElementDecl : public XMLElementDecl
{
public :
// -----------------------------------------------------------------------
// Class specific types
//
// ModelTypes
// Indicates the type of content model that an element has. This
// indicates how the content model is represented and validated.
// -----------------------------------------------------------------------
enum ModelTypes
{
Empty
, Any
, Mixed_Simple
, Mixed_Complex
, Children
, Simple
, ElementOnlyEmpty
, ModelTypes_Count
};
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
SchemaElementDecl(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
SchemaElementDecl
(
const XMLCh* const prefix
, const XMLCh* const localPart
, const int uriId
, const ModelTypes modelType = Any
, const unsigned int enclosingScope = Grammar::TOP_LEVEL_SCOPE
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
SchemaElementDecl
(
const QName* const elementName
, const ModelTypes modelType = Any
, const unsigned int enclosingScope = Grammar::TOP_LEVEL_SCOPE
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
~SchemaElementDecl();
// -----------------------------------------------------------------------
// The virtual element decl interface
// -----------------------------------------------------------------------
virtual XMLAttDefList& getAttDefList() const;
virtual CharDataOpts getCharDataOpts() const;
virtual bool hasAttDefs() const;
virtual const ContentSpecNode* getContentSpec() const;
virtual ContentSpecNode* getContentSpec();
virtual void setContentSpec(ContentSpecNode* toAdopt);
virtual XMLContentModel* getContentModel();
virtual void setContentModel(XMLContentModel* const newModelToAdopt);
virtual const XMLCh* getFormattedContentModel () const;
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
const SchemaAttDef* getAttDef(const XMLCh* const baseName, const int uriId) const;
SchemaAttDef* getAttDef(const XMLCh* const baseName, const int uriId);
const SchemaAttDef* getAttWildCard() const;
SchemaAttDef* getAttWildCard();
ModelTypes getModelType() const;
PSVIDefs::PSVIScope getPSVIScope() const;
DatatypeValidator* getDatatypeValidator() const;
unsigned int getEnclosingScope() const;
int getFinalSet() const;
int getBlockSet() const;
int getMiscFlags() const;
XMLCh* getDefaultValue() const;
ComplexTypeInfo* getComplexTypeInfo() const;
virtual bool isGlobalDecl() const;
SchemaElementDecl* getSubstitutionGroupElem() const;
// -----------------------------------------------------------------------
// Setter methods
// -----------------------------------------------------------------------
void setModelType(const SchemaElementDecl::ModelTypes toSet);
void setPSVIScope(const PSVIDefs::PSVIScope toSet);
void setDatatypeValidator(DatatypeValidator* newDatatypeValidator);
void setEnclosingScope(const unsigned int enclosingScope);
void setFinalSet(const int finalSet);
void setBlockSet(const int blockSet);
void setMiscFlags(const int flags);
void setDefaultValue(const XMLCh* const value);
void setComplexTypeInfo(ComplexTypeInfo* const typeInfo);
void setAttWildCard(SchemaAttDef* const attWildCard);
void setSubstitutionGroupElem(SchemaElementDecl* const elemDecl);
// -----------------------------------------------------------------------
// IC methods
// -----------------------------------------------------------------------
void addIdentityConstraint(IdentityConstraint* const ic);
XMLSize_t getIdentityConstraintCount() const;
IdentityConstraint* getIdentityConstraintAt(XMLSize_t index) const;
/***
* Support for Serialization/De-serialization
***/
DECL_XSERIALIZABLE(SchemaElementDecl)
virtual XMLElementDecl::objectType getObjectType() const;
private :
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
SchemaElementDecl(const SchemaElementDecl&);
SchemaElementDecl& operator=(const SchemaElementDecl&);
// -----------------------------------------------------------------------
// Private data members
//
// fModelType
// The content model type of this element. This tells us what kind
// of content model to create.
//
// fDatatypeValidator
// The DatatypeValidator used to validate this element type.
//
// fEnclosingScope
// The enclosing scope where this element is declared.
//
// fFinalSet
// The value set of the 'final' attribute.
//
// fBlockSet
// The value set of the 'block' attribute.
//
// fMiscFlags
// Stores 'abstract/nullable' values
//
// fDefaultValue
// The default/fixed value
//
// fComplexTypeInfo
// Stores complex type information
// (no need to delete - handled by schema grammar)
//
// fAttDefs
// The list of attributes that are faulted in for this element
// when ComplexTypeInfo does not exist. We want to keep track
// of these faulted in attributes to avoid duplicate redundant
// error.
//
// fIdentityConstraints
// Store information about an element identity constraints.
//
// fAttWildCard
// Store wildcard attribute in the case of an element with a type of
// 'anyType'.
//
// fSubstitutionGroupElem
// The substitution group element declaration.
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
ModelTypes fModelType;
PSVIDefs::PSVIScope fPSVIScope;
unsigned int fEnclosingScope;
int fFinalSet;
int fBlockSet;
int fMiscFlags;
XMLCh* fDefaultValue;
ComplexTypeInfo* fComplexTypeInfo;
RefHash2KeysTableOf<SchemaAttDef>* fAttDefs;
RefVectorOf<IdentityConstraint>* fIdentityConstraints;
SchemaAttDef* fAttWildCard;
SchemaElementDecl* fSubstitutionGroupElem;
DatatypeValidator* fDatatypeValidator;
};
// ---------------------------------------------------------------------------
// SchemaElementDecl: XMLElementDecl virtual interface implementation
// ---------------------------------------------------------------------------
inline ContentSpecNode* SchemaElementDecl::getContentSpec()
{
if (fComplexTypeInfo != 0) {
return fComplexTypeInfo->getContentSpec();
}
return 0;
}
inline const ContentSpecNode* SchemaElementDecl::getContentSpec() const
{
if (fComplexTypeInfo != 0) {
return fComplexTypeInfo->getContentSpec();
}
return 0;
}
inline void
SchemaElementDecl::setContentSpec(ContentSpecNode*)
{
//Handled by complexType
}
inline XMLContentModel* SchemaElementDecl::getContentModel()
{
if (fComplexTypeInfo != 0) {
return fComplexTypeInfo->getContentModel();
}
return 0;
}
inline void
SchemaElementDecl::setContentModel(XMLContentModel* const)
{
//Handled by complexType
}
// ---------------------------------------------------------------------------
// SchemaElementDecl: Getter methods
// ---------------------------------------------------------------------------
inline SchemaElementDecl::ModelTypes SchemaElementDecl::getModelType() const
{
if (fComplexTypeInfo) {
return (SchemaElementDecl::ModelTypes) fComplexTypeInfo->getContentType();
}
return fModelType;
}
inline PSVIDefs::PSVIScope SchemaElementDecl::getPSVIScope() const
{
return fPSVIScope;
}
inline DatatypeValidator* SchemaElementDecl::getDatatypeValidator() const
{
return fDatatypeValidator;
}
inline unsigned int SchemaElementDecl::getEnclosingScope() const
{
return fEnclosingScope;
}
inline int SchemaElementDecl::getFinalSet() const
{
return fFinalSet;
}
inline int SchemaElementDecl::getBlockSet() const
{
return fBlockSet;
}
inline int SchemaElementDecl::getMiscFlags() const
{
return fMiscFlags;
}
inline XMLCh* SchemaElementDecl::getDefaultValue() const
{
return fDefaultValue;
}
inline ComplexTypeInfo* SchemaElementDecl::getComplexTypeInfo() const
{
return fComplexTypeInfo;
}
inline const SchemaAttDef* SchemaElementDecl::getAttWildCard() const {
return fAttWildCard;
}
inline SchemaAttDef* SchemaElementDecl::getAttWildCard() {
return fAttWildCard;
}
inline bool SchemaElementDecl::isGlobalDecl() const {
return (fEnclosingScope == Grammar::TOP_LEVEL_SCOPE);
}
inline SchemaElementDecl*
SchemaElementDecl::getSubstitutionGroupElem() const {
return fSubstitutionGroupElem;
}
// ---------------------------------------------------------------------------
// SchemaElementDecl: Setter methods
// ---------------------------------------------------------------------------
inline void
SchemaElementDecl::setModelType(const SchemaElementDecl::ModelTypes toSet)
{
fModelType = toSet;
}
inline void
SchemaElementDecl::setPSVIScope(const PSVIDefs::PSVIScope toSet)
{
fPSVIScope = toSet;
}
inline void SchemaElementDecl::setDatatypeValidator(DatatypeValidator* newDatatypeValidator)
{
fDatatypeValidator = newDatatypeValidator;
}
inline void SchemaElementDecl::setEnclosingScope(const unsigned int newEnclosingScope)
{
fEnclosingScope = newEnclosingScope;
}
inline void SchemaElementDecl::setFinalSet(const int finalSet)
{
fFinalSet = finalSet;
}
inline void SchemaElementDecl::setBlockSet(const int blockSet)
{
fBlockSet = blockSet;
}
inline void SchemaElementDecl::setMiscFlags(const int flags)
{
fMiscFlags = flags;
}
inline void SchemaElementDecl::setDefaultValue(const XMLCh* const value)
{
if (fDefaultValue) {
getMemoryManager()->deallocate(fDefaultValue);//delete[] fDefaultValue;
}
fDefaultValue = XMLString::replicate(value, getMemoryManager());
}
inline void
SchemaElementDecl::setComplexTypeInfo(ComplexTypeInfo* const typeInfo)
{
fComplexTypeInfo = typeInfo;
}
inline void
SchemaElementDecl::setAttWildCard(SchemaAttDef* const attWildCard) {
if (fAttWildCard)
delete fAttWildCard;
fAttWildCard = attWildCard;
}
inline void
SchemaElementDecl::setSubstitutionGroupElem(SchemaElementDecl* const elemDecl) {
fSubstitutionGroupElem = elemDecl;
}
// ---------------------------------------------------------------------------
// SchemaElementDecl: IC methods
// ---------------------------------------------------------------------------
inline void
SchemaElementDecl::addIdentityConstraint(IdentityConstraint* const ic) {
if (!fIdentityConstraints) {
fIdentityConstraints = new (getMemoryManager()) RefVectorOf<IdentityConstraint>(16, true, getMemoryManager());
}
fIdentityConstraints->addElement(ic);
}
inline XMLSize_t SchemaElementDecl::getIdentityConstraintCount() const {
if (fIdentityConstraints) {
return fIdentityConstraints->size();
}
return 0;
}
inline IdentityConstraint*
SchemaElementDecl::getIdentityConstraintAt(XMLSize_t index) const {
if (fIdentityConstraints) {
return fIdentityConstraints->elementAt(index);
}
return 0;
}
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,638 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* $Id: SchemaGrammar.hpp 883376 2009-11-23 15:45:23Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_SCHEMAGRAMMAR_HPP)
#define XERCESC_INCLUDE_GUARD_SCHEMAGRAMMAR_HPP
#include <xercesc/framework/XMLNotationDecl.hpp>
#include <xercesc/util/RefHash3KeysIdPool.hpp>
#include <xercesc/util/NameIdPool.hpp>
#include <xercesc/util/StringPool.hpp>
#include <xercesc/validators/common/Grammar.hpp>
#include <xercesc/validators/schema/SchemaElementDecl.hpp>
#include <xercesc/util/ValueVectorOf.hpp>
#include <xercesc/validators/datatype/IDDatatypeValidator.hpp>
#include <xercesc/validators/datatype/DatatypeValidatorFactory.hpp>
#include <xercesc/framework/XMLSchemaDescription.hpp>
#include <xercesc/framework/ValidationContext.hpp>
XERCES_CPP_NAMESPACE_BEGIN
//
// This class stores the Schema information
// NOTE: Schemas are not namespace aware, so we just use regular NameIdPool
// data structures to store element and attribute decls. They are all set
// to be in the global namespace and the full QName is used as the base name
// of the decl. This means that all the URI parameters below are expected
// to be null pointers (and anything else will cause an exception.)
//
// ---------------------------------------------------------------------------
// Forward Declarations
// ---------------------------------------------------------------------------
class ComplexTypeInfo;
class XercesGroupInfo;
class XercesAttGroupInfo;
class XSAnnotation;
// ---------------------------------------------------------------------------
// typedef declaration
// ---------------------------------------------------------------------------
typedef ValueVectorOf<SchemaElementDecl*> ElemVector;
class VALIDATORS_EXPORT SchemaGrammar : public Grammar
{
public:
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
SchemaGrammar(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
virtual ~SchemaGrammar();
// -----------------------------------------------------------------------
// Implementation of Virtual Interface
// -----------------------------------------------------------------------
virtual Grammar::GrammarType getGrammarType() const;
virtual const XMLCh* getTargetNamespace() const;
// this method should only be used while the grammar is being
// constructed, not while it is being used
// in a validation episode!
virtual XMLElementDecl* findOrAddElemDecl
(
const unsigned int uriId
, const XMLCh* const baseName
, const XMLCh* const prefixName
, const XMLCh* const qName
, unsigned int scope
, bool& wasAdded
) ;
virtual XMLSize_t getElemId
(
const unsigned int uriId
, const XMLCh* const baseName
, const XMLCh* const qName
, unsigned int scope
) const ;
virtual const XMLElementDecl* getElemDecl
(
const unsigned int uriId
, const XMLCh* const baseName
, const XMLCh* const qName
, unsigned int scope
) const ;
virtual XMLElementDecl* getElemDecl
(
const unsigned int uriId
, const XMLCh* const baseName
, const XMLCh* const qName
, unsigned int scope
);
virtual const XMLElementDecl* getElemDecl
(
const unsigned int elemId
) const;
virtual XMLElementDecl* getElemDecl
(
const unsigned int elemId
);
virtual const XMLNotationDecl* getNotationDecl
(
const XMLCh* const notName
) const;
virtual XMLNotationDecl* getNotationDecl
(
const XMLCh* const notName
);
virtual bool getValidated() const;
virtual XMLElementDecl* putElemDecl
(
const unsigned int uriId
, const XMLCh* const baseName
, const XMLCh* const prefixName
, const XMLCh* const qName
, unsigned int scope
, const bool notDeclared = false
);
virtual XMLSize_t putElemDecl
(
XMLElementDecl* const elemDecl
, const bool notDeclared = false
) ;
virtual XMLSize_t putNotationDecl
(
XMLNotationDecl* const notationDecl
) const;
virtual void setValidated(const bool newState);
virtual void reset();
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
RefHash3KeysIdPoolEnumerator<SchemaElementDecl> getElemEnumerator() const;
NameIdPoolEnumerator<XMLNotationDecl> getNotationEnumerator() const;
RefHashTableOf<XMLAttDef>* getAttributeDeclRegistry() const;
RefHashTableOf<ComplexTypeInfo>* getComplexTypeRegistry() const;
RefHashTableOf<XercesGroupInfo>* getGroupInfoRegistry() const;
RefHashTableOf<XercesAttGroupInfo>* getAttGroupInfoRegistry() const;
DatatypeValidatorFactory* getDatatypeRegistry();
RefHash2KeysTableOf<ElemVector>* getValidSubstitutionGroups() const;
// @deprecated
ValidationContext* getValidationContext() const;
// -----------------------------------------------------------------------
// Setter methods
// -----------------------------------------------------------------------
void setTargetNamespace(const XMLCh* const targetNamespace);
void setAttributeDeclRegistry(RefHashTableOf<XMLAttDef>* const attReg);
void setComplexTypeRegistry(RefHashTableOf<ComplexTypeInfo>* const other);
void setGroupInfoRegistry(RefHashTableOf<XercesGroupInfo>* const other);
void setAttGroupInfoRegistry(RefHashTableOf<XercesAttGroupInfo>* const other);
void setValidSubstitutionGroups(RefHash2KeysTableOf<ElemVector>* const);
virtual void setGrammarDescription( XMLGrammarDescription*);
virtual XMLGrammarDescription* getGrammarDescription() const;
// -----------------------------------------------------------------------
// Helper methods
// -----------------------------------------------------------------------
XMLSize_t putGroupElemDecl
(
XMLElementDecl* const elemDecl
) const;
// -----------------------------------------------------------------------
// Annotation management methods
// -----------------------------------------------------------------------
/**
* Add annotation to the list of annotations for a given key
*/
void putAnnotation(void* key, XSAnnotation* const annotation);
/**
* Add global annotation
*
* Note: XSAnnotation acts as a linked list
*/
void addAnnotation(XSAnnotation* const annotation);
/**
* Retrieve the annotation that is associated with the specified key
*
* @param key represents a schema component object (i.e. SchemaGrammar)
* @return XSAnnotation associated with the key object
*/
XSAnnotation* getAnnotation(const void* const key);
/**
* Retrieve the annotation that is associated with the specified key
*
* @param key represents a schema component object (i.e. SchemaGrammar)
* @return XSAnnotation associated with the key object
*/
const XSAnnotation* getAnnotation(const void* const key) const;
/**
* Get global annotation
*/
XSAnnotation* getAnnotation();
const XSAnnotation* getAnnotation() const;
/**
* Get annotation hash table, to enumerate through them
*/
RefHashTableOf<XSAnnotation, PtrHasher>* getAnnotations();
const RefHashTableOf<XSAnnotation, PtrHasher>* getAnnotations() const;
/**
* Get/set scope count.
*/
unsigned int getScopeCount () const;
void setScopeCount (unsigned int);
/**
* Get/set anonymous type count.
*/
unsigned int getAnonTypeCount () const;
void setAnonTypeCount (unsigned int);
/***
* Support for Serialization/De-serialization
***/
DECL_XSERIALIZABLE(SchemaGrammar)
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
SchemaGrammar(const SchemaGrammar&);
SchemaGrammar& operator=(const SchemaGrammar&);
// -----------------------------------------------------------------------
// Helper methods
// -----------------------------------------------------------------------
void cleanUp();
// -----------------------------------------------------------------------
// Private data members
//
// fElemDeclPool
// This is the element decl pool. It contains all of the elements
// declared in the Schema (and their associated attributes.)
//
// fElemNonDeclPool
// This is the element decl pool that is is populated as new elements
// are seen in the XML document (not declared in the Schema), and they
// are given default characteristics.
//
// fGroupElemDeclPool
// This is the element decl pool for elements in a group that are
// referenced in different scope. It contains all of the elements
// declared in the Schema (and their associated attributes.)
//
// fNotationDeclPool
// This is a pool of NotationDecl objects, which contains all of the
// notations declared in the Schema.
//
// fTargetNamespace
// Target name space for this grammar.
//
// fAttributeDeclRegistry
// Global attribute declarations
//
// fComplexTypeRegistry
// Stores complexType declaration info
//
// fGroupInfoRegistry
// Stores global <group> declaration info
//
// fAttGroupInfoRegistry
// Stores global <attributeGroup> declaration info
//
// fDatatypeRegistry
// Datatype validator factory
//
// fValidSubstitutionGroups
// Valid list of elements that can substitute a given element
//
// fIDRefList
// List of ids of schema declarations extracted during schema grammar
// traversal
//
// fValidated
// Indicates if the content of the Grammar has been pre-validated
// or not (UPA checking, etc.). When using a cached grammar, no need
// for pre content validation.
//
// fGramDesc: adopted
//
// -----------------------------------------------------------------------
XMLCh* fTargetNamespace;
RefHash3KeysIdPool<SchemaElementDecl>* fElemDeclPool;
RefHash3KeysIdPool<SchemaElementDecl>* fElemNonDeclPool;
RefHash3KeysIdPool<SchemaElementDecl>* fGroupElemDeclPool;
NameIdPool<XMLNotationDecl>* fNotationDeclPool;
RefHashTableOf<XMLAttDef>* fAttributeDeclRegistry;
RefHashTableOf<ComplexTypeInfo>* fComplexTypeRegistry;
RefHashTableOf<XercesGroupInfo>* fGroupInfoRegistry;
RefHashTableOf<XercesAttGroupInfo>* fAttGroupInfoRegistry;
RefHash2KeysTableOf<ElemVector>* fValidSubstitutionGroups;
// @deprecated
ValidationContext* fValidationContext;
MemoryManager* fMemoryManager;
XMLSchemaDescription* fGramDesc;
RefHashTableOf<XSAnnotation, PtrHasher>* fAnnotations;
bool fValidated;
DatatypeValidatorFactory fDatatypeRegistry;
unsigned int fScopeCount;
unsigned int fAnonTypeCount;
};
// ---------------------------------------------------------------------------
// SchemaGrammar: Getter methods
// ---------------------------------------------------------------------------
inline RefHash3KeysIdPoolEnumerator<SchemaElementDecl>
SchemaGrammar::getElemEnumerator() const
{
return RefHash3KeysIdPoolEnumerator<SchemaElementDecl>(fElemDeclPool, false, fMemoryManager);
}
inline NameIdPoolEnumerator<XMLNotationDecl>
SchemaGrammar::getNotationEnumerator() const
{
return NameIdPoolEnumerator<XMLNotationDecl>(fNotationDeclPool, fMemoryManager);
}
inline RefHashTableOf<XMLAttDef>* SchemaGrammar::getAttributeDeclRegistry() const {
return fAttributeDeclRegistry;
}
inline RefHashTableOf<ComplexTypeInfo>*
SchemaGrammar::getComplexTypeRegistry() const {
return fComplexTypeRegistry;
}
inline RefHashTableOf<XercesGroupInfo>*
SchemaGrammar::getGroupInfoRegistry() const {
return fGroupInfoRegistry;
}
inline RefHashTableOf<XercesAttGroupInfo>*
SchemaGrammar::getAttGroupInfoRegistry() const {
return fAttGroupInfoRegistry;
}
inline DatatypeValidatorFactory* SchemaGrammar::getDatatypeRegistry() {
return &fDatatypeRegistry;
}
inline RefHash2KeysTableOf<ElemVector>*
SchemaGrammar::getValidSubstitutionGroups() const {
return fValidSubstitutionGroups;
}
// @deprecated
inline ValidationContext* SchemaGrammar::getValidationContext() const {
return fValidationContext;
}
inline XMLGrammarDescription* SchemaGrammar::getGrammarDescription() const
{
return fGramDesc;
}
inline XSAnnotation* SchemaGrammar::getAnnotation(const void* const key)
{
return fAnnotations->get(key);
}
inline const XSAnnotation* SchemaGrammar::getAnnotation(const void* const key) const
{
return fAnnotations->get(key);
}
inline XSAnnotation* SchemaGrammar::getAnnotation()
{
return fAnnotations->get(this);
}
inline const XSAnnotation* SchemaGrammar::getAnnotation() const
{
return fAnnotations->get(this);
}
inline RefHashTableOf<XSAnnotation, PtrHasher>* SchemaGrammar::getAnnotations()
{
return fAnnotations;
}
inline const RefHashTableOf<XSAnnotation, PtrHasher>* SchemaGrammar::getAnnotations() const
{
return fAnnotations;
}
// -----------------------------------------------------------------------
// Setter methods
// -----------------------------------------------------------------------
inline void SchemaGrammar::setTargetNamespace(const XMLCh* const targetNamespace)
{
if (fTargetNamespace)
fMemoryManager->deallocate(fTargetNamespace);//delete [] fTargetNamespace;
fTargetNamespace = XMLString::replicate(targetNamespace, fMemoryManager);
}
inline void
SchemaGrammar::setAttributeDeclRegistry(RefHashTableOf<XMLAttDef>* const attReg) {
fAttributeDeclRegistry = attReg;
}
inline void
SchemaGrammar::setComplexTypeRegistry(RefHashTableOf<ComplexTypeInfo>* const other) {
fComplexTypeRegistry = other;
}
inline void
SchemaGrammar::setGroupInfoRegistry(RefHashTableOf<XercesGroupInfo>* const other) {
fGroupInfoRegistry = other;
}
inline void
SchemaGrammar::setAttGroupInfoRegistry(RefHashTableOf<XercesAttGroupInfo>* const other) {
fAttGroupInfoRegistry = other;
}
inline void
SchemaGrammar::setValidSubstitutionGroups(RefHash2KeysTableOf<ElemVector>* const other) {
fValidSubstitutionGroups = other;
}
// ---------------------------------------------------------------------------
// SchemaGrammar: Virtual methods
// ---------------------------------------------------------------------------
inline Grammar::GrammarType SchemaGrammar::getGrammarType() const {
return Grammar::SchemaGrammarType;
}
inline const XMLCh* SchemaGrammar::getTargetNamespace() const {
return fTargetNamespace;
}
// Element Decl
inline XMLSize_t SchemaGrammar::getElemId (const unsigned int uriId
, const XMLCh* const baseName
, const XMLCh* const
, unsigned int scope ) const
{
//
// In this case, we don't return zero to mean 'not found', so we have to
// map it to the official not found value if we don't find it.
//
const SchemaElementDecl* decl = fElemDeclPool->getByKey(baseName, uriId, scope);
if (!decl) {
decl = fGroupElemDeclPool->getByKey(baseName, uriId, scope);
if (!decl)
return XMLElementDecl::fgInvalidElemId;
}
return decl->getId();
}
inline const XMLElementDecl* SchemaGrammar::getElemDecl( const unsigned int uriId
, const XMLCh* const baseName
, const XMLCh* const
, unsigned int scope ) const
{
const SchemaElementDecl* decl = fElemDeclPool->getByKey(baseName, uriId, scope);
if (!decl) {
decl = fGroupElemDeclPool->getByKey(baseName, uriId, scope);
if (!decl && fElemNonDeclPool)
decl = fElemNonDeclPool->getByKey(baseName, uriId, scope);
}
return decl;
}
inline XMLElementDecl* SchemaGrammar::getElemDecl (const unsigned int uriId
, const XMLCh* const baseName
, const XMLCh* const
, unsigned int scope )
{
SchemaElementDecl* decl = fElemDeclPool->getByKey(baseName, uriId, scope);
if (!decl) {
decl = fGroupElemDeclPool->getByKey(baseName, uriId, scope);
if (!decl && fElemNonDeclPool)
decl = fElemNonDeclPool->getByKey(baseName, uriId, scope);
}
return decl;
}
inline const XMLElementDecl* SchemaGrammar::getElemDecl(const unsigned int elemId) const
{
// Look up this element decl by id
const SchemaElementDecl* decl = fElemDeclPool->getById(elemId);
if (!decl)
decl = fGroupElemDeclPool->getById(elemId);
return decl;
}
inline XMLElementDecl* SchemaGrammar::getElemDecl(const unsigned int elemId)
{
// Look up this element decl by id
SchemaElementDecl* decl = fElemDeclPool->getById(elemId);
if (!decl)
decl = fGroupElemDeclPool->getById(elemId);
return decl;
}
inline XMLSize_t
SchemaGrammar::putElemDecl(XMLElementDecl* const elemDecl,
const bool notDeclared)
{
if (notDeclared)
{
if(!fElemNonDeclPool)
fElemNonDeclPool = new (fMemoryManager) RefHash3KeysIdPool<SchemaElementDecl>(29, true, 128, fMemoryManager);
return fElemNonDeclPool->put(elemDecl->getBaseName(), elemDecl->getURI(), ((SchemaElementDecl* )elemDecl)->getEnclosingScope(), (SchemaElementDecl*) elemDecl);
}
return fElemDeclPool->put(elemDecl->getBaseName(), elemDecl->getURI(), ((SchemaElementDecl* )elemDecl)->getEnclosingScope(), (SchemaElementDecl*) elemDecl);
}
inline XMLSize_t SchemaGrammar::putGroupElemDecl (XMLElementDecl* const elemDecl) const
{
return fGroupElemDeclPool->put(elemDecl->getBaseName(), elemDecl->getURI(), ((SchemaElementDecl* )elemDecl)->getEnclosingScope(), (SchemaElementDecl*) elemDecl);
}
// Notation Decl
inline const XMLNotationDecl* SchemaGrammar::getNotationDecl(const XMLCh* const notName) const
{
return fNotationDeclPool->getByKey(notName);
}
inline XMLNotationDecl* SchemaGrammar::getNotationDecl(const XMLCh* const notName)
{
return fNotationDeclPool->getByKey(notName);
}
inline XMLSize_t SchemaGrammar::putNotationDecl(XMLNotationDecl* const notationDecl) const
{
return fNotationDeclPool->put(notationDecl);
}
inline bool SchemaGrammar::getValidated() const
{
return fValidated;
}
inline void SchemaGrammar::setValidated(const bool newState)
{
fValidated = newState;
}
inline unsigned int
SchemaGrammar::getScopeCount () const
{
return fScopeCount;
}
inline void
SchemaGrammar::setScopeCount (unsigned int scopeCount)
{
fScopeCount = scopeCount;
}
inline unsigned int
SchemaGrammar::getAnonTypeCount () const
{
return fAnonTypeCount;
}
inline void
SchemaGrammar::setAnonTypeCount (unsigned int count)
{
fAnonTypeCount = count;
}
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,432 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* $Id: SchemaInfo.hpp 925236 2010-03-19 14:29:47Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_SCHEMAINFO_HPP)
#define XERCESC_INCLUDE_GUARD_SCHEMAINFO_HPP
/** When in a <redefine>, type definitions being used (and indeed
* refs to <group>'s and <attributeGroup>'s) may refer to info
* items either in the schema being redefined, in the <redefine>,
* or else in the schema doing the redefining. Because of this
* latter we have to be prepared sometimes to look for our type
* definitions outside the schema stored in fSchemaRootElement.
* This simple class does this; it's just a linked list that
* lets us look at the <schema>'s on the queue; note also that this
* should provide us with a mechanism to handle nested <redefine>'s.
* It's also a handy way of saving schema info when importing/including.
*/
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <xercesc/dom/DOMElement.hpp>
#include <xercesc/util/RefVectorOf.hpp>
#include <xercesc/util/ValueVectorOf.hpp>
#include <xercesc/util/RefHashTableOf.hpp>
XERCES_CPP_NAMESPACE_BEGIN
// ---------------------------------------------------------------------------
// Forward Declarations
// ---------------------------------------------------------------------------
class XMLScanner;
class ValidationContext;
class NamespaceScope;
class VALIDATORS_EXPORT SchemaInfo : public XMemory
{
public:
enum ListType {
// Redefine is treated as an include
IMPORT = 1,
INCLUDE = 2
};
enum {
C_ComplexType,
C_SimpleType,
C_Group,
C_Attribute,
C_AttributeGroup,
C_Element,
C_Notation,
C_Count
};
// -----------------------------------------------------------------------
// Constructor/Destructor
// -----------------------------------------------------------------------
SchemaInfo(const unsigned short fElemAttrDefaultQualified,
const int blockDefault,
const int finalDefault,
const int targetNSURI,
const NamespaceScope* const currNamespaceScope,
const XMLCh* const schemaURL,
const XMLCh* const targetNSURIString,
const DOMElement* const root,
XMLScanner* xmlScanner,
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
~SchemaInfo();
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
XMLCh* getCurrentSchemaURL() const;
const XMLCh* getTargetNSURIString() const;
const DOMElement* getRoot() const;
bool getProcessed() const;
int getBlockDefault() const;
int getFinalDefault() const;
int getTargetNSURI() const;
NamespaceScope* getNamespaceScope() const;
unsigned short getElemAttrDefaultQualified() const;
BaseRefVectorEnumerator<SchemaInfo> getImportingListEnumerator() const;
ValueVectorOf<const DOMElement*>* getRecursingAnonTypes() const;
ValueVectorOf<const XMLCh*>* getRecursingTypeNames() const;
ValueVectorOf<DOMNode*>* getNonXSAttList() const;
ValidationContext* getValidationContext() const;
// -----------------------------------------------------------------------
// Setter methods
// -----------------------------------------------------------------------
void setProcessed(const bool aValue = true);
void setBlockDefault(const int aValue);
void setFinalDefault(const int aValue);
void setElemAttrDefaultQualified(const unsigned short aValue);
void resetRoot ();
// -----------------------------------------------------------------------
// Access methods
// -----------------------------------------------------------------------
void addSchemaInfo(SchemaInfo* const toAdd, const ListType aListType);
bool containsInfo(const SchemaInfo* const toCheck, const ListType aListType) const;
SchemaInfo* getImportInfo(const unsigned int namespaceURI) const;
DOMElement* getTopLevelComponent(const unsigned short compCategory,
const XMLCh* const compName,
const XMLCh* const name);
DOMElement* getTopLevelComponent(const unsigned short compCategory,
const XMLCh* const compName,
const XMLCh* const name,
SchemaInfo** enclosingSchema);
void updateImportingInfo(SchemaInfo* const importingInfo);
bool circularImportExist(const unsigned int nameSpaceURI);
bool isFailedRedefine(const DOMElement* const anElem);
void addFailedRedefine(const DOMElement* const anElem);
void addRecursingType(const DOMElement* const elem, const XMLCh* const name);
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
SchemaInfo(const SchemaInfo&);
SchemaInfo& operator=(const SchemaInfo&);
// -----------------------------------------------------------------------
// Private helper methods
// -----------------------------------------------------------------------
void clearTopLevelComponents();
// -----------------------------------------------------------------------
// Private data members
// -----------------------------------------------------------------------
bool fAdoptInclude;
bool fProcessed;
unsigned short fElemAttrDefaultQualified;
int fBlockDefault;
int fFinalDefault;
int fTargetNSURI;
NamespaceScope* fNamespaceScope;
XMLCh* fCurrentSchemaURL;
XMLCh* fTargetNSURIString;
const DOMElement* fSchemaRootElement;
RefVectorOf<SchemaInfo>* fIncludeInfoList;
RefVectorOf<SchemaInfo>* fImportedInfoList;
RefVectorOf<SchemaInfo>* fImportingInfoList;
ValueVectorOf<const DOMElement*>* fFailedRedefineList;
ValueVectorOf<const DOMElement*>* fRecursingAnonTypes;
ValueVectorOf<const XMLCh*>* fRecursingTypeNames;
RefHashTableOf<DOMElement>* fTopLevelComponents[C_Count];
DOMElement* fLastTopLevelComponent[C_Count];
ValueVectorOf<DOMNode*>* fNonXSAttList;
ValidationContext* fValidationContext;
MemoryManager* fMemoryManager;
};
// ---------------------------------------------------------------------------
// SchemaInfo: Getter methods
// ---------------------------------------------------------------------------
inline unsigned short SchemaInfo::getElemAttrDefaultQualified() const {
return fElemAttrDefaultQualified;
}
inline bool SchemaInfo::getProcessed() const {
return fProcessed;
}
inline int SchemaInfo::getBlockDefault() const {
return fBlockDefault;
}
inline int SchemaInfo::getFinalDefault() const {
return fFinalDefault;
}
inline NamespaceScope* SchemaInfo::getNamespaceScope() const {
return fNamespaceScope;
}
inline XMLCh* SchemaInfo::getCurrentSchemaURL() const {
return fCurrentSchemaURL;
}
inline const XMLCh* SchemaInfo::getTargetNSURIString() const {
return fTargetNSURIString;
}
inline const DOMElement* SchemaInfo::getRoot() const {
return fSchemaRootElement;
}
inline int SchemaInfo::getTargetNSURI() const {
return fTargetNSURI;
}
inline BaseRefVectorEnumerator<SchemaInfo>
SchemaInfo::getImportingListEnumerator() const {
return BaseRefVectorEnumerator<SchemaInfo>(fImportingInfoList);
}
inline ValueVectorOf<const DOMElement*>*
SchemaInfo::getRecursingAnonTypes() const {
return fRecursingAnonTypes;
}
inline ValueVectorOf<const XMLCh*>*
SchemaInfo::getRecursingTypeNames() const {
return fRecursingTypeNames;
}
inline ValueVectorOf<DOMNode*>* SchemaInfo::getNonXSAttList() const
{
return fNonXSAttList;
}
// ---------------------------------------------------------------------------
// Setter methods
// ---------------------------------------------------------------------------
inline void SchemaInfo::setBlockDefault(const int aValue) {
fBlockDefault = aValue;
}
inline void SchemaInfo::setFinalDefault(const int aValue) {
fFinalDefault = aValue;
}
inline void SchemaInfo::setElemAttrDefaultQualified(const unsigned short aValue) {
fElemAttrDefaultQualified = aValue;
}
inline void SchemaInfo::setProcessed(const bool aValue) {
fProcessed = aValue;
/* if (fProcessed && fIncludeInfoList) {
unsigned int includeListLen = fIncludeInfoList->size());
for (unsigned int i = 0; i < includeListLen; i++) {
fIncludeInfoList->elementAt(i)->clearTopLevelComponents();
}
}*/
}
inline void SchemaInfo::resetRoot ()
{
fSchemaRootElement = 0;
}
// ---------------------------------------------------------------------------
// SchemaInfo: Access methods
// ---------------------------------------------------------------------------
inline void SchemaInfo::addSchemaInfo(SchemaInfo* const toAdd,
const ListType aListType) {
if (aListType == IMPORT) {
if (!fImportedInfoList)
fImportedInfoList = new (fMemoryManager) RefVectorOf<SchemaInfo>(4, false, fMemoryManager);
if (!fImportedInfoList->containsElement(toAdd)) {
fImportedInfoList->addElement(toAdd);
toAdd->updateImportingInfo(this);
}
}
else {
if (!fIncludeInfoList) {
fIncludeInfoList = new (fMemoryManager) RefVectorOf<SchemaInfo>(8, false, fMemoryManager);
fAdoptInclude = true;
}
if (!fIncludeInfoList->containsElement(toAdd)) {
fIncludeInfoList->addElement(toAdd);
//code was originally:
//toAdd->fIncludeInfoList = fIncludeInfoList;
//however for handling multiple imports this was causing
//to schemaInfo's to have the same fIncludeInfoList which they
//both owned so when it was deleted it crashed.
if (toAdd->fIncludeInfoList) {
if (toAdd->fIncludeInfoList != fIncludeInfoList) {
XMLSize_t size = toAdd->fIncludeInfoList->size();
for (XMLSize_t i=0; i<size; i++) {
if (!fIncludeInfoList->containsElement(toAdd->fIncludeInfoList->elementAt(i))) {
fIncludeInfoList->addElement(toAdd->fIncludeInfoList->elementAt(i));
}
}
size = fIncludeInfoList->size();
for (XMLSize_t j=0; j<size; j++) {
if (!toAdd->fIncludeInfoList->containsElement(fIncludeInfoList->elementAt(j))) {
toAdd->fIncludeInfoList->addElement(fIncludeInfoList->elementAt(j));
}
}
}
}
else {
toAdd->fIncludeInfoList = fIncludeInfoList;
}
}
}
}
inline SchemaInfo* SchemaInfo::getImportInfo(const unsigned int namespaceURI) const {
XMLSize_t importSize = (fImportedInfoList) ? fImportedInfoList->size() : 0;
SchemaInfo* currInfo = 0;
for (XMLSize_t i=0; i < importSize; i++) {
currInfo = fImportedInfoList->elementAt(i);
if (currInfo->getTargetNSURI() == (int) namespaceURI)
return currInfo;
}
return 0;
}
inline ValidationContext* SchemaInfo::getValidationContext() const {
return fValidationContext;
}
inline bool SchemaInfo::containsInfo(const SchemaInfo* const toCheck,
const ListType aListType) const {
if ((aListType == INCLUDE) && fIncludeInfoList) {
return fIncludeInfoList->containsElement(toCheck);
}
else if ((aListType == IMPORT) && fImportedInfoList) {
return fImportedInfoList->containsElement(toCheck);
}
return false;
}
inline bool SchemaInfo::circularImportExist(const unsigned int namespaceURI) {
XMLSize_t importSize = fImportingInfoList->size();
for (XMLSize_t i=0; i < importSize; i++) {
if (fImportingInfoList->elementAt(i)->getTargetNSURI() == (int) namespaceURI) {
return true;
}
}
return false;
}
inline bool SchemaInfo::isFailedRedefine(const DOMElement* const anElem) {
if (fFailedRedefineList)
return (fFailedRedefineList->containsElement(anElem));
return false;
}
inline void SchemaInfo::addFailedRedefine(const DOMElement* const anElem) {
if (!fFailedRedefineList) {
fFailedRedefineList = new (fMemoryManager) ValueVectorOf<const DOMElement*>(4, fMemoryManager);
}
fFailedRedefineList->addElement(anElem);
}
inline void SchemaInfo::addRecursingType(const DOMElement* const elem,
const XMLCh* const name) {
if (!fRecursingAnonTypes) {
fRecursingAnonTypes = new (fMemoryManager) ValueVectorOf<const DOMElement*>(8, fMemoryManager);
fRecursingTypeNames = new (fMemoryManager) ValueVectorOf<const XMLCh*>(8, fMemoryManager);
}
fRecursingAnonTypes->addElement(elem);
fRecursingTypeNames->addElement(name);
}
inline void SchemaInfo::clearTopLevelComponents() {
for (unsigned int i = 0; i < C_Count; i++) {
delete fTopLevelComponents[i];
fTopLevelComponents[i] = 0;
fLastTopLevelComponent[i] = 0;
}
}
XERCES_CPP_NAMESPACE_END
#endif
/**
* End of file SchemaInfo.hpp
*/

View File

@@ -0,0 +1,254 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* $Id: SchemaSymbols.hpp 802804 2009-08-10 14:21:48Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_SCHEMASYMBOLS_HPP)
#define XERCESC_INCLUDE_GUARD_SCHEMASYMBOLS_HPP
#include <xercesc/util/XercesDefs.hpp>
XERCES_CPP_NAMESPACE_BEGIN
/*
* Collection of symbols used to parse a Schema Grammar
*/
class VALIDATORS_EXPORT SchemaSymbols
{
public :
// -----------------------------------------------------------------------
// Constant data
// -----------------------------------------------------------------------
static const XMLCh fgURI_XSI[];
static const XMLCh fgURI_SCHEMAFORSCHEMA[];
// deprecated (typo)
static const XMLCh fgXSI_SCHEMALOCACTION[];
// deprecated (typo)
static const XMLCh fgXSI_NONAMESPACESCHEMALOCACTION[];
static const XMLCh fgXSI_SCHEMALOCATION[];
static const XMLCh fgXSI_NONAMESPACESCHEMALOCATION[];
static const XMLCh fgXSI_TYPE[];
static const XMLCh fgELT_ALL[];
static const XMLCh fgELT_ANNOTATION[];
static const XMLCh fgELT_ANY[];
static const XMLCh fgELT_WILDCARD[];
static const XMLCh fgELT_ANYATTRIBUTE[];
static const XMLCh fgELT_APPINFO[];
static const XMLCh fgELT_ATTRIBUTE[];
static const XMLCh fgELT_ATTRIBUTEGROUP[];
static const XMLCh fgELT_CHOICE[];
static const XMLCh fgELT_COMPLEXTYPE[];
static const XMLCh fgELT_CONTENT[];
static const XMLCh fgELT_DOCUMENTATION[];
static const XMLCh fgELT_DURATION[];
static const XMLCh fgELT_ELEMENT[];
static const XMLCh fgELT_ENCODING[];
static const XMLCh fgELT_ENUMERATION[];
static const XMLCh fgELT_FIELD[];
static const XMLCh fgELT_WHITESPACE[];
static const XMLCh fgELT_GROUP[];
static const XMLCh fgELT_IMPORT[];
static const XMLCh fgELT_INCLUDE[];
static const XMLCh fgELT_REDEFINE[];
static const XMLCh fgELT_KEY[];
static const XMLCh fgELT_KEYREF[];
static const XMLCh fgELT_LENGTH[];
static const XMLCh fgELT_MAXEXCLUSIVE[];
static const XMLCh fgELT_MAXINCLUSIVE[];
static const XMLCh fgELT_MAXLENGTH[];
static const XMLCh fgELT_MINEXCLUSIVE[];
static const XMLCh fgELT_MININCLUSIVE[];
static const XMLCh fgELT_MINLENGTH[];
static const XMLCh fgELT_NOTATION[];
static const XMLCh fgELT_PATTERN[];
static const XMLCh fgELT_PERIOD[];
static const XMLCh fgELT_TOTALDIGITS[];
static const XMLCh fgELT_FRACTIONDIGITS[];
static const XMLCh fgELT_SCHEMA[];
static const XMLCh fgELT_SELECTOR[];
static const XMLCh fgELT_SEQUENCE[];
static const XMLCh fgELT_SIMPLETYPE[];
static const XMLCh fgELT_UNION[];
static const XMLCh fgELT_LIST[];
static const XMLCh fgELT_UNIQUE[];
static const XMLCh fgELT_COMPLEXCONTENT[];
static const XMLCh fgELT_SIMPLECONTENT[];
static const XMLCh fgELT_RESTRICTION[];
static const XMLCh fgELT_EXTENSION[];
static const XMLCh fgATT_ABSTRACT[];
static const XMLCh fgATT_ATTRIBUTEFORMDEFAULT[];
static const XMLCh fgATT_BASE[];
static const XMLCh fgATT_ITEMTYPE[];
static const XMLCh fgATT_MEMBERTYPES[];
static const XMLCh fgATT_BLOCK[];
static const XMLCh fgATT_BLOCKDEFAULT[];
static const XMLCh fgATT_DEFAULT[];
static const XMLCh fgATT_ELEMENTFORMDEFAULT[];
static const XMLCh fgATT_SUBSTITUTIONGROUP[];
static const XMLCh fgATT_FINAL[];
static const XMLCh fgATT_FINALDEFAULT[];
static const XMLCh fgATT_FIXED[];
static const XMLCh fgATT_FORM[];
static const XMLCh fgATT_ID[];
static const XMLCh fgATT_MAXOCCURS[];
static const XMLCh fgATT_MINOCCURS[];
static const XMLCh fgATT_NAME[];
static const XMLCh fgATT_NAMESPACE[];
static const XMLCh fgATT_NILL[];
static const XMLCh fgATT_NILLABLE[];
static const XMLCh fgATT_PROCESSCONTENTS[];
static const XMLCh fgATT_REF[];
static const XMLCh fgATT_REFER[];
static const XMLCh fgATT_SCHEMALOCATION[];
static const XMLCh fgATT_SOURCE[];
static const XMLCh fgATT_SYSTEM[];
static const XMLCh fgATT_PUBLIC[];
static const XMLCh fgATT_TARGETNAMESPACE[];
static const XMLCh fgATT_TYPE[];
static const XMLCh fgATT_USE[];
static const XMLCh fgATT_VALUE[];
static const XMLCh fgATT_MIXED[];
static const XMLCh fgATT_VERSION[];
static const XMLCh fgATT_XPATH[];
static const XMLCh fgATTVAL_TWOPOUNDANY[];
static const XMLCh fgATTVAL_TWOPOUNDLOCAL[];
static const XMLCh fgATTVAL_TWOPOUNDOTHER[];
static const XMLCh fgATTVAL_TWOPOUNDTRAGETNAMESPACE[];
static const XMLCh fgATTVAL_POUNDALL[];
static const XMLCh fgATTVAL_BASE64[];
static const XMLCh fgATTVAL_BOOLEAN[];
static const XMLCh fgATTVAL_DEFAULT[];
static const XMLCh fgATTVAL_ELEMENTONLY[];
static const XMLCh fgATTVAL_EMPTY[];
static const XMLCh fgATTVAL_EXTENSION[];
static const XMLCh fgATTVAL_FALSE[];
static const XMLCh fgATTVAL_FIXED[];
static const XMLCh fgATTVAL_HEX[];
static const XMLCh fgATTVAL_ID[];
static const XMLCh fgATTVAL_LAX[];
static const XMLCh fgATTVAL_MAXLENGTH[];
static const XMLCh fgATTVAL_MINLENGTH[];
static const XMLCh fgATTVAL_MIXED[];
static const XMLCh fgATTVAL_NCNAME[];
static const XMLCh fgATTVAL_OPTIONAL[];
static const XMLCh fgATTVAL_PROHIBITED[];
static const XMLCh fgATTVAL_QNAME[];
static const XMLCh fgATTVAL_QUALIFIED[];
static const XMLCh fgATTVAL_REQUIRED[];
static const XMLCh fgATTVAL_RESTRICTION[];
static const XMLCh fgATTVAL_SKIP[];
static const XMLCh fgATTVAL_STRICT[];
static const XMLCh fgATTVAL_STRING[];
static const XMLCh fgATTVAL_TEXTONLY[];
static const XMLCh fgATTVAL_TIMEDURATION[];
static const XMLCh fgATTVAL_TRUE[];
static const XMLCh fgATTVAL_UNQUALIFIED[];
static const XMLCh fgATTVAL_URI[];
static const XMLCh fgATTVAL_URIREFERENCE[];
static const XMLCh fgATTVAL_SUBSTITUTIONGROUP[];
static const XMLCh fgATTVAL_SUBSTITUTION[];
static const XMLCh fgATTVAL_ANYTYPE[];
static const XMLCh fgWS_PRESERVE[];
static const XMLCh fgWS_COLLAPSE[];
static const XMLCh fgWS_REPLACE[];
static const XMLCh fgDT_STRING[];
static const XMLCh fgDT_TOKEN[];
static const XMLCh fgDT_LANGUAGE[];
static const XMLCh fgDT_NAME[];
static const XMLCh fgDT_NCNAME[];
static const XMLCh fgDT_INTEGER[];
static const XMLCh fgDT_DECIMAL[];
static const XMLCh fgDT_BOOLEAN[];
static const XMLCh fgDT_NONPOSITIVEINTEGER[];
static const XMLCh fgDT_NEGATIVEINTEGER[];
static const XMLCh fgDT_LONG[];
static const XMLCh fgDT_INT[];
static const XMLCh fgDT_SHORT[];
static const XMLCh fgDT_BYTE[];
static const XMLCh fgDT_NONNEGATIVEINTEGER[];
static const XMLCh fgDT_ULONG[];
static const XMLCh fgDT_UINT[];
static const XMLCh fgDT_USHORT[];
static const XMLCh fgDT_UBYTE[];
static const XMLCh fgDT_POSITIVEINTEGER[];
//datetime
static const XMLCh fgDT_DATETIME[];
static const XMLCh fgDT_DATE[];
static const XMLCh fgDT_TIME[];
static const XMLCh fgDT_DURATION[];
static const XMLCh fgDT_DAY[];
static const XMLCh fgDT_MONTH[];
static const XMLCh fgDT_MONTHDAY[];
static const XMLCh fgDT_YEAR[];
static const XMLCh fgDT_YEARMONTH[];
static const XMLCh fgDT_BASE64BINARY[];
static const XMLCh fgDT_HEXBINARY[];
static const XMLCh fgDT_FLOAT[];
static const XMLCh fgDT_DOUBLE[];
static const XMLCh fgDT_URIREFERENCE[];
static const XMLCh fgDT_ANYURI[];
static const XMLCh fgDT_QNAME[];
static const XMLCh fgDT_NORMALIZEDSTRING[];
static const XMLCh fgDT_ANYSIMPLETYPE[];
static const XMLCh fgRegEx_XOption[];
static const XMLCh fgRedefIdentifier[];
static const int fgINT_MIN_VALUE;
static const int fgINT_MAX_VALUE;
enum {
XSD_EMPTYSET = 0,
XSD_SUBSTITUTION = 1,
XSD_EXTENSION = 2,
XSD_RESTRICTION = 4,
XSD_LIST = 8,
XSD_UNION = 16,
XSD_ENUMERATION = 32
};
// group orders
enum {
XSD_CHOICE = 0,
XSD_SEQUENCE= 1,
XSD_ALL = 2
};
enum {
XSD_UNBOUNDED = -1,
XSD_NILLABLE = 1,
XSD_ABSTRACT = 2,
XSD_FIXED = 4
};
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
SchemaSymbols();
};
XERCES_CPP_NAMESPACE_END
#endif
/**
* End of file SchemaSymbols.hpp
*/

View File

@@ -0,0 +1,443 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* $Id: SchemaValidator.hpp 932887 2010-04-11 13:04:59Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_SCHEMAVALIDATOR_HPP)
#define XERCESC_INCLUDE_GUARD_SCHEMAVALIDATOR_HPP
#include <xercesc/framework/XMLValidator.hpp>
#include <xercesc/framework/XMLBuffer.hpp>
#include <xercesc/util/ValueStackOf.hpp>
#include <xercesc/validators/common/ContentSpecNode.hpp>
#include <xercesc/validators/schema/SchemaGrammar.hpp>
#include <xercesc/validators/schema/XSDErrorReporter.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class GrammarResolver;
class DatatypeValidator;
class SchemaElementDecl;
//
// This is a derivative of the abstract validator interface. This class
// implements a validator that supports standard XML Schema semantics.
// This class handles scanning the of the schema, and provides
// the standard validation services against the Schema info it found.
//
class VALIDATORS_EXPORT SchemaValidator : public XMLValidator
{
public:
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
SchemaValidator
(
XMLErrorReporter* const errReporter = 0
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
virtual ~SchemaValidator();
// -----------------------------------------------------------------------
// Implementation of the XMLValidator interface
// -----------------------------------------------------------------------
virtual bool checkContent
(
XMLElementDecl* const elemDecl
, QName** const children
, XMLSize_t childCount
, XMLSize_t* indexFailingChild
);
virtual void faultInAttr
(
XMLAttr& toFill
, const XMLAttDef& attDef
) const;
virtual void preContentValidation(bool reuseGrammar,
bool validateDefAttr = false);
virtual void postParseValidation();
virtual void reset();
virtual bool requiresNamespaces() const;
virtual void validateAttrValue
(
const XMLAttDef* attDef
, const XMLCh* const attrValue
, bool preValidation = false
, const XMLElementDecl* elemDecl = 0
);
virtual void validateElement
(
const XMLElementDecl* elemDef
);
virtual Grammar* getGrammar() const;
virtual void setGrammar(Grammar* aGrammar);
// -----------------------------------------------------------------------
// Virtual DTD handler interface.
// -----------------------------------------------------------------------
virtual bool handlesDTD() const;
// -----------------------------------------------------------------------
// Virtual Schema handler interface. handlesSchema() always return false.
// -----------------------------------------------------------------------
virtual bool handlesSchema() const;
// -----------------------------------------------------------------------
// Schema Validator methods
// -----------------------------------------------------------------------
void normalizeWhiteSpace(DatatypeValidator* dV, const XMLCh* const value, XMLBuffer& toFill, bool bStandalone = false);
// -----------------------------------------------------------------------
// Setter methods
// -----------------------------------------------------------------------
void setGrammarResolver(GrammarResolver* grammarResolver);
void setXsiType(const XMLCh* const prefix
, const XMLCh* const localPart
, const unsigned int uriId);
void setNillable(bool isNil);
void resetNillable();
void setErrorReporter(XMLErrorReporter* const errorReporter);
void setExitOnFirstFatal(const bool newValue);
void setDatatypeBuffer(const XMLCh* const value);
void clearDatatypeBuffer();
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
ComplexTypeInfo* getCurrentTypeInfo() const;
DatatypeValidator *getCurrentDatatypeValidator() const;
DatatypeValidator *getMostRecentAttrValidator() const;
bool getErrorOccurred() const;
bool getIsElemSpecified() const;
bool getIsXsiTypeSet() const;
const XMLCh* getNormalizedValue() const;
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
SchemaValidator(const SchemaValidator&);
SchemaValidator& operator=(const SchemaValidator&);
// -----------------------------------------------------------------------
// Element Consistency Checking methods
// -----------------------------------------------------------------------
void checkRefElementConsistency(SchemaGrammar* const currentGrammar,
const ComplexTypeInfo* const curTypeInfo,
const XercesGroupInfo* const curGroup = 0);
// -----------------------------------------------------------------------
// Particle Derivation Checking methods
// -----------------------------------------------------------------------
void checkParticleDerivation(SchemaGrammar* const currentGrammar,
const ComplexTypeInfo* const typeInfo);
void checkParticleDerivationOk(SchemaGrammar* const currentGrammar,
ContentSpecNode* const curNode,
const int derivedScope,
ContentSpecNode* const baseNode,
const int baseScope,
const ComplexTypeInfo* const baseInfo = 0,
const bool toCheckOccurrence = true);
ContentSpecNode* checkForPointlessOccurrences(ContentSpecNode* const specNode,
const ContentSpecNode::NodeTypes nodeType,
ValueVectorOf<ContentSpecNode*>* const nodes);
void gatherChildren(const ContentSpecNode::NodeTypes parentNodeType,
ContentSpecNode* const specNode,
ValueVectorOf<ContentSpecNode*>* const nodes);
bool isOccurrenceRangeOK(const int min1, const int max1, const int min2, const int max2);
void checkNSCompat(const ContentSpecNode* const derivedSpecNode,
const ContentSpecNode* const baseSpecNode,
const bool toCheckOccurence);
bool wildcardEltAllowsNamespace(const ContentSpecNode* const baseSpecNode,
const unsigned int derivedURI);
void checkNameAndTypeOK(SchemaGrammar* const currentGrammar,
const ContentSpecNode* const derivedSpecNode,
const int derivedScope,
const ContentSpecNode* const baseSpecNode,
const int baseScope,
const ComplexTypeInfo* const baseInfo = 0);
SchemaElementDecl* findElement(const int scope,
const unsigned int uriIndex,
const XMLCh* const name,
SchemaGrammar* const grammar,
const ComplexTypeInfo* const typeInfo = 0);
void checkICRestriction(const SchemaElementDecl* const derivedElemDecl,
const SchemaElementDecl* const baseElemDecl,
const XMLCh* const derivedElemName,
const XMLCh* const baseElemName);
void checkTypesOK(const SchemaElementDecl* const derivedElemDecl,
const SchemaElementDecl* const baseElemDecl,
const XMLCh* const derivedElemName);
void checkRecurseAsIfGroup(SchemaGrammar* const currentGrammar,
ContentSpecNode* const derivedSpecNode,
const int derivedScope,
const ContentSpecNode* const baseSpecNode,
const int baseScope,
ValueVectorOf<ContentSpecNode*>* const nodes,
const ComplexTypeInfo* const baseInfo);
void checkRecurse(SchemaGrammar* const currentGrammar,
const ContentSpecNode* const derivedSpecNode,
const int derivedScope,
ValueVectorOf<ContentSpecNode*>* const derivedNodes,
const ContentSpecNode* const baseSpecNode,
const int baseScope,
ValueVectorOf<ContentSpecNode*>* const baseNodes,
const ComplexTypeInfo* const baseInfo,
const bool toLax = false);
void checkNSSubset(const ContentSpecNode* const derivedSpecNode,
const ContentSpecNode* const baseSpecNode);
bool checkNSSubsetChoiceRoot(const ContentSpecNode* const derivedSpecNode,
const ContentSpecNode* const baseSpecNode);
bool checkNSSubsetChoice(const ContentSpecNode* const derivedSpecNode,
const ContentSpecNode* const baseSpecNode);
bool isWildCardEltSubset(const ContentSpecNode* const derivedSpecNode,
const ContentSpecNode* const baseSpecNode);
void checkNSRecurseCheckCardinality(SchemaGrammar* const currentGrammar,
const ContentSpecNode* const derivedSpecNode,
ValueVectorOf<ContentSpecNode*>* const derivedNodes,
const int derivedScope,
ContentSpecNode* const baseSpecNode,
const bool toCheckOccurence);
void checkRecurseUnordered(SchemaGrammar* const currentGrammar,
const ContentSpecNode* const derivedSpecNode,
ValueVectorOf<ContentSpecNode*>* const derivedNodes,
const int derivedScope,
ContentSpecNode* const baseSpecNode,
ValueVectorOf<ContentSpecNode*>* const baseNodes,
const int baseScope,
const ComplexTypeInfo* const baseInfo);
void checkMapAndSum(SchemaGrammar* const currentGrammar,
const ContentSpecNode* const derivedSpecNode,
ValueVectorOf<ContentSpecNode*>* const derivedNodes,
const int derivedScope,
ContentSpecNode* const baseSpecNode,
ValueVectorOf<ContentSpecNode*>* const baseNodes,
const int baseScope,
const ComplexTypeInfo* const baseInfo);
ContentSpecNode* getNonUnaryGroup(ContentSpecNode* const pNode);
// -----------------------------------------------------------------------
// Private data members
//
// -----------------------------------------------------------------------
// The following comes from or set by the Scanner
// fSchemaGrammar
// The current schema grammar used by the validator
//
// fGrammarResolver
// All the schema grammar stored
//
// fXsiType
// Store the Schema Type Attribute Value if schema type is specified
//
// fNil
// Indicates if a nil value is acceptable
// fNilFound
// Indicates if Nillable has been set
// -----------------------------------------------------------------------
// The following used internally in the validator
//
// fCurrentDatatypeValidator
// The validator used for validating the content of elements
// with simple types
//
// fDatatypeBuffer
// Buffer for simple type element string content
//
// fTrailing
// Previous chunk had a trailing space
//
// fSeenNonWhiteSpace
// Seen a non-whitespace character in the previous chunk
//
// fSeenId
// Indicate if an attribute of ID type has been seen already, reset per element.
//
// fSchemaErrorReporter
// Report schema process errors
//
// fTypeStack
// Stack of complex type declarations.
//
// fMostRecentAttrValidator
// DatatypeValidator that validated attribute most recently processed
//
// fErrorOccurred
// whether an error occurred in the most recent operation
// -----------------------------------------------------------------------
MemoryManager* fMemoryManager;
SchemaGrammar* fSchemaGrammar;
GrammarResolver* fGrammarResolver;
QName* fXsiType;
bool fNil;
bool fNilFound;
DatatypeValidator* fCurrentDatatypeValidator;
XMLBuffer* fNotationBuf;
XMLBuffer fDatatypeBuffer;
bool fTrailing;
bool fSeenNonWhiteSpace;
bool fSeenId;
XSDErrorReporter fSchemaErrorReporter;
ValueStackOf<ComplexTypeInfo*>* fTypeStack;
DatatypeValidator * fMostRecentAttrValidator;
bool fErrorOccurred;
bool fElemIsSpecified;
};
// ---------------------------------------------------------------------------
// SchemaValidator: Setter methods
// ---------------------------------------------------------------------------
inline void SchemaValidator::setGrammarResolver(GrammarResolver* grammarResolver) {
fGrammarResolver = grammarResolver;
}
inline void SchemaValidator::setXsiType(const XMLCh* const prefix
, const XMLCh* const localPart
, const unsigned int uriId)
{
delete fXsiType;
fXsiType = new (fMemoryManager) QName(prefix, localPart, uriId, fMemoryManager);
}
inline void SchemaValidator::setNillable(bool isNil) {
fNil = isNil;
fNilFound = true;
}
inline void SchemaValidator::resetNillable() {
fNil = false;
fNilFound = false;
}
inline void SchemaValidator::setExitOnFirstFatal(const bool newValue) {
fSchemaErrorReporter.setExitOnFirstFatal(newValue);
}
inline void SchemaValidator::setDatatypeBuffer(const XMLCh* const value)
{
fDatatypeBuffer.append(value);
}
inline void SchemaValidator::clearDatatypeBuffer()
{
fDatatypeBuffer.reset();
}
// ---------------------------------------------------------------------------
// SchemaValidator: Getter methods
// ---------------------------------------------------------------------------
inline ComplexTypeInfo* SchemaValidator::getCurrentTypeInfo() const {
if (fTypeStack->empty())
return 0;
return fTypeStack->peek();
}
inline DatatypeValidator * SchemaValidator::getCurrentDatatypeValidator() const
{
return fCurrentDatatypeValidator;
}
inline DatatypeValidator *SchemaValidator::getMostRecentAttrValidator() const
{
return fMostRecentAttrValidator;
}
// ---------------------------------------------------------------------------
// Virtual interface
// ---------------------------------------------------------------------------
inline Grammar* SchemaValidator::getGrammar() const {
return fSchemaGrammar;
}
inline void SchemaValidator::setGrammar(Grammar* aGrammar) {
fSchemaGrammar = (SchemaGrammar*) aGrammar;
}
inline void SchemaValidator::setErrorReporter(XMLErrorReporter* const errorReporter) {
XMLValidator::setErrorReporter(errorReporter);
fSchemaErrorReporter.setErrorReporter(errorReporter);
}
// ---------------------------------------------------------------------------
// SchemaValidator: DTD handler interface
// ---------------------------------------------------------------------------
inline bool SchemaValidator::handlesDTD() const
{
// No DTD scanning
return false;
}
// ---------------------------------------------------------------------------
// SchemaValidator: Schema handler interface
// ---------------------------------------------------------------------------
inline bool SchemaValidator::handlesSchema() const
{
return true;
}
// ---------------------------------------------------------------------------
// SchemaValidator: Particle derivation checking
// ---------------------------------------------------------------------------
inline bool
SchemaValidator::isOccurrenceRangeOK(const int min1, const int max1,
const int min2, const int max2) {
if (min1 >= min2 &&
(max2 == SchemaSymbols::XSD_UNBOUNDED ||
(max1 != SchemaSymbols::XSD_UNBOUNDED && max1 <= max2))) {
return true;
}
return false;
}
inline bool SchemaValidator::getErrorOccurred() const
{
return fErrorOccurred;
}
inline bool SchemaValidator::getIsElemSpecified() const
{
return fElemIsSpecified;
}
inline const XMLCh* SchemaValidator::getNormalizedValue() const
{
return fDatatypeBuffer.getRawBuffer();
}
inline bool SchemaValidator::getIsXsiTypeSet() const
{
return (fXsiType!=0);
}
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,126 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* $Id: SubstitutionGroupComparator.hpp 932887 2010-04-11 13:04:59Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_SUBSTITUTIONGROUPCOMPARATOR_HPP)
#define XERCESC_INCLUDE_GUARD_SUBSTITUTIONGROUPCOMPARATOR_HPP
#include <xercesc/util/StringPool.hpp>
#include <xercesc/util/QName.hpp>
#include <xercesc/validators/common/GrammarResolver.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class SchemaGrammar;
class VALIDATORS_EXPORT SubstitutionGroupComparator : public XMemory
{
public:
// -----------------------------------------------------------------------
// Public Constructor
// -----------------------------------------------------------------------
/** @name Constructor. */
//@{
SubstitutionGroupComparator(GrammarResolver* const pGrammarResolver
, XMLStringPool* const pStringPool);
//@}
// -----------------------------------------------------------------------
// Public Destructor
// -----------------------------------------------------------------------
/** @name Destructor. */
//@{
~SubstitutionGroupComparator();
//@}
// -----------------------------------------------------------------------
// Validation methods
// -----------------------------------------------------------------------
/** @name Validation Function */
//@{
/**
* Checks that the "anElement" is within the substitution group.
*
* @param anElement QName of the element
*
* @param exemplar QName of the head element in the group
*/
bool isEquivalentTo(const QName* const anElement
, const QName* const exemplar);
//@}
/*
* check whether one element or any element in its substitution group
* is allowed by a given wildcard uri
*
* @param pGrammar the grammar where the wildcard is declared
* @param element the QName of a given element
* @param wuri the uri of the wildcard
* @param wother whether the uri is from ##other, so wuri is excluded
*
* @return whether the element is allowed by the wildcard
*/
bool isAllowedByWildcard(SchemaGrammar* const pGrammar, QName* const element, unsigned int wuri, bool wother);
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
SubstitutionGroupComparator();
SubstitutionGroupComparator(const SubstitutionGroupComparator&);
SubstitutionGroupComparator& operator=(const SubstitutionGroupComparator&);
// -----------------------------------------------------------------------
// Private data members
//
//
// -----------------------------------------------------------------------
GrammarResolver *fGrammarResolver;
XMLStringPool *fStringPool;
};
// ---------------------------------------------------------------------------
// SubstitutionGroupComparator: Getters
// ---------------------------------------------------------------------------
inline SubstitutionGroupComparator::SubstitutionGroupComparator(GrammarResolver* const pGrammarResolver
, XMLStringPool* const pStringPool)
:fGrammarResolver(pGrammarResolver)
,fStringPool(pStringPool)
{}
inline SubstitutionGroupComparator::~SubstitutionGroupComparator()
{}
XERCES_CPP_NAMESPACE_END
#endif
/**
* End of file SubstitutionGroupComparator.hpp
*/

View File

@@ -0,0 +1,925 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* $Id: TraverseSchema.hpp 932887 2010-04-11 13:04:59Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_TRAVERSESCHEMA_HPP)
#define XERCESC_INCLUDE_GUARD_TRAVERSESCHEMA_HPP
/**
* Instances of this class get delegated to Traverse the Schema and
* to populate the SchemaGrammar internal representation.
*/
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <xercesc/util/XMLUniDefs.hpp>
#include <xercesc/dom/DOMElement.hpp>
#include <xercesc/dom/DOMAttr.hpp>
#include <xercesc/framework/XMLBuffer.hpp>
#include <xercesc/framework/XMLErrorCodes.hpp>
#include <xercesc/validators/schema/SchemaSymbols.hpp>
#include <xercesc/util/ValueVectorOf.hpp>
#include <xercesc/util/RefHash2KeysTableOf.hpp>
#include <xercesc/validators/common/ContentSpecNode.hpp>
#include <xercesc/validators/schema/SchemaGrammar.hpp>
#include <xercesc/validators/schema/SchemaInfo.hpp>
#include <xercesc/validators/schema/GeneralAttributeCheck.hpp>
#include <xercesc/validators/schema/XSDErrorReporter.hpp>
#include <xercesc/util/XMLResourceIdentifier.hpp>
XERCES_CPP_NAMESPACE_BEGIN
// ---------------------------------------------------------------------------
// Forward Declarations
// ---------------------------------------------------------------------------
class GrammarResolver;
class XMLEntityHandler;
class XMLScanner;
class DatatypeValidator;
class DatatypeValidatorFactory;
class QName;
class ComplexTypeInfo;
class XMLAttDef;
class NamespaceScope;
class SchemaAttDef;
class InputSource;
class XercesGroupInfo;
class XercesAttGroupInfo;
class IdentityConstraint;
class XSDLocator;
class XSDDOMParser;
class XMLErrorReporter;
class VALIDATORS_EXPORT TraverseSchema : public XMemory
{
public:
// -----------------------------------------------------------------------
// Public Constructors/Destructor
// -----------------------------------------------------------------------
TraverseSchema
(
DOMElement* const schemaRoot
, XMLStringPool* const uriStringPool
, SchemaGrammar* const schemaGrammar
, GrammarResolver* const grammarResolver
, RefHash2KeysTableOf<SchemaInfo>* cachedSchemaInfoList
, RefHash2KeysTableOf<SchemaInfo>* schemaInfoList
, XMLScanner* const xmlScanner
, const XMLCh* const schemaURL
, XMLEntityHandler* const entityHandler
, XMLErrorReporter* const errorReporter
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
, bool multipleImport = false
);
~TraverseSchema();
private:
// This enumeration is defined here for compatibility with the CodeWarrior
// compiler, which apparently doesn't like to accept default parameter
// arguments that it hasn't yet seen. The Not_All_Context argument is
// used in the declaration of checkMinMax, below.
//
// Flags indicate any special restrictions on minOccurs and maxOccurs
// relating to "all".
// Not_All_Context - not processing an <all>
// All_Element - processing an <element> in an <all>
// Group_Ref_With_All - processing <group> reference that contained <all>
// All_Group - processing an <all> group itself
enum
{
Not_All_Context = 0
, All_Element = 1
, Group_Ref_With_All = 2
, All_Group = 4
};
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
TraverseSchema(const TraverseSchema&);
TraverseSchema& operator=(const TraverseSchema&);
// -----------------------------------------------------------------------
// Init/CleanUp methods
// -----------------------------------------------------------------------
void init();
void cleanUp();
// -----------------------------------------------------------------------
// Traversal methods
// -----------------------------------------------------------------------
/**
* Traverse the Schema DOM tree
*/
void doTraverseSchema(const DOMElement* const schemaRoot);
void preprocessSchema(DOMElement* const schemaRoot,
const XMLCh* const schemaURL,
bool multipleImport = false);
void traverseSchemaHeader(const DOMElement* const schemaRoot);
XSAnnotation* traverseAnnotationDecl(const DOMElement* const childElem,
ValueVectorOf<DOMNode*>* const nonXSAttList,
const bool topLevel = false);
void traverseInclude(const DOMElement* const childElem);
void traverseImport(const DOMElement* const childElem);
void traverseRedefine(const DOMElement* const childElem);
void traverseAttributeDecl(const DOMElement* const childElem,
ComplexTypeInfo* const typeInfo,
const bool topLevel = false);
void traverseSimpleContentDecl(const XMLCh* const typeName,
const XMLCh* const qualifiedName,
const DOMElement* const contentDecl,
ComplexTypeInfo* const typeInfo,
Janitor<XSAnnotation>* const janAnnot);
void traverseComplexContentDecl(const XMLCh* const typeName,
const DOMElement* const contentDecl,
ComplexTypeInfo* const typeInfo,
const bool isMixed,
Janitor<XSAnnotation>* const janAnnot);
DatatypeValidator* traverseSimpleTypeDecl(const DOMElement* const childElem,
const bool topLevel = true,
int baseRefContext = SchemaSymbols::XSD_EMPTYSET);
int traverseComplexTypeDecl(const DOMElement* const childElem,
const bool topLevel = true,
const XMLCh* const recursingTypeName = 0);
DatatypeValidator* traverseByList(const DOMElement* const rootElem,
const DOMElement* const contentElem,
const XMLCh* const typeName,
const XMLCh* const qualifiedName,
const int finalSet,
Janitor<XSAnnotation>* const janAnnot);
DatatypeValidator* traverseByRestriction(const DOMElement* const rootElem,
const DOMElement* const contentElem,
const XMLCh* const typeName,
const XMLCh* const qualifiedName,
const int finalSet,
Janitor<XSAnnotation>* const janAnnot);
DatatypeValidator* traverseByUnion(const DOMElement* const rootElem,
const DOMElement* const contentElem,
const XMLCh* const typeName,
const XMLCh* const qualifiedName,
const int finalSet,
int baseRefContext,
Janitor<XSAnnotation>* const janAnnot);
SchemaElementDecl* traverseElementDecl(const DOMElement* const childElem,
const bool topLevel = false);
const XMLCh* traverseNotationDecl(const DOMElement* const childElem);
const XMLCh* traverseNotationDecl(const DOMElement* const childElem,
const XMLCh* const name,
const XMLCh* const uriStr);
ContentSpecNode* traverseChoiceSequence(const DOMElement* const elemDecl,
const int modelGroupType,
bool& hasChildren);
ContentSpecNode* traverseAny(const DOMElement* const anyDecl);
ContentSpecNode* traverseAll(const DOMElement* const allElem,
bool& hasChildren);
XercesGroupInfo* traverseGroupDecl(const DOMElement* const childElem,
const bool topLevel = true);
XercesAttGroupInfo* traverseAttributeGroupDecl(const DOMElement* const elem,
ComplexTypeInfo* const typeInfo,
const bool topLevel = false);
XercesAttGroupInfo* traverseAttributeGroupDeclNS(const DOMElement* const elem,
const XMLCh* const uriStr,
const XMLCh* const name);
SchemaAttDef* traverseAnyAttribute(const DOMElement* const elem);
void traverseKey(const DOMElement* const icElem,
SchemaElementDecl* const elemDecl);
void traverseUnique(const DOMElement* const icElem,
SchemaElementDecl* const elemDecl);
void traverseKeyRef(const DOMElement* const icElem,
SchemaElementDecl* const elemDecl);
bool traverseIdentityConstraint(IdentityConstraint* const ic,
const DOMElement* const icElem);
// -----------------------------------------------------------------------
// Error Reporting methods
// -----------------------------------------------------------------------
void reportSchemaError(const XSDLocator* const aLocator,
const XMLCh* const msgDomain,
const int errorCode);
void reportSchemaError(const XSDLocator* const aLocator,
const XMLCh* const msgDomain,
const int errorCode,
const XMLCh* const text1,
const XMLCh* const text2 = 0,
const XMLCh* const text3 = 0,
const XMLCh* const text4 = 0);
void reportSchemaError(const DOMElement* const elem,
const XMLCh* const msgDomain,
const int errorCode);
void reportSchemaError(const DOMElement* const elem,
const XMLCh* const msgDomain,
const int errorCode,
const XMLCh* const text1,
const XMLCh* const text2 = 0,
const XMLCh* const text3 = 0,
const XMLCh* const text4 = 0);
void reportSchemaError(const DOMElement* const elem,
const XMLException& except);
// -----------------------------------------------------------------------
// Private Helper methods
// -----------------------------------------------------------------------
/**
* Keep track of the xs:import found
*/
bool isImportingNS(const int namespaceURI);
void addImportedNS(const int namespaceURI);
/**
* Retrieved the Namespace mapping from the schema element
*/
bool retrieveNamespaceMapping(const DOMElement* const elem);
/**
* Loop through the children, and traverse the corresponding schema type
* type declaration (simpleType, complexType, import, ....)
*/
void processChildren(const DOMElement* const root);
void preprocessChildren(const DOMElement* const root);
void preprocessImport(const DOMElement* const elemNode);
void preprocessInclude(const DOMElement* const elemNode);
void preprocessRedefine(const DOMElement* const elemNode);
/**
* Parameters:
* rootElem - top element for a given type declaration
* contentElem - content must be annotation? or some other simple content
* isEmpty: - true if (annotation?, smth_else), false if (annotation?)
* processAnnot - default is true, false if reprocessing a complex type
* since we have already processed the annotation.
*
* Check for Annotation if it is present, traverse it. If a sibling is
* found and it is not an annotation return it, otherwise return 0.
* Used by traverseSimpleTypeDecl.
*/
DOMElement* checkContent(const DOMElement* const rootElem,
DOMElement* const contentElem,
const bool isEmpty, bool processAnnot = true);
/**
* Parameters:
* contentElem - content element to check
*
* Check for identity constraints content.
*/
const DOMElement* checkIdentityConstraintContent(const DOMElement* const contentElem);
DatatypeValidator* getDatatypeValidator(const XMLCh* const uriStr,
const XMLCh* const localPartStr);
/**
* Process simpleType content of a list|restriction|union
* Return a dataype validator if valid type, otherwise 0.
*/
DatatypeValidator* checkForSimpleTypeValidator(const DOMElement* const content,
int baseRefContext = SchemaSymbols::XSD_EMPTYSET);
/**
* Process complexType content of an element
* Return a ComplexTypeInfo if valid type, otherwise 0.
*/
ComplexTypeInfo* checkForComplexTypeInfo(const DOMElement* const content);
/**
* Return DatatypeValidator available for the baseTypeStr.
*/
DatatypeValidator* findDTValidator(const DOMElement* const elem,
const XMLCh* const derivedTypeName,
const XMLCh* const baseTypeName,
const int baseRefContext);
const XMLCh* resolvePrefixToURI(const DOMElement* const elem,
const XMLCh* const prefix);
/**
* Return the prefix for a given rawname string
*
* Function allocated, caller managed (facm) - pointer to be deleted by
* caller.
*/
const XMLCh* getPrefix(const XMLCh* const rawName);
/**
* Return the local for a given rawname string
*
* caller allocated, caller managed (cacm)
*/
const XMLCh* getLocalPart(const XMLCh* const rawName);
/**
* Process a 'ref' of an Element declaration
*/
SchemaElementDecl* processElementDeclRef(const DOMElement* const elem,
const XMLCh* const refName);
void processElemDeclAttrs(const DOMElement* const elem,
SchemaElementDecl* const elemDecl,
const XMLCh*& valConstraint,
bool isTopLevel = false);
void processElemDeclIC(DOMElement* const elem,
SchemaElementDecl* const elemDecl);
bool checkElemDeclValueConstraint(const DOMElement* const elem,
SchemaElementDecl* const elemDecl,
const XMLCh* const valConstraint,
ComplexTypeInfo* const typeInfo,
DatatypeValidator* const validator);
/**
* Process a 'ref' of an Attribute declaration
*/
void processAttributeDeclRef(const DOMElement* const elem,
ComplexTypeInfo* const typeInfo,
const XMLCh* const refName,
const XMLCh* const useVal,
const XMLCh* const defaultVal,
const XMLCh* const fixedVal);
/**
* Process a 'ref' on a group
*/
XercesGroupInfo* processGroupRef(const DOMElement* const elem,
const XMLCh* const refName);
/**
* Process a 'ref' on a attributeGroup
*/
XercesAttGroupInfo* processAttributeGroupRef(const DOMElement* const elem,
const XMLCh* const refName,
ComplexTypeInfo* const typeInfo);
/**
* Parse block & final items
*/
int parseBlockSet(const DOMElement* const elem, const int blockType, const bool isRoot = false);
int parseFinalSet(const DOMElement* const elem, const int finalType, const bool isRoot = false);
/**
* Return true if a name is an identity constraint, otherwise false
*/
bool isIdentityConstraintName(const XMLCh* const constraintName);
/**
* If 'typeStr' belongs to a different schema, return that schema URI,
* otherwise return 0;
*/
const XMLCh* checkTypeFromAnotherSchema(const DOMElement* const elem,
const XMLCh* const typeStr);
/**
* Return the datatype validator for a given element type attribute if
* the type is a simple type
*/
DatatypeValidator* getElementTypeValidator(const DOMElement* const elem,
const XMLCh* const typeStr,
bool& noErrorDetected,
const XMLCh* const otherSchemaURI);
/**
* Return the complexType info for a given element type attribute if
* the type is a complex type
*/
ComplexTypeInfo* getElementComplexTypeInfo(const DOMElement* const elem,
const XMLCh* const typeStr,
const XMLCh* const otherSchemaURI);
/**
* Return global schema element declaration for a given element name
*/
SchemaElementDecl* getGlobalElemDecl(const DOMElement* const elem,
const XMLCh* const name);
/**
* Check validity constraint of a substitutionGroup attribute in
* an element declaration
*/
bool isSubstitutionGroupValid(const DOMElement* const elem,
const SchemaElementDecl* const elemDecl,
const ComplexTypeInfo* const typeInfo,
const DatatypeValidator* const validator,
const XMLCh* const elemName,
const bool toEmit = true);
bool isSubstitutionGroupCircular(SchemaElementDecl* const elemDecl,
SchemaElementDecl* const subsElemDecl);
void processSubstitutionGroup(const DOMElement* const elem,
SchemaElementDecl* const elemDecl,
ComplexTypeInfo*& typeInfo,
DatatypeValidator*& validator,
const XMLCh* const subsElemQName);
/**
* Create a 'SchemaElementDecl' object and add it to SchemaGrammar
*/
SchemaElementDecl* createSchemaElementDecl(const DOMElement* const elem,
const XMLCh* const name,
bool& isDuplicate,
const XMLCh*& valConstraint,
const bool topLevel);
/**
* Return the value of a given attribute name from an element node
*/
const XMLCh* getElementAttValue(const DOMElement* const elem,
const XMLCh* const attName,
const DatatypeValidator::ValidatorType attType = DatatypeValidator::UnKnown);
/* return minOccurs */
int checkMinMax(ContentSpecNode* const specNode,
const DOMElement* const elem,
const int allContext = Not_All_Context);
/**
* Process complex content for a complexType
*/
void processComplexContent(const DOMElement* const elem,
const XMLCh* const typeName,
const DOMElement* const childElem,
ComplexTypeInfo* const typeInfo,
const XMLCh* const baseLocalPart,
const bool isMixed,
const bool isBaseAnyType = false);
/**
* Process "base" information for a complexType
*/
void processBaseTypeInfo(const DOMElement* const elem,
const XMLCh* const baseName,
const XMLCh* const localPart,
const XMLCh* const uriStr,
ComplexTypeInfo* const typeInfo);
/**
* Check if base is from another schema
*/
bool isBaseFromAnotherSchema(const XMLCh* const baseURI);
/**
* Get complexType infp from another schema
*/
ComplexTypeInfo* getTypeInfoFromNS(const DOMElement* const elem,
const XMLCh* const uriStr,
const XMLCh* const localPart);
DatatypeValidator*
getAttrDatatypeValidatorNS(const DOMElement* const elem,
const XMLCh* localPart,
const XMLCh* typeURI);
/**
* Returns true if a DOM Element is an attribute or attribute group
*/
bool isAttrOrAttrGroup(const DOMElement* const elem);
/**
* Process attributes of a complex type
*/
void processAttributes(const DOMElement* const elem,
const DOMElement* const attElem,
ComplexTypeInfo* const typeInfo,
const bool isBaseAnyType = false);
/**
* Generate a name for an anonymous type
*/
const XMLCh* genAnonTypeName(const XMLCh* const prefix);
void defaultComplexTypeInfo(ComplexTypeInfo* const typeInfo);
/**
* Resolve a schema location attribute value to an input source.
* Caller to delete the returned object.
*/
InputSource* resolveSchemaLocation
(
const XMLCh* const loc
, const XMLResourceIdentifier::ResourceIdentifierType resourceIdentitiferType
, const XMLCh* const nameSpace=0
);
void restoreSchemaInfo(SchemaInfo* const toRestore,
SchemaInfo::ListType const aListType = SchemaInfo::INCLUDE,
const unsigned int saveScope = Grammar::TOP_LEVEL_SCOPE);
void popCurrentTypeNameStack();
/**
* Check whether a mixed content is emptiable or not.
* Needed to validate element constraint values (defualt, fixed)
*/
bool emptiableParticle(const ContentSpecNode* const specNode);
void checkFixedFacet(const DOMElement* const, const XMLCh* const,
const DatatypeValidator* const, unsigned int&);
void buildValidSubstitutionListF(const DOMElement* const elem,
SchemaElementDecl* const,
SchemaElementDecl* const);
void buildValidSubstitutionListB(const DOMElement* const elem,
SchemaElementDecl* const,
SchemaElementDecl* const);
void checkEnumerationRequiredNotation(const DOMElement* const elem,
const XMLCh* const name,
const XMLCh* const typeStr);
void processElements(const DOMElement* const elem,
ComplexTypeInfo* const baseTypeInfo,
ComplexTypeInfo* const newTypeInfo);
void processElements(const DOMElement* const elem,
XercesGroupInfo* const fromGroup,
ComplexTypeInfo* const typeInfo);
void copyGroupElements(const DOMElement* const elem,
XercesGroupInfo* const fromGroup,
XercesGroupInfo* const toGroup,
ComplexTypeInfo* const typeInfo);
void copyAttGroupAttributes(const DOMElement* const elem,
XercesAttGroupInfo* const fromAttGroup,
XercesAttGroupInfo* const toAttGroup,
ComplexTypeInfo* const typeInfo);
void checkForEmptyTargetNamespace(const DOMElement* const elem);
/**
* Attribute wild card intersection.
*
* Note:
* The first parameter will be the result of the intersection, so
* we need to make sure that first parameter is a copy of the
* actual attribute definition we need to intersect with.
*
* What we need to wory about is: type, defaultType, namespace,
* and URI. All remaining data members should be the same.
*/
void attWildCardIntersection(SchemaAttDef* const resultWildCart,
const SchemaAttDef* const toCompareWildCard);
/**
* Attribute wild card union.
*
* Note:
* The first parameter will be the result of the union, so
* we need to make sure that first parameter is a copy of the
* actual attribute definition we need to intersect with.
*
* What we need to wory about is: type, defaultType, namespace,
* and URI. All remaining data members should be the same.
*/
void attWildCardUnion(SchemaAttDef* const resultWildCart,
const SchemaAttDef* const toCompareWildCard);
void copyWildCardData(const SchemaAttDef* const srcWildCard,
SchemaAttDef* const destWildCard);
/**
* Check that the attributes of a type derived by restriction satisfy
* the constraints of derivation valid restriction
*/
void checkAttDerivationOK(const DOMElement* const elem,
const ComplexTypeInfo* const baseTypeInfo,
const ComplexTypeInfo* const childTypeInfo);
void checkAttDerivationOK(const DOMElement* const elem,
const XercesAttGroupInfo* const baseAttGrpInfo,
const XercesAttGroupInfo* const childAttGrpInfo);
/**
* Check whether a namespace value is valid with respect to wildcard
* constraint
*/
bool wildcardAllowsNamespace(const SchemaAttDef* const baseAttWildCard,
const unsigned int nameURI);
/**
* Check whether a namespace constraint is an intensional subset of
* another namespace constraint
*/
bool isWildCardSubset(const SchemaAttDef* const baseAttWildCard,
const SchemaAttDef* const childAttWildCard);
bool openRedefinedSchema(const DOMElement* const redefineElem);
/**
* The purpose of this method is twofold:
* 1. To find and appropriately modify all information items
* in redefinedSchema with names that are redefined by children of
* redefineElem.
* 2. To make sure the redefine element represented by
* redefineElem is valid as far as content goes and with regard to
* properly referencing components to be redefined.
*
* No traversing is done here!
* This method also takes actions to find and, if necessary, modify
* the names of elements in <redefine>'s in the schema that's being
* redefined.
*/
void renameRedefinedComponents(const DOMElement* const redefineElem,
SchemaInfo* const redefiningSchemaInfo,
SchemaInfo* const redefinedSchemaInfo);
/**
* This method returns true if the redefine component is valid, and if
* it was possible to revise it correctly.
*/
bool validateRedefineNameChange(const DOMElement* const redefineChildElem,
const XMLCh* const redefineChildElemName,
const XMLCh* const redefineChildDeclName,
const int redefineNameCounter,
SchemaInfo* const redefiningSchemaInfo);
/**
* This function looks among the children of 'redefineChildElem' for a
* component of type 'redefineChildComponentName'. If it finds one, it
* evaluates whether its ref attribute contains a reference to
* 'refChildTypeName'. If it does, it returns 1 + the value returned by
* calls to itself on all other children. In all other cases it returns
* 0 plus the sum of the values returned by calls to itself on
* redefineChildElem's children. It also resets the value of ref so that
* it will refer to the renamed type from the schema being redefined.
*/
int changeRedefineGroup(const DOMElement* const redefineChildElem,
const XMLCh* const redefineChildComponentName,
const XMLCh* const redefineChildTypeName,
const int redefineNameCounter);
/** This simple function looks for the first occurrence of a
* 'redefineChildTypeName' item in the redefined schema and appropriately
* changes the value of its name. If it turns out that what we're looking
* for is in a <redefine> though, then we just rename it--and it's
* reference--to be the same.
*/
void fixRedefinedSchema(const DOMElement* const elem,
SchemaInfo* const redefinedSchemaInfo,
const XMLCh* const redefineChildComponentName,
const XMLCh* const redefineChildTypeName,
const int redefineNameCounter);
void getRedefineNewTypeName(const XMLCh* const oldTypeName,
const int redefineCounter,
XMLBuffer& newTypeName);
/**
* This purpose of this method is threefold:
* 1. To extract the schema information of included/redefined schema.
* 2. Rename redefined components.
* 3. Process components of included/redefined schemas
*/
void preprocessRedefineInclude(SchemaInfo* const currSchemaInfo);
/**
* Update the list of valid substitution groups in the case of circular
* import.
*/
void updateCircularSubstitutionList(SchemaInfo* const aSchemaInfo);
void processKeyRefFor(SchemaInfo* const aSchemaInfo,
ValueVectorOf<SchemaInfo*>* const infoList);
void processAttValue(const XMLCh* const attVal, XMLBuffer& aBuf);
// routine to generate synthetic annotations
XSAnnotation* generateSyntheticAnnotation(const DOMElement* const elem
, ValueVectorOf<DOMNode*>* nonXSAttList);
// routine to validate annotations
void validateAnnotations();
// -----------------------------------------------------------------------
// Private constants
// -----------------------------------------------------------------------
enum
{
ES_Block
, C_Block
, S_Final
, EC_Final
, ECS_Final
};
enum ExceptionCodes
{
NoException = 0,
InvalidComplexTypeInfo = 1,
RecursingElement = 2
};
enum
{
Elem_Def_Qualified = 1,
Attr_Def_Qualified = 2
};
// -----------------------------------------------------------------------
// Private data members
// -----------------------------------------------------------------------
bool fFullConstraintChecking;
int fTargetNSURI;
int fEmptyNamespaceURI;
unsigned int fCurrentScope;
unsigned int fScopeCount;
unsigned int fAnonXSTypeCount;
XMLSize_t fCircularCheckIndex;
const XMLCh* fTargetNSURIString;
DatatypeValidatorFactory* fDatatypeRegistry;
GrammarResolver* fGrammarResolver;
SchemaGrammar* fSchemaGrammar;
XMLEntityHandler* fEntityHandler;
XMLErrorReporter* fErrorReporter;
XMLStringPool* fURIStringPool;
XMLStringPool* fStringPool;
XMLBuffer fBuffer;
XMLScanner* fScanner;
RefHashTableOf<XMLAttDef>* fAttributeDeclRegistry;
RefHashTableOf<ComplexTypeInfo>* fComplexTypeRegistry;
RefHashTableOf<XercesGroupInfo>* fGroupRegistry;
RefHashTableOf<XercesAttGroupInfo>* fAttGroupRegistry;
RefHashTableOf<ElemVector>* fIC_ElementsNS;
RefHashTableOf<SchemaInfo, PtrHasher>* fPreprocessedNodes;
SchemaInfo* fSchemaInfo;
XercesGroupInfo* fCurrentGroupInfo;
XercesAttGroupInfo* fCurrentAttGroupInfo;
ComplexTypeInfo* fCurrentComplexType;
ValueVectorOf<unsigned int>* fCurrentTypeNameStack;
ValueVectorOf<unsigned int>* fCurrentGroupStack;
ValueVectorOf<SchemaElementDecl*>* fIC_Elements;
ValueVectorOf<const DOMElement*>* fDeclStack;
ValueVectorOf<unsigned int>** fGlobalDeclarations;
ValueVectorOf<DOMNode*>* fNonXSAttList;
ValueVectorOf<int>* fImportedNSList;
RefHashTableOf<ValueVectorOf<DOMElement*>, PtrHasher>* fIC_NodeListNS;
RefHash2KeysTableOf<XMLCh>* fNotationRegistry;
RefHash2KeysTableOf<XMLCh>* fRedefineComponents;
RefHash2KeysTableOf<IdentityConstraint>* fIdentityConstraintNames;
RefHash2KeysTableOf<ElemVector>* fValidSubstitutionGroups;
RefHash2KeysTableOf<SchemaInfo>* fSchemaInfoList;
RefHash2KeysTableOf<SchemaInfo>* fCachedSchemaInfoList;
XSDDOMParser* fParser;
XSDErrorReporter fXSDErrorReporter;
XSDLocator* fLocator;
MemoryManager* fMemoryManager;
MemoryManager* fGrammarPoolMemoryManager;
XSAnnotation* fAnnotation;
GeneralAttributeCheck fAttributeCheck;
friend class GeneralAttributeCheck;
friend class NamespaceScopeManager;
};
// ---------------------------------------------------------------------------
// TraverseSchema: Helper methods
// ---------------------------------------------------------------------------
inline const XMLCh* TraverseSchema::getPrefix(const XMLCh* const rawName) {
int colonIndex = XMLString::indexOf(rawName, chColon);
if (colonIndex == -1 || colonIndex == 0) {
return XMLUni::fgZeroLenString;
}
fBuffer.set(rawName, colonIndex);
return fStringPool->getValueForId(fStringPool->addOrFind(fBuffer.getRawBuffer()));
}
inline const XMLCh* TraverseSchema::getLocalPart(const XMLCh* const rawName) {
int colonIndex = XMLString::indexOf(rawName, chColon);
XMLSize_t rawNameLen = XMLString::stringLen(rawName);
if (XMLSize_t(colonIndex + 1) == rawNameLen) {
return XMLUni::fgZeroLenString;
}
if (colonIndex == -1) {
fBuffer.set(rawName, rawNameLen);
}
else {
fBuffer.set(rawName + colonIndex + 1, rawNameLen - colonIndex - 1);
}
return fStringPool->getValueForId(fStringPool->addOrFind(fBuffer.getRawBuffer()));
}
inline void
TraverseSchema::checkForEmptyTargetNamespace(const DOMElement* const elem) {
const XMLCh* targetNS = getElementAttValue(elem, SchemaSymbols::fgATT_TARGETNAMESPACE);
if (targetNS && !*targetNS) {
reportSchemaError(elem, XMLUni::fgXMLErrDomain, XMLErrs::InvalidTargetNSValue);
}
}
inline bool TraverseSchema::isBaseFromAnotherSchema(const XMLCh* const baseURI)
{
if (!XMLString::equals(baseURI,fTargetNSURIString)
&& !XMLString::equals(baseURI, SchemaSymbols::fgURI_SCHEMAFORSCHEMA)
&& (baseURI && *baseURI)) {
//REVISIT, !!!! a hack: for schema that has no
//target namespace, e.g. personal-schema.xml
return true;
}
return false;
}
inline bool TraverseSchema::isAttrOrAttrGroup(const DOMElement* const elem) {
const XMLCh* elementName = elem->getLocalName();
if (XMLString::equals(elementName, SchemaSymbols::fgELT_ATTRIBUTE) ||
XMLString::equals(elementName, SchemaSymbols::fgELT_ATTRIBUTEGROUP) ||
XMLString::equals(elementName, SchemaSymbols::fgELT_ANYATTRIBUTE)) {
return true;
}
return false;
}
inline const XMLCh* TraverseSchema::genAnonTypeName(const XMLCh* const prefix) {
XMLCh anonCountStr[16]; // a count of 15 digits should be enough
XMLString::sizeToText(fAnonXSTypeCount++, anonCountStr, 15, 10, fMemoryManager);
fBuffer.set(prefix);
fBuffer.append(anonCountStr);
return fStringPool->getValueForId(fStringPool->addOrFind(fBuffer.getRawBuffer()));
}
inline void TraverseSchema::popCurrentTypeNameStack() {
XMLSize_t stackSize = fCurrentTypeNameStack->size();
if (stackSize != 0) {
fCurrentTypeNameStack->removeElementAt(stackSize - 1);
}
}
inline void
TraverseSchema::copyWildCardData(const SchemaAttDef* const srcWildCard,
SchemaAttDef* const destWildCard) {
destWildCard->getAttName()->setURI(srcWildCard->getAttName()->getURI());
destWildCard->setType(srcWildCard->getType());
destWildCard->setDefaultType(srcWildCard->getDefaultType());
}
inline void TraverseSchema::getRedefineNewTypeName(const XMLCh* const oldTypeName,
const int redefineCounter,
XMLBuffer& newTypeName) {
newTypeName.set(oldTypeName);
for (int i=0; i < redefineCounter; i++) {
newTypeName.append(SchemaSymbols::fgRedefIdentifier);
}
}
inline bool TraverseSchema::isImportingNS(const int namespaceURI) {
if (!fImportedNSList)
return false;
return (fImportedNSList->containsElement(namespaceURI));
}
inline void TraverseSchema::addImportedNS(const int namespaceURI) {
if (!fImportedNSList) {
fImportedNSList = new (fMemoryManager) ValueVectorOf<int>(4, fMemoryManager);
}
if (!fImportedNSList->containsElement(namespaceURI))
fImportedNSList->addElement(namespaceURI);
}
XERCES_CPP_NAMESPACE_END
#endif
/**
* End of file TraverseSchema.hpp
*/

View File

@@ -0,0 +1,185 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* $Id: XMLSchemaDescriptionImpl.hpp 527149 2007-04-10 14:56:39Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_XMLSCHEMADESCRIPTIONIMPL_HPP)
#define XERCESC_INCLUDE_GUARD_XMLSCHEMADESCRIPTIONIMPL_HPP
#include <xercesc/framework/XMLSchemaDescription.hpp>
#include <xercesc/util/RefVectorOf.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class XMLAttDefs;
class XMLPARSER_EXPORT XMLSchemaDescriptionImpl : public XMLSchemaDescription
{
public :
// -----------------------------------------------------------------------
/** @name constructor and destructor */
// -----------------------------------------------------------------------
//@{
XMLSchemaDescriptionImpl(
const XMLCh* const targetNamespace
, MemoryManager* const memMgr
);
~XMLSchemaDescriptionImpl();
//@}
// -----------------------------------------------------------------------
/** @name Implementation of GrammarDescription Interface */
// -----------------------------------------------------------------------
//@{
/**
* getGrammarKey
*
*/
virtual const XMLCh* getGrammarKey() const;
//@}
// -----------------------------------------------------------------------
/** @name Implementation of SchemaDescription Interface */
// -----------------------------------------------------------------------
//@{
/**
* getContextType
*
*/
virtual ContextType getContextType() const;
/**
* getTargetNamespace
*
*/
virtual const XMLCh* getTargetNamespace() const;
/**
* getLocationHints
*
*/
virtual const RefArrayVectorOf<XMLCh>* getLocationHints() const;
/**
* getTriggeringComponent
*
*/
virtual const QName* getTriggeringComponent() const;
/**
* getenclosingElementName
*
*/
virtual const QName* getEnclosingElementName() const;
/**
* getAttributes
*
*/
virtual const XMLAttDef* getAttributes() const;
/**
* setContextType
*
*/
virtual void setContextType(ContextType);
/**
* setTargetNamespace
*
*/
virtual void setTargetNamespace(const XMLCh* const);
/**
* setLocationHints
*
*/
virtual void setLocationHints(const XMLCh* const);
/**
* setTriggeringComponent
*
*/
virtual void setTriggeringComponent(QName* const);
/**
* getenclosingElementName
*
*/
virtual void setEnclosingElementName(QName* const);
/**
* setAttributes
*
*/
virtual void setAttributes(XMLAttDef* const);
//@}
/***
* Support for Serialization/De-serialization
***/
DECL_XSERIALIZABLE(XMLSchemaDescriptionImpl)
XMLSchemaDescriptionImpl(MemoryManager* const memMgr = XMLPlatformUtils::fgMemoryManager);
private :
// -----------------------------------------------------------------------
/** name Unimplemented copy constructor and operator= */
// -----------------------------------------------------------------------
//@{
XMLSchemaDescriptionImpl(const XMLSchemaDescriptionImpl& );
XMLSchemaDescriptionImpl& operator=(const XMLSchemaDescriptionImpl& );
//@}
// -----------------------------------------------------------------------
// Private data members
//
// All data member in this implementation are owned to out survive
// parser. Except for fNamespace which is replicated upon set, the
// rest shall be created by the embedded memoryManager.
//
// fContextType
//
// fNamespace owned
//
// fLocationHints owned
//
// fTriggeringComponent owned
//
// fEnclosingElementName owned
//
// fAttributes referenced
//
// -----------------------------------------------------------------------
XMLSchemaDescription::ContextType fContextType;
const XMLCh* fNamespace;
RefArrayVectorOf<XMLCh>* fLocationHints;
const QName* fTriggeringComponent;
const QName* fEnclosingElementName;
const XMLAttDef* fAttributes;
};
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,322 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* $Id: XSDDOMParser.hpp 932887 2010-04-11 13:04:59Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_XSDDOMPARSER_HPP)
#define XERCESC_INCLUDE_GUARD_XSDDOMPARSER_HPP
#include <xercesc/parsers/XercesDOMParser.hpp>
#include <xercesc/validators/schema/XSDErrorReporter.hpp>
#include <xercesc/validators/schema/XSDLocator.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class DOMElement;
class XMLValidator;
/**
* This class is used to parse schema documents into DOM trees
*/
class PARSERS_EXPORT XSDDOMParser : public XercesDOMParser
{
public :
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
/** @name Constructors and Destructor */
//@{
/** Construct a XSDDOMParser, with an optional validator
*
* Constructor with an instance of validator class to use for
* validation. If you don't provide a validator, a default one will
* be created for you in the scanner.
*
* @param gramPool Pointer to the grammar pool instance from
* external application.
* The parser does NOT own it.
*
* @param valToAdopt Pointer to the validator instance to use. The
* parser is responsible for freeing the memory.
*/
XSDDOMParser
(
XMLValidator* const valToAdopt = 0
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
, XMLGrammarPool* const gramPool = 0
);
/**
* Destructor
*/
~XSDDOMParser();
//@}
// -----------------------------------------------------------------------
// Implementation of the XMLDocumentHandler interface.
// -----------------------------------------------------------------------
/** @name Implementation of the XMLDocumentHandler interface. */
//@{
/** Handle a start element event
*
* This method is used to report the start of an element. It is
* called at the end of the element, by which time all attributes
* specified are also parsed. A new DOM Element node is created
* along with as many attribute nodes as required. This new element
* is added appended as a child of the current node in the tree, and
* then replaces it as the current node (if the isEmpty flag is false.)
*
* @param elemDecl A const reference to the object containing element
* declaration information.
* @param urlId An id referring to the namespace prefix, if
* namespaces setting is switched on.
* @param elemPrefix A const pointer to a Unicode string containing
* the namespace prefix for this element. Applicable
* only when namespace processing is enabled.
* @param attrList A const reference to the object containing the
* list of attributes just scanned for this element.
* @param attrCount A count of number of attributes in the list
* specified by the parameter 'attrList'.
* @param isEmpty A flag indicating whether this is an empty element
* or not. If empty, then no endElement() call will
* be made.
* @param isRoot A flag indicating whether this element was the
* root element.
* @see DocumentHandler#startElement
*/
virtual void startElement
(
const XMLElementDecl& elemDecl
, const unsigned int urlId
, const XMLCh* const elemPrefix
, const RefVectorOf<XMLAttr>& attrList
, const XMLSize_t attrCount
, const bool isEmpty
, const bool isRoot
);
/** Handle and end of element event
*
* This method is used to indicate the end tag of an element. The
* DOM parser pops the current element off the top of the element
* stack, and make it the new current element.
*
* @param elemDecl A const reference to the object containing element
* declaration information.
* @param urlId An id referring to the namespace prefix, if
* namespaces setting is switched on.
* @param isRoot A flag indicating whether this element was the
* root element.
* @param elemPrefix A const pointer to a Unicode string containing
* the namespace prefix for this element. Applicable
* only when namespace processing is enabled.
*/
virtual void endElement
(
const XMLElementDecl& elemDecl
, const unsigned int urlId
, const bool isRoot
, const XMLCh* const elemPrefix
);
/** Handle document character events
*
* This method is used to report all the characters scanned by the
* parser. This DOM implementation stores this data in the appropriate
* DOM node, creating one if necessary.
*
* @param chars A const pointer to a Unicode string representing the
* character data.
* @param length The length of the Unicode string returned in 'chars'.
* @param cdataSection A flag indicating if the characters represent
* content from the CDATA section.
*/
virtual void docCharacters
(
const XMLCh* const chars
, const XMLSize_t length
, const bool cdataSection
);
/** Handle a document comment event
*
* This method is used to report any comments scanned by the parser.
* A new comment node is created which stores this data.
*
* @param comment A const pointer to a null terminated Unicode
* string representing the comment text.
*/
virtual void docComment
(
const XMLCh* const comment
);
/** Handle a start entity reference event
*
* This method is used to indicate the start of an entity reference.
* If the expand entity reference flag is true, then a new
* DOM Entity reference node is created.
*
* @param entDecl A const reference to the object containing the
* entity declaration information.
*/
virtual void startEntityReference
(
const XMLEntityDecl& entDecl
);
/** Handle and end of entity reference event
*
* This method is used to indicate that an end of an entity reference
* was just scanned.
*
* @param entDecl A const reference to the object containing the
* entity declaration information.
*/
virtual void endEntityReference
(
const XMLEntityDecl& entDecl
);
/** Handle an ignorable whitespace vent
*
* This method is used to report all the whitespace characters, which
* are determined to be 'ignorable'. This distinction between characters
* is only made, if validation is enabled.
*
* Any whitespace before content is ignored. If the current node is
* already of type DOMNode::TEXT_NODE, then these whitespaces are
* appended, otherwise a new Text node is created which stores this
* data. Essentially all contiguous ignorable characters are collected
* in one node.
*
* @param chars A const pointer to a Unicode string representing the
* ignorable whitespace character data.
* @param length The length of the Unicode string 'chars'.
* @param cdataSection A flag indicating if the characters represent
* content from the CDATA section.
*/
virtual void ignorableWhitespace
(
const XMLCh* const chars
, const XMLSize_t length
, const bool cdataSection
);
//@}
// -----------------------------------------------------------------------
// Get methods
// -----------------------------------------------------------------------
bool getSawFatal() const;
// -----------------------------------------------------------------------
// Set methods
// -----------------------------------------------------------------------
void setUserErrorReporter(XMLErrorReporter* const errorReporter);
void setUserEntityHandler(XMLEntityHandler* const entityHandler);
// -----------------------------------------------------------------------
// XMLErrorReporter interface
// -----------------------------------------------------------------------
virtual void error
(
const unsigned int errCode
, const XMLCh* const errDomain
, const ErrTypes type
, const XMLCh* const errorText
, const XMLCh* const systemId
, const XMLCh* const publicId
, const XMLFileLoc lineNum
, const XMLFileLoc colNum
);
// -----------------------------------------------------------------------
// XMLEntityHandler interface
// -----------------------------------------------------------------------
virtual InputSource* resolveEntity(XMLResourceIdentifier* resourceIdentifier);
protected :
// -----------------------------------------------------------------------
// Protected Helper methods
// -----------------------------------------------------------------------
virtual DOMElement* createElementNSNode(const XMLCh *fNamespaceURI,
const XMLCh *qualifiedName);
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
XSDDOMParser(const XSDDOMParser&);
XSDDOMParser& operator=(const XSDDOMParser&);
// -----------------------------------------------------------------------
// Private Helper methods
// -----------------------------------------------------------------------
void startAnnotation
(
const XMLElementDecl& elemDecl
, const RefVectorOf<XMLAttr>& attrList
, const XMLSize_t attrCount
);
void startAnnotationElement
(
const XMLElementDecl& elemDecl
, const RefVectorOf<XMLAttr>& attrList
, const XMLSize_t attrCount
);
void endAnnotationElement
(
const XMLElementDecl& elemDecl
, bool complete
);
// -----------------------------------------------------------------------
// Private data members
// -----------------------------------------------------------------------
bool fSawFatal;
int fAnnotationDepth;
int fInnerAnnotationDepth;
int fDepth;
XMLErrorReporter* fUserErrorReporter;
XMLEntityHandler* fUserEntityHandler;
ValueVectorOf<unsigned int>* fURIs;
XMLBuffer fAnnotationBuf;
XSDErrorReporter fXSDErrorReporter;
XSDLocator fXSLocator;
};
inline bool XSDDOMParser::getSawFatal() const
{
return fSawFatal;
}
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,115 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* $Id: XSDErrorReporter.hpp 527149 2007-04-10 14:56:39Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_XSDERRORREPORTER_HPP)
#define XERCESC_INCLUDE_GUARD_XSDERRORREPORTER_HPP
#include <xercesc/util/XMemory.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class Locator;
class XMLErrorReporter;
/**
* This class reports schema errors
*/
class VALIDATORS_EXPORT XSDErrorReporter : public XMemory
{
public:
// -----------------------------------------------------------------------
// Constructors are hidden, only the virtual destructor is exposed
// -----------------------------------------------------------------------
XSDErrorReporter(XMLErrorReporter* const errorReporter = 0);
virtual ~XSDErrorReporter()
{
}
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
bool getExitOnFirstFatal() const;
// -----------------------------------------------------------------------
// Setter methods
// -----------------------------------------------------------------------
void setErrorReporter(XMLErrorReporter* const errorReporter);
void setExitOnFirstFatal(const bool newValue);
// -----------------------------------------------------------------------
// Report error methods
// -----------------------------------------------------------------------
void emitError(const unsigned int toEmit,
const XMLCh* const msgDomain,
const Locator* const aLocator);
void emitError(const unsigned int toEmit,
const XMLCh* const msgDomain,
const Locator* const aLocator,
const XMLCh* const text1,
const XMLCh* const text2 = 0,
const XMLCh* const text3 = 0,
const XMLCh* const text4 = 0,
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
void emitError(const XMLException& except,
const Locator* const aLocator);
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and destructor
// -----------------------------------------------------------------------
XSDErrorReporter(const XSDErrorReporter&);
XSDErrorReporter& operator=(const XSDErrorReporter&);
// -----------------------------------------------------------------------
// Private data members
// -----------------------------------------------------------------------
bool fExitOnFirstFatal;
XMLErrorReporter* fErrorReporter;
};
// ---------------------------------------------------------------------------
// XSDErrorReporter: Getter methods
// ---------------------------------------------------------------------------
inline bool XSDErrorReporter::getExitOnFirstFatal() const
{
return fExitOnFirstFatal;
}
// ---------------------------------------------------------------------------
// XSDErrorReporter: Setter methods
// ---------------------------------------------------------------------------
inline void XSDErrorReporter::setExitOnFirstFatal(const bool newValue)
{
fExitOnFirstFatal = newValue;
}
inline void XSDErrorReporter::setErrorReporter(XMLErrorReporter* const errorReporter)
{
fErrorReporter = errorReporter;
}
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,141 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* $Id: XSDLocator.hpp 672273 2008-06-27 13:57:00Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_XSDLOCATOR_HPP)
#define XERCESC_INCLUDE_GUARD_XSDLOCATOR_HPP
/**
* A Locator implementation
*/
#include <xercesc/util/XMemory.hpp>
#include <xercesc/sax/Locator.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class VALIDATORS_EXPORT XSDLocator: public XMemory, public Locator
{
public:
/** @name Constructors and Destructor */
//@{
/** Default constructor */
XSDLocator();
/** Destructor */
virtual ~XSDLocator()
{
}
//@}
/** @name The locator interface */
//@{
/**
* Return the public identifier for the current document event.
* <p>This will be the public identifier
* @return A string containing the public identifier, or
* null if none is available.
* @see #getSystemId
*/
virtual const XMLCh* getPublicId() const;
/**
* Return the system identifier for the current document event.
*
* <p>If the system identifier is a URL, the parser must resolve it
* fully before passing it to the application.</p>
*
* @return A string containing the system identifier, or null
* if none is available.
* @see #getPublicId
*/
virtual const XMLCh* getSystemId() const;
/**
* Return the line number where the current document event ends.
* Note that this is the line position of the first character
* after the text associated with the document event.
* @return The line number, or 0 if none is available.
* @see #getColumnNumber
*/
virtual XMLFileLoc getLineNumber() const;
/**
* Return the column number where the current document event ends.
* Note that this is the column number of the first
* character after the text associated with the document
* event. The first column in a line is position 1.
* @return The column number, or 0 if none is available.
* @see #getLineNumber
*/
virtual XMLFileLoc getColumnNumber() const;
//@}
// -----------------------------------------------------------------------
// Setter methods
// -----------------------------------------------------------------------
void setValues(const XMLCh* const systemId,
const XMLCh* const publicId,
const XMLFileLoc lineNo, const XMLFileLoc columnNo);
private :
// -----------------------------------------------------------------------
// Unimplemented constructors and destructor
// -----------------------------------------------------------------------
XSDLocator(const XSDLocator&);
XSDLocator& operator=(const XSDLocator&);
// -----------------------------------------------------------------------
// Private data members
// -----------------------------------------------------------------------
XMLFileLoc fLineNo;
XMLFileLoc fColumnNo;
const XMLCh* fSystemId;
const XMLCh* fPublicId;
};
// ---------------------------------------------------------------------------
// XSDLocator: Getter methods
// ---------------------------------------------------------------------------
inline XMLFileLoc XSDLocator::getLineNumber() const
{
return fLineNo;
}
inline XMLFileLoc XSDLocator::getColumnNumber() const
{
return fColumnNo;
}
inline const XMLCh* XSDLocator::getPublicId() const
{
return fPublicId;
}
inline const XMLCh* XSDLocator::getSystemId() const
{
return fSystemId;
}
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,71 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* $Id: XUtil.hpp 527149 2007-04-10 14:56:39Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_XUTIL_HPP)
#define XERCESC_INCLUDE_GUARD_XUTIL_HPP
#include <xercesc/dom/DOMElement.hpp>
#include <xercesc/dom/DOMDocument.hpp>
#include <xercesc/dom/DOMNamedNodeMap.hpp>
#include <xercesc/dom/DOMNode.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class DOMNode;
class DOMElement;
/**
* Some useful utility methods.
*/
class VALIDATORS_EXPORT XUtil
{
public:
// Finds and returns the first child element node.
static DOMElement* getFirstChildElement(const DOMNode* const parent);
// Finds and returns the first child node with the given qualifiedname.
static DOMElement* getFirstChildElementNS(const DOMNode* const parent
, const XMLCh** const elemNames
, const XMLCh* const uriStr
, unsigned int length);
// Finds and returns the next sibling element node.
static DOMElement* getNextSiblingElement(const DOMNode* const node);
static DOMElement* getNextSiblingElementNS(const DOMNode* const node
, const XMLCh** const elemNames
, const XMLCh* const uriStr
, unsigned int length);
private:
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
// This class cannot be instantiated.
XUtil() {};
~XUtil() {};
};
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,257 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* $Id: XercesAttGroupInfo.hpp 932887 2010-04-11 13:04:59Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_XERCESATTGROUPINFO_HPP)
#define XERCESC_INCLUDE_GUARD_XERCESATTGROUPINFO_HPP
/**
* The class act as a place holder to store attributeGroup information.
*
* The class is intended for internal use.
*/
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <xercesc/util/RefVectorOf.hpp>
#include <xercesc/validators/schema/SchemaAttDef.hpp>
#include <xercesc/internal/XSerializable.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class VALIDATORS_EXPORT XercesAttGroupInfo : public XSerializable, public XMemory
{
public:
// -----------------------------------------------------------------------
// Public Constructors/Destructor
// -----------------------------------------------------------------------
XercesAttGroupInfo
(
unsigned int attGroupNameId
, unsigned int attGroupNamespaceId
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
~XercesAttGroupInfo();
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
bool containsTypeWithId() const;
XMLSize_t attributeCount() const;
XMLSize_t anyAttributeCount() const;
unsigned int getNameId() const;
unsigned int getNamespaceId() const;
SchemaAttDef* attributeAt(const XMLSize_t index);
const SchemaAttDef* attributeAt(const XMLSize_t index) const;
SchemaAttDef* anyAttributeAt(const XMLSize_t index);
const SchemaAttDef* anyAttributeAt(const XMLSize_t index) const;
SchemaAttDef* getCompleteWildCard() const;
const SchemaAttDef* getAttDef(const XMLCh* const baseName,
const int uriId) const;
// -----------------------------------------------------------------------
// Setter methods
// -----------------------------------------------------------------------
void setTypeWithId(const bool other);
void addAttDef(SchemaAttDef* const toAdd, const bool toClone = false);
void addAnyAttDef(SchemaAttDef* const toAdd, const bool toClone = false);
void setCompleteWildCard(SchemaAttDef* const toSet);
// -----------------------------------------------------------------------
// Query methods
// -----------------------------------------------------------------------
bool containsAttribute(const XMLCh* const name, const unsigned int uri);
/***
* Support for Serialization/De-serialization
***/
DECL_XSERIALIZABLE(XercesAttGroupInfo)
XercesAttGroupInfo(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
XercesAttGroupInfo(const XercesAttGroupInfo& elemInfo);
XercesAttGroupInfo& operator= (const XercesAttGroupInfo& other);
// -----------------------------------------------------------------------
// Private data members
// -----------------------------------------------------------------------
bool fTypeWithId;
unsigned int fNameId;
unsigned int fNamespaceId;
RefVectorOf<SchemaAttDef>* fAttributes;
RefVectorOf<SchemaAttDef>* fAnyAttributes;
SchemaAttDef* fCompleteWildCard;
MemoryManager* fMemoryManager;
};
// ---------------------------------------------------------------------------
// XercesAttGroupInfo: Getter methods
// ---------------------------------------------------------------------------
inline bool XercesAttGroupInfo::containsTypeWithId() const {
return fTypeWithId;
}
inline XMLSize_t XercesAttGroupInfo::attributeCount() const {
if (fAttributes) {
return fAttributes->size();
}
return 0;
}
inline XMLSize_t XercesAttGroupInfo::anyAttributeCount() const {
if (fAnyAttributes) {
return fAnyAttributes->size();
}
return 0;
}
inline unsigned int XercesAttGroupInfo::getNameId() const
{
return fNameId;
}
inline unsigned int XercesAttGroupInfo::getNamespaceId() const
{
return fNamespaceId;
}
inline SchemaAttDef*
XercesAttGroupInfo::attributeAt(const XMLSize_t index) {
if (fAttributes) {
return fAttributes->elementAt(index);
}
return 0;
}
inline const SchemaAttDef*
XercesAttGroupInfo::attributeAt(const XMLSize_t index) const {
if (fAttributes) {
return fAttributes->elementAt(index);
}
return 0;
}
inline SchemaAttDef*
XercesAttGroupInfo::anyAttributeAt(const XMLSize_t index) {
if (fAnyAttributes) {
return fAnyAttributes->elementAt(index);
}
return 0;
}
inline const SchemaAttDef*
XercesAttGroupInfo::anyAttributeAt(const XMLSize_t index) const {
if (fAnyAttributes) {
return fAnyAttributes->elementAt(index);
}
return 0;
}
inline SchemaAttDef*
XercesAttGroupInfo::getCompleteWildCard() const {
return fCompleteWildCard;
}
// ---------------------------------------------------------------------------
// XercesAttGroupInfo: Setter methods
// ---------------------------------------------------------------------------
inline void XercesAttGroupInfo::setTypeWithId(const bool other) {
fTypeWithId = other;
}
inline void XercesAttGroupInfo::addAttDef(SchemaAttDef* const toAdd,
const bool toClone) {
if (!fAttributes) {
fAttributes = new (fMemoryManager) RefVectorOf<SchemaAttDef>(4, true, fMemoryManager);
}
if (toClone) {
SchemaAttDef* clonedAttDef = new (fMemoryManager) SchemaAttDef(toAdd);
if (!clonedAttDef->getBaseAttDecl())
clonedAttDef->setBaseAttDecl(toAdd);
fAttributes->addElement(clonedAttDef);
}
else {
fAttributes->addElement(toAdd);
}
}
inline void XercesAttGroupInfo::addAnyAttDef(SchemaAttDef* const toAdd,
const bool toClone) {
if (!fAnyAttributes) {
fAnyAttributes = new (fMemoryManager) RefVectorOf<SchemaAttDef>(2, true, fMemoryManager);
}
if (toClone) {
SchemaAttDef* clonedAttDef = new (fMemoryManager) SchemaAttDef(toAdd);
if (!clonedAttDef->getBaseAttDecl())
clonedAttDef->setBaseAttDecl(toAdd);
fAnyAttributes->addElement(clonedAttDef);
}
else {
fAnyAttributes->addElement(toAdd);
}
}
inline void
XercesAttGroupInfo::setCompleteWildCard(SchemaAttDef* const toSet) {
if (fCompleteWildCard) {
delete fCompleteWildCard;
}
fCompleteWildCard = toSet;
}
XERCES_CPP_NAMESPACE_END
#endif
/**
* End of file XercesAttGroupInfo.hpp
*/

View File

@@ -0,0 +1,81 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* $Id: XercesElementWildcard.hpp 527149 2007-04-10 14:56:39Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_XERCESELEMENTWILDCARD_HPP)
#define XERCESC_INCLUDE_GUARD_XERCESELEMENTWILDCARD_HPP
#include <xercesc/util/QName.hpp>
#include <xercesc/validators/common/ContentSpecNode.hpp>
#include <xercesc/validators/schema/SubstitutionGroupComparator.hpp>
XERCES_CPP_NAMESPACE_BEGIN
// ---------------------------------------------------------------------------
// Forward declarations
// ---------------------------------------------------------------------------
class SchemaGrammar;
class VALIDATORS_EXPORT XercesElementWildcard
{
public :
// -----------------------------------------------------------------------
// Class static methods
// -----------------------------------------------------------------------
/*
* check whether two elements are in conflict
*/
static bool conflict(SchemaGrammar* const pGrammar,
ContentSpecNode::NodeTypes type1,
QName* q1,
ContentSpecNode::NodeTypes type2,
QName* q2,
SubstitutionGroupComparator* comparator);
private:
// -----------------------------------------------------------------------
// private helper methods
// -----------------------------------------------------------------------
static bool uriInWildcard(SchemaGrammar* const pGrammar,
QName* qname,
unsigned int wildcard,
ContentSpecNode::NodeTypes wtype,
SubstitutionGroupComparator* comparator);
static bool wildcardIntersect(ContentSpecNode::NodeTypes t1,
unsigned int w1,
ContentSpecNode::NodeTypes t2,
unsigned int w2);
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
XercesElementWildcard();
~XercesElementWildcard();
};
XERCES_CPP_NAMESPACE_END
#endif // XERCESELEMENTWILDCARD_HPP

View File

@@ -0,0 +1,204 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* $Id: XercesGroupInfo.hpp 932887 2010-04-11 13:04:59Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_XERCESGROUPINFO_HPP)
#define XERCESC_INCLUDE_GUARD_XERCESGROUPINFO_HPP
/**
* The class act as a place holder to store group information.
*
* The class is intended for internal use.
*/
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <xercesc/util/RefVectorOf.hpp>
#include <xercesc/validators/schema/SchemaElementDecl.hpp>
#include <xercesc/internal/XSerializable.hpp>
XERCES_CPP_NAMESPACE_BEGIN
// ---------------------------------------------------------------------------
// Forward Declarations
// ---------------------------------------------------------------------------
class ContentSpecNode;
class XSDLocator;
class VALIDATORS_EXPORT XercesGroupInfo : public XSerializable, public XMemory
{
public:
// -----------------------------------------------------------------------
// Public Constructors/Destructor
// -----------------------------------------------------------------------
XercesGroupInfo
(
unsigned int groupNameId
, unsigned int groupNamespaceId
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
~XercesGroupInfo();
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
bool getCheckElementConsistency() const;
unsigned int getScope() const;
XMLSize_t elementCount() const;
ContentSpecNode* getContentSpec() const;
SchemaElementDecl* elementAt(const XMLSize_t index);
const SchemaElementDecl* elementAt(const XMLSize_t index) const;
XSDLocator* getLocator() const;
XercesGroupInfo* getBaseGroup() const;
unsigned int getNameId() const;
unsigned int getNamespaceId() const;
// -----------------------------------------------------------------------
// Setter methods
// -----------------------------------------------------------------------
void setScope(const unsigned int other);
void setContentSpec(ContentSpecNode* const other);
void addElement(SchemaElementDecl* const toAdd);
void setLocator(XSDLocator* const aLocator);
void setBaseGroup(XercesGroupInfo* const baseGroup);
void setCheckElementConsistency(const bool aValue);
/***
* Support for Serialization/De-serialization
***/
DECL_XSERIALIZABLE(XercesGroupInfo)
XercesGroupInfo(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
XercesGroupInfo(const XercesGroupInfo& elemInfo);
XercesGroupInfo& operator= (const XercesGroupInfo& other);
// -----------------------------------------------------------------------
// Private data members
// -----------------------------------------------------------------------
bool fCheckElementConsistency;
unsigned int fScope;
unsigned int fNameId;
unsigned int fNamespaceId;
ContentSpecNode* fContentSpec;
RefVectorOf<SchemaElementDecl>* fElements;
XercesGroupInfo* fBaseGroup; // redefine by restriction
XSDLocator* fLocator;
};
// ---------------------------------------------------------------------------
// XercesGroupInfo: Getter methods
// ---------------------------------------------------------------------------
inline unsigned int XercesGroupInfo::getScope() const {
return fScope;
}
inline XMLSize_t XercesGroupInfo::elementCount() const {
return fElements->size();
}
inline ContentSpecNode* XercesGroupInfo::getContentSpec() const {
return fContentSpec;
}
inline SchemaElementDecl*
XercesGroupInfo::elementAt(const XMLSize_t index) {
return fElements->elementAt(index);
}
inline const SchemaElementDecl*
XercesGroupInfo::elementAt(const XMLSize_t index) const {
return fElements->elementAt(index);
}
inline XSDLocator* XercesGroupInfo::getLocator() const {
return fLocator;
}
inline XercesGroupInfo* XercesGroupInfo::getBaseGroup() const {
return fBaseGroup;
}
inline bool XercesGroupInfo::getCheckElementConsistency() const {
return fCheckElementConsistency;
}
inline unsigned int XercesGroupInfo::getNameId() const
{
return fNameId;
}
inline unsigned int XercesGroupInfo::getNamespaceId() const
{
return fNamespaceId;
}
// ---------------------------------------------------------------------------
// XercesGroupInfo: Setter methods
// ---------------------------------------------------------------------------}
inline void XercesGroupInfo::setScope(const unsigned int other) {
fScope = other;
}
inline void XercesGroupInfo::setContentSpec(ContentSpecNode* const other) {
fContentSpec = other;
}
inline void XercesGroupInfo::addElement(SchemaElementDecl* const elem) {
if (!fElements->containsElement(elem))
fElements->addElement(elem);
}
inline void XercesGroupInfo::setBaseGroup(XercesGroupInfo* const baseGroup) {
fBaseGroup = baseGroup;
}
inline void XercesGroupInfo::setCheckElementConsistency(const bool aValue) {
fCheckElementConsistency = aValue;
}
XERCES_CPP_NAMESPACE_END
#endif
/**
* End of file XercesGroupInfo.hpp
*/

View File

@@ -0,0 +1,141 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* $Id: FieldActivator.hpp 679340 2008-07-24 10:28:29Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_FIELDACTIVATOR_HPP)
#define XERCESC_INCLUDE_GUARD_FIELDACTIVATOR_HPP
/**
* This class is responsible for activating fields within a specific scope;
* the caller merely requests the fields to be activated.
*/
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <xercesc/util/ValueHashTableOf.hpp>
XERCES_CPP_NAMESPACE_BEGIN
// ---------------------------------------------------------------------------
// Forward Declaration
// ---------------------------------------------------------------------------
class IdentityConstraint;
class XPathMatcher;
class ValueStoreCache;
class IC_Field;
class XPathMatcherStack;
class VALIDATORS_EXPORT FieldActivator : public XMemory
{
public:
// -----------------------------------------------------------------------
// Constructors/Destructor
// -----------------------------------------------------------------------
FieldActivator(ValueStoreCache* const valueStoreCache,
XPathMatcherStack* const matcherStack,
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
FieldActivator(const FieldActivator& other);
~FieldActivator();
// -----------------------------------------------------------------------
// Operator methods
// -----------------------------------------------------------------------
FieldActivator& operator =(const FieldActivator& other);
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
bool getMayMatch(IC_Field* const field);
// -----------------------------------------------------------------------
// Setter methods
// -----------------------------------------------------------------------
void setValueStoreCache(ValueStoreCache* const other);
void setMatcherStack(XPathMatcherStack* const matcherStack);
void setMayMatch(IC_Field* const field, bool value);
// -----------------------------------------------------------------------
// Activation methods
// -----------------------------------------------------------------------
/**
* Start the value scope for the specified identity constraint. This
* method is called when the selector matches in order to initialize
* the value store.
*/
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, const int initialDepth);
/**
* Ends the value scope for the specified identity constraint.
*/
void endValueScopeFor(const IdentityConstraint* const ic, const int initialDepth);
private:
// -----------------------------------------------------------------------
// Data
// -----------------------------------------------------------------------
ValueStoreCache* fValueStoreCache;
XPathMatcherStack* fMatcherStack;
ValueHashTableOf<bool, PtrHasher>* fMayMatch;
MemoryManager* fMemoryManager;
};
// ---------------------------------------------------------------------------
// FieldActivator: Getter methods
// ---------------------------------------------------------------------------
inline bool FieldActivator::getMayMatch(IC_Field* const field) {
return fMayMatch->get(field);
}
// ---------------------------------------------------------------------------
// FieldActivator: Setter methods
// ---------------------------------------------------------------------------
inline void FieldActivator::setValueStoreCache(ValueStoreCache* const other) {
fValueStoreCache = other;
}
inline void
FieldActivator::setMatcherStack(XPathMatcherStack* const matcherStack) {
fMatcherStack = matcherStack;
}
inline void FieldActivator::setMayMatch(IC_Field* const field, bool value) {
fMayMatch->put(field, value);
}
XERCES_CPP_NAMESPACE_END
#endif
/**
* End of file FieldActivator.hpp
*/

View File

@@ -0,0 +1,198 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* $Id: FieldValueMap.hpp 708224 2008-10-27 16:02:26Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_FIELDVALUEMAP_HPP)
#define XERCESC_INCLUDE_GUARD_FIELDVALUEMAP_HPP
/**
* This class maps values associated with fields of an identity constraint
* that have successfully matched some string in an instance document.
*/
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <xercesc/util/XMLString.hpp>
#include <xercesc/util/ValueVectorOf.hpp>
#include <xercesc/util/RefArrayVectorOf.hpp>
XERCES_CPP_NAMESPACE_BEGIN
// ---------------------------------------------------------------------------
// Forward Declaration
// ---------------------------------------------------------------------------
class IC_Field;
class DatatypeValidator;
class VALIDATORS_EXPORT FieldValueMap : public XMemory
{
public:
// -----------------------------------------------------------------------
// Constructors/Destructor
// -----------------------------------------------------------------------
FieldValueMap(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
FieldValueMap(const FieldValueMap& other);
~FieldValueMap();
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
DatatypeValidator* getDatatypeValidatorAt(const XMLSize_t index) const;
DatatypeValidator* getDatatypeValidatorFor(const IC_Field* const key) const;
XMLCh* getValueAt(const XMLSize_t index) const;
XMLCh* getValueFor(const IC_Field* const key) const;
IC_Field* keyAt(const XMLSize_t index) const;
// -----------------------------------------------------------------------
// Setter methods
// -----------------------------------------------------------------------
void put(IC_Field* const key, DatatypeValidator* const dv,
const XMLCh* const value);
// -----------------------------------------------------------------------
// Helper methods
// -----------------------------------------------------------------------
XMLSize_t size() const;
bool indexOf(const IC_Field* const key, XMLSize_t& location) const;
void clear();
private:
// -----------------------------------------------------------------------
// Private helper methods
// -----------------------------------------------------------------------
void cleanUp();
// -----------------------------------------------------------------------
// Unimplemented operators
// -----------------------------------------------------------------------
FieldValueMap& operator= (const FieldValueMap& other);
// -----------------------------------------------------------------------
// Data
// -----------------------------------------------------------------------
ValueVectorOf<IC_Field*>* fFields;
ValueVectorOf<DatatypeValidator*>* fValidators;
RefArrayVectorOf<XMLCh>* fValues;
MemoryManager* fMemoryManager;
};
// ---------------------------------------------------------------------------
// FieldValueMap: Getter methods
// ---------------------------------------------------------------------------
inline DatatypeValidator*
FieldValueMap::getDatatypeValidatorAt(const XMLSize_t index) const {
if (fValidators) {
return fValidators->elementAt(index);
}
return 0;
}
inline DatatypeValidator*
FieldValueMap::getDatatypeValidatorFor(const IC_Field* const key) const {
XMLSize_t location;
if (fValidators && indexOf(key, location)) {
return fValidators->elementAt(location);
}
return 0;
}
inline XMLCh* FieldValueMap::getValueAt(const XMLSize_t index) const {
if (fValues) {
return fValues->elementAt(index);
}
return 0;
}
inline XMLCh* FieldValueMap::getValueFor(const IC_Field* const key) const {
XMLSize_t location;
if (fValues && indexOf(key, location)) {
return fValues->elementAt(location);
}
return 0;
}
inline IC_Field* FieldValueMap::keyAt(const XMLSize_t index) const {
if (fFields) {
return fFields->elementAt(index);
}
return 0;
}
// ---------------------------------------------------------------------------
// FieldValueMap: Helper methods
// ---------------------------------------------------------------------------
inline XMLSize_t FieldValueMap::size() const {
if (fFields) {
return fFields->size();
}
return 0;
}
// ---------------------------------------------------------------------------
// FieldValueMap: Setter methods
// ---------------------------------------------------------------------------
inline void FieldValueMap::put(IC_Field* const key,
DatatypeValidator* const dv,
const XMLCh* const value) {
if (!fFields) {
fFields = new (fMemoryManager) ValueVectorOf<IC_Field*>(4, fMemoryManager);
fValidators = new (fMemoryManager) ValueVectorOf<DatatypeValidator*>(4, fMemoryManager);
fValues = new (fMemoryManager) RefArrayVectorOf<XMLCh>(4, true, fMemoryManager);
}
XMLSize_t keyIndex;
bool bFound=indexOf(key, keyIndex);
if (!bFound) {
fFields->addElement(key);
fValidators->addElement(dv);
fValues->addElement(XMLString::replicate(value, fMemoryManager));
}
else {
fValidators->setElementAt(dv, keyIndex);
fValues->setElementAt(XMLString::replicate(value, fMemoryManager), keyIndex);
}
}
XERCES_CPP_NAMESPACE_END
#endif
/**
* End of file FieldValueMap.hpp
*/

View File

@@ -0,0 +1,152 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* $Id: IC_Field.hpp 932887 2010-04-11 13:04:59Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_IC_FIELD_HPP)
#define XERCESC_INCLUDE_GUARD_IC_FIELD_HPP
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <xercesc/validators/schema/identity/XPathMatcher.hpp>
#include <xercesc/internal/XSerializable.hpp>
XERCES_CPP_NAMESPACE_BEGIN
// ---------------------------------------------------------------------------
// Forward Declaration
// ---------------------------------------------------------------------------
class ValueStore;
class FieldActivator;
class VALIDATORS_EXPORT IC_Field : public XSerializable, public XMemory
{
public:
// -----------------------------------------------------------------------
// Constructors/Destructor
// -----------------------------------------------------------------------
IC_Field(XercesXPath* const xpath,
IdentityConstraint* const identityConstraint);
~IC_Field();
// -----------------------------------------------------------------------
// operators
// -----------------------------------------------------------------------
bool operator== (const IC_Field& other) const;
bool operator!= (const IC_Field& other) const;
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
XercesXPath* getXPath() const { return fXPath; }
IdentityConstraint* getIdentityConstraint() const { return fIdentityConstraint; }
// -----------------------------------------------------------------------
// Factory methods
// -----------------------------------------------------------------------
XPathMatcher* createMatcher
(
FieldActivator* const fieldActivator
, ValueStore* const valueStore
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
/***
* Support for Serialization/De-serialization
***/
DECL_XSERIALIZABLE(IC_Field)
IC_Field(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
IC_Field(const IC_Field& other);
IC_Field& operator= (const IC_Field& other);
// -----------------------------------------------------------------------
// Data members
// -----------------------------------------------------------------------
XercesXPath* fXPath;
IdentityConstraint* fIdentityConstraint;
};
class VALIDATORS_EXPORT FieldMatcher : public XPathMatcher
{
public:
// -----------------------------------------------------------------------
// Constructors/Destructor
// -----------------------------------------------------------------------
~FieldMatcher() {}
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
ValueStore* getValueStore() const { return fValueStore; }
IC_Field* getField() const { return fField; }
// -----------------------------------------------------------------------
// Virtual methods
// -----------------------------------------------------------------------
void matched(const XMLCh* const content, DatatypeValidator* const dv,
const bool isNil);
private:
// -----------------------------------------------------------------------
// Constructors/Destructor
// -----------------------------------------------------------------------
FieldMatcher(XercesXPath* const anXPath,
IC_Field* const aField,
ValueStore* const valueStore,
FieldActivator* const fieldActivator,
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
FieldMatcher(const FieldMatcher& other);
FieldMatcher& operator= (const FieldMatcher& other);
// -----------------------------------------------------------------------
// Friends
// -----------------------------------------------------------------------
friend class IC_Field;
// -----------------------------------------------------------------------
// Data members
// -----------------------------------------------------------------------
ValueStore* fValueStore;
IC_Field* fField;
FieldActivator* fFieldActivator;
};
XERCES_CPP_NAMESPACE_END
#endif
/**
* End of file IC_Field.hpp
*/

View File

@@ -0,0 +1,80 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* $Id: IC_Key.hpp 932887 2010-04-11 13:04:59Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_IC_KEY_HPP)
#define XERCESC_INCLUDE_GUARD_IC_KEY_HPP
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <xercesc/validators/schema/identity/IdentityConstraint.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class VALIDATORS_EXPORT IC_Key: public IdentityConstraint
{
public:
// -----------------------------------------------------------------------
// Constructors/Destructor
// -----------------------------------------------------------------------
IC_Key(const XMLCh* const identityConstraintName,
const XMLCh* const elemName,
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
~IC_Key();
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
short getType() const;
/***
* Support for Serialization/De-serialization
***/
DECL_XSERIALIZABLE(IC_Key)
IC_Key(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
IC_Key(const IC_Key& other);
IC_Key& operator= (const IC_Key& other);
};
// ---------------------------------------------------------------------------
// IC_Key: Getter methods
// ---------------------------------------------------------------------------
inline short IC_Key::getType() const {
return IdentityConstraint::ICType_KEY;
}
XERCES_CPP_NAMESPACE_END
#endif
/**
* End of file IC_Key.hpp
*/

View File

@@ -0,0 +1,92 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* $Id: IC_KeyRef.hpp 932887 2010-04-11 13:04:59Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_IC_KEYREF_HPP)
#define XERCESC_INCLUDE_GUARD_IC_KEYREF_HPP
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <xercesc/validators/schema/identity/IdentityConstraint.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class VALIDATORS_EXPORT IC_KeyRef: public IdentityConstraint
{
public:
// -----------------------------------------------------------------------
// Constructors/Destructor
// -----------------------------------------------------------------------
IC_KeyRef(const XMLCh* const identityConstraintName,
const XMLCh* const elemName,
IdentityConstraint* const icKey,
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
~IC_KeyRef();
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
short getType() const;
IdentityConstraint* getKey() const;
/***
* Support for Serialization/De-serialization
***/
DECL_XSERIALIZABLE(IC_KeyRef)
IC_KeyRef(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
IC_KeyRef(const IC_KeyRef& other);
IC_KeyRef& operator= (const IC_KeyRef& other);
// -----------------------------------------------------------------------
// Data members
// -----------------------------------------------------------------------
IdentityConstraint* fKey;
};
// ---------------------------------------------------------------------------
// IC_KeyRef: Getter methods
// ---------------------------------------------------------------------------
inline short IC_KeyRef::getType() const {
return IdentityConstraint::ICType_KEYREF;
}
inline IdentityConstraint* IC_KeyRef::getKey() const {
return fKey;
}
XERCES_CPP_NAMESPACE_END
#endif
/**
* End of file IC_KeyRef.hpp
*/

View File

@@ -0,0 +1,155 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* $Id: IC_Selector.hpp 932887 2010-04-11 13:04:59Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_IC_SELECTOR_HPP)
#define XERCESC_INCLUDE_GUARD_IC_SELECTOR_HPP
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <xercesc/validators/schema/identity/XPathMatcher.hpp>
#include <xercesc/internal/XSerializable.hpp>
XERCES_CPP_NAMESPACE_BEGIN
// ---------------------------------------------------------------------------
// Forward Declaration
// ---------------------------------------------------------------------------
class FieldActivator;
class VALIDATORS_EXPORT IC_Selector : public XSerializable, public XMemory
{
public:
// -----------------------------------------------------------------------
// Constructors/Destructor
// -----------------------------------------------------------------------
IC_Selector(XercesXPath* const xpath,
IdentityConstraint* const identityConstraint);
~IC_Selector();
// -----------------------------------------------------------------------
// operators
// -----------------------------------------------------------------------
bool operator== (const IC_Selector& other) const;
bool operator!= (const IC_Selector& other) const;
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
XercesXPath* getXPath() const { return fXPath; }
IdentityConstraint* getIdentityConstraint() const { return fIdentityConstraint; }
// -----------------------------------------------------------------------
// Factory methods
// -----------------------------------------------------------------------
XPathMatcher* createMatcher(FieldActivator* const fieldActivator,
const int initialDepth,
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
/***
* Support for Serialization/De-serialization
***/
DECL_XSERIALIZABLE(IC_Selector)
IC_Selector(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
IC_Selector(const IC_Selector& other);
IC_Selector& operator= (const IC_Selector& other);
// -----------------------------------------------------------------------
// Data members
// -----------------------------------------------------------------------
XercesXPath* fXPath;
IdentityConstraint* fIdentityConstraint;
};
class VALIDATORS_EXPORT SelectorMatcher : public XPathMatcher
{
public:
// -----------------------------------------------------------------------
// Constructors/Destructor
// -----------------------------------------------------------------------
~SelectorMatcher() {}
int getInitialDepth() const { return fInitialDepth; }
// -----------------------------------------------------------------------
// XMLDocumentHandler methods
// -----------------------------------------------------------------------
virtual void startDocumentFragment();
virtual void startElement(const XMLElementDecl& elemDecl,
const unsigned int urlId,
const XMLCh* const elemPrefix,
const RefVectorOf<XMLAttr>& attrList,
const XMLSize_t attrCount,
ValidationContext* validationContext = 0);
virtual void endElement(const XMLElementDecl& elemDecl,
const XMLCh* const elemContent,
ValidationContext* validationContext = 0,
DatatypeValidator* actualValidator = 0);
private:
// -----------------------------------------------------------------------
// Constructors/Destructor
// -----------------------------------------------------------------------
SelectorMatcher(XercesXPath* const anXPath,
IC_Selector* const selector,
FieldActivator* const fieldActivator,
const int initialDepth,
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
SelectorMatcher(const SelectorMatcher& other);
SelectorMatcher& operator= (const SelectorMatcher& other);
// -----------------------------------------------------------------------
// Friends
// -----------------------------------------------------------------------
friend class IC_Selector;
// -----------------------------------------------------------------------
// Data members
// -----------------------------------------------------------------------
int fInitialDepth;
int fElementDepth;
int fMatchedDepth;
IC_Selector* fSelector;
FieldActivator* fFieldActivator;
};
XERCES_CPP_NAMESPACE_END
#endif
/**
* End of file IC_Selector.hpp
*/

View File

@@ -0,0 +1,84 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* $Id: IC_Unique.hpp 932887 2010-04-11 13:04:59Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_IC_UNIQUE_HPP)
#define XERCESC_INCLUDE_GUARD_IC_UNIQUE_HPP
/**
* Schema unique identity constraint
*/
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <xercesc/validators/schema/identity/IdentityConstraint.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class VALIDATORS_EXPORT IC_Unique: public IdentityConstraint
{
public:
// -----------------------------------------------------------------------
// Constructors/Destructor
// -----------------------------------------------------------------------
IC_Unique(const XMLCh* const identityConstraintName,
const XMLCh* const elemName,
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
~IC_Unique();
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
short getType() const;
/***
* Support for Serialization/De-serialization
***/
DECL_XSERIALIZABLE(IC_Unique)
IC_Unique(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
IC_Unique(const IC_Unique& other);
IC_Unique& operator= (const IC_Unique& other);
};
// ---------------------------------------------------------------------------
// IC_Unique: Getter methods
// ---------------------------------------------------------------------------
inline short IC_Unique::getType() const {
return IdentityConstraint::ICType_UNIQUE;
}
XERCES_CPP_NAMESPACE_END
#endif
/**
* End of file IC_Unique.hpp
*/

View File

@@ -0,0 +1,223 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* $Id: IdentityConstraint.hpp 932887 2010-04-11 13:04:59Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_IDENTITYCONSTRAINT_HPP)
#define XERCESC_INCLUDE_GUARD_IDENTITYCONSTRAINT_HPP
/**
* The class act as a base class for schema identity constraints.
*/
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <xercesc/util/RefVectorOf.hpp>
#include <xercesc/validators/schema/identity/IC_Field.hpp>
#include <xercesc/internal/XSerializable.hpp>
XERCES_CPP_NAMESPACE_BEGIN
// ---------------------------------------------------------------------------
// Forward Declarations
// ---------------------------------------------------------------------------
class IC_Selector;
class VALIDATORS_EXPORT IdentityConstraint : public XSerializable, public XMemory
{
public:
// -----------------------------------------------------------------------
// Constants
// -----------------------------------------------------------------------
enum ICType {
ICType_UNIQUE = 0,
ICType_KEY = 1,
ICType_KEYREF = 2,
ICType_UNKNOWN
};
// -----------------------------------------------------------------------
// Constructors/Destructor
// -----------------------------------------------------------------------
virtual ~IdentityConstraint();
// -----------------------------------------------------------------------
// operators
// -----------------------------------------------------------------------
bool operator== (const IdentityConstraint& other) const;
bool operator!= (const IdentityConstraint& other) const;
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
virtual short getType() const = 0;
XMLSize_t getFieldCount() const;
XMLCh* getIdentityConstraintName() const;
XMLCh* getElementName() const;
IC_Selector* getSelector() const;
int getNamespaceURI() const;
// -----------------------------------------------------------------------
// Setter methods
// -----------------------------------------------------------------------
void setSelector(IC_Selector* const selector);
void setNamespaceURI(int uri);
// -----------------------------------------------------------------------
// Access methods
// -----------------------------------------------------------------------
void addField(IC_Field* const field);
const IC_Field* getFieldAt(const XMLSize_t index) const;
IC_Field* getFieldAt(const XMLSize_t index);
/***
* Support for Serialization/De-serialization
***/
DECL_XSERIALIZABLE(IdentityConstraint)
static void storeIC(XSerializeEngine& serEng
, IdentityConstraint* const ic);
static IdentityConstraint* loadIC(XSerializeEngine& serEng);
protected:
// -----------------------------------------------------------------------
// Constructors/Destructor
// -----------------------------------------------------------------------
IdentityConstraint(const XMLCh* const identityConstraintName,
const XMLCh* const elementName,
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
IdentityConstraint(const IdentityConstraint& other);
IdentityConstraint& operator= (const IdentityConstraint& other);
// -----------------------------------------------------------------------
// CleanUp methods
// -----------------------------------------------------------------------
void cleanUp();
// -----------------------------------------------------------------------
// Data members
//
// fIdentityConstraintName
// The identity constraint name
//
// fElemName
// The element name
//
// fSelector
// The selector information
//
// fFields
// The field(s) information
// -----------------------------------------------------------------------
XMLCh* fIdentityConstraintName;
XMLCh* fElemName;
IC_Selector* fSelector;
RefVectorOf<IC_Field>* fFields;
MemoryManager* fMemoryManager;
int fNamespaceURI;
};
// ---------------------------------------------------------------------------
// IdentityConstraint: Getter methods
// ---------------------------------------------------------------------------
inline XMLSize_t IdentityConstraint::getFieldCount() const {
if (fFields) {
return fFields->size();
}
return 0;
}
inline XMLCh* IdentityConstraint::getIdentityConstraintName() const {
return fIdentityConstraintName;
}
inline XMLCh* IdentityConstraint::getElementName() const {
return fElemName;
}
inline IC_Selector* IdentityConstraint::getSelector() const {
return fSelector;
}
inline int IdentityConstraint::getNamespaceURI() const
{
return fNamespaceURI;
}
// ---------------------------------------------------------------------------
// IdentityConstraint: Setter methods
// ---------------------------------------------------------------------------
inline void IdentityConstraint::setNamespaceURI(int uri)
{
fNamespaceURI = uri;
}
// ---------------------------------------------------------------------------
// IdentityConstraint: Access methods
// ---------------------------------------------------------------------------
inline void IdentityConstraint::addField(IC_Field* const field) {
if (!fFields) {
fFields = new (fMemoryManager) RefVectorOf<IC_Field>(4, true, fMemoryManager);
}
fFields->addElement(field);
}
inline const IC_Field* IdentityConstraint::getFieldAt(const XMLSize_t index) const {
if (fFields) {
return (fFields->elementAt(index));
}
return 0;
}
inline IC_Field* IdentityConstraint::getFieldAt(const XMLSize_t index) {
if (fFields) {
return (fFields->elementAt(index));
}
return 0;
}
XERCES_CPP_NAMESPACE_END
#endif
/**
* End of file IdentityConstraint.hpp
*/

View File

@@ -0,0 +1,159 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* $Id: IdentityConstraintHandler.hpp 932887 2010-04-11 13:04:59Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_IDENTITYCONSTRAINT_HANDLER_HPP)
#define XERCESC_INCLUDE_GUARD_IDENTITYCONSTRAINT_HANDLER_HPP
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <xercesc/validators/schema/identity/ValueStoreCache.hpp>
#include <xercesc/validators/schema/identity/XPathMatcherStack.hpp>
XERCES_CPP_NAMESPACE_BEGIN
// ---------------------------------------------------------------------------
// Forward Declarations
// ---------------------------------------------------------------------------
class XMLScanner;
class FieldActivator;
class MemoryManager;
class XMLElementDecl;
class VALIDATORS_EXPORT IdentityConstraintHandler: public XMemory
{
public:
// -----------------------------------------------------------------------
// Constructors/Destructor
// -----------------------------------------------------------------------
virtual ~IdentityConstraintHandler();
IdentityConstraintHandler
(
XMLScanner* const scanner
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
inline XMLSize_t getMatcherCount() const;
// -----------------------------------------------------------------------
// Setter methods
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
// Access methods
// -----------------------------------------------------------------------
inline void endDocument();
void deactivateContext
(
SchemaElementDecl* const elem
, const XMLCh* const content
, ValidationContext* validationContext = 0
, DatatypeValidator* actualValidator = 0);
void activateIdentityConstraint
(
SchemaElementDecl* const elem
, int elemDepth
, const unsigned int uriId
, const XMLCh* const elemPrefix
, const RefVectorOf<XMLAttr>& attrList
, const XMLSize_t attrCount
, ValidationContext* validationContext = 0 );
void reset();
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
IdentityConstraintHandler(const IdentityConstraintHandler& other);
IdentityConstraintHandler& operator= (const IdentityConstraintHandler& other);
// -----------------------------------------------------------------------
// CleanUp methods
// -----------------------------------------------------------------------
void cleanUp();
// -----------------------------------------------------------------------
// Helper
// -----------------------------------------------------------------------
void activateSelectorFor(
IdentityConstraint* const ic
, const int initialDepth
) ;
// -----------------------------------------------------------------------
// Data members
//
// fMatcherStack
// Stack of active XPath matchers for identity constraints. All
// active XPath matchers are notified of startElement, characters
// and endElement callbacks in order to perform their matches.
//
// fValueStoreCache
// Cache of value stores for identity constraint fields.
//
// fFieldActivator
// Activates fields within a certain scope when a selector matches
// its xpath.
//
// -----------------------------------------------------------------------
XMLScanner* fScanner;
MemoryManager* fMemoryManager;
XPathMatcherStack* fMatcherStack;
ValueStoreCache* fValueStoreCache;
FieldActivator* fFieldActivator;
};
// ---------------------------------------------------------------------------
// IdentityConstraintHandler:
// ---------------------------------------------------------------------------
inline
void IdentityConstraintHandler::endDocument()
{
fValueStoreCache->endDocument();
}
inline
XMLSize_t IdentityConstraintHandler::getMatcherCount() const
{
return fMatcherStack->getMatcherCount();
}
XERCES_CPP_NAMESPACE_END
#endif
/**
* End of file IdentityConstraintHandler.hpp
*/

View File

@@ -0,0 +1,146 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* $Id: ValueStore.hpp 932887 2010-04-11 13:04:59Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_VALUESTORE_HPP)
#define XERCESC_INCLUDE_GUARD_VALUESTORE_HPP
/**
* This class stores values associated to an identity constraint.
* Each value stored corresponds to a field declared for the identity
* constraint.
*/
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <xercesc/validators/schema/identity/FieldValueMap.hpp>
#include <xercesc/util/RefHashTableOf.hpp>
XERCES_CPP_NAMESPACE_BEGIN
// ---------------------------------------------------------------------------
// Forward Declaration
// ---------------------------------------------------------------------------
class FieldActivator;
class IdentityConstraint;
class XMLScanner;
class ValueStoreCache;
struct ICValueHasher
{
ICValueHasher(MemoryManager* const manager) : fMemoryManager(manager) {}
XMLSize_t getHashVal(const void* key, XMLSize_t mod) const;
bool equals(const void *const key1, const void *const key2) const;
// -----------------------------------------------------------------------
// Helper methods
// -----------------------------------------------------------------------
/**
* Returns whether a field associated <DatatypeValidator, String> value
* is a duplicate of another associated value.
* It is a duplicate only if either of these conditions are true:
* - The Datatypes are the same or related by derivation and the values
* are in the same valuespace.
* - The datatypes are unrelated and the values are Stringwise identical.
*/
bool isDuplicateOf(DatatypeValidator* const dv1, const XMLCh* const val1,
DatatypeValidator* const dv2, const XMLCh* const val2) const;
MemoryManager* fMemoryManager;
};
class VALIDATORS_EXPORT ValueStore : public XMemory
{
public:
// -----------------------------------------------------------------------
// Constructors/Destructor
// -----------------------------------------------------------------------
ValueStore(IdentityConstraint* const ic,
XMLScanner* const scanner,
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
~ValueStore();
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
IdentityConstraint* getIdentityConstraint() const;
// -----------------------------------------------------------------------
// Helper methods
// -----------------------------------------------------------------------
void append(const ValueStore* const other);
void startValueScope();
void endValueScope();
void addValue(FieldActivator* const fieldActivator,
IC_Field* const field,
DatatypeValidator* const dv,
const XMLCh* const value);
bool contains(const FieldValueMap* const other);
void clear();
// -----------------------------------------------------------------------
// Document handling methods
// -----------------------------------------------------------------------
void endDocumentFragment(ValueStoreCache* const valueStoreCache);
// -----------------------------------------------------------------------
// Error reporting methods
// -----------------------------------------------------------------------
void duplicateValue();
void reportNilError(IdentityConstraint* const ic);
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
ValueStore(const ValueStore& other);
ValueStore& operator= (const ValueStore& other);
// -----------------------------------------------------------------------
// Data
// -----------------------------------------------------------------------
bool fDoReportError;
XMLSize_t fValuesCount;
IdentityConstraint* fIdentityConstraint;
FieldValueMap fValues;
RefHashTableOf<FieldValueMap, ICValueHasher>* fValueTuples;
XMLScanner* fScanner; // for error reporting - REVISIT
MemoryManager* fMemoryManager;
};
// ---------------------------------------------------------------------------
// ValueStore: Getter methods
// ---------------------------------------------------------------------------
inline IdentityConstraint*
ValueStore::getIdentityConstraint() const {
return fIdentityConstraint;
}
XERCES_CPP_NAMESPACE_END
#endif
/**
* End of file ValueStore.hpp
*/

View File

@@ -0,0 +1,172 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* $Id: ValueStoreCache.hpp 932887 2010-04-11 13:04:59Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_VALUESTORECACHE_HPP)
#define XERCESC_INCLUDE_GUARD_VALUESTORECACHE_HPP
/**
* This class is used to store the values for identity constraints.
*
* Sketch of algorithm:
* - When a constraint is first encountered, its values are stored in the
* (local) fIC2ValueStoreMap;
* - Once it is validated (i.e., when it goes out of scope), its values are
* merged into the fGlobalICMap;
* - As we encounter keyref's, we look at the global table to validate them.
* - Validation always occurs against the fGlobalIDConstraintMap (which
* comprises all the "eligible" id constraints). When an endelement is
* found, this Hashtable is merged with the one below in the stack. When a
* start tag is encountered, we create a new fGlobalICMap.
* i.e., the top of the fGlobalIDMapStack always contains the preceding
* siblings' eligible id constraints; the fGlobalICMap contains
* descendants+self. Keyrefs can only match descendants+self.
*/
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#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>
XERCES_CPP_NAMESPACE_BEGIN
// ---------------------------------------------------------------------------
// Forward Declaration
// ---------------------------------------------------------------------------
class ValueStore;
class SchemaElementDecl;
class XMLScanner;
class VALIDATORS_EXPORT ValueStoreCache : public XMemory
{
public:
// -----------------------------------------------------------------------
// Constructors/Destructor
// -----------------------------------------------------------------------
ValueStoreCache(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
~ValueStoreCache();
// -----------------------------------------------------------------------
// Setter Methods
// -----------------------------------------------------------------------
void setScanner(XMLScanner* const scanner);
// -----------------------------------------------------------------------
// Document Handling methods
// -----------------------------------------------------------------------
void startDocument();
void startElement();
void endElement();
void endDocument();
// -----------------------------------------------------------------------
// Initialization methods
// -----------------------------------------------------------------------
void initValueStoresFor(SchemaElementDecl* const elemDecl, const int initialDepth);
// -----------------------------------------------------------------------
// Access methods
// -----------------------------------------------------------------------
ValueStore* getValueStoreFor(const IC_Field* const field, const int initialDepth);
ValueStore* getValueStoreFor(const IdentityConstraint* const ic, const int initialDepth);
ValueStore* getGlobalValueStoreFor(const IdentityConstraint* const ic);
// -----------------------------------------------------------------------
// Helper methods
// -----------------------------------------------------------------------
/** This method takes the contents of the (local) ValueStore associated
* 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, const int initialDepth);
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
ValueStoreCache(const ValueStoreCache& other);
ValueStoreCache& operator= (const ValueStoreCache& other);
// -----------------------------------------------------------------------
// Helper methods
// -----------------------------------------------------------------------
void init();
void cleanUp();
// -----------------------------------------------------------------------
// Data
// -----------------------------------------------------------------------
RefVectorOf<ValueStore>* fValueStores;
RefHashTableOf<ValueStore, PtrHasher>* fGlobalICMap;
RefHash2KeysTableOf<ValueStore, PtrHasher>* fIC2ValueStoreMap;
RefStackOf<RefHashTableOf<ValueStore, PtrHasher> >* fGlobalMapStack;
XMLScanner* fScanner;
MemoryManager* fMemoryManager;
};
// ---------------------------------------------------------------------------
// ValueStoreCache: Access methods
// ---------------------------------------------------------------------------
inline void ValueStoreCache::setScanner(XMLScanner* const scanner) {
fScanner = scanner;
}
// ---------------------------------------------------------------------------
// ValueStoreCache: Access methods
// ---------------------------------------------------------------------------
inline ValueStore*
ValueStoreCache::getValueStoreFor(const IC_Field* const field, const int initialDepth) {
return fIC2ValueStoreMap->get(field->getIdentityConstraint(), initialDepth);
}
inline ValueStore*
ValueStoreCache::getValueStoreFor(const IdentityConstraint* const ic, const int initialDepth) {
return fIC2ValueStoreMap->get(ic, initialDepth);
}
inline ValueStore*
ValueStoreCache::getGlobalValueStoreFor(const IdentityConstraint* const ic) {
return fGlobalICMap->get(ic);
}
// ---------------------------------------------------------------------------
// ValueStoreCache: Document handling methods
// ---------------------------------------------------------------------------
inline void ValueStoreCache::endDocument() {
}
XERCES_CPP_NAMESPACE_END
#endif
/**
* End of file ValueStoreCache.hpp
*/

View File

@@ -0,0 +1,34 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* $Id: XPathException.hpp 527149 2007-04-10 14:56:39Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_XPATHEXCEPTION_HPP)
#define XERCESC_INCLUDE_GUARD_XPATHEXCEPTION_HPP
#include <xercesc/util/XercesDefs.hpp>
#include <xercesc/util/XMLException.hpp>
XERCES_CPP_NAMESPACE_BEGIN
MakeXMLException(XPathException, VALIDATORS_EXPORT)
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,182 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* $Id: XPathMatcher.hpp 803869 2009-08-13 12:56:21Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_XPATHMATCHER_HPP)
#define XERCESC_INCLUDE_GUARD_XPATHMATCHER_HPP
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <xercesc/util/ValueStackOf.hpp>
#include <xercesc/util/RefVectorOf.hpp>
#include <xercesc/framework/XMLBuffer.hpp>
XERCES_CPP_NAMESPACE_BEGIN
// ---------------------------------------------------------------------------
// Forward Declaration
// ---------------------------------------------------------------------------
class XMLElementDecl;
class XercesXPath;
class IdentityConstraint;
class DatatypeValidator;
class XMLStringPool;
class XercesLocationPath;
class XMLAttr;
class XercesNodeTest;
class QName;
class ValidationContext;
class VALIDATORS_EXPORT XPathMatcher : public XMemory
{
public:
// -----------------------------------------------------------------------
// Constructors/Destructor
// -----------------------------------------------------------------------
XPathMatcher(XercesXPath* const xpath,
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
XPathMatcher(XercesXPath* const xpath,
IdentityConstraint* const ic,
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
virtual ~XPathMatcher();
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
IdentityConstraint* getIdentityConstraint() const { return fIdentityConstraint; }
MemoryManager* getMemoryManager() const { return fMemoryManager; }
// -----------------------------------------------------------------------
// Match methods
// -----------------------------------------------------------------------
/**
* Returns true if XPath has been matched.
*/
unsigned char isMatched();
virtual int getInitialDepth() const;
// -----------------------------------------------------------------------
// XMLDocumentHandler methods
// -----------------------------------------------------------------------
virtual void startDocumentFragment();
virtual void startElement(const XMLElementDecl& elemDecl,
const unsigned int urlId,
const XMLCh* const elemPrefix,
const RefVectorOf<XMLAttr>& attrList,
const XMLSize_t attrCount,
ValidationContext* validationContext = 0);
virtual void endElement(const XMLElementDecl& elemDecl,
const XMLCh* const elemContent,
ValidationContext* validationContext = 0,
DatatypeValidator* actualValidator = 0);
enum
{
XP_MATCHED = 1 // matched any way
, XP_MATCHED_A = 3 // matched on the attribute axis
, XP_MATCHED_D = 5 // matched on the descendant-or-self axixs
, XP_MATCHED_DP = 13 // matched some previous (ancestor) node on the
// descendant-or-self-axis, but not this node
};
protected:
// -----------------------------------------------------------------------
// Match methods
// -----------------------------------------------------------------------
/**
* This method is called when the XPath handler matches the XPath
* expression. Subclasses can override this method to provide default
* handling upon a match.
*/
virtual void matched(const XMLCh* const content,
DatatypeValidator* const dv, const bool isNil);
bool matches(const XercesNodeTest* nodeTest, const QName* qName);
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
XPathMatcher(const XPathMatcher&);
XPathMatcher& operator=(const XPathMatcher&);
// -----------------------------------------------------------------------
// Helper methods
// -----------------------------------------------------------------------
void init(XercesXPath* const xpath);
void cleanUp();
// -----------------------------------------------------------------------
// Data members
//
// fMatched
// Indicates whether XPath has been matched or not
//
// fNoMatchDepth
// Indicates whether matching is successful for the given xpath
// expression.
//
// fCurrentStep
// Stores current step.
//
// fStepIndexes
// Integer stack of step indexes.
//
// fLocationPaths
// fLocationPathSize
// XPath location path, and its size.
//
// fIdentityConstraint
// The identity constraint we're the matcher for. Only used for
// selectors.
//
// -----------------------------------------------------------------------
XMLSize_t fLocationPathSize;
unsigned char* fMatched;
XMLSize_t* fNoMatchDepth;
XMLSize_t* fCurrentStep;
RefVectorOf<ValueStackOf<XMLSize_t> >* fStepIndexes;
RefVectorOf<XercesLocationPath>* fLocationPaths;
IdentityConstraint* fIdentityConstraint;
MemoryManager* fMemoryManager;
};
// ---------------------------------------------------------------------------
// XPathMatcher: Helper methods
// ---------------------------------------------------------------------------
inline void XPathMatcher::cleanUp() {
fMemoryManager->deallocate(fMatched);//delete [] fMatched;
fMemoryManager->deallocate(fNoMatchDepth);//delete [] fNoMatchDepth;
fMemoryManager->deallocate(fCurrentStep);//delete [] fCurrentStep;
delete fStepIndexes;
}
XERCES_CPP_NAMESPACE_END
#endif
/**
* End of file XPathMatcher.hpp
*/

View File

@@ -0,0 +1,139 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* $Id: XPathMatcherStack.hpp 932887 2010-04-11 13:04:59Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_XPATHMATCHERSTACK_HPP)
#define XERCESC_INCLUDE_GUARD_XPATHMATCHERSTACK_HPP
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <xercesc/validators/schema/identity/XPathMatcher.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class VALIDATORS_EXPORT XPathMatcherStack : public XMemory
{
public:
// -----------------------------------------------------------------------
// Constructors/Destructor
// -----------------------------------------------------------------------
XPathMatcherStack(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
~XPathMatcherStack();
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
XPathMatcher* getMatcherAt(const XMLSize_t index) const;
XMLSize_t getMatcherCount() const;
XMLSize_t size() const;
// -----------------------------------------------------------------------
// Access methods
// -----------------------------------------------------------------------
void addMatcher(XPathMatcher* const matcher);
// -----------------------------------------------------------------------
// Stack methods
// -----------------------------------------------------------------------
void pushContext();
void popContext();
// -----------------------------------------------------------------------
// Reset methods
// -----------------------------------------------------------------------
void clear();
private:
// -----------------------------------------------------------------------
// Private helper methods
// -----------------------------------------------------------------------
void cleanUp();
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
XPathMatcherStack(const XPathMatcherStack& other);
XPathMatcherStack& operator= (const XPathMatcherStack& other);
// -----------------------------------------------------------------------
// Data members
// -----------------------------------------------------------------------
unsigned int fMatchersCount;
ValueStackOf<int>* fContextStack;
RefVectorOf<XPathMatcher>* fMatchers;
};
// ---------------------------------------------------------------------------
// XPathMatcherStack: Getter methods
// ---------------------------------------------------------------------------
inline XMLSize_t XPathMatcherStack::size() const {
return fContextStack->size();
}
inline XMLSize_t XPathMatcherStack::getMatcherCount() const {
return fMatchersCount;
}
inline XPathMatcher*
XPathMatcherStack::getMatcherAt(const XMLSize_t index) const {
return fMatchers->elementAt(index);
}
// ---------------------------------------------------------------------------
// XPathMatcherStack: Stack methods
// ---------------------------------------------------------------------------
inline void XPathMatcherStack::pushContext() {
fContextStack->push(fMatchersCount);
}
inline void XPathMatcherStack::popContext() {
fMatchersCount = fContextStack->pop();
}
// ---------------------------------------------------------------------------
// XPathMatcherStack: Access methods
// ---------------------------------------------------------------------------
inline void XPathMatcherStack::addMatcher(XPathMatcher* const matcher) {
if (fMatchersCount == fMatchers->size()) {
fMatchers->addElement(matcher);
fMatchersCount++;
}
else {
fMatchers->setElementAt(matcher, fMatchersCount++);
}
}
XERCES_CPP_NAMESPACE_END
#endif
/**
* End of file XPathMatcherStack.hpp
*/

View File

@@ -0,0 +1,75 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* $Id: XPathSymbols.hpp 527149 2007-04-10 14:56:39Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_XPATHSYMBOLS_HPP)
#define XERCESC_INCLUDE_GUARD_XPATHSYMBOLS_HPP
#include <xercesc/util/XercesDefs.hpp>
XERCES_CPP_NAMESPACE_BEGIN
/*
* Collection of symbols used to parse a Schema Grammar
*/
class VALIDATORS_EXPORT XPathSymbols
{
public :
// -----------------------------------------------------------------------
// Constant data
// -----------------------------------------------------------------------
static const XMLCh fgSYMBOL_AND[];
static const XMLCh fgSYMBOL_OR[];
static const XMLCh fgSYMBOL_MOD[];
static const XMLCh fgSYMBOL_DIV[];
static const XMLCh fgSYMBOL_COMMENT[];
static const XMLCh fgSYMBOL_TEXT[];
static const XMLCh fgSYMBOL_PI[];
static const XMLCh fgSYMBOL_NODE[];
static const XMLCh fgSYMBOL_ANCESTOR[];
static const XMLCh fgSYMBOL_ANCESTOR_OR_SELF[];
static const XMLCh fgSYMBOL_ATTRIBUTE[];
static const XMLCh fgSYMBOL_CHILD[];
static const XMLCh fgSYMBOL_DESCENDANT[];
static const XMLCh fgSYMBOL_DESCENDANT_OR_SELF[];
static const XMLCh fgSYMBOL_FOLLOWING[];
static const XMLCh fgSYMBOL_FOLLOWING_SIBLING[];
static const XMLCh fgSYMBOL_NAMESPACE[];
static const XMLCh fgSYMBOL_PARENT[];
static const XMLCh fgSYMBOL_PRECEDING[];
static const XMLCh fgSYMBOL_PRECEDING_SIBLING[];
static const XMLCh fgSYMBOL_SELF[];
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
XPathSymbols();
};
XERCES_CPP_NAMESPACE_END
#endif
/**
* End of file XPathSymbols.hpp
*/

View File

@@ -0,0 +1,499 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* $Id: XercesXPath.hpp 932887 2010-04-11 13:04:59Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_XERCESXPATH_HPP)
#define XERCESC_INCLUDE_GUARD_XERCESXPATH_HPP
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <xercesc/util/QName.hpp>
#include <xercesc/util/RefVectorOf.hpp>
#include <xercesc/util/ValueVectorOf.hpp>
#include <xercesc/validators/schema/NamespaceScope.hpp>
#include <xercesc/internal/XSerializable.hpp>
XERCES_CPP_NAMESPACE_BEGIN
// ---------------------------------------------------------------------------
// Forward Declarations
// ---------------------------------------------------------------------------
class XMLStringPool;
class VALIDATORS_EXPORT XercesNodeTest : public XSerializable, public XMemory
{
public:
// -----------------------------------------------------------------------
// Constants
// -----------------------------------------------------------------------
enum NodeType {
NodeType_QNAME = 1,
NodeType_WILDCARD = 2,
NodeType_NODE = 3,
NodeType_NAMESPACE= 4,
NodeType_UNKNOWN
};
// -----------------------------------------------------------------------
// Constructors/Destructor
// -----------------------------------------------------------------------
XercesNodeTest(const short type,
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
XercesNodeTest(const QName* const qName);
XercesNodeTest(const XMLCh* const prefix, const unsigned int uriId,
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
XercesNodeTest(const XercesNodeTest& other);
~XercesNodeTest() { delete fName; }
// -----------------------------------------------------------------------
// Operators
// -----------------------------------------------------------------------
XercesNodeTest& operator= (const XercesNodeTest& other);
bool operator== (const XercesNodeTest& other) const;
bool operator!= (const XercesNodeTest& other) const;
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
short getType() const { return fType; }
QName* getName() const { return fName; }
/***
* Support for Serialization/De-serialization
***/
DECL_XSERIALIZABLE(XercesNodeTest)
XercesNodeTest(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
private:
// -----------------------------------------------------------------------
// Data members
// -----------------------------------------------------------------------
short fType;
QName* fName;
};
/**
* A location path step comprised of an axis and node test.
*/
class VALIDATORS_EXPORT XercesStep : public XSerializable, public XMemory
{
public:
// -----------------------------------------------------------------------
// Constants
// -----------------------------------------------------------------------
enum AxisType { // Axis type
AxisType_CHILD = 1,
AxisType_ATTRIBUTE = 2,
AxisType_SELF = 3,
AxisType_DESCENDANT = 4,
AxisType_UNKNOWN
};
// -----------------------------------------------------------------------
// Constructors/Destructor
// -----------------------------------------------------------------------
XercesStep(const unsigned short axisType, XercesNodeTest* const nodeTest);
XercesStep(const XercesStep& other);
~XercesStep() { delete fNodeTest; }
// -----------------------------------------------------------------------
// Operators
// -----------------------------------------------------------------------
XercesStep& operator= (const XercesStep& other);
bool operator== (const XercesStep& other) const;
bool operator!= (const XercesStep& other) const;
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
unsigned short getAxisType() const { return fAxisType; }
XercesNodeTest* getNodeTest() const { return fNodeTest; }
/***
* Support for Serialization/De-serialization
***/
DECL_XSERIALIZABLE(XercesStep)
XercesStep(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
private:
// -----------------------------------------------------------------------
// Data members
// -----------------------------------------------------------------------
unsigned short fAxisType;
XercesNodeTest* fNodeTest;
};
/**
* A location path representation for an XPath expression.
*/
class VALIDATORS_EXPORT XercesLocationPath : public XSerializable, public XMemory
{
public:
// -----------------------------------------------------------------------
// Constructors/Destructor
// -----------------------------------------------------------------------
XercesLocationPath(RefVectorOf<XercesStep>* const steps);
~XercesLocationPath() { delete fSteps; }
// -----------------------------------------------------------------------
// Operators
// -----------------------------------------------------------------------
bool operator== (const XercesLocationPath& other) const;
bool operator!= (const XercesLocationPath& other) const;
// -----------------------------------------------------------------------
// Access methods
// -----------------------------------------------------------------------
XMLSize_t getStepSize() const;
void addStep(XercesStep* const aStep);
XercesStep* getStep(const XMLSize_t index) const;
/***
* Support for Serialization/De-serialization
***/
DECL_XSERIALIZABLE(XercesLocationPath)
XercesLocationPath(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
XercesLocationPath(const XercesLocationPath& other);
XercesLocationPath& operator= (const XercesLocationPath& other);
// -----------------------------------------------------------------------
// Data members
// -----------------------------------------------------------------------
RefVectorOf<XercesStep>* fSteps;
};
class VALIDATORS_EXPORT XercesXPath : public XSerializable, public XMemory
{
public:
// -----------------------------------------------------------------------
// Constants
// -----------------------------------------------------------------------
/**
* [28] ExprToken ::= '(' | ')' | '[' | ']' | '.' | '..' | '@' | ',' | '::'
* | NameTest | NodeType | Operator | FunctionName
* | AxisName | Literal | Number | VariableReference
*/
enum {
EXPRTOKEN_OPEN_PAREN = 0,
EXPRTOKEN_CLOSE_PAREN = 1,
EXPRTOKEN_OPEN_BRACKET = 2,
EXPRTOKEN_CLOSE_BRACKET = 3,
EXPRTOKEN_PERIOD = 4,
EXPRTOKEN_DOUBLE_PERIOD = 5,
EXPRTOKEN_ATSIGN = 6,
EXPRTOKEN_COMMA = 7,
EXPRTOKEN_DOUBLE_COLON = 8,
EXPRTOKEN_NAMETEST_ANY = 9,
EXPRTOKEN_NAMETEST_NAMESPACE = 10,
EXPRTOKEN_NAMETEST_QNAME = 11,
EXPRTOKEN_NODETYPE_COMMENT = 12,
EXPRTOKEN_NODETYPE_TEXT = 13,
EXPRTOKEN_NODETYPE_PI = 14,
EXPRTOKEN_NODETYPE_NODE = 15,
EXPRTOKEN_OPERATOR_AND = 16,
EXPRTOKEN_OPERATOR_OR = 17,
EXPRTOKEN_OPERATOR_MOD = 18,
EXPRTOKEN_OPERATOR_DIV = 19,
EXPRTOKEN_OPERATOR_MULT = 20,
EXPRTOKEN_OPERATOR_SLASH = 21,
EXPRTOKEN_OPERATOR_DOUBLE_SLASH = 22,
EXPRTOKEN_OPERATOR_UNION = 23,
EXPRTOKEN_OPERATOR_PLUS = 24,
EXPRTOKEN_OPERATOR_MINUS = 25,
EXPRTOKEN_OPERATOR_EQUAL = 26,
EXPRTOKEN_OPERATOR_NOT_EQUAL = 27,
EXPRTOKEN_OPERATOR_LESS = 28,
EXPRTOKEN_OPERATOR_LESS_EQUAL = 29,
EXPRTOKEN_OPERATOR_GREATER = 30,
EXPRTOKEN_OPERATOR_GREATER_EQUAL = 31,
EXPRTOKEN_FUNCTION_NAME = 32,
EXPRTOKEN_AXISNAME_ANCESTOR = 33,
EXPRTOKEN_AXISNAME_ANCESTOR_OR_SELF = 34,
EXPRTOKEN_AXISNAME_ATTRIBUTE = 35,
EXPRTOKEN_AXISNAME_CHILD = 36,
EXPRTOKEN_AXISNAME_DESCENDANT = 37,
EXPRTOKEN_AXISNAME_DESCENDANT_OR_SELF = 38,
EXPRTOKEN_AXISNAME_FOLLOWING = 39,
EXPRTOKEN_AXISNAME_FOLLOWING_SIBLING = 40,
EXPRTOKEN_AXISNAME_NAMESPACE = 41,
EXPRTOKEN_AXISNAME_PARENT = 42,
EXPRTOKEN_AXISNAME_PRECEDING = 43,
EXPRTOKEN_AXISNAME_PRECEDING_SIBLING = 44,
EXPRTOKEN_AXISNAME_SELF = 45,
EXPRTOKEN_LITERAL = 46,
EXPRTOKEN_NUMBER = 47,
EXPRTOKEN_VARIABLE_REFERENCE = 48
};
// -----------------------------------------------------------------------
// Constructors/Destructor
// -----------------------------------------------------------------------
XercesXPath(const XMLCh* const xpathExpr,
XMLStringPool* const stringPool,
XercesNamespaceResolver* const scopeContext,
const unsigned int emptyNamespaceId,
const bool isSelector = false,
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
~XercesXPath();
// -----------------------------------------------------------------------
// Operators
// -----------------------------------------------------------------------
bool operator== (const XercesXPath& other) const;
bool operator!= (const XercesXPath& other) const;
// -----------------------------------------------------------------------
// Constructors/Destructor
// -----------------------------------------------------------------------
RefVectorOf<XercesLocationPath>* getLocationPaths() const;
/***
* Support for Serialization/De-serialization
***/
DECL_XSERIALIZABLE(XercesXPath)
XercesXPath(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
XMLCh* getExpression();
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
XercesXPath(const XercesXPath& other);
XercesXPath& operator= (const XercesXPath& other);
// -----------------------------------------------------------------------
// Helper methods
// -----------------------------------------------------------------------
void cleanUp();
void checkForSelectedAttributes();
void parseExpression(XMLStringPool* const stringPool,
XercesNamespaceResolver* const scopeContext);
// -----------------------------------------------------------------------
// Data members
// -----------------------------------------------------------------------
unsigned int fEmptyNamespaceId;
XMLCh* fExpression;
RefVectorOf<XercesLocationPath>* fLocationPaths;
MemoryManager* fMemoryManager;
};
class VALIDATORS_EXPORT XPathScanner : public XMemory
{
public:
// -----------------------------------------------------------------------
// Constants
// -----------------------------------------------------------------------
enum {
CHARTYPE_INVALID = 0, // invalid XML character
CHARTYPE_OTHER = 1, // not special - one of "#%&;?\^`{}~" or DEL
CHARTYPE_WHITESPACE = 2, // one of "\t\n\r " (0x09, 0x0A, 0x0D, 0x20)
CHARTYPE_EXCLAMATION = 3, // '!' (0x21)
CHARTYPE_QUOTE = 4, // '\"' or '\'' (0x22 and 0x27)
CHARTYPE_DOLLAR = 5, // '$' (0x24)
CHARTYPE_OPEN_PAREN = 6, // '(' (0x28)
CHARTYPE_CLOSE_PAREN = 7, // ')' (0x29)
CHARTYPE_STAR = 8, // '*' (0x2A)
CHARTYPE_PLUS = 9, // '+' (0x2B)
CHARTYPE_COMMA = 10, // ',' (0x2C)
CHARTYPE_MINUS = 11, // '-' (0x2D)
CHARTYPE_PERIOD = 12, // '.' (0x2E)
CHARTYPE_SLASH = 13, // '/' (0x2F)
CHARTYPE_DIGIT = 14, // '0'-'9' (0x30 to 0x39)
CHARTYPE_COLON = 15, // ':' (0x3A)
CHARTYPE_LESS = 16, // '<' (0x3C)
CHARTYPE_EQUAL = 17, // '=' (0x3D)
CHARTYPE_GREATER = 18, // '>' (0x3E)
CHARTYPE_ATSIGN = 19, // '@' (0x40)
CHARTYPE_LETTER = 20, // 'A'-'Z' or 'a'-'z' (0x41 to 0x5A and 0x61 to 0x7A)
CHARTYPE_OPEN_BRACKET = 21, // '[' (0x5B)
CHARTYPE_CLOSE_BRACKET = 22, // ']' (0x5D)
CHARTYPE_UNDERSCORE = 23, // '_' (0x5F)
CHARTYPE_UNION = 24, // '|' (0x7C)
CHARTYPE_NONASCII = 25 // Non-ASCII Unicode codepoint (>= 0x80)
};
// -----------------------------------------------------------------------
// Constructors/Destructor
// -----------------------------------------------------------------------
XPathScanner(XMLStringPool* const stringPool);
virtual ~XPathScanner() {}
// -----------------------------------------------------------------------
// Scan methods
// -----------------------------------------------------------------------
bool scanExpression(const XMLCh* const data, XMLSize_t currentOffset,
const XMLSize_t endOffset, ValueVectorOf<int>* const tokens);
protected:
// -----------------------------------------------------------------------
// Helper methods
// -----------------------------------------------------------------------
/**
* This method adds the specified token to the token list. By default,
* this method allows all tokens. However, subclasses can can override
* this method in order to disallow certain tokens from being used in the
* scanned XPath expression. This is a convenient way of allowing only
* a subset of XPath.
*/
virtual void addToken(ValueVectorOf<int>* const tokens, const int aToken);
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
XPathScanner(const XPathScanner& other);
XPathScanner& operator= (const XPathScanner& other);
// -----------------------------------------------------------------------
// Helper methods
// -----------------------------------------------------------------------
void init();
// -----------------------------------------------------------------------
// Scan methods
// -----------------------------------------------------------------------
XMLSize_t scanNCName(const XMLCh* const data, const XMLSize_t endOffset,
XMLSize_t currentOffset);
XMLSize_t scanNumber(const XMLCh* const data, const XMLSize_t endOffset,
XMLSize_t currentOffset, ValueVectorOf<int>* const tokens);
// -----------------------------------------------------------------------
// Data members
// -----------------------------------------------------------------------
int fAndSymbol;
int fOrSymbol;
int fModSymbol;
int fDivSymbol;
int fCommentSymbol;
int fTextSymbol;
int fPISymbol;
int fNodeSymbol;
int fAncestorSymbol;
int fAncestorOrSelfSymbol;
int fAttributeSymbol;
int fChildSymbol;
int fDescendantSymbol;
int fDescendantOrSelfSymbol;
int fFollowingSymbol;
int fFollowingSiblingSymbol;
int fNamespaceSymbol;
int fParentSymbol;
int fPrecedingSymbol;
int fPrecedingSiblingSymbol;
int fSelfSymbol;
XMLStringPool* fStringPool;
static const XMLByte fASCIICharMap[128];
};
class VALIDATORS_EXPORT XPathScannerForSchema: public XPathScanner
{
public:
// -----------------------------------------------------------------------
// Constructors/Destructor
// -----------------------------------------------------------------------
XPathScannerForSchema(XMLStringPool* const stringPool);
~XPathScannerForSchema() {}
protected:
// -----------------------------------------------------------------------
// Helper methods
// -----------------------------------------------------------------------
void addToken(ValueVectorOf<int>* const tokens, const int aToken);
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
XPathScannerForSchema(const XPathScannerForSchema& other);
XPathScannerForSchema& operator= (const XPathScannerForSchema& other);
};
// ---------------------------------------------------------------------------
// XercesLocationPath: Access methods
// ---------------------------------------------------------------------------
inline XMLSize_t XercesLocationPath::getStepSize() const {
if (fSteps)
return fSteps->size();
return 0;
}
inline void XercesLocationPath::addStep(XercesStep* const aStep) {
fSteps->addElement(aStep);
}
inline XercesStep* XercesLocationPath::getStep(const XMLSize_t index) const {
if (fSteps)
return fSteps->elementAt(index);
return 0;
}
// ---------------------------------------------------------------------------
// XercesScanner: Helper methods
// ---------------------------------------------------------------------------
inline void XPathScanner::addToken(ValueVectorOf<int>* const tokens,
const int aToken) {
tokens->addElement(aToken);
}
// ---------------------------------------------------------------------------
// XercesXPath: Getter methods
// ---------------------------------------------------------------------------
inline RefVectorOf<XercesLocationPath>* XercesXPath::getLocationPaths() const {
return fLocationPaths;
}
inline XMLCh* XercesXPath::getExpression() {
return fExpression;
}
XERCES_CPP_NAMESPACE_END
#endif
/**
* End of file XercesPath.hpp
*/