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,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: DTDAttDef.hpp 676911 2008-07-15 13:27:32Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_DTDATTDEF_HPP)
#define XERCESC_INCLUDE_GUARD_DTDATTDEF_HPP
#include <xercesc/framework/XMLAttDef.hpp>
XERCES_CPP_NAMESPACE_BEGIN
//
// This class is a derivative of the core XMLAttDef class. This class adds
// any DTD specific data members and provides DTD specific implementations
// of any underlying attribute def virtual methods.
//
// In the DTD we don't do namespaces, so the attribute names are just the
// QName literally from the DTD. This is what we return as the full name,
// which is what is used to key these in any name keyed collections.
//
class VALIDATORS_EXPORT DTDAttDef : public XMLAttDef
{
public :
// -----------------------------------------------------------------------
// Constructors and Destructors
// -----------------------------------------------------------------------
DTDAttDef(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
DTDAttDef
(
const XMLCh* const attName
, const XMLAttDef::AttTypes type = CData
, const XMLAttDef::DefAttTypes defType = Implied
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
DTDAttDef
(
const XMLCh* const attName
, const XMLCh* const attValue
, const XMLAttDef::AttTypes type
, const XMLAttDef::DefAttTypes defType
, const XMLCh* const enumValues = 0
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
~DTDAttDef();
// -----------------------------------------------------------------------
// Implementation of the XMLAttDef interface
// -----------------------------------------------------------------------
virtual const XMLCh* getFullName() const;
//does nothing currently
virtual void reset() {};
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
XMLSize_t getElemId() const;
// -----------------------------------------------------------------------
// Setter methods
// -----------------------------------------------------------------------
void setElemId(const XMLSize_t newId);
void setName(const XMLCh* const newName);
/***
* Support for Serialization/De-serialization
***/
DECL_XSERIALIZABLE(DTDAttDef)
private :
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
DTDAttDef(const DTDAttDef &);
DTDAttDef& operator = (const DTDAttDef&);
// -----------------------------------------------------------------------
// 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.
//
// fName
// This is the name of the attribute. Since we don't do namespaces
// in the DTD, its just the fully qualified name.
// -----------------------------------------------------------------------
XMLSize_t fElemId;
XMLCh* fName;
};
// ---------------------------------------------------------------------------
// DTDAttDef: Implementation of the XMLAttDef interface
// ---------------------------------------------------------------------------
inline const XMLCh* DTDAttDef::getFullName() const
{
return fName;
}
// ---------------------------------------------------------------------------
// DTDAttDef: Getter methods
// ---------------------------------------------------------------------------
inline XMLSize_t DTDAttDef::getElemId() const
{
return fElemId;
}
// ---------------------------------------------------------------------------
// DTDAttDef: Setter methods
// ---------------------------------------------------------------------------
inline void DTDAttDef::setElemId(const XMLSize_t newId)
{
fElemId = newId;
}
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,161 @@
/*
* 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: DTDAttDefList.hpp 932887 2010-04-11 13:04:59Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_DTDATTDEFLIST_HPP)
#define XERCESC_INCLUDE_GUARD_DTDATTDEFLIST_HPP
#include <xercesc/util/RefHashTableOf.hpp>
#include <xercesc/validators/DTD/DTDElementDecl.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.
//
// Since each validator can store attributes differently, this abstract
// interface allows each validator to provide an implementation of this
// data structure that works best for it.
//
// For us, we just wrap the RefHashTableOf collection that the DTDElementDecl
// class uses to store the attributes that belong to it.
//
// This clss 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 DTDAttDefList : public XMLAttDefList
{
public :
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
DTDAttDefList
(
RefHashTableOf<DTDAttDef>* const listToUse,
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
~DTDAttDefList();
// -----------------------------------------------------------------------
// 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;
/**
* 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(DTDAttDefList)
DTDAttDefList(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
private :
void addAttDef(DTDAttDef *toAdd);
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
DTDAttDefList(const DTDAttDefList &);
DTDAttDefList& operator = (const DTDAttDefList&);
// -----------------------------------------------------------------------
// Private data members
//
// fEnum
// This is an enerator for the list that we use to do the enumerator
// type methods of this class.
//
// fList
// The list of DTDAttDef 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
// -----------------------------------------------------------------------
RefHashTableOfEnumerator<DTDAttDef>* fEnum;
RefHashTableOf<DTDAttDef>* fList;
DTDAttDef** fArray;
XMLSize_t fSize;
XMLSize_t fCount;
friend class DTDElementDecl;
};
inline void DTDAttDefList::addAttDef(DTDAttDef *toAdd)
{
if(fCount == fSize)
{
// need to grow fArray
fSize <<= 1;
DTDAttDef** newArray = (DTDAttDef **)((getMemoryManager())->allocate( sizeof(DTDAttDef*) * fSize ));
memcpy(newArray, fArray, fCount * sizeof(DTDAttDef *));
(getMemoryManager())->deallocate(fArray);
fArray = newArray;
}
fArray[fCount++] = toAdd;
}
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,247 @@
/*
* 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: DTDElementDecl.hpp 932887 2010-04-11 13:04:59Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_DTDELEMENTDECL_HPP)
#define XERCESC_INCLUDE_GUARD_DTDELEMENTDECL_HPP
#include <xercesc/util/RefHashTableOf.hpp>
#include <xercesc/util/QName.hpp>
#include <xercesc/framework/XMLElementDecl.hpp>
#include <xercesc/framework/XMLContentModel.hpp>
#include <xercesc/validators/DTD/DTDAttDef.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class ContentSpecNode;
class DTDAttDefList;
//
// This class is a derivative of the basic element decl. This one implements
// the virtuals so that they work for a DTD. The big difference is that
// they don't live in any URL in the DTD. The names are just stored as full
// QNames, so they are not split out and element decls don't live within
// URL namespaces or anything like that.
//
class VALIDATORS_EXPORT DTDElementDecl : 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
, Children
, ModelTypes_Count
};
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
DTDElementDecl(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
DTDElementDecl
(
const XMLCh* const elemRawName
, const unsigned int uriId
, const ModelTypes modelType
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
DTDElementDecl
(
QName* const elementName
, const ModelTypes modelType = Any
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
~DTDElementDecl();
// -----------------------------------------------------------------------
// 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;
// -----------------------------------------------------------------------
// Support keyed collections
//
// This method allows objects of this type be placed into one of the
// standard keyed collections. This method will return the full name of
// the element, which will vary depending upon the type of the grammar.
// -----------------------------------------------------------------------
const XMLCh* getKey() const;
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
const DTDAttDef* getAttDef(const XMLCh* const attName) const;
DTDAttDef* getAttDef(const XMLCh* const attName);
ModelTypes getModelType() const;
// -----------------------------------------------------------------------
// Setter methods
// -----------------------------------------------------------------------
void addAttDef(DTDAttDef* const toAdd);
void setModelType(const DTDElementDecl::ModelTypes toSet);
/***
* Support for Serialization/De-serialization
***/
DECL_XSERIALIZABLE(DTDElementDecl)
virtual XMLElementDecl::objectType getObjectType() const;
private :
// -----------------------------------------------------------------------
// Private helper methods
// -----------------------------------------------------------------------
void faultInAttDefList() const;
XMLContentModel* createChildModel() ;
XMLContentModel* makeContentModel() ;
XMLCh* formatContentModel () const ;
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
DTDElementDecl(const DTDElementDecl &);
DTDElementDecl& operator = (const DTDElementDecl&);
// -----------------------------------------------------------------------
// Private data members
//
// fAttDefs
// The list of attributes that are defined for this element. Each
// element is its own little 'namespace' for attributes, so each
// element maintains its own list of owned attribute defs. It is
// faulted in when an attribute is actually added.
//
// fAttList
// We have to return a view of our att defs via the abstract view
// that the scanner understands. It may or may not ever be asked
// for so we fault it in as needed.
//
// fContentSpec
// This is the content spec for the node. It contains the original
// content spec that was read from the DTD, as a tree of nodes. This
// one is always set up, and is used to build the fContentModel
// version if we are validating.
//
// fModelType
// The content model type of this element. This tells us what kind
// of content model to create.
//
// fContentModel
// The content model object for this element. It is stored here via
// its abstract interface.
//
// fFormattedModel
// This is a faulted in member. When the outside world asks for
// our content model as a string, we format it and fault it into
// this field (to avoid doing the formatted over and over.)
// -----------------------------------------------------------------------
ModelTypes fModelType;
RefHashTableOf<DTDAttDef>* fAttDefs;
DTDAttDefList* fAttList;
ContentSpecNode* fContentSpec;
XMLContentModel* fContentModel;
XMLCh* fFormattedModel;
};
// ---------------------------------------------------------------------------
// DTDElementDecl: XMLElementDecl virtual interface implementation
// ---------------------------------------------------------------------------
inline ContentSpecNode* DTDElementDecl::getContentSpec()
{
return fContentSpec;
}
inline const ContentSpecNode* DTDElementDecl::getContentSpec() const
{
return fContentSpec;
}
inline XMLContentModel* DTDElementDecl::getContentModel()
{
if (!fContentModel)
fContentModel = makeContentModel();
return fContentModel;
}
inline void
DTDElementDecl::setContentModel(XMLContentModel* const newModelToAdopt)
{
delete fContentModel;
fContentModel = newModelToAdopt;
// reset formattedModel
if (fFormattedModel)
{
getMemoryManager()->deallocate(fFormattedModel);
fFormattedModel = 0;
}
}
// ---------------------------------------------------------------------------
// DTDElementDecl: Miscellaneous methods
// ---------------------------------------------------------------------------
inline const XMLCh* DTDElementDecl::getKey() const
{
return getFullName();
}
// ---------------------------------------------------------------------------
// DTDElementDecl: Getter methods
// ---------------------------------------------------------------------------
inline DTDElementDecl::ModelTypes DTDElementDecl::getModelType() const
{
return fModelType;
}
// ---------------------------------------------------------------------------
// DTDElementDecl: Setter methods
// ---------------------------------------------------------------------------
inline void
DTDElementDecl::setModelType(const DTDElementDecl::ModelTypes toSet)
{
fModelType = toSet;
}
XERCES_CPP_NAMESPACE_END
#endif

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: DTDEntityDecl.hpp 527149 2007-04-10 14:56:39Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_DTDENTITYDECL_HPP)
#define XERCESC_INCLUDE_GUARD_DTDENTITYDECL_HPP
#include <xercesc/framework/XMLEntityDecl.hpp>
XERCES_CPP_NAMESPACE_BEGIN
//
// This is a derivative of the abstract version of an entity decl in the
// framework directory. We just need to provide implementation of a couple
// of methods.
//
class VALIDATORS_EXPORT DTDEntityDecl : public XMLEntityDecl
{
public :
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
DTDEntityDecl(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
DTDEntityDecl
(
const XMLCh* const entName
, const bool fromIntSubset = false
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
DTDEntityDecl
(
const XMLCh* const entName
, const XMLCh* const value
, const bool fromIntSubset = false
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
DTDEntityDecl
(
const XMLCh* const entName
, const XMLCh value
, const bool fromIntSubset = false
, const bool specialChar = false
);
~DTDEntityDecl();
// -----------------------------------------------------------------------
// Implementation of the virtual XMLEntityDecl interface
// -----------------------------------------------------------------------
virtual bool getDeclaredInIntSubset() const;
virtual bool getIsParameter() const;
virtual bool getIsSpecialChar() const;
// -----------------------------------------------------------------------
// Setter methods
// -----------------------------------------------------------------------
void setDeclaredInIntSubset(const bool newValue);
void setIsParameter(const bool newValue);
void setIsSpecialChar(const bool newValue);
/***
* Support for Serialization/De-serialization
***/
DECL_XSERIALIZABLE(DTDEntityDecl)
private :
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
DTDEntityDecl(const DTDEntityDecl&);
DTDEntityDecl& operator=(DTDEntityDecl&);
// -----------------------------------------------------------------------
// Private data members
//
// fDeclaredInIntSubset
// Indicates whether the entity was declared in the internal subset
// or not. If not, it cannot be referred to from a standalone
// document.
//
// fIsParameter
// Indicates whether this is a parameter entity or a general entity.
//
// fIsSpecialChar
// This indicates that its one of the special character entities,
// e.g. lt or gt or amp. We need to know this because there are
// places where only a numeric char ref or special char ref is valid
// and all others are ignored or illegal.
// -----------------------------------------------------------------------
bool fDeclaredInIntSubset;
bool fIsParameter;
bool fIsSpecialChar;
};
// ---------------------------------------------------------------------------
// DTDEntityDecl: Constructors and Destructor
// ---------------------------------------------------------------------------
inline DTDEntityDecl::DTDEntityDecl(MemoryManager* const manager) :
XMLEntityDecl(manager)
, fDeclaredInIntSubset(false)
, fIsParameter(false)
, fIsSpecialChar(false)
{
}
inline DTDEntityDecl::DTDEntityDecl( const XMLCh* const entName
, const bool fromIntSubset
, MemoryManager* const manager) :
XMLEntityDecl(entName, manager)
, fDeclaredInIntSubset(fromIntSubset)
, fIsParameter(false)
, fIsSpecialChar(false)
{
}
inline DTDEntityDecl::DTDEntityDecl( const XMLCh* const entName
, const XMLCh* const value
, const bool fromIntSubset
, MemoryManager* const manager) :
XMLEntityDecl(entName, value, manager)
, fDeclaredInIntSubset(fromIntSubset)
, fIsParameter(false)
, fIsSpecialChar(false)
{
}
inline DTDEntityDecl::DTDEntityDecl(const XMLCh* const entName
, const XMLCh value
, const bool fromIntSubset
, const bool specialChar) :
XMLEntityDecl(entName, value, XMLPlatformUtils::fgMemoryManager)
, fDeclaredInIntSubset(fromIntSubset)
, fIsParameter(false)
, fIsSpecialChar(specialChar)
{
}
inline DTDEntityDecl::~DTDEntityDecl()
{
}
// ---------------------------------------------------------------------------
// DTDEntityDecl: Getter methods
// ---------------------------------------------------------------------------
inline bool DTDEntityDecl::getDeclaredInIntSubset() const
{
return fDeclaredInIntSubset;
}
inline bool DTDEntityDecl::getIsParameter() const
{
return fIsParameter;
}
inline bool DTDEntityDecl::getIsSpecialChar() const
{
return fIsSpecialChar;
}
// ---------------------------------------------------------------------------
// DTDEntityDecl: Setter methods
// ---------------------------------------------------------------------------
inline void DTDEntityDecl::setDeclaredInIntSubset(const bool newValue)
{
fDeclaredInIntSubset = newValue;
}
inline void DTDEntityDecl::setIsParameter(const bool newValue)
{
fIsParameter = newValue;
}
inline void DTDEntityDecl::setIsSpecialChar(const bool newValue)
{
fIsSpecialChar = newValue;
}
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,391 @@
/*
* 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: DTDGrammar.hpp 883368 2009-11-23 15:28:19Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_DTDGRAMMAR_HPP)
#define XERCESC_INCLUDE_GUARD_DTDGRAMMAR_HPP
#include <xercesc/util/RefHashTableOf.hpp>
#include <xercesc/util/NameIdPool.hpp>
#include <xercesc/util/StringPool.hpp>
#include <xercesc/validators/common/Grammar.hpp>
#include <xercesc/validators/DTD/DTDElementDecl.hpp>
#include <xercesc/validators/DTD/DTDEntityDecl.hpp>
#include <xercesc/framework/XMLDTDDescription.hpp>
XERCES_CPP_NAMESPACE_BEGIN
//
// This class stores the DTD information
// NOTE: DTDs 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.)
//
class VALIDATORS_EXPORT DTDGrammar : public Grammar
{
public:
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
DTDGrammar(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
virtual ~DTDGrammar();
// -----------------------------------------------------------------------
// 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
// -----------------------------------------------------------------------
const DTDEntityDecl* getEntityDecl(const XMLCh* const entName) const;
DTDEntityDecl* getEntityDecl(const XMLCh* const entName);
NameIdPool<DTDEntityDecl>* getEntityDeclPool();
const NameIdPool<DTDEntityDecl>* getEntityDeclPool() const;
NameIdPoolEnumerator<DTDElementDecl> getElemEnumerator() const;
NameIdPoolEnumerator<DTDEntityDecl> getEntityEnumerator() const;
NameIdPoolEnumerator<XMLNotationDecl> getNotationEnumerator() const;
// -----------------------------------------------------------------------
// Setter methods
// -----------------------------------------------------------------------
virtual void setGrammarDescription( XMLGrammarDescription*);
virtual XMLGrammarDescription* getGrammarDescription() const;
// -----------------------------------------------------------------------
// Content management methods
// -----------------------------------------------------------------------
XMLSize_t putEntityDecl(DTDEntityDecl* const entityDecl) const;
/***
* Support for Serialization/De-serialization
***/
DECL_XSERIALIZABLE(DTDGrammar)
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
DTDGrammar(const DTDGrammar &);
DTDGrammar& operator = (const DTDGrammar&);
// -----------------------------------------------------------------------
// Private data members
//
// fElemDeclPool
// This is the element decl pool. It contains all of the elements
// declared in the DTD (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 DTD), and they
// are given default characteristics.
//
// fEntityDeclPool
// This is a pool of EntityDecl objects, which contains all of the
// general entities that are declared in the DTD subsets, plus the
// default entities (such as &gt; &lt; ...) defined by the XML Standard.
//
// fNotationDeclPool
// This is a pool of NotationDecl objects, which contains all of the
// notations declared in the DTD subsets.
//
// fValidated
// Indicates if the content of the Grammar has been pre-validated
// or not. When using a cached grammar, no need for pre content
// validation.
//
// fGramDesc: adopted
//
// -----------------------------------------------------------------------
static NameIdPool<DTDEntityDecl>* fDefaultEntities;
MemoryManager* fMemoryManager;
NameIdPool<DTDElementDecl>* fElemDeclPool;
NameIdPool<DTDElementDecl>* fElemNonDeclPool;
NameIdPool<DTDEntityDecl>* fEntityDeclPool;
NameIdPool<XMLNotationDecl>* fNotationDeclPool;
XMLDTDDescription* fGramDesc;
bool fValidated;
friend class XMLInitializer;
};
// ---------------------------------------------------------------------------
// DTDGrammar: Getter methods
// ---------------------------------------------------------------------------
inline NameIdPoolEnumerator<DTDElementDecl>
DTDGrammar::getElemEnumerator() const
{
return NameIdPoolEnumerator<DTDElementDecl>(fElemDeclPool, fMemoryManager);
}
inline NameIdPoolEnumerator<DTDEntityDecl>
DTDGrammar::getEntityEnumerator() const
{
return NameIdPoolEnumerator<DTDEntityDecl>(fEntityDeclPool, fMemoryManager);
}
inline NameIdPoolEnumerator<XMLNotationDecl>
DTDGrammar::getNotationEnumerator() const
{
return NameIdPoolEnumerator<XMLNotationDecl>(fNotationDeclPool, fMemoryManager);
}
inline const DTDEntityDecl*
DTDGrammar::getEntityDecl(const XMLCh* const entName) const
{
DTDEntityDecl* decl = fDefaultEntities->getByKey(entName);
if (!decl)
return fEntityDeclPool->getByKey(entName);
return decl;
}
inline DTDEntityDecl* DTDGrammar::getEntityDecl(const XMLCh* const entName)
{
DTDEntityDecl* decl = fDefaultEntities->getByKey(entName);
if (!decl)
return fEntityDeclPool->getByKey(entName);
return decl;
}
inline NameIdPool<DTDEntityDecl>* DTDGrammar::getEntityDeclPool()
{
return fEntityDeclPool;
}
inline const NameIdPool<DTDEntityDecl>* DTDGrammar::getEntityDeclPool() const
{
return fEntityDeclPool;
}
// -----------------------------------------------------------------------
// Setter methods
// -----------------------------------------------------------------------
inline XMLSize_t DTDGrammar::putEntityDecl(DTDEntityDecl* const entityDecl) const
{
return fEntityDeclPool->put(entityDecl);
}
// ---------------------------------------------------------------------------
// DTDGrammar: Virtual methods
// ---------------------------------------------------------------------------
inline Grammar::GrammarType DTDGrammar::getGrammarType() const {
return Grammar::DTDGrammarType;
}
inline const XMLCh* DTDGrammar::getTargetNamespace() const {
return XMLUni::fgZeroLenString;
}
// Element Decl
inline XMLSize_t DTDGrammar::getElemId (const unsigned int
, const XMLCh* const
, const XMLCh* const qName
, unsigned int) 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 DTDElementDecl* decl = fElemDeclPool->getByKey(qName);
if (!decl)
return XMLElementDecl::fgInvalidElemId;
return decl->getId();
}
inline const XMLElementDecl* DTDGrammar::getElemDecl( const unsigned int
, const XMLCh* const
, const XMLCh* const qName
, unsigned int) const
{
const XMLElementDecl* elemDecl = fElemDeclPool->getByKey(qName);
if (!elemDecl && fElemNonDeclPool)
elemDecl = fElemNonDeclPool->getByKey(qName);
return elemDecl;
}
inline XMLElementDecl* DTDGrammar::getElemDecl (const unsigned int
, const XMLCh* const
, const XMLCh* const qName
, unsigned int)
{
XMLElementDecl* elemDecl = fElemDeclPool->getByKey(qName);
if (!elemDecl && fElemNonDeclPool)
elemDecl = fElemNonDeclPool->getByKey(qName);
return elemDecl;
}
inline const XMLElementDecl* DTDGrammar::getElemDecl(const unsigned int elemId) const
{
// Look up this element decl by id
return fElemDeclPool->getById(elemId);
}
inline XMLElementDecl* DTDGrammar::getElemDecl(const unsigned int elemId)
{
// Look up this element decl by id
return fElemDeclPool->getById(elemId);
}
inline XMLSize_t
DTDGrammar::putElemDecl(XMLElementDecl* const elemDecl,
const bool notDeclared)
{
if (notDeclared)
{
if(!fElemNonDeclPool)
fElemNonDeclPool = new (fMemoryManager) NameIdPool<DTDElementDecl>(29, 128, fMemoryManager);
return fElemNonDeclPool->put((DTDElementDecl*) elemDecl);
}
return fElemDeclPool->put((DTDElementDecl*) elemDecl);
}
// Notation Decl
inline const XMLNotationDecl* DTDGrammar::getNotationDecl(const XMLCh* const notName) const
{
return fNotationDeclPool->getByKey(notName);
}
inline XMLNotationDecl* DTDGrammar::getNotationDecl(const XMLCh* const notName)
{
return fNotationDeclPool->getByKey(notName);
}
inline XMLSize_t DTDGrammar::putNotationDecl(XMLNotationDecl* const notationDecl) const
{
return fNotationDeclPool->put(notationDecl);
}
inline bool DTDGrammar::getValidated() const
{
return fValidated;
}
inline void DTDGrammar::setValidated(const bool newState)
{
fValidated = newState;
}
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,277 @@
/*
* 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: DTDScanner.hpp 676911 2008-07-15 13:27:32Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_DTDSCANNER_HPP)
#define XERCESC_INCLUDE_GUARD_DTDSCANNER_HPP
#include <xercesc/validators/DTD/DTDGrammar.hpp>
#include <xercesc/validators/DTD/DTDEntityDecl.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class XMLScanner;
/*
* Default implementation of an XML DTD scanner.
*/
class DocTypeHandler;
class VALIDATORS_EXPORT DTDScanner : public XMemory
{
public:
// -----------------------------------------------------------------------
// Class specific types
//
// EntityExpRes
// Returned from scanEntityRef() to indicate how the expanded text
// was treated.
//
// IDTypes
// Type of the ID
// -----------------------------------------------------------------------
enum EntityExpRes
{
EntityExp_Failed
, EntityExp_Pushed
, EntityExp_Returned
};
enum IDTypes
{
IDType_Public
, IDType_External
, IDType_Either
};
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
DTDScanner
(
DTDGrammar* dtdGrammar
, DocTypeHandler* const docTypeHandler
, MemoryManager* const grammarPoolMemoryManager
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
virtual ~DTDScanner();
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
DocTypeHandler* getDocTypeHandler();
const DocTypeHandler* getDocTypeHandler() const;
// -----------------------------------------------------------------------
// Setter methods
//
// setScannerInfo() is called by the scanner to tell the DTDScanner
// about the stuff it needs to have access to.
// -----------------------------------------------------------------------
void setScannerInfo
(
XMLScanner* const owningScanner
, ReaderMgr* const readerMgr
, XMLBufferMgr* const bufMgr
);
void setDocTypeHandler
(
DocTypeHandler* const handlerToSet
);
void scanExtSubsetDecl(const bool inIncludeSect, const bool isDTD);
bool scanInternalSubset();
bool scanId
(
XMLBuffer& pubIdToFill
, XMLBuffer& sysIdToFill
, const IDTypes whatKind
);
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
DTDScanner(const DTDScanner &);
DTDScanner& operator = (const DTDScanner&);
// -----------------------------------------------------------------------
// Private DTD scanning methods. These are all in XMLValidator2.cpp
// -----------------------------------------------------------------------
bool checkForPERef
(
const bool inLiteral
, const bool inMarkup
);
bool expandPERef
(
const bool scanExternal
, const bool inLiteral
, const bool inMarkup
, const bool throwEndOfExt = false
);
bool getQuotedString(XMLBuffer& toFill);
XMLAttDef* scanAttDef(DTDElementDecl& elemDecl, XMLBuffer& bufToUse);
bool scanAttValue
(
const XMLCh* const attrName
, XMLBuffer& toFill
, const XMLAttDef::AttTypes type
);
void scanAttListDecl();
ContentSpecNode* scanChildren
(
const DTDElementDecl& elemDecl
, XMLBuffer& bufToUse
);
bool scanCharRef(XMLCh& toFill, XMLCh& second);
void scanComment();
bool scanContentSpec(DTDElementDecl& toFill);
void scanDefaultDecl(DTDAttDef& toFill);
void scanElementDecl();
void scanEntityDecl();
bool scanEntityDef();
bool scanEntityLiteral(XMLBuffer& toFill);
bool scanEntityDef(DTDEntityDecl& decl, const bool isPEDecl);
EntityExpRes scanEntityRef(XMLCh& firstCh, XMLCh& secondCh, bool& escaped);
bool scanEnumeration
(
const DTDAttDef& attDef
, XMLBuffer& toFill
, const bool notation
);
bool scanEq();
void scanIgnoredSection();
void scanMarkupDecl(const bool parseTextDecl);
bool scanMixed(DTDElementDecl& toFill);
void scanNotationDecl();
void scanPI();
bool scanPublicLiteral(XMLBuffer& toFill);
bool scanSystemLiteral(XMLBuffer& toFill);
void scanTextDecl();
bool isReadingExternalEntity();
// -----------------------------------------------------------------------
// Private data members
//
// fDocTypeHandler
// This holds the optional doc type handler that can be installed
// and used to call back for all markup events. It is DTD specific.
//
// fDumAttDef
// fDumElemDecl
// fDumEntityDecl
// These are dummy objects into which mark decls are parsed when
// they are just overrides of previously declared markup decls. In
// such situations, the first one wins but we need to have somewhere
// to parse them into. So these are lazily created and used as needed
// when such markup decls are seen.
//
// fInternalSubset
// This is used to track whether we are in the internal subset or not,
// in which case we are in the external subset.
//
// fNextAttrId
// Since att defs are per-element, we don't have a validator wide
// attribute def pool. So we use a simpler data structure in each
// element decl to store its att defs, and we use this simple counter
// to apply a unique id to each new attribute.
//
// fDTDGrammar
// The DTD information we scanned like element decl, attribute decl
// are stored in this Grammar.
//
// fBufMgr
// This is the buffer manager of the scanner. This is provided as a
// convenience so that the DTDScanner doesn't have to create its own
// buffer manager during the parse process.
//
// fReaderMgr
// This is a pointer to the reader manager that is being used by the scanner.
//
// fScanner
// The pointer to the scanner to which this DTDScanner belongs
//
// fPEntityDeclPool
// This is a pool of EntityDecl objects, which contains all of the
// parameter entities that are declared in the DTD subsets.
//
// fEmptyNamespaceId
// The uri for all DTD decls
//
// fDocTypeReaderId
// The original reader in the fReaderMgr - to be compared against the
// current reader to decide whether we are processing an external/internal
// declaration
// -----------------------------------------------------------------------
MemoryManager* fMemoryManager;
MemoryManager* fGrammarPoolMemoryManager;
DocTypeHandler* fDocTypeHandler;
DTDAttDef* fDumAttDef;
DTDElementDecl* fDumElemDecl;
DTDEntityDecl* fDumEntityDecl;
bool fInternalSubset;
unsigned int fNextAttrId;
DTDGrammar* fDTDGrammar;
XMLBufferMgr* fBufMgr;
ReaderMgr* fReaderMgr;
XMLScanner* fScanner;
NameIdPool<DTDEntityDecl>* fPEntityDeclPool;
unsigned int fEmptyNamespaceId;
XMLSize_t fDocTypeReaderId;
};
// ---------------------------------------------------------------------------
// DTDScanner: Getter methods
// ---------------------------------------------------------------------------
inline DocTypeHandler* DTDScanner::getDocTypeHandler()
{
return fDocTypeHandler;
}
inline const DocTypeHandler* DTDScanner::getDocTypeHandler() const
{
return fDocTypeHandler;
}
// ---------------------------------------------------------------------------
// DTDScanner: Setter methods
// ---------------------------------------------------------------------------
inline void DTDScanner::setDocTypeHandler(DocTypeHandler* const handlerToSet)
{
fDocTypeHandler = handlerToSet;
}
// -----------------------------------------------------------------------
// Helper methods
// -----------------------------------------------------------------------
inline bool DTDScanner::isReadingExternalEntity() {
return (fDocTypeReaderId != fReaderMgr->getCurrentReaderNum());
}
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,158 @@
/*
* 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: DTDValidator.hpp 676911 2008-07-15 13:27:32Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_DTDVALIDATOR_HPP)
#define XERCESC_INCLUDE_GUARD_DTDVALIDATOR_HPP
#include <xercesc/util/NameIdPool.hpp>
#include <xercesc/framework/XMLValidator.hpp>
#include <xercesc/validators/DTD/DTDGrammar.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class XMLMsgLoader;
//
// This is a derivative of the abstract validator interface. This class
// implements a validator that supports standard XML 1.0 DTD semantics.
// This class handles scanning the internal and external subsets of the
// DTD, and provides the standard validation services against the DTD info
// it found.
//
class VALIDATORS_EXPORT DTDValidator : public XMLValidator
{
public:
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
DTDValidator(XMLErrorReporter* const errReporter = 0);
virtual ~DTDValidator();
// -----------------------------------------------------------------------
// 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;
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
DTDValidator(const DTDValidator &);
DTDValidator& operator = (const DTDValidator&);
// -----------------------------------------------------------------------
// Helper
// -----------------------------------------------------------------------
void checkTokenList(const XMLAttDef& attDef
, bool toValidateNotation);
// -----------------------------------------------------------------------
// Private data members
//
// fDTDGrammar
// The DTD information stored.
//
// -----------------------------------------------------------------------
DTDGrammar* fDTDGrammar;
};
// ---------------------------------------------------------------------------
// Virtual interface
// ---------------------------------------------------------------------------
inline Grammar* DTDValidator::getGrammar() const {
return fDTDGrammar;
}
inline void DTDValidator::setGrammar(Grammar* aGrammar) {
fDTDGrammar = (DTDGrammar*) aGrammar;
}
inline void DTDValidator::validateElement (const XMLElementDecl*) {
// no special DTD Element validation
}
// ---------------------------------------------------------------------------
// DTDValidator: DTD handler interface
// ---------------------------------------------------------------------------
inline bool DTDValidator::handlesDTD() const
{
// We definitely want to handle DTD scanning
return true;
}
// ---------------------------------------------------------------------------
// DTDValidator: Schema handler interface
// ---------------------------------------------------------------------------
inline bool DTDValidator::handlesSchema() const
{
// No Schema scanning
return false;
}
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,145 @@
/*
* 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: DocTypeHandler.hpp 557282 2007-07-18 14:54:15Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_DOCTYPEHANDLER_HPP)
#define XERCESC_INCLUDE_GUARD_DOCTYPEHANDLER_HPP
#include <xercesc/util/XercesDefs.hpp>
#include <xercesc/framework/XMLNotationDecl.hpp>
#include <xercesc/validators/DTD/DTDAttDef.hpp>
#include <xercesc/validators/DTD/DTDElementDecl.hpp>
#include <xercesc/validators/DTD/DTDEntityDecl.hpp>
XERCES_CPP_NAMESPACE_BEGIN
//
// This abstract class defines the document type handler API's which can be
// used to process the DTD events generated by the DTDScanner as it scans the
// internal and external subset.
class VALIDATORS_EXPORT DocTypeHandler
{
public:
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
DocTypeHandler()
{
}
virtual ~DocTypeHandler()
{
}
// -----------------------------------------------------------------------
// The document type handler virtual handler interface
// -----------------------------------------------------------------------
virtual void attDef
(
const DTDElementDecl& elemDecl
, const DTDAttDef& attDef
, const bool ignoring
) = 0;
virtual void doctypeComment
(
const XMLCh* const comment
) = 0;
virtual void doctypeDecl
(
const DTDElementDecl& elemDecl
, const XMLCh* const publicId
, const XMLCh* const systemId
, const bool hasIntSubset
, const bool hasExtSubset = false
) = 0;
virtual void doctypePI
(
const XMLCh* const target
, const XMLCh* const data
) = 0;
virtual void doctypeWhitespace
(
const XMLCh* const chars
, const XMLSize_t length
) = 0;
virtual void elementDecl
(
const DTDElementDecl& decl
, const bool isIgnored
) = 0;
virtual void endAttList
(
const DTDElementDecl& elemDecl
) = 0;
virtual void endIntSubset() = 0;
virtual void endExtSubset() = 0;
virtual void entityDecl
(
const DTDEntityDecl& entityDecl
, const bool isPEDecl
, const bool isIgnored
) = 0;
virtual void resetDocType() = 0;
virtual void notationDecl
(
const XMLNotationDecl& notDecl
, const bool isIgnored
) = 0;
virtual void startAttList
(
const DTDElementDecl& elemDecl
) = 0;
virtual void startIntSubset() = 0;
virtual void startExtSubset() = 0;
virtual void TextDecl
(
const XMLCh* const versionStr
, const XMLCh* const encodingStr
) = 0;
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
DocTypeHandler(const DocTypeHandler&);
DocTypeHandler& operator=(const DocTypeHandler&);
};
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,108 @@
/*
* 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: XMLDTDDescriptionImpl.hpp 527149 2007-04-10 14:56:39Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_XMLDTDDESCRIPTIONIMPL_HPP)
#define XERCESC_INCLUDE_GUARD_XMLDTDDESCRIPTIONIMPL_HPP
#include <xercesc/framework/XMLDTDDescription.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class XMLPARSER_EXPORT XMLDTDDescriptionImpl : public XMLDTDDescription
{
public :
// -----------------------------------------------------------------------
/** @name constructor and destructor */
// -----------------------------------------------------------------------
//@{
XMLDTDDescriptionImpl(
const XMLCh* const systemId
, MemoryManager* const memMgr
);
~XMLDTDDescriptionImpl();
//@}
// -----------------------------------------------------------------------
/** @name Implementation of GrammarDescription Interface */
// -----------------------------------------------------------------------
//@{
/**
* getGrammarKey
*
*/
virtual const XMLCh* getGrammarKey() const ;
//@}
// -----------------------------------------------------------------------
/** @name Implementation of DTDDescription Interface */
// -----------------------------------------------------------------------
//@{
/**
* Getter
*
*/
virtual const XMLCh* getRootName() const;
virtual const XMLCh* getSystemId() const;
/**
* Setter
*
*/
virtual void setRootName(const XMLCh* const);
virtual void setSystemId(const XMLCh* const);
//@}
/***
* Support for Serialization/De-serialization
***/
DECL_XSERIALIZABLE(XMLDTDDescriptionImpl)
XMLDTDDescriptionImpl(MemoryManager* const memMgr = XMLPlatformUtils::fgMemoryManager);
private :
// -----------------------------------------------------------------------
/** name Unimplemented copy constructor and operator= */
// -----------------------------------------------------------------------
//@{
XMLDTDDescriptionImpl(const XMLDTDDescriptionImpl& );
XMLDTDDescriptionImpl& operator=(const XMLDTDDescriptionImpl& );
//@}
// -----------------------------------------------------------------------
//
// fSystemId:
// SYSTEM ID of the grammar
//
// fRootName:
// root name of the grammar
//
// -----------------------------------------------------------------------
const XMLCh* fSystemId;
const XMLCh* fRootName;
};
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,177 @@
/*
* 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: AllContentModel.hpp 901107 2010-01-20 08:45:02Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_ALLCONTENTMODEL_HPP)
#define XERCESC_INCLUDE_GUARD_ALLCONTENTMODEL_HPP
#include <xercesc/framework/XMLContentModel.hpp>
#include <xercesc/util/ValueVectorOf.hpp>
#include <xercesc/validators/common/ContentLeafNameTypeVector.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class ContentSpecNode;
//
// AllContentModel is a derivative of the abstract content model base
// class that handles the special case of <all> feature in schema. If a model
// is <all>, all non-optional children must appear
//
// So, all we have to do is to keep an array of the possible children and
// validate by just looking up each child being validated by looking it up
// in the list, and make sure all non-optional children appear.
//
class AllContentModel : public XMLContentModel
{
public :
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
AllContentModel
(
ContentSpecNode* const parentContentSpec
, const bool isMixed
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
~AllContentModel();
// -----------------------------------------------------------------------
// Implementation of the ContentModel virtual interface
// -----------------------------------------------------------------------
virtual bool validateContent
(
QName** const children
, XMLSize_t childCount
, unsigned int emptyNamespaceId
, XMLSize_t* indexFailingChild
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
) const;
virtual bool validateContentSpecial
(
QName** const children
, XMLSize_t childCount
, unsigned int emptyNamespaceId
, GrammarResolver* const pGrammarResolver
, XMLStringPool* const pStringPool
, XMLSize_t* indexFailingChild
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
) const;
virtual ContentLeafNameTypeVector* getContentLeafNameTypeVector() const ;
virtual unsigned int getNextState(unsigned int currentState,
XMLSize_t elementIndex) const;
virtual bool handleRepetitions( const QName* const curElem,
unsigned int curState,
unsigned int currentLoop,
unsigned int& nextState,
unsigned int& nextLoop,
XMLSize_t elementIndex,
SubstitutionGroupComparator * comparator) const;
virtual void checkUniqueParticleAttribution
(
SchemaGrammar* const pGrammar
, GrammarResolver* const pGrammarResolver
, XMLStringPool* const pStringPool
, XMLValidator* const pValidator
, unsigned int* const pContentSpecOrgURI
, const XMLCh* pComplexTypeName = 0
) ;
private :
// -----------------------------------------------------------------------
// Private helper methods
// -----------------------------------------------------------------------
void buildChildList
(
ContentSpecNode* const curNode
, ValueVectorOf<QName*>& toFill
, ValueVectorOf<bool>& toType
);
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
AllContentModel();
AllContentModel(const AllContentModel&);
AllContentModel& operator=(const AllContentModel&);
// -----------------------------------------------------------------------
// Private data members
//
// fCount
// The count of possible children in the fChildren member.
//
// fChildren
// The list of possible children that we have to accept. This array
// is allocated as large as needed in the constructor.
//
// fChildOptional
// The corresponding list of optional state of each child in fChildren
// True if the child is optional (i.e. minOccurs = 0).
//
// fNumRequired
// The number of required children in <all> (i.e. minOccurs = 1)
//
// fIsMixed
// AllContentModel with mixed PCDATA.
// -----------------------------------------------------------------------
MemoryManager* fMemoryManager;
XMLSize_t fCount;
QName** fChildren;
bool* fChildOptional;
unsigned int fNumRequired;
bool fIsMixed;
bool fHasOptionalContent;
};
inline ContentLeafNameTypeVector* AllContentModel::getContentLeafNameTypeVector() const
{
return 0;
}
inline unsigned int
AllContentModel::getNextState(unsigned int,
XMLSize_t) const {
return XMLContentModel::gInvalidTrans;
}
inline bool
AllContentModel::handleRepetitions( const QName* const /*curElem*/,
unsigned int /*curState*/,
unsigned int /*currentLoop*/,
unsigned int& /*nextState*/,
unsigned int& /*nextLoop*/,
XMLSize_t /*elementIndex*/,
SubstitutionGroupComparator * /*comparator*/) const
{
return true;
}
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,99 @@
/*
* 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: CMAny.hpp 677396 2008-07-16 19:36:20Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_CMANY_HPP)
#define XERCESC_INCLUDE_GUARD_CMANY_HPP
#include <xercesc/validators/common/CMNode.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class CMStateSet;
class CMAny : public CMNode
{
public :
// -----------------------------------------------------------------------
// Constructors
// -----------------------------------------------------------------------
CMAny
(
ContentSpecNode::NodeTypes type
, unsigned int URI
, unsigned int position
, unsigned int maxStates
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
~CMAny();
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
unsigned int getURI() const;
unsigned int getPosition() const;
// -----------------------------------------------------------------------
// Setter methods
// -----------------------------------------------------------------------
void setPosition(const unsigned int newPosition);
// -----------------------------------------------------------------------
// Implementation of the public CMNode virtual interface
// -----------------------------------------------------------------------
virtual void orphanChild();
protected :
// -----------------------------------------------------------------------
// Implementation of the protected CMNode virtual interface
// -----------------------------------------------------------------------
void calcFirstPos(CMStateSet& toSet) const;
void calcLastPos(CMStateSet& toSet) const;
private :
// -----------------------------------------------------------------------
// Private data members
//
// fURI;
// URI of the any content model. This value is set if the type is
// of the following:
// XMLContentSpec.CONTENTSPECNODE_ANY,
// XMLContentSpec.CONTENTSPECNODE_ANY_OTHER.
//
// fPosition
// Part of the algorithm to convert a regex directly to a DFA
// numbers each leaf sequentially. If its -1, that means its an
// epsilon node. Zero and greater are non-epsilon positions.
// -----------------------------------------------------------------------
unsigned int fURI;
unsigned int fPosition;
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
CMAny(const CMAny&);
CMAny& operator=(const CMAny&);
};
XERCES_CPP_NAMESPACE_END
#endif

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: CMBinaryOp.hpp 677396 2008-07-16 19:36:20Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_CMBINARYOP_HPP)
#define XERCESC_INCLUDE_GUARD_CMBINARYOP_HPP
#include <xercesc/validators/common/CMNode.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class CMStateSet;
class CMBinaryOp : public CMNode
{
public :
// -----------------------------------------------------------------------
// Constructors
// -----------------------------------------------------------------------
CMBinaryOp
(
ContentSpecNode::NodeTypes type
, CMNode* const leftToAdopt
, CMNode* const rightToAdopt
, unsigned int maxStates
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
~CMBinaryOp();
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
const CMNode* getLeft() const;
CMNode* getLeft();
const CMNode* getRight() const;
CMNode* getRight();
// -----------------------------------------------------------------------
// Implementation of the public CMNode virtual interface
// -----------------------------------------------------------------------
virtual void orphanChild();
protected :
// -----------------------------------------------------------------------
// Implementation of the protected CMNode virtual interface
// -----------------------------------------------------------------------
void calcFirstPos(CMStateSet& toSet) const;
void calcLastPos(CMStateSet& toSet) const;
private :
// -----------------------------------------------------------------------
// Private data members
//
// fLeftChild
// fRightChild
// These are the references to the two nodes that are on either side
// of this binary operation. We own them both.
// -----------------------------------------------------------------------
CMNode* fLeftChild;
CMNode* fRightChild;
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
CMBinaryOp(const CMBinaryOp&);
CMBinaryOp& operator=(const CMBinaryOp&);
};
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,253 @@
/*
* 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: CMLeaf.hpp 677396 2008-07-16 19:36:20Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_CMLEAF_HPP)
#define XERCESC_INCLUDE_GUARD_CMLEAF_HPP
#include <xercesc/validators/common/CMNode.hpp>
XERCES_CPP_NAMESPACE_BEGIN
//
// This class represents a leaf in the content spec node tree of an
// element's content model. It just has an element qname and a position value,
// the latter of which is used during the building of a DFA.
//
class CMLeaf : public CMNode
{
public :
// -----------------------------------------------------------------------
// Constructors
// -----------------------------------------------------------------------
CMLeaf
(
QName* const element
, unsigned int position
, unsigned int maxStates
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
CMLeaf
(
QName* const element
, unsigned int position
, bool adopt
, unsigned int maxStates
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
~CMLeaf();
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
QName* getElement();
const QName* getElement() const;
unsigned int getPosition() const;
virtual bool isRepeatableLeaf() const;
// -----------------------------------------------------------------------
// Setter methods
// -----------------------------------------------------------------------
void setPosition(const unsigned int newPosition);
// -----------------------------------------------------------------------
// Implementation of public CMNode virtual interface
// -----------------------------------------------------------------------
virtual void orphanChild();
protected :
// -----------------------------------------------------------------------
// Implementation of protected CMNode virtual interface
// -----------------------------------------------------------------------
void calcFirstPos(CMStateSet& toSet) const;
void calcLastPos(CMStateSet& toSet) const;
private :
// -----------------------------------------------------------------------
// Private data members
//
// fElement
// This is the element that this leaf represents.
//
// fPosition
// Part of the algorithm to convert a regex directly to a DFA
// numbers each leaf sequentially. If its -1, that means its an
// epsilon node. All others are non-epsilon positions.
//
// fAdopt
// This node is responsible for the storage of the fElement QName.
// -----------------------------------------------------------------------
QName* fElement;
unsigned int fPosition;
bool fAdopt;
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
CMLeaf(const CMLeaf&);
CMLeaf& operator=(const CMLeaf&);
};
// -----------------------------------------------------------------------
// Constructors
// -----------------------------------------------------------------------
inline CMLeaf::CMLeaf( QName* const element
, unsigned int position
, unsigned int maxStates
, MemoryManager* const manager) :
CMNode(ContentSpecNode::Leaf, maxStates, manager)
, fElement(0)
, fPosition(position)
, fAdopt(false)
{
if (!element)
{
fElement = new (fMemoryManager) QName
(
XMLUni::fgZeroLenString
, XMLUni::fgZeroLenString
, XMLElementDecl::fgInvalidElemId
, fMemoryManager
);
// We have to be responsible for this QName - override default fAdopt
fAdopt = true;
}
else
{
fElement = element;
}
// Leaf nodes are never nullable unless its an epsilon node
fIsNullable=(fPosition == epsilonNode);
}
inline CMLeaf::CMLeaf( QName* const element
, unsigned int position
, bool adopt
, unsigned int maxStates
, MemoryManager* const manager) :
CMNode(ContentSpecNode::Leaf, maxStates, manager)
, fElement(0)
, fPosition(position)
, fAdopt(adopt)
{
if (!element)
{
fElement = new (fMemoryManager) QName
(
XMLUni::fgZeroLenString
, XMLUni::fgZeroLenString
, XMLElementDecl::fgInvalidElemId
, fMemoryManager
);
// We have to be responsible for this QName - override adopt parameter
fAdopt = true;
}
else
{
fElement = element;
}
// Leaf nodes are never nullable unless its an epsilon node
fIsNullable=(fPosition == epsilonNode);
}
inline CMLeaf::~CMLeaf()
{
if (fAdopt)
delete fElement;
}
// ---------------------------------------------------------------------------
// Getter methods
// ---------------------------------------------------------------------------
inline QName* CMLeaf::getElement()
{
return fElement;
}
inline const QName* CMLeaf::getElement() const
{
return fElement;
}
inline unsigned int CMLeaf::getPosition() const
{
return fPosition;
}
inline bool CMLeaf::isRepeatableLeaf() const
{
return false;
}
// ---------------------------------------------------------------------------
// Setter methods
// ---------------------------------------------------------------------------
inline void CMLeaf::setPosition(const unsigned int newPosition)
{
fPosition = newPosition;
}
// ---------------------------------------------------------------------------
// Implementation of public CMNode virtual interface
// ---------------------------------------------------------------------------
inline void CMLeaf::orphanChild()
{
}
// ---------------------------------------------------------------------------
// Implementation of protected CMNode virtual interface
// ---------------------------------------------------------------------------
inline void CMLeaf::calcFirstPos(CMStateSet& toSet) const
{
// If we are an epsilon node, then the first pos is an empty set
if (isNullable())
{
toSet.zeroBits();
return;
}
// Otherwise, its just the one bit of our position
toSet.setBit(fPosition);
}
inline void CMLeaf::calcLastPos(CMStateSet& toSet) const
{
// If we are an epsilon node, then the last pos is an empty set
if (isNullable())
{
toSet.zeroBits();
return;
}
// Otherwise, its just the one bit of our position
toSet.setBit(fPosition);
}
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,193 @@
/*
* 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: CMNode.hpp 677430 2008-07-16 21:05:31Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_CMNODE_HPP)
#define XERCESC_INCLUDE_GUARD_CMNODE_HPP
#include <limits.h>
#include <xercesc/validators/common/ContentSpecNode.hpp>
#include <xercesc/validators/common/CMStateSet.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class CMNode : public XMemory
{
public :
enum {
// Special value to indicate a nullable node
epsilonNode = UINT_MAX - 1
};
// -----------------------------------------------------------------------
// Constructors and Destructors
// -----------------------------------------------------------------------
CMNode
(
const ContentSpecNode::NodeTypes type
, unsigned int maxStates
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
virtual ~CMNode();
// -----------------------------------------------------------------------
// Virtual methods to be provided derived node classes
// -----------------------------------------------------------------------
virtual void orphanChild() = 0;
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
ContentSpecNode::NodeTypes getType() const;
const CMStateSet& getFirstPos();
const CMStateSet& getLastPos();
bool isNullable() const;
protected :
// -----------------------------------------------------------------------
// Protected, abstract methods
// -----------------------------------------------------------------------
virtual void calcFirstPos(CMStateSet& toUpdate) const = 0;
virtual void calcLastPos(CMStateSet& toUpdate) const = 0;
// -----------------------------------------------------------------------
// Protected data members
//
// fMemoryManager
// Pluggable memory manager for dynamic allocation/deallocation.
// -----------------------------------------------------------------------
MemoryManager* fMemoryManager;
private :
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
CMNode();
CMNode(const CMNode&);
CMNode& operator=(const CMNode&);
// -----------------------------------------------------------------------
// Private data members
//
// fType
// The type of node. This indicates whether its a leaf or an
// operation.
//
// fFirstPos
// The set of NFA states that represent the entry states of this
// node in the DFA.
//
// fLastPos
// The set of NFA states that represent the final states of this
// node in the DFA.
//
// fMaxStates
// The maximum number of states that the NFA has, which means the
// max number of NFA states that have to be traced in the state
// sets during the building of the DFA. Its unfortunate that it
// has to be stored redundantly, but we need to fault in the
// state set members and they have to be sized to this size.
//
// fIsNullable
// Whether the node can be empty
// -----------------------------------------------------------------------
ContentSpecNode::NodeTypes fType;
CMStateSet* fFirstPos;
CMStateSet* fLastPos;
unsigned int fMaxStates;
protected:
bool fIsNullable;
};
// ---------------------------------------------------------------------------
// CMNode: Constructors and Destructors
// ---------------------------------------------------------------------------
inline CMNode::CMNode(const ContentSpecNode::NodeTypes type
, unsigned int maxStates
, MemoryManager* const manager) :
fMemoryManager(manager)
, fType(type)
, fFirstPos(0)
, fLastPos(0)
, fMaxStates(maxStates)
, fIsNullable(false)
{
}
inline CMNode::~CMNode()
{
// Clean up any position sets that got created
delete fFirstPos;
delete fLastPos;
}
// ---------------------------------------------------------------------------
// CMNode: Getter methods
// ---------------------------------------------------------------------------
inline ContentSpecNode::NodeTypes CMNode::getType() const
{
return fType;
}
inline const CMStateSet& CMNode::getFirstPos()
{
//
// Fault in the state set if needed. Since we can't use mutable members
// cast off the const'ness.
//
if (!fFirstPos)
{
fFirstPos = new (fMemoryManager) CMStateSet(fMaxStates, fMemoryManager);
calcFirstPos(*fFirstPos);
}
return *fFirstPos;
}
inline const CMStateSet& CMNode::getLastPos()
{
//
// Fault in the state set if needed. Since we can't use mutable members
// cast off the const'ness.
//
if (!fLastPos)
{
fLastPos = new (fMemoryManager) CMStateSet(fMaxStates, fMemoryManager);
calcLastPos(*fLastPos);
}
return *fLastPos;
}
inline bool CMNode::isNullable() const
{
return fIsNullable;
}
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,136 @@
/*
* 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: CMRepeatingLeaf.hpp 677396 2008-07-16 19:36:20Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_CMREPEATINGLEAF_HPP)
#define XERCESC_INCLUDE_GUARD_CMREPEATINGLEAF_HPP
#include <xercesc/validators/common/CMLeaf.hpp>
XERCES_CPP_NAMESPACE_BEGIN
//
// A compound content model leaf node which carries occurence information.
//
class CMRepeatingLeaf : public CMLeaf
{
public :
// -----------------------------------------------------------------------
// Constructors
// -----------------------------------------------------------------------
CMRepeatingLeaf
(
QName* const element
, int minOccurs
, int maxOccurs
, unsigned int position
, unsigned int maxStates
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
CMRepeatingLeaf
(
QName* const element
, int minOccurs
, int maxOccurs
, unsigned int position
, bool adopt
, unsigned int maxStates
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
int getMinOccurs() const;
int getMaxOccurs() const;
virtual bool isRepeatableLeaf() const;
private :
// -----------------------------------------------------------------------
// Private data members
//
// fMinOccurs
// fMaxOccurs
// The cardinality of the repeating leaf
//
// -----------------------------------------------------------------------
int fMinOccurs;
int fMaxOccurs;
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
CMRepeatingLeaf(const CMRepeatingLeaf&);
CMRepeatingLeaf& operator=(const CMRepeatingLeaf&);
};
// -----------------------------------------------------------------------
// Constructors
// -----------------------------------------------------------------------
inline CMRepeatingLeaf::CMRepeatingLeaf( QName* const element
, int minOccurs
, int maxOccurs
, unsigned int position
, unsigned int maxStates
, MemoryManager* const manager) :
CMLeaf(element, position, maxStates, manager)
, fMinOccurs(minOccurs)
, fMaxOccurs(maxOccurs)
{
}
inline CMRepeatingLeaf::CMRepeatingLeaf( QName* const element
, int minOccurs
, int maxOccurs
, unsigned int position
, bool adopt
, unsigned int maxStates
, MemoryManager* const manager) :
CMLeaf(element, position, adopt, maxStates, manager)
, fMinOccurs(minOccurs)
, fMaxOccurs(maxOccurs)
{
}
// ---------------------------------------------------------------------------
// Getter methods
// ---------------------------------------------------------------------------
inline int CMRepeatingLeaf::getMinOccurs() const
{
return fMinOccurs;
}
inline int CMRepeatingLeaf::getMaxOccurs() const
{
return fMaxOccurs;
}
inline bool CMRepeatingLeaf::isRepeatableLeaf() const
{
return true;
}
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,627 @@
/*
* 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: CMStateSet.hpp 901107 2010-01-20 08:45:02Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_CMSTATESET_HPP)
#define XERCESC_INCLUDE_GUARD_CMSTATESET_HPP
// DESCRIPTION:
//
// This class is a specialized bitset class for the content model code of
// the validator. It assumes that its never called with two objects of
// different bit counts, and that bit sets smaller than a threshold are far
// and away the most common. So it can be a lot more optimized than a general
// purpose utility bitset class
//
#include <xercesc/util/ArrayIndexOutOfBoundsException.hpp>
#include <xercesc/util/RuntimeException.hpp>
#include <xercesc/util/PlatformUtils.hpp>
#include <xercesc/framework/MemoryManager.hpp>
#include <string.h>
#if XERCES_HAVE_EMMINTRIN_H
# include <emmintrin.h>
#endif
XERCES_CPP_NAMESPACE_BEGIN
class CMStateSetEnumerator;
// This value must be 4 in order to use the SSE2 instruction set
#define CMSTATE_CACHED_INT32_SIZE 4
// This value must be a multiple of 128 in order to use the SSE2 instruction set
#define CMSTATE_BITFIELD_CHUNK 1024
#define CMSTATE_BITFIELD_INT32_SIZE (1024 / 32)
struct CMDynamicBuffer
{
// fArraySize
// This indicates the number of elements of the fBitArray vector
//
// fBitArray
// A vector of arrays of XMLInt32; each array is allocated on demand
// if a bit needs to be set in that range
//
// fMemoryManager
// The memory manager used to allocate and deallocate memory
//
XMLSize_t fArraySize;
XMLInt32** fBitArray;
MemoryManager* fMemoryManager;
};
class CMStateSet : public XMemory
{
public :
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
CMStateSet( const XMLSize_t bitCount
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager) :
fBitCount(bitCount)
, fDynamicBuffer(0)
{
//
// See if we need to allocate the byte array or whether we can live
// within the cached bit high performance scheme.
//
if (fBitCount > (CMSTATE_CACHED_INT32_SIZE * 32))
{
fDynamicBuffer = (CMDynamicBuffer*)manager->allocate(sizeof(CMDynamicBuffer));
fDynamicBuffer->fMemoryManager = manager;
// allocate an array of vectors, each one containing CMSTATE_BITFIELD_CHUNK bits
fDynamicBuffer->fArraySize = fBitCount / CMSTATE_BITFIELD_CHUNK;
if (fBitCount % CMSTATE_BITFIELD_CHUNK)
fDynamicBuffer->fArraySize++;
fDynamicBuffer->fBitArray = (XMLInt32**) fDynamicBuffer->fMemoryManager->allocate(fDynamicBuffer->fArraySize*sizeof(XMLInt32*));
for(XMLSize_t index = 0; index < fDynamicBuffer->fArraySize; index++)
fDynamicBuffer->fBitArray[index]=NULL;
}
else
{
for (XMLSize_t index = 0; index < CMSTATE_CACHED_INT32_SIZE; index++)
fBits[index] = 0;
}
}
CMStateSet(const CMStateSet& toCopy) :
XMemory(toCopy)
, fBitCount(toCopy.fBitCount)
, fDynamicBuffer(0)
{
//
// See if we need to allocate the byte array or whether we can live
// within the cahced bit high performance scheme.
//
if (fBitCount > (CMSTATE_CACHED_INT32_SIZE * 32))
{
fDynamicBuffer = (CMDynamicBuffer*) toCopy.fDynamicBuffer->fMemoryManager->allocate(sizeof(CMDynamicBuffer));
fDynamicBuffer->fMemoryManager = toCopy.fDynamicBuffer->fMemoryManager;
fDynamicBuffer->fArraySize = fBitCount / CMSTATE_BITFIELD_CHUNK;
if (fBitCount % CMSTATE_BITFIELD_CHUNK)
fDynamicBuffer->fArraySize++;
fDynamicBuffer->fBitArray = (XMLInt32**) fDynamicBuffer->fMemoryManager->allocate(fDynamicBuffer->fArraySize*sizeof(XMLInt32*));
for(XMLSize_t index = 0; index < fDynamicBuffer->fArraySize; index++)
{
if(toCopy.fDynamicBuffer->fBitArray[index]!=NULL)
{
allocateChunk(index);
memcpy((void *) fDynamicBuffer->fBitArray[index],
(const void *) toCopy.fDynamicBuffer->fBitArray[index],
CMSTATE_BITFIELD_INT32_SIZE * sizeof(XMLInt32));
}
else
fDynamicBuffer->fBitArray[index]=NULL;
}
}
else
{
memcpy((void *) fBits,
(const void *) toCopy.fBits,
CMSTATE_CACHED_INT32_SIZE * sizeof(XMLInt32));
}
}
~CMStateSet()
{
if(fDynamicBuffer)
{
for(XMLSize_t index = 0; index < fDynamicBuffer->fArraySize; index++)
if(fDynamicBuffer->fBitArray[index]!=NULL)
deallocateChunk(index);
fDynamicBuffer->fMemoryManager->deallocate(fDynamicBuffer->fBitArray);
fDynamicBuffer->fMemoryManager->deallocate(fDynamicBuffer);
}
}
// -----------------------------------------------------------------------
// Set manipulation methods
// -----------------------------------------------------------------------
void operator|=(const CMStateSet& setToOr)
{
if(fDynamicBuffer==0)
{
#ifdef XERCES_HAVE_SSE2_INTRINSIC
if(XMLPlatformUtils::fgSSE2ok)
{
__m128i xmm1 = _mm_loadu_si128((__m128i*)fBits);
__m128i xmm2 = _mm_loadu_si128((__m128i*)setToOr.fBits);
__m128i xmm3 = _mm_or_si128(xmm1, xmm2); // OR 4 32-bit words
_mm_storeu_si128((__m128i*)fBits, xmm3);
}
else
#endif
{
for (XMLSize_t index = 0; index < CMSTATE_CACHED_INT32_SIZE; index++)
if(setToOr.fBits[index])
{
if(fBits[index])
fBits[index] |= setToOr.fBits[index];
else
fBits[index] = setToOr.fBits[index];
}
}
}
else
{
for (XMLSize_t index = 0; index < fDynamicBuffer->fArraySize; index++)
{
XMLInt32 *& other = setToOr.fDynamicBuffer->fBitArray[index];
if(other!=NULL)
{
// if we haven't allocated the subvector yet, allocate it and copy
if(fDynamicBuffer->fBitArray[index]==NULL)
{
allocateChunk(index);
memcpy((void *) fDynamicBuffer->fBitArray[index],
(const void *) other,
CMSTATE_BITFIELD_INT32_SIZE * sizeof(XMLInt32));
}
else
{
// otherwise, merge them
XMLInt32*& mine = fDynamicBuffer->fBitArray[index];
#ifdef XERCES_HAVE_SSE2_INTRINSIC
if(XMLPlatformUtils::fgSSE2ok)
{
for(XMLSize_t subIndex = 0; subIndex < CMSTATE_BITFIELD_INT32_SIZE; subIndex+=4)
{
__m128i xmm1 = _mm_load_si128((__m128i*)&other[subIndex]);
__m128i xmm2 = _mm_load_si128((__m128i*)&mine[subIndex]);
__m128i xmm3 = _mm_or_si128(xmm1, xmm2); // OR 4 32-bit words
_mm_store_si128((__m128i*)&mine[subIndex], xmm3);
}
}
else
#endif
{
for(XMLSize_t subIndex = 0; subIndex < CMSTATE_BITFIELD_INT32_SIZE; subIndex++)
if(setToOr.fDynamicBuffer->fBitArray[index][subIndex])
{
if(fDynamicBuffer->fBitArray[index][subIndex])
fDynamicBuffer->fBitArray[index][subIndex] |= setToOr.fDynamicBuffer->fBitArray[index][subIndex];
else
fDynamicBuffer->fBitArray[index][subIndex] = setToOr.fDynamicBuffer->fBitArray[index][subIndex];
}
}
}
}
}
}
}
bool operator==(const CMStateSet& setToCompare) const
{
if (fBitCount != setToCompare.fBitCount)
return false;
if(fDynamicBuffer==0)
{
for (XMLSize_t index = 0; index < CMSTATE_CACHED_INT32_SIZE; index++)
{
if (fBits[index] != setToCompare.fBits[index])
return false;
}
}
else
{
for (XMLSize_t index = 0; index < fDynamicBuffer->fArraySize; index++)
{
XMLInt32 *& other = setToCompare.fDynamicBuffer->fBitArray[index],
*& mine = fDynamicBuffer->fBitArray[index];
if(mine==NULL && other==NULL)
continue;
else if(mine==NULL || other==NULL) // the other should have been empty too
return false;
else
{
for(XMLSize_t subIndex = 0; subIndex < CMSTATE_BITFIELD_INT32_SIZE; subIndex++)
if(mine[subIndex]!=other[subIndex])
return false;
}
}
}
return true;
}
CMStateSet& operator=(const CMStateSet& srcSet)
{
if (this == &srcSet)
return *this;
// They have to be the same size
if (fBitCount != srcSet.fBitCount)
{
if(fDynamicBuffer)
ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Bitset_NotEqualSize, fDynamicBuffer->fMemoryManager);
else
ThrowXML(RuntimeException, XMLExcepts::Bitset_NotEqualSize);
}
if(fDynamicBuffer==0)
{
for (XMLSize_t index = 0; index < CMSTATE_CACHED_INT32_SIZE; index++)
fBits[index] = srcSet.fBits[index];
}
else
{
for (XMLSize_t index = 0; index < fDynamicBuffer->fArraySize; index++)
if(srcSet.fDynamicBuffer->fBitArray[index]==NULL)
{
// delete this subentry
if(fDynamicBuffer->fBitArray[index]!=NULL)
deallocateChunk(index);
}
else
{
// if we haven't allocated the subvector yet, allocate it and copy
if(fDynamicBuffer->fBitArray[index]==NULL)
allocateChunk(index);
memcpy((void *) fDynamicBuffer->fBitArray[index],
(const void *) srcSet.fDynamicBuffer->fBitArray[index],
CMSTATE_BITFIELD_INT32_SIZE * sizeof(XMLInt32));
}
}
return *this;
}
XMLSize_t getBitCountInRange(XMLSize_t start, XMLSize_t end) const
{
XMLSize_t count = 0;
end /= 32;
if(fDynamicBuffer==0)
{
if(end > CMSTATE_CACHED_INT32_SIZE)
end = CMSTATE_CACHED_INT32_SIZE;
for (XMLSize_t index = start / 32; index < end; index++)
{
if (fBits[index] != 0)
for(int i=0;i<32;i++)
{
const XMLInt32 mask = 1UL << i;
if(fBits[index] & mask)
count++;
}
}
}
else
{
if(end > fDynamicBuffer->fArraySize)
end = fDynamicBuffer->fArraySize;
for (XMLSize_t index = start / 32; index < end; index++)
{
if(fDynamicBuffer->fBitArray[index]==NULL)
continue;
for(XMLSize_t subIndex=0;subIndex < CMSTATE_BITFIELD_INT32_SIZE; subIndex++)
{
if (fDynamicBuffer->fBitArray[index][subIndex] != 0)
for(int i=0;i<32;i++)
{
const XMLInt32 mask = 1UL << i;
if(fDynamicBuffer->fBitArray[index][subIndex] & mask)
count++;
}
}
}
}
return count;
}
bool getBit(const XMLSize_t bitToGet) const
{
if (bitToGet >= fBitCount)
{
if(fDynamicBuffer)
ThrowXMLwithMemMgr(ArrayIndexOutOfBoundsException, XMLExcepts::Bitset_BadIndex, fDynamicBuffer->fMemoryManager);
else
ThrowXML(ArrayIndexOutOfBoundsException, XMLExcepts::Bitset_BadIndex);
}
// And access the right bit and byte
if(fDynamicBuffer==0)
{
const XMLInt32 mask = 1UL << (bitToGet % 32);
const XMLSize_t byteOfs = bitToGet / 32;
return (fBits[byteOfs]!=0 && (fBits[byteOfs] & mask) != 0);
}
else
{
const XMLSize_t vectorOfs = bitToGet / CMSTATE_BITFIELD_CHUNK;
if(fDynamicBuffer->fBitArray[vectorOfs]==NULL)
return false;
const XMLInt32 mask = 1UL << (bitToGet % 32);
const XMLSize_t byteOfs = (bitToGet % CMSTATE_BITFIELD_CHUNK) / 32;
return (fDynamicBuffer->fBitArray[vectorOfs][byteOfs]!=0 && (fDynamicBuffer->fBitArray[vectorOfs][byteOfs] & mask) != 0);
}
}
bool isEmpty() const
{
if(fDynamicBuffer==0)
{
for (XMLSize_t index = 0; index < CMSTATE_CACHED_INT32_SIZE; index++)
{
if (fBits[index] != 0)
return false;
}
}
else
{
for (XMLSize_t index = 0; index < fDynamicBuffer->fArraySize; index++)
{
if(fDynamicBuffer->fBitArray[index]==NULL)
continue;
for(XMLSize_t subIndex=0;subIndex < CMSTATE_BITFIELD_INT32_SIZE; subIndex++)
{
if (fDynamicBuffer->fBitArray[index][subIndex] != 0)
return false;
}
}
}
return true;
}
void setBit(const XMLSize_t bitToSet)
{
if (bitToSet >= fBitCount)
{
if(fDynamicBuffer)
ThrowXMLwithMemMgr(ArrayIndexOutOfBoundsException, XMLExcepts::Bitset_BadIndex, fDynamicBuffer->fMemoryManager);
else
ThrowXML(ArrayIndexOutOfBoundsException, XMLExcepts::Bitset_BadIndex);
}
const XMLInt32 mask = 1UL << (bitToSet % 32);
// And access the right bit and byte
if(fDynamicBuffer==0)
{
const XMLSize_t byteOfs = bitToSet / 32;
fBits[byteOfs] &= ~mask;
fBits[byteOfs] |= mask;
}
else
{
const XMLSize_t vectorOfs = bitToSet / CMSTATE_BITFIELD_CHUNK;
if(fDynamicBuffer->fBitArray[vectorOfs]==NULL)
{
allocateChunk(vectorOfs);
for(XMLSize_t index=0;index < CMSTATE_BITFIELD_INT32_SIZE; index++)
fDynamicBuffer->fBitArray[vectorOfs][index]=0;
}
const XMLSize_t byteOfs = (bitToSet % CMSTATE_BITFIELD_CHUNK) / 32;
fDynamicBuffer->fBitArray[vectorOfs][byteOfs] &= ~mask;
fDynamicBuffer->fBitArray[vectorOfs][byteOfs] |= mask;
}
}
void zeroBits()
{
if(fDynamicBuffer==0)
{
for (XMLSize_t index = 0; index < CMSTATE_CACHED_INT32_SIZE; index++)
fBits[index] = 0;
}
else
{
for (XMLSize_t index = 0; index < fDynamicBuffer->fArraySize; index++)
// delete this subentry
if(fDynamicBuffer->fBitArray[index]!=NULL)
deallocateChunk(index);
}
}
XMLSize_t hashCode() const
{
XMLSize_t hash = 0;
if(fDynamicBuffer==0)
{
for (XMLSize_t index = 0; index<CMSTATE_CACHED_INT32_SIZE; index++)
hash = fBits[index] + hash * 31;
}
else
{
for (XMLSize_t index = 0; index<fDynamicBuffer->fArraySize; index++)
{
if(fDynamicBuffer->fBitArray[index]==NULL)
// simulates the iteration on the missing bits
for(XMLSize_t subIndex=0;subIndex < CMSTATE_BITFIELD_INT32_SIZE; subIndex++)
hash *= 31;
else
for(XMLSize_t subIndex=0;subIndex < CMSTATE_BITFIELD_INT32_SIZE; subIndex++)
hash = fDynamicBuffer->fBitArray[index][subIndex] + hash * 31;
}
}
return hash;
}
private :
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
CMStateSet();
// -----------------------------------------------------------------------
// Helpers
// -----------------------------------------------------------------------
void allocateChunk(const XMLSize_t index)
{
#ifdef XERCES_HAVE_SSE2_INTRINSIC
if(XMLPlatformUtils::fgSSE2ok)
fDynamicBuffer->fBitArray[index]=(XMLInt32*)_mm_malloc(CMSTATE_BITFIELD_INT32_SIZE * sizeof(XMLInt32), 16);
else
#endif
fDynamicBuffer->fBitArray[index]=(XMLInt32*)fDynamicBuffer->fMemoryManager->allocate(CMSTATE_BITFIELD_INT32_SIZE * sizeof(XMLInt32));
}
void deallocateChunk(const XMLSize_t index)
{
#ifdef XERCES_HAVE_SSE2_INTRINSIC
if(XMLPlatformUtils::fgSSE2ok)
_mm_free(fDynamicBuffer->fBitArray[index]);
else
#endif
fDynamicBuffer->fMemoryManager->deallocate(fDynamicBuffer->fBitArray[index]);
fDynamicBuffer->fBitArray[index]=NULL;
}
// -----------------------------------------------------------------------
// Private data members
//
// fBitCount
// The count of bits that the outside world wants to support,
// so its the max bit index plus one.
//
// fBits
// When the bit count is less than a threshold (very common), these hold the bits.
// Otherwise, the fDynamicBuffer member holds htem.
//
// fDynamicBuffer
// If the bit count is greater than the threshold, then we allocate this structure to
// store the bits, the length, and the memory manager to allocate/deallocate
// the memory
//
// -----------------------------------------------------------------------
XMLSize_t fBitCount;
XMLInt32 fBits[CMSTATE_CACHED_INT32_SIZE];
CMDynamicBuffer* fDynamicBuffer;
friend class CMStateSetEnumerator;
};
class CMStateSetEnumerator : public XMemory
{
public:
CMStateSetEnumerator(const CMStateSet* toEnum, XMLSize_t start = 0) :
fToEnum(toEnum),
fIndexCount((XMLSize_t)-1),
fLastValue(0)
{
// if a starting bit is specified, place fIndexCount at the beginning of the previous 32 bit area
// so the findNext moves to the one where 'start' is located
if(start > 32)
fIndexCount = (start/32 - 1) * 32;
findNext();
// if we found data, and fIndexCount is still pointing to the area where 'start' is located, erase the bits before 'start'
if(hasMoreElements() && fIndexCount < start)
{
for(XMLSize_t i=0;i< (start - fIndexCount);i++)
{
XMLInt32 mask=1UL << i;
if(fLastValue & mask)
fLastValue &= ~mask;
}
// in case the 32 bit area contained only bits before 'start', advance
if(fLastValue==0)
findNext();
}
}
bool hasMoreElements()
{
return fLastValue!=0;
}
unsigned int nextElement()
{
for(int i=0;i<32;i++)
{
XMLInt32 mask=1UL << i;
if(fLastValue & mask)
{
fLastValue &= ~mask;
unsigned int retVal=(unsigned int)fIndexCount+i;
if(fLastValue==0)
findNext();
return retVal;
}
}
return 0;
}
private:
void findNext()
{
if(fToEnum->fDynamicBuffer==0)
{
XMLSize_t nOffset=((fIndexCount==(XMLSize_t)-1)?0:(fIndexCount/32)+1);
for(XMLSize_t index=nOffset;index<CMSTATE_CACHED_INT32_SIZE;index++)
{
if(fToEnum->fBits[index]!=0)
{
fIndexCount=index*32;
fLastValue=fToEnum->fBits[index];
return;
}
}
}
else
{
XMLSize_t nOffset=((fIndexCount==(XMLSize_t)-1)?0:(fIndexCount/CMSTATE_BITFIELD_CHUNK));
XMLSize_t nSubOffset=((fIndexCount==(XMLSize_t)-1)?0:((fIndexCount % CMSTATE_BITFIELD_CHUNK) /32)+1);
for (XMLSize_t index = nOffset; index<fToEnum->fDynamicBuffer->fArraySize; index++)
{
if(fToEnum->fDynamicBuffer->fBitArray[index]!=NULL)
{
for(XMLSize_t subIndex=nSubOffset;subIndex < CMSTATE_BITFIELD_INT32_SIZE; subIndex++)
if(fToEnum->fDynamicBuffer->fBitArray[index][subIndex]!=0)
{
fIndexCount=index*CMSTATE_BITFIELD_CHUNK + subIndex*32;
fLastValue=fToEnum->fDynamicBuffer->fBitArray[index][subIndex];
return;
}
}
nSubOffset = 0; // next chunks will be processed from the beginning
}
}
}
const CMStateSet* fToEnum;
XMLSize_t fIndexCount;
XMLInt32 fLastValue;
};
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,88 @@
/*
* 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: CMUnaryOp.hpp 677396 2008-07-16 19:36:20Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_CMUNARYOP_HPP)
#define XERCESC_INCLUDE_GUARD_CMUNARYOP_HPP
#include <xercesc/validators/common/CMNode.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class CMStateSet;
class CMUnaryOp : public CMNode
{
public :
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
CMUnaryOp
(
ContentSpecNode::NodeTypes type
, CMNode* const nodeToAdopt
, unsigned int maxStates
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
~CMUnaryOp();
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
const CMNode* getChild() const;
CMNode* getChild();
// -----------------------------------------------------------------------
// Implementation of the public CMNode virtual interface
// -----------------------------------------------------------------------
virtual void orphanChild();
protected :
// -----------------------------------------------------------------------
// Implementation of the protected CMNode virtual interface
// -----------------------------------------------------------------------
void calcFirstPos(CMStateSet& toSet) const;
void calcLastPos(CMStateSet& toSet) const;
private :
// -----------------------------------------------------------------------
// Private data members
//
// fChild
// This is the reference to the one child that we have for this
// unary operation. We own it.
// -----------------------------------------------------------------------
CMNode* fChild;
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
CMUnaryOp(const CMUnaryOp&);
CMUnaryOp& operator=(const CMUnaryOp&);
};
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,119 @@
/*
* 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: ContentLeafNameTypeVector.hpp 676911 2008-07-15 13:27:32Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_CONTENTLEAFNAMETYPEVECTOR_HPP)
#define XERCESC_INCLUDE_GUARD_CONTENTLEAFNAMETYPEVECTOR_HPP
#include <xercesc/validators/common/ContentSpecNode.hpp>
#include <xercesc/framework/MemoryManager.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class XMLPARSER_EXPORT ContentLeafNameTypeVector : public XMemory
{
public :
// -----------------------------------------------------------------------
// Class specific types
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
ContentLeafNameTypeVector
(
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
ContentLeafNameTypeVector
(
QName** const qName
, ContentSpecNode::NodeTypes* const types
, const XMLSize_t count
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
~ContentLeafNameTypeVector();
ContentLeafNameTypeVector(const ContentLeafNameTypeVector&);
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
QName* getLeafNameAt(const XMLSize_t pos) const;
ContentSpecNode::NodeTypes getLeafTypeAt(const XMLSize_t pos) const;
XMLSize_t getLeafCount() const;
// -----------------------------------------------------------------------
// Setter methods
// -----------------------------------------------------------------------
void setValues
(
QName** const qName
, ContentSpecNode::NodeTypes* const types
, const XMLSize_t count
);
// -----------------------------------------------------------------------
// Miscellaneous
// -----------------------------------------------------------------------
private :
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
ContentLeafNameTypeVector& operator=(const ContentLeafNameTypeVector&);
// -----------------------------------------------------------------------
// helper methods
// -----------------------------------------------------------------------
void cleanUp();
void init(const XMLSize_t size);
// -----------------------------------------------------------------------
// Private Data Members
//
// -----------------------------------------------------------------------
MemoryManager* fMemoryManager;
QName** fLeafNames;
ContentSpecNode::NodeTypes *fLeafTypes;
XMLSize_t fLeafCount;
};
inline void ContentLeafNameTypeVector::cleanUp()
{
fMemoryManager->deallocate(fLeafNames); //delete [] fLeafNames;
fMemoryManager->deallocate(fLeafTypes); //delete [] fLeafTypes;
}
inline void ContentLeafNameTypeVector::init(const XMLSize_t size)
{
fLeafNames = (QName**) fMemoryManager->allocate(size * sizeof(QName*));//new QName*[size];
fLeafTypes = (ContentSpecNode::NodeTypes *) fMemoryManager->allocate
(
size * sizeof(ContentSpecNode::NodeTypes)
); //new ContentSpecNode::NodeTypes [size];
fLeafCount = size;
}
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,467 @@
/*
* 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: ContentSpecNode.hpp 932887 2010-04-11 13:04:59Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_CONTENTSPECNODE_HPP)
#define XERCESC_INCLUDE_GUARD_CONTENTSPECNODE_HPP
#include <xercesc/framework/XMLElementDecl.hpp>
#include <xercesc/framework/MemoryManager.hpp>
#include <xercesc/internal/XSerializable.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class XMLBuffer;
class Grammar;
class XMLUTIL_EXPORT ContentSpecNode : public XSerializable, public XMemory
{
public :
// -----------------------------------------------------------------------
// Class specific types
// -----------------------------------------------------------------------
enum NodeTypes
{
Leaf = 0
, ZeroOrOne
, ZeroOrMore
, OneOrMore
, Choice
, Sequence
, Any
, Any_Other
, Any_NS = 8
, All = 9
, Loop = 10
, Any_NS_Choice = 20 // 16 + 4 (Choice)
, ModelGroupSequence = 21 // 16 + 5 (Sequence)
, Any_Lax = 22 // 16 + 6 (Any)
, Any_Other_Lax = 23 // 16 + 7 (Any_Other)
, Any_NS_Lax = 24 // 16 + 8 (Any_NS)
, ModelGroupChoice = 36 // 32 + 4 (Choice)
, Any_Skip = 38 // 32 + 6 (Any)
, Any_Other_Skip = 39 // 32 + 7 (Any_Other)
, Any_NS_Skip = 40 // 32 + 8 (Any_NS)
, UnknownType = -1
};
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
ContentSpecNode(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
ContentSpecNode
(
QName* const toAdopt
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
ContentSpecNode
(
XMLElementDecl* const elemDecl
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
ContentSpecNode
(
QName* const toAdopt
, const bool copyQName
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
ContentSpecNode
(
const NodeTypes type
, ContentSpecNode* const firstToAdopt
, ContentSpecNode* const secondToAdopt
, const bool adoptFirst = true
, const bool adoptSecond = true
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
ContentSpecNode(const ContentSpecNode&);
~ContentSpecNode();
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
QName* getElement();
const QName* getElement() const;
XMLElementDecl* getElementDecl();
const XMLElementDecl* getElementDecl() const;
ContentSpecNode* getFirst();
const ContentSpecNode* getFirst() const;
ContentSpecNode* getSecond();
const ContentSpecNode* getSecond() const;
NodeTypes getType() const;
ContentSpecNode* orphanFirst();
ContentSpecNode* orphanSecond();
int getMinOccurs() const;
int getMaxOccurs() const;
bool isFirstAdopted() const;
bool isSecondAdopted() const;
// -----------------------------------------------------------------------
// Setter methods
// -----------------------------------------------------------------------
void setElement(QName* const toAdopt);
void setFirst(ContentSpecNode* const toAdopt);
void setSecond(ContentSpecNode* const toAdopt);
void setType(const NodeTypes type);
void setMinOccurs(int min);
void setMaxOccurs(int max);
void setAdoptFirst(bool adoptFirst);
void setAdoptSecond(bool adoptSecond);
// -----------------------------------------------------------------------
// Miscellaneous
// -----------------------------------------------------------------------
void formatSpec (XMLBuffer& bufToFill) const;
bool hasAllContent();
int getMinTotalRange() const;
int getMaxTotalRange() const;
/***
* Support for Serialization/De-serialization
***/
DECL_XSERIALIZABLE(ContentSpecNode)
private :
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
ContentSpecNode& operator=(const ContentSpecNode&);
// -----------------------------------------------------------------------
// Private Data Members
//
// fElement
// If the type is Leaf/Any*, then this is the qName of the element. If the URI
// is fgPCDataElemId, then its a PCData node. Else, it is zero.
//
// fFirst
// fSecond
// The optional first and second nodes. The fType field indicates
// which of these are valid. The validity constraints are:
//
// Leaf = Neither valid
// ZeroOrOne, ZeroOrMore = First
// Choice, Sequence, All = First and Second
// Any* = Neither valid
//
// fType
// The type of node. This controls how many of the child node fields
// are used.
//
// fAdoptFirst
// Indicate if this ContentSpecNode adopts the fFirst, and is responsible
// for deleting it.
//
// fAdoptSecond
// Indicate if this ContentSpecNode adopts the fSecond, and is responsible
// for deleting it.
//
// fMinOccurs
// Indicate the minimum times that this node can occur
//
// fMaxOccurs
// Indicate the maximum times that this node can occur
// -1 (Unbounded), default (1)
// -----------------------------------------------------------------------
MemoryManager* fMemoryManager;
QName* fElement;
XMLElementDecl* fElementDecl;
ContentSpecNode* fFirst;
ContentSpecNode* fSecond;
NodeTypes fType;
bool fAdoptFirst;
bool fAdoptSecond;
int fMinOccurs;
int fMaxOccurs;
};
// ---------------------------------------------------------------------------
// ContentSpecNode: Constructors and Destructor
// ---------------------------------------------------------------------------
inline ContentSpecNode::ContentSpecNode(MemoryManager* const manager) :
fMemoryManager(manager)
, fElement(0)
, fElementDecl(0)
, fFirst(0)
, fSecond(0)
, fType(ContentSpecNode::Leaf)
, fAdoptFirst(true)
, fAdoptSecond(true)
, fMinOccurs(1)
, fMaxOccurs(1)
{
}
inline
ContentSpecNode::ContentSpecNode(QName* const element,
MemoryManager* const manager) :
fMemoryManager(manager)
, fElement(0)
, fElementDecl(0)
, fFirst(0)
, fSecond(0)
, fType(ContentSpecNode::Leaf)
, fAdoptFirst(true)
, fAdoptSecond(true)
, fMinOccurs(1)
, fMaxOccurs(1)
{
if (element)
fElement = new (fMemoryManager) QName(*element);
}
inline
ContentSpecNode::ContentSpecNode(XMLElementDecl* const elemDecl,
MemoryManager* const manager) :
fMemoryManager(manager)
, fElement(0)
, fElementDecl(elemDecl)
, fFirst(0)
, fSecond(0)
, fType(ContentSpecNode::Leaf)
, fAdoptFirst(true)
, fAdoptSecond(true)
, fMinOccurs(1)
, fMaxOccurs(1)
{
if (elemDecl)
fElement = new (manager) QName(*(elemDecl->getElementName()));
}
inline
ContentSpecNode::ContentSpecNode( QName* const element
, const bool copyQName
, MemoryManager* const manager) :
fMemoryManager(manager)
, fElement(0)
, fElementDecl(0)
, fFirst(0)
, fSecond(0)
, fType(ContentSpecNode::Leaf)
, fAdoptFirst(true)
, fAdoptSecond(true)
, fMinOccurs(1)
, fMaxOccurs(1)
{
if (copyQName)
{
if (element)
fElement = new (fMemoryManager) QName(*element);
}
else
{
fElement = element;
}
}
inline
ContentSpecNode::ContentSpecNode(const NodeTypes type
, ContentSpecNode* const firstAdopt
, ContentSpecNode* const secondAdopt
, const bool adoptFirst
, const bool adoptSecond
, MemoryManager* const manager) :
fMemoryManager(manager)
, fElement(0)
, fElementDecl(0)
, fFirst(firstAdopt)
, fSecond(secondAdopt)
, fType(type)
, fAdoptFirst(adoptFirst)
, fAdoptSecond(adoptSecond)
, fMinOccurs(1)
, fMaxOccurs(1)
{
}
inline ContentSpecNode::~ContentSpecNode()
{
// Delete our children, which cause recursive cleanup
if (fAdoptFirst) {
delete fFirst;
}
if (fAdoptSecond) {
delete fSecond;
}
delete fElement;
}
// ---------------------------------------------------------------------------
// ContentSpecNode: Getter methods
// ---------------------------------------------------------------------------
inline QName* ContentSpecNode::getElement()
{
return fElement;
}
inline const QName* ContentSpecNode::getElement() const
{
return fElement;
}
inline XMLElementDecl* ContentSpecNode::getElementDecl()
{
return fElementDecl;
}
inline const XMLElementDecl* ContentSpecNode::getElementDecl() const
{
return fElementDecl;
}
inline ContentSpecNode* ContentSpecNode::getFirst()
{
return fFirst;
}
inline const ContentSpecNode* ContentSpecNode::getFirst() const
{
return fFirst;
}
inline ContentSpecNode* ContentSpecNode::getSecond()
{
return fSecond;
}
inline const ContentSpecNode* ContentSpecNode::getSecond() const
{
return fSecond;
}
inline ContentSpecNode::NodeTypes ContentSpecNode::getType() const
{
return fType;
}
inline ContentSpecNode* ContentSpecNode::orphanFirst()
{
ContentSpecNode* retNode = fFirst;
fFirst = 0;
return retNode;
}
inline ContentSpecNode* ContentSpecNode::orphanSecond()
{
ContentSpecNode* retNode = fSecond;
fSecond = 0;
return retNode;
}
inline int ContentSpecNode::getMinOccurs() const
{
return fMinOccurs;
}
inline int ContentSpecNode::getMaxOccurs() const
{
return fMaxOccurs;
}
inline bool ContentSpecNode::isFirstAdopted() const
{
return fAdoptFirst;
}
inline bool ContentSpecNode::isSecondAdopted() const
{
return fAdoptSecond;
}
// ---------------------------------------------------------------------------
// ContentSpecType: Setter methods
// ---------------------------------------------------------------------------
inline void ContentSpecNode::setElement(QName* const element)
{
delete fElement;
fElement = 0;
if (element)
fElement = new (fMemoryManager) QName(*element);
}
inline void ContentSpecNode::setFirst(ContentSpecNode* const toAdopt)
{
if (fAdoptFirst)
delete fFirst;
fFirst = toAdopt;
}
inline void ContentSpecNode::setSecond(ContentSpecNode* const toAdopt)
{
if (fAdoptSecond)
delete fSecond;
fSecond = toAdopt;
}
inline void ContentSpecNode::setType(const NodeTypes type)
{
fType = type;
}
inline void ContentSpecNode::setMinOccurs(int min)
{
fMinOccurs = min;
}
inline void ContentSpecNode::setMaxOccurs(int max)
{
fMaxOccurs = max;
}
inline void ContentSpecNode::setAdoptFirst(bool newState)
{
fAdoptFirst = newState;
}
inline void ContentSpecNode::setAdoptSecond(bool newState)
{
fAdoptSecond = newState;
}
// ---------------------------------------------------------------------------
// ContentSpecNode: Miscellaneous
// ---------------------------------------------------------------------------
inline bool ContentSpecNode::hasAllContent() {
if (fType == ContentSpecNode::ZeroOrOne) {
return (fFirst->getType() == ContentSpecNode::All);
}
return (fType == ContentSpecNode::All);
}
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,274 @@
/*
* 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: DFAContentModel.hpp 677705 2008-07-17 20:15:32Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_DFACONTENTMODEL_HPP)
#define XERCESC_INCLUDE_GUARD_DFACONTENTMODEL_HPP
#include <xercesc/util/XercesDefs.hpp>
#include <xercesc/util/ArrayIndexOutOfBoundsException.hpp>
#include <xercesc/framework/XMLContentModel.hpp>
#include <xercesc/validators/common/ContentLeafNameTypeVector.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class ContentSpecNode;
class CMLeaf;
class CMRepeatingLeaf;
class CMNode;
class CMStateSet;
//
// DFAContentModel is the heavy weight derivative of ContentModel that does
// all of the non-trivial element content validation. This guy does the full
// bore regular expression to DFA conversion to create a DFA that it then
// uses in its validation algorithm.
//
// NOTE: Upstream work insures that this guy will never see a content model
// with PCDATA in it. Any model with PCDATA is 'mixed' and is handled
// via the MixedContentModel class, since mixed models are very
// constrained in form and easily handled via a special case. This
// also makes our life much easier here.
//
class DFAContentModel : public XMLContentModel
{
public:
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
DFAContentModel
(
const bool dtd
, ContentSpecNode* const elemContentSpec
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
DFAContentModel
(
const bool dtd
, ContentSpecNode* const elemContentSpec
, const bool isMixed
, MemoryManager* const manager
);
virtual ~DFAContentModel();
// -----------------------------------------------------------------------
// Implementation of the virtual content model interface
// -----------------------------------------------------------------------
virtual bool validateContent
(
QName** const children
, XMLSize_t childCount
, unsigned int emptyNamespaceId
, XMLSize_t* indexFailingChild
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
) const;
virtual bool validateContentSpecial
(
QName** const children
, XMLSize_t childCount
, unsigned int emptyNamespaceId
, GrammarResolver* const pGrammarResolver
, XMLStringPool* const pStringPool
, XMLSize_t* indexFailingChild
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
) const;
virtual void checkUniqueParticleAttribution
(
SchemaGrammar* const pGrammar
, GrammarResolver* const pGrammarResolver
, XMLStringPool* const pStringPool
, XMLValidator* const pValidator
, unsigned int* const pContentSpecOrgURI
, const XMLCh* pComplexTypeName = 0
) ;
virtual ContentLeafNameTypeVector* getContentLeafNameTypeVector() const ;
virtual unsigned int getNextState(unsigned int currentState,
XMLSize_t elementIndex) const;
virtual bool handleRepetitions( const QName* const curElem,
unsigned int curState,
unsigned int currentLoop,
unsigned int& nextState,
unsigned int& nextLoop,
XMLSize_t elementIndex,
SubstitutionGroupComparator * comparator) const;
private :
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
DFAContentModel();
DFAContentModel(const DFAContentModel&);
DFAContentModel& operator=(const DFAContentModel&);
// -----------------------------------------------------------------------
// Private helper methods
// -----------------------------------------------------------------------
void buildDFA(ContentSpecNode* const curNode);
CMNode* buildSyntaxTree(ContentSpecNode* const curNode, unsigned int& curIndex);
unsigned int* makeDefStateList() const;
unsigned int countLeafNodes(ContentSpecNode* const curNode);
class Occurence : public XMemory
{
public:
Occurence(int minOcc, int maxOcc, int eltIndex);
int minOccurs;
int maxOccurs;
int elemIndex;
};
// -----------------------------------------------------------------------
// Private data members
//
// fElemMap
// fElemMapSize
// This is the map of unique input symbol elements to indices into
// each state's per-input symbol transition table entry. This is part
// of the built DFA information that must be kept around to do the
// actual validation.
//
// fElemMapType
// This is a map of whether the element map contains information
// related to ANY models.
//
// fEmptyOk
// This is an optimization. While building the transition table we
// can see whether this content model would approve of an empty
// content (which could happen if everything was optional.) So we
// set this flag and short circuit that check, which would otherwise
// be ugly and time consuming if we tried to determine it at each
// validation call.
//
// fEOCPos
// The NFA position of the special EOC (end of content) node. This
// is saved away since its used during the DFA build.
//
// fFinalStateFlags
// This is an array of booleans, one per state (there are
// fTransTableSize states in the DFA) that indicates whether that
// state is a final state.
//
// fFollowList
// The list of follow positions for each NFA position (i.e. for each
// non-epsilon leaf node.) This is only used during the building of
// the DFA, and is let go afterwards.
//
// fHeadNode
// This is the head node of our intermediate representation. It is
// only non-null during the building of the DFA (just so that it
// does not have to be passed all around.) Once the DFA is built,
// this is no longer required so its deleted.
//
// fLeafCount
// The count of leaf nodes. This is an important number that set some
// limits on the sizes of data structures in the DFA process.
//
// fLeafList
// An array of non-epsilon leaf nodes, which is used during the DFA
// build operation, then dropped. These are just references to nodes
// pointed to by fHeadNode, so we don't have to clean them up, just
// the actually leaf list array itself needs cleanup.
//
// fLeafListType
// Array mapping ANY types to the leaf list.
//
// fTransTable
// fTransTableSize
// This is the transition table that is the main by product of all
// of the effort here. It is an array of arrays of ints. The first
// dimension is the number of states we end up with in the DFA. The
// second dimensions is the number of unique elements in the content
// model (fElemMapSize). Each entry in the second dimension indicates
// the new state given that input for the first dimension's start
// state.
//
// The fElemMap array handles mapping from element indexes to
// positions in the second dimension of the transition table.
//
// fTransTableSize is the number of valid entries in the transition
// table, and in the other related tables such as fFinalStateFlags.
//
// fCountingStates
// This is the table holding the minOccurs/maxOccurs for elements
// that can be repeated a finite number of times.
//
// fDTD
// Boolean to allow DTDs to validate even with namespace support.
//
// fIsMixed
// DFA ContentModel with mixed PCDATA.
// -----------------------------------------------------------------------
QName** fElemMap;
ContentSpecNode::NodeTypes* fElemMapType;
unsigned int fElemMapSize;
bool fEmptyOk;
unsigned int fEOCPos;
bool* fFinalStateFlags;
CMStateSet** fFollowList;
CMNode* fHeadNode;
unsigned int fLeafCount;
CMLeaf** fLeafList;
ContentSpecNode::NodeTypes* fLeafListType;
unsigned int** fTransTable;
unsigned int fTransTableSize;
Occurence** fCountingStates;
bool fDTD;
bool fIsMixed;
ContentLeafNameTypeVector * fLeafNameTypeVector;
MemoryManager* fMemoryManager;
};
inline unsigned int
DFAContentModel::getNextState(unsigned int currentState,
XMLSize_t elementIndex) const {
if (currentState == XMLContentModel::gInvalidTrans) {
return XMLContentModel::gInvalidTrans;
}
if (currentState >= fTransTableSize || elementIndex >= fElemMapSize) {
ThrowXMLwithMemMgr(ArrayIndexOutOfBoundsException, XMLExcepts::Array_BadIndex, fMemoryManager);
}
return fTransTable[currentState][elementIndex];
}
inline
DFAContentModel::Occurence::Occurence(int minOcc, int maxOcc, int eltIndex)
{
minOccurs = minOcc;
maxOccurs = maxOcc;
elemIndex = eltIndex;
}
XERCES_CPP_NAMESPACE_END
#endif

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: Grammar.hpp 676911 2008-07-15 13:27:32Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_GRAMMAR_HPP)
#define XERCESC_INCLUDE_GUARD_GRAMMAR_HPP
#include <limits.h>
#include <xercesc/framework/XMLElementDecl.hpp>
#include <xercesc/framework/XMLEntityDecl.hpp>
#include <xercesc/framework/XMLNotationDecl.hpp>
#include <xercesc/internal/XSerializable.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class XMLGrammarDescription;
//
// This abstract class specifies the interface for a Grammar
//
class VALIDATORS_EXPORT Grammar : public XSerializable, public XMemory
{
public:
// -----------------------------------------------------------------------
// Class Specific Types
//
// DTDGrammarType - Indicate this Grammar is built from a DTD.
// SchemaGrammarType - Indicate this Grammar is built from a Schema.
//
// TOP_LEVEL_SCOPE - outermost scope level (i.e. global) of a declaration.
// For DTD, all element decls and attribute decls always
// have TOP_LEVEL_SCOPE. For schema, it may vary if
// it is inside a complex type.
//
// UNKNOWN_SCOPE - unknown scope level. None of the decls should have this.
//
// -----------------------------------------------------------------------
enum GrammarType {
DTDGrammarType
, SchemaGrammarType
, UnKnown
};
enum {
// These are well-known values that must simply be larger
// than any reasonable scope
UNKNOWN_SCOPE = UINT_MAX - 0
, TOP_LEVEL_SCOPE = UINT_MAX - 1
};
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
virtual ~Grammar(){};
// -----------------------------------------------------------------------
// Virtual Getter methods
// -----------------------------------------------------------------------
virtual GrammarType getGrammarType() const =0;
virtual const XMLCh* getTargetNamespace() const =0;
virtual bool getValidated() const = 0;
// Element Decl
// 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
) = 0;
virtual XMLSize_t getElemId
(
const unsigned int uriId
, const XMLCh* const baseName
, const XMLCh* const qName
, unsigned int scope
) const = 0;
virtual const XMLElementDecl* getElemDecl
(
const unsigned int uriId
, const XMLCh* const baseName
, const XMLCh* const qName
, unsigned int scope
) const = 0;
virtual XMLElementDecl* getElemDecl
(
const unsigned int uriId
, const XMLCh* const baseName
, const XMLCh* const qName
, unsigned int scope
) = 0;
virtual const XMLElementDecl* getElemDecl
(
const unsigned int elemId
) const = 0;
virtual XMLElementDecl* getElemDecl
(
const unsigned int elemId
) = 0;
// Notation
virtual const XMLNotationDecl* getNotationDecl
(
const XMLCh* const notName
) const=0;
virtual XMLNotationDecl* getNotationDecl
(
const XMLCh* const notName
)=0;
// -----------------------------------------------------------------------
// Virtual Setter methods
// -----------------------------------------------------------------------
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
) = 0;
virtual XMLSize_t putElemDecl
(
XMLElementDecl* const elemDecl
, const bool notDeclared = false
) = 0;
virtual XMLSize_t putNotationDecl
(
XMLNotationDecl* const notationDecl
) const=0;
virtual void setValidated(const bool newState) = 0;
// -----------------------------------------------------------------------
// Virtual methods
// -----------------------------------------------------------------------
virtual void reset()=0;
virtual void setGrammarDescription( XMLGrammarDescription*) = 0;
virtual XMLGrammarDescription* getGrammarDescription() const = 0;
/***
* Support for Serialization/De-serialization
***/
DECL_XSERIALIZABLE(Grammar)
static void storeGrammar(XSerializeEngine& serEng
, Grammar* const grammar);
static Grammar* loadGrammar(XSerializeEngine& serEng);
protected :
// -----------------------------------------------------------------------
// Hidden constructors
// -----------------------------------------------------------------------
Grammar(){};
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
Grammar(const Grammar&);
Grammar& operator=(const Grammar&);
};
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,271 @@
/*
* 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: GrammarResolver.hpp 932887 2010-04-11 13:04:59Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_GRAMMARRESOLVER_HPP)
#define XERCESC_INCLUDE_GUARD_GRAMMARRESOLVER_HPP
#include <xercesc/framework/XMLGrammarPool.hpp>
#include <xercesc/util/RefHashTableOf.hpp>
#include <xercesc/util/StringPool.hpp>
#include <xercesc/validators/common/Grammar.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class DatatypeValidator;
class DatatypeValidatorFactory;
class XMLGrammarDescription;
/**
* This class embodies the representation of a Grammar pool Resolver.
* This class is called from the validator.
*
*/
class VALIDATORS_EXPORT GrammarResolver : public XMemory
{
public:
/** @name Constructor and Destructor */
//@{
/**
*
* Default Constructor
*/
GrammarResolver(
XMLGrammarPool* const gramPool
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
/**
* Destructor
*/
~GrammarResolver();
//@}
/** @name Getter methods */
//@{
/**
* Retrieve the DatatypeValidator
*
* @param uriStr the namespace URI
* @param typeName the type name
* @return the DatatypeValidator associated with namespace & type name
*/
DatatypeValidator* getDatatypeValidator(const XMLCh* const uriStr,
const XMLCh* const typeName);
/**
* Retrieve the DatatypeValidatorFactory used for built-in schema types
*
* @return the DatatypeValidator associated with namespace for XMLSchema
*/
DatatypeValidatorFactory* getBuiltinDatatypeValidatorFactory();
/**
* Retrieve the grammar that is associated with the specified namespace key
*
* @param gramDesc grammar description for the grammar
* @return Grammar abstraction associated with the grammar description
*/
Grammar* getGrammar( XMLGrammarDescription* const gramDesc ) ;
/**
* Retrieve the grammar that is associated with the specified namespace key
*
* @param namespaceKey Namespace key into Grammar pool
* @return Grammar abstraction associated with the NameSpace key.
*/
Grammar* getGrammar( const XMLCh* const namespaceKey ) ;
/**
* Get an enumeration of Grammar in the Grammar pool
*
* @return enumeration of Grammar in Grammar pool
*/
RefHashTableOfEnumerator<Grammar> getGrammarEnumerator() const;
/**
* Get an enumeration of the referenced Grammars
*
* @return enumeration of referenced Grammars
*/
RefHashTableOfEnumerator<Grammar> getReferencedGrammarEnumerator() const;
/**
* Get an enumeration of the cached Grammars in the Grammar pool
*
* @return enumeration of the cached Grammars in Grammar pool
*/
RefHashTableOfEnumerator<Grammar> getCachedGrammarEnumerator() const;
/**
* Get a string pool of schema grammar element/attribute names/prefixes
* (used by TraverseSchema)
*
* @return a string pool of schema grammar element/attribute names/prefixes
*/
XMLStringPool* getStringPool();
/**
* Is the specified Namespace key in Grammar pool?
*
* @param nameSpaceKey Namespace key
* @return True if Namespace key association is in the Grammar pool.
*/
bool containsNameSpace( const XMLCh* const nameSpaceKey );
inline XMLGrammarPool* getGrammarPool() const;
inline MemoryManager* getGrammarPoolMemoryManager() const;
//@}
/** @name Setter methods */
//@{
/**
* Set the 'Grammar caching' flag
*/
void cacheGrammarFromParse(const bool newState);
/**
* Set the 'Use cached grammar' flag
*/
void useCachedGrammarInParse(const bool newState);
//@}
/** @name GrammarResolver methods */
//@{
/**
* Add the Grammar with Namespace Key associated to the Grammar Pool.
* The Grammar will be owned by the Grammar Pool.
*
* @param grammarToAdopt Grammar abstraction used by validator.
*/
void putGrammar(Grammar* const grammarToAdopt );
/**
* Returns the Grammar with Namespace Key associated from the Grammar Pool
* The Key entry is removed from the table (grammar is not deleted if
* adopted - now owned by caller).
*
* @param nameSpaceKey Key to associate with Grammar abstraction
*/
Grammar* orphanGrammar(const XMLCh* const nameSpaceKey);
/**
* Cache the grammars in fGrammarBucket to fCachedGrammarRegistry.
* If a grammar with the same key is already cached, an exception is
* thrown and none of the grammars will be cached.
*/
void cacheGrammars();
/**
* Reset internal Namespace/Grammar registry.
*/
void reset();
void resetCachedGrammar();
/**
* Returns an XSModel, either from the GrammarPool or by creating one
*/
XSModel* getXSModel();
ValueVectorOf<SchemaGrammar*>* getGrammarsToAddToXSModel();
//@}
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
GrammarResolver(const GrammarResolver&);
GrammarResolver& operator=(const GrammarResolver&);
// -----------------------------------------------------------------------
// Private data members
//
// fStringPool The string pool used by TraverseSchema to store
// element/attribute names and prefixes.
// Always owned by Grammar pool implementation
//
// fGrammarBucket The parsed Grammar Pool, if no caching option.
//
// fGrammarFromPool Referenced Grammar Set, not owned
//
// fGrammarPool The Grammar Set either plugged or created.
//
// fDataTypeReg DatatypeValidatorFactory registry
//
// fMemoryManager Pluggable memory manager for dynamic memory
// allocation/deallocation
// -----------------------------------------------------------------------
bool fCacheGrammar;
bool fUseCachedGrammar;
bool fGrammarPoolFromExternalApplication;
XMLStringPool* fStringPool;
RefHashTableOf<Grammar>* fGrammarBucket;
RefHashTableOf<Grammar>* fGrammarFromPool;
DatatypeValidatorFactory* fDataTypeReg;
MemoryManager* fMemoryManager;
XMLGrammarPool* fGrammarPool;
XSModel* fXSModel;
XSModel* fGrammarPoolXSModel;
ValueVectorOf<SchemaGrammar*>* fGrammarsToAddToXSModel;
};
inline XMLStringPool* GrammarResolver::getStringPool() {
return fStringPool;
}
inline void GrammarResolver::useCachedGrammarInParse(const bool aValue)
{
fUseCachedGrammar = aValue;
}
inline XMLGrammarPool* GrammarResolver::getGrammarPool() const
{
return fGrammarPool;
}
inline MemoryManager* GrammarResolver::getGrammarPoolMemoryManager() const
{
return fGrammarPool->getMemoryManager();
}
inline ValueVectorOf<SchemaGrammar*>* GrammarResolver::getGrammarsToAddToXSModel()
{
return fGrammarsToAddToXSModel;
}
inline DatatypeValidatorFactory* GrammarResolver::getBuiltinDatatypeValidatorFactory()
{
return fDataTypeReg;
}
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,212 @@
/*
* 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: MixedContentModel.hpp 901107 2010-01-20 08:45:02Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_MIXEDCONTENTMODEL_HPP)
#define XERCESC_INCLUDE_GUARD_MIXEDCONTENTMODEL_HPP
#include <xercesc/util/ValueVectorOf.hpp>
#include <xercesc/framework/XMLContentModel.hpp>
#include <xercesc/validators/common/ContentLeafNameTypeVector.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class ContentSpecNode;
//
// MixedContentModel is a derivative of the abstract content model base
// class that handles the special case of mixed model elements. If an element
// is mixed model, it has PCDATA as its first possible content, followed
// by an alternation of the possible children. The children cannot have any
// numeration or order, so it must look like this:
//
// <!ELEMENT Foo ((#PCDATA|a|b|c|)*)>
//
// So, all we have to do is to keep an array of the possible children and
// validate by just looking up each child being validated by looking it up
// in the list.
//
class MixedContentModel : public XMLContentModel
{
public :
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
MixedContentModel
(
const bool dtd
, ContentSpecNode* const parentContentSpec
, const bool ordered = false
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
~MixedContentModel();
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
bool hasDups() const;
// -----------------------------------------------------------------------
// Implementation of the ContentModel virtual interface
// -----------------------------------------------------------------------
virtual bool validateContent
(
QName** const children
, XMLSize_t childCount
, unsigned int emptyNamespaceId
, XMLSize_t* indexFailingChild
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
) const;
virtual bool validateContentSpecial
(
QName** const children
, XMLSize_t childCount
, unsigned int emptyNamespaceId
, GrammarResolver* const pGrammarResolver
, XMLStringPool* const pStringPool
, XMLSize_t* indexFailingChild
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
) const;
virtual ContentLeafNameTypeVector* getContentLeafNameTypeVector() const ;
virtual unsigned int getNextState(unsigned int currentState,
XMLSize_t elementIndex) const;
virtual bool handleRepetitions( const QName* const curElem,
unsigned int curState,
unsigned int currentLoop,
unsigned int& nextState,
unsigned int& nextLoop,
XMLSize_t elementIndex,
SubstitutionGroupComparator * comparator) const;
virtual void checkUniqueParticleAttribution
(
SchemaGrammar* const pGrammar
, GrammarResolver* const pGrammarResolver
, XMLStringPool* const pStringPool
, XMLValidator* const pValidator
, unsigned int* const pContentSpecOrgURI
, const XMLCh* pComplexTypeName = 0
) ;
private :
// -----------------------------------------------------------------------
// Private helper methods
// -----------------------------------------------------------------------
void buildChildList
(
ContentSpecNode* const curNode
, ValueVectorOf<QName*>& toFill
, ValueVectorOf<ContentSpecNode::NodeTypes>& toType
);
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
MixedContentModel();
MixedContentModel(const MixedContentModel&);
MixedContentModel& operator=(const MixedContentModel&);
// -----------------------------------------------------------------------
// Private data members
//
// fCount
// The count of possible children in the fChildren member.
//
// fChildren
// The list of possible children that we have to accept. This array
// is allocated as large as needed in the constructor.
//
// fChildTypes
// The type of the children to support ANY.
//
// fOrdered
// True if mixed content model is ordered. DTD mixed content models
// are <em>always</em> unordered.
//
// fDTD
// Boolean to allow DTDs to validate even with namespace support.
//
// -----------------------------------------------------------------------
XMLSize_t fCount;
QName** fChildren;
ContentSpecNode::NodeTypes* fChildTypes;
bool fOrdered;
bool fDTD;
MemoryManager* fMemoryManager;
};
inline ContentLeafNameTypeVector* MixedContentModel::getContentLeafNameTypeVector() const
{
return 0;
}
inline unsigned int
MixedContentModel::getNextState(unsigned int,
XMLSize_t) const {
return XMLContentModel::gInvalidTrans;
}
inline bool
MixedContentModel::handleRepetitions( const QName* const /*curElem*/,
unsigned int /*curState*/,
unsigned int /*currentLoop*/,
unsigned int& /*nextState*/,
unsigned int& /*nextLoop*/,
XMLSize_t /*elementIndex*/,
SubstitutionGroupComparator * /*comparator*/) const
{
return true;
}
inline void MixedContentModel::checkUniqueParticleAttribution
(
SchemaGrammar* const
, GrammarResolver* const
, XMLStringPool* const
, XMLValidator* const
, unsigned int* const pContentSpecOrgURI
, const XMLCh* /*pComplexTypeName*/ /*= 0*/
)
{
// rename back
unsigned int i = 0;
for (i = 0; i < fCount; i++) {
unsigned int orgURIIndex = fChildren[i]->getURI();
if ((orgURIIndex != XMLContentModel::gEOCFakeId) &&
(orgURIIndex != XMLElementDecl::fgInvalidElemId) &&
(orgURIIndex != XMLElementDecl::fgPCDataElemId))
fChildren[i]->setURI(pContentSpecOrgURI[orgURIIndex]);
}
// for mixed content model, it's only a sequence
// UPA checking is not necessary
}
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,212 @@
/*
* 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: SimpleContentModel.hpp 901107 2010-01-20 08:45:02Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_SIMPLECONTENTMODEL_HPP)
#define XERCESC_INCLUDE_GUARD_SIMPLECONTENTMODEL_HPP
#include <xercesc/framework/XMLContentModel.hpp>
#include <xercesc/validators/common/ContentSpecNode.hpp>
XERCES_CPP_NAMESPACE_BEGIN
//
// SimpleContentModel is a derivative of the abstract content model base
// class that handles a small set of simple content models that are just
// way overkill to give the DFA treatment.
//
// DESCRIPTION:
//
// This guy handles the following scenarios:
//
// a
// a?
// a*
// a+
// a,b
// a|b
//
// These all involve a unary operation with one element type, or a binary
// operation with two elements. These are very simple and can be checked
// in a simple way without a DFA and without the overhead of setting up a
// DFA for such a simple check.
//
// NOTE: Pass the XMLElementDecl::fgPCDataElemId value to represent a
// PCData node. Pass XMLElementDecl::fgInvalidElemId for unused element
//
class SimpleContentModel : public XMLContentModel
{
public :
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
SimpleContentModel
(
const bool dtd
, QName* const firstChild
, QName* const secondChild
, const ContentSpecNode::NodeTypes cmOp
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
~SimpleContentModel();
// -----------------------------------------------------------------------
// Implementation of the ContentModel virtual interface
// -----------------------------------------------------------------------
virtual bool validateContent
(
QName** const children
, XMLSize_t childCount
, unsigned int emptyNamespaceId
, XMLSize_t* indexFailingChild
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
) const;
virtual bool validateContentSpecial
(
QName** const children
, XMLSize_t childCount
, unsigned int emptyNamespaceId
, GrammarResolver* const pGrammarResolver
, XMLStringPool* const pStringPool
, XMLSize_t* indexFailingChild
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
) const;
virtual ContentLeafNameTypeVector *getContentLeafNameTypeVector() const;
virtual unsigned int getNextState(unsigned int currentState,
XMLSize_t elementIndex) const;
virtual bool handleRepetitions( const QName* const curElem,
unsigned int curState,
unsigned int currentLoop,
unsigned int& nextState,
unsigned int& nextLoop,
XMLSize_t elementIndex,
SubstitutionGroupComparator * comparator) const;
virtual void checkUniqueParticleAttribution
(
SchemaGrammar* const pGrammar
, GrammarResolver* const pGrammarResolver
, XMLStringPool* const pStringPool
, XMLValidator* const pValidator
, unsigned int* const pContentSpecOrgURI
, const XMLCh* pComplexTypeName = 0
) ;
private :
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
SimpleContentModel();
SimpleContentModel(const SimpleContentModel&);
SimpleContentModel& operator=(const SimpleContentModel&);
// -----------------------------------------------------------------------
// Private data members
//
// fFirstChild
// fSecondChild
// The first (and optional second) child node. The
// operation code tells us whether the second child is used or not.
//
// fOp
// The operation that this object represents. Since this class only
// does simple contents, there is only ever a single operation
// involved (i.e. the children of the operation are always one or
// two leafs.)
//
// fDTD
// Boolean to allow DTDs to validate even with namespace support. */
//
// -----------------------------------------------------------------------
QName* fFirstChild;
QName* fSecondChild;
ContentSpecNode::NodeTypes fOp;
bool fDTD;
MemoryManager* const fMemoryManager;
};
// ---------------------------------------------------------------------------
// SimpleContentModel: Constructors and Destructor
// ---------------------------------------------------------------------------
inline SimpleContentModel::SimpleContentModel
(
const bool dtd
, QName* const firstChild
, QName* const secondChild
, const ContentSpecNode::NodeTypes cmOp
, MemoryManager* const manager
)
: fFirstChild(0)
, fSecondChild(0)
, fOp(cmOp)
, fDTD(dtd)
, fMemoryManager(manager)
{
if (firstChild)
fFirstChild = new (manager) QName(*firstChild);
else
fFirstChild = new (manager) QName(XMLUni::fgZeroLenString, XMLUni::fgZeroLenString, XMLElementDecl::fgInvalidElemId, manager);
if (secondChild)
fSecondChild = new (manager) QName(*secondChild);
else
fSecondChild = new (manager) QName(XMLUni::fgZeroLenString, XMLUni::fgZeroLenString, XMLElementDecl::fgInvalidElemId, manager);
}
inline SimpleContentModel::~SimpleContentModel()
{
delete fFirstChild;
delete fSecondChild;
}
// ---------------------------------------------------------------------------
// SimpleContentModel: Virtual methods
// ---------------------------------------------------------------------------
inline unsigned int
SimpleContentModel::getNextState(unsigned int,
XMLSize_t) const {
return XMLContentModel::gInvalidTrans;
}
inline bool
SimpleContentModel::handleRepetitions( const QName* const /*curElem*/,
unsigned int /*curState*/,
unsigned int /*currentLoop*/,
unsigned int& /*nextState*/,
unsigned int& /*nextLoop*/,
XMLSize_t /*elementIndex*/,
SubstitutionGroupComparator * /*comparator*/) const
{
return true;
}
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,201 @@
/*
* 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: AbstractNumericFacetValidator.hpp 673155 2008-07-01 17:55:39Z dbertoni $
*/
#if !defined(XERCESC_INCLUDE_GUARD_ABSTRACT_NUMERIC_FACET_VALIDATOR_HPP)
#define XERCESC_INCLUDE_GUARD_ABSTRACT_NUMERIC_FACET_VALIDATOR_HPP
#include <xercesc/validators/datatype/DatatypeValidator.hpp>
#include <xercesc/util/RefArrayVectorOf.hpp>
#include <xercesc/util/XMLNumber.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class VALIDATORS_EXPORT AbstractNumericFacetValidator : public DatatypeValidator
{
public:
// -----------------------------------------------------------------------
// Public ctor/dtor
// -----------------------------------------------------------------------
/** @name Constructor. */
//@{
virtual ~AbstractNumericFacetValidator();
//@}
virtual const RefArrayVectorOf<XMLCh>* getEnumString() const;
/***
* Support for Serialization/De-serialization
***/
DECL_XSERIALIZABLE(AbstractNumericFacetValidator)
protected:
AbstractNumericFacetValidator
(
DatatypeValidator* const baseValidator
, RefHashTableOf<KVStringPair>* const facets
, const int finalSet
, const ValidatorType type
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
void init(RefArrayVectorOf<XMLCh>* const enums
, MemoryManager* const manager);
//
// Abstract interface
//
virtual void assignAdditionalFacet(const XMLCh* const key
, const XMLCh* const value
, MemoryManager* const manager);
virtual void inheritAdditionalFacet();
virtual void checkAdditionalFacetConstraints(MemoryManager* const manager) const;
virtual void checkAdditionalFacetConstraintsBase(MemoryManager* const manager) const;
virtual int compareValues(const XMLNumber* const lValue
, const XMLNumber* const rValue) = 0;
virtual void checkContent(const XMLCh* const content
, ValidationContext* const context
, bool asBase
, MemoryManager* const manager) = 0;
// -----------------------------------------------------------------------
// Setter methods
// -----------------------------------------------------------------------
virtual void setMaxInclusive(const XMLCh* const) = 0;
virtual void setMaxExclusive(const XMLCh* const) = 0;
virtual void setMinInclusive(const XMLCh* const) = 0;
virtual void setMinExclusive(const XMLCh* const) = 0;
virtual void setEnumeration(MemoryManager* const manager) = 0;
static const int INDETERMINATE;
public:
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
inline XMLNumber* getMaxInclusive() const;
inline XMLNumber* getMaxExclusive() const;
inline XMLNumber* getMinInclusive() const;
inline XMLNumber* getMinExclusive() const;
inline RefVectorOf<XMLNumber>* getEnumeration() const;
protected:
// -----------------------------------------------------------------------
// Protected data members
//
// Allow access to derived class
//
// -----------------------------------------------------------------------
bool fMaxInclusiveInherited;
bool fMaxExclusiveInherited;
bool fMinInclusiveInherited;
bool fMinExclusiveInherited;
bool fEnumerationInherited;
XMLNumber* fMaxInclusive;
XMLNumber* fMaxExclusive;
XMLNumber* fMinInclusive;
XMLNumber* fMinExclusive;
RefVectorOf<XMLNumber>* fEnumeration; // save the actual value
RefArrayVectorOf<XMLCh>* fStrEnumeration;
private:
void assignFacet(MemoryManager* const manager);
void inspectFacet(MemoryManager* const manager);
void inspectFacetBase(MemoryManager* const manager);
void inheritFacet();
void storeClusive(XSerializeEngine&
, bool
, XMLNumber*);
void loadClusive(XSerializeEngine&
, bool&
, XMLNumber*&
, XMLNumber::NumberType
, int );
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
AbstractNumericFacetValidator(const AbstractNumericFacetValidator&);
AbstractNumericFacetValidator& operator=(const AbstractNumericFacetValidator&);
};
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
inline XMLNumber* AbstractNumericFacetValidator::getMaxInclusive() const
{
return fMaxInclusive;
}
inline XMLNumber* AbstractNumericFacetValidator::getMaxExclusive() const
{
return fMaxExclusive;
}
inline XMLNumber* AbstractNumericFacetValidator::getMinInclusive() const
{
return fMinInclusive;
}
inline XMLNumber* AbstractNumericFacetValidator::getMinExclusive() const
{
return fMinExclusive;
}
inline RefVectorOf<XMLNumber>* AbstractNumericFacetValidator::getEnumeration() const
{
return fEnumeration;
}
XERCES_CPP_NAMESPACE_END
#endif
/**
* End of file AbstractNumericFacetValidator.hpp
*/

View File

@@ -0,0 +1,109 @@
/*
* 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: AbstractNumericValidator.hpp 527149 2007-04-10 14:56:39Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_ABSTRACT_NUMERIC_VALIDATOR_HPP)
#define XERCESC_INCLUDE_GUARD_ABSTRACT_NUMERIC_VALIDATOR_HPP
#include <xercesc/validators/datatype/AbstractNumericFacetValidator.hpp>
#include <xercesc/util/RefVectorOf.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class VALIDATORS_EXPORT AbstractNumericValidator : public AbstractNumericFacetValidator
{
public:
// -----------------------------------------------------------------------
// Public ctor/dtor
// -----------------------------------------------------------------------
/** @name Constructor. */
//@{
virtual ~AbstractNumericValidator();
//@}
virtual void validate
(
const XMLCh* const content
, ValidationContext* const context = 0
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
virtual const XMLCh* getCanonicalRepresentation
(
const XMLCh* const rawData
, MemoryManager* const memMgr = 0
, bool toValidate = false
) const;
/***
* Support for Serialization/De-serialization
***/
DECL_XSERIALIZABLE(AbstractNumericValidator)
protected:
AbstractNumericValidator
(
DatatypeValidator* const baseValidator
, RefHashTableOf<KVStringPair>* const facets
, const int finalSet
, const ValidatorType type
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
inline void init(RefArrayVectorOf<XMLCh>* const enums
, MemoryManager* const manager);
//
// Abstract interface
//
virtual void checkContent(const XMLCh* const content
, ValidationContext* const context
, bool asBase
, MemoryManager* const manager) = 0;
void boundsCheck(const XMLNumber* const
, MemoryManager* const manager);
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
AbstractNumericValidator(const AbstractNumericValidator&);
AbstractNumericValidator& operator=(const AbstractNumericValidator&);
};
inline void AbstractNumericValidator::init(RefArrayVectorOf<XMLCh>* const enums
, MemoryManager* const manager)
{
AbstractNumericFacetValidator::init(enums, manager);
}
XERCES_CPP_NAMESPACE_END
#endif
/**
* End of file AbstractNumericValidator.hpp
*/

View File

@@ -0,0 +1,250 @@
/*
* 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: AbstractStringValidator.hpp 695949 2008-09-16 15:57:44Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_ABSTRACT_STRING_VALIDATOR_HPP)
#define XERCESC_INCLUDE_GUARD_ABSTRACT_STRING_VALIDATOR_HPP
#include <xercesc/validators/datatype/DatatypeValidator.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class VALIDATORS_EXPORT AbstractStringValidator : public DatatypeValidator
{
public:
// -----------------------------------------------------------------------
// Public ctor/dtor
// -----------------------------------------------------------------------
/** @name Constructor. */
//@{
virtual ~AbstractStringValidator();
//@}
virtual const RefArrayVectorOf<XMLCh>* getEnumString() const;
// -----------------------------------------------------------------------
// Validation methods
// -----------------------------------------------------------------------
/** @name Validation Function */
//@{
/**
* validate that a string matches the boolean datatype
* @param content A string containing the content to be validated
*
* @exception throws InvalidDatatypeException if the content is
* is not valid.
*/
virtual void validate
(
const XMLCh* const content
, ValidationContext* const context = 0
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
//@}
// -----------------------------------------------------------------------
// Compare methods
// -----------------------------------------------------------------------
/** @name Compare Function */
//@{
virtual int compare(const XMLCh* const, const XMLCh* const
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
//@}
/***
* Support for Serialization/De-serialization
***/
DECL_XSERIALIZABLE(AbstractStringValidator)
protected:
AbstractStringValidator
(
DatatypeValidator* const baseValidator
, RefHashTableOf<KVStringPair>* const facets
, const int finalSet
, const ValidatorType type
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
void init(RefArrayVectorOf<XMLCh>* const enums
, MemoryManager* const manager);
//
// Abstract interface
//
virtual void assignAdditionalFacet(const XMLCh* const key
, const XMLCh* const value
, MemoryManager* const manager);
virtual void inheritAdditionalFacet();
virtual void checkAdditionalFacetConstraints(MemoryManager* const manager) const;
virtual void checkAdditionalFacet(const XMLCh* const content
, MemoryManager* const manager) const;
virtual XMLSize_t getLength(const XMLCh* const content
, MemoryManager* const manager) const;
virtual void checkValueSpace(const XMLCh* const content
, MemoryManager* const manager) = 0;
//
// to Allow ListDTV to overwrite
//
virtual void inspectFacetBase(MemoryManager* const manager);
virtual void inheritFacet();
virtual void checkContent(const XMLCh* const content
, ValidationContext* const context
, bool asBase
, MemoryManager* const manager);
/*
** Base64BinaryDatatypeValidator to overwrite
*/
virtual void normalizeEnumeration(MemoryManager* const manager);
virtual void normalizeContent(XMLCh* const, MemoryManager* const manager) const;
public:
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
inline XMLSize_t getLength() const;
inline XMLSize_t getMaxLength() const;
inline XMLSize_t getMinLength() const;
inline RefArrayVectorOf<XMLCh>* getEnumeration() const;
protected:
// -----------------------------------------------------------------------
// Setter methods
// -----------------------------------------------------------------------
inline void setLength(XMLSize_t);
inline void setMaxLength(XMLSize_t);
inline void setMinLength(XMLSize_t);
inline void setEnumeration(RefArrayVectorOf<XMLCh>*, bool);
private:
void assignFacet(MemoryManager* const manager);
void inspectFacet(MemoryManager* const manager);
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
AbstractStringValidator(const AbstractStringValidator&);
AbstractStringValidator& operator=(const AbstractStringValidator&);
// -----------------------------------------------------------------------
// Private data members
//
// -----------------------------------------------------------------------
XMLSize_t fLength;
XMLSize_t fMaxLength;
XMLSize_t fMinLength;
bool fEnumerationInherited;
RefArrayVectorOf<XMLCh>* fEnumeration;
};
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
inline XMLSize_t AbstractStringValidator::getLength() const
{
return fLength;
}
inline XMLSize_t AbstractStringValidator::getMaxLength() const
{
return fMaxLength;
}
inline XMLSize_t AbstractStringValidator::getMinLength() const
{
return fMinLength;
}
inline RefArrayVectorOf<XMLCh>* AbstractStringValidator:: getEnumeration() const
{
return fEnumeration;
}
// -----------------------------------------------------------------------
// Setter methods
// -----------------------------------------------------------------------
inline void AbstractStringValidator::setLength(XMLSize_t newLength)
{
fLength = newLength;
}
inline void AbstractStringValidator::setMaxLength(XMLSize_t newMaxLength)
{
fMaxLength = newMaxLength;
}
inline void AbstractStringValidator::setMinLength(XMLSize_t newMinLength)
{
fMinLength = newMinLength;
}
inline void AbstractStringValidator::setEnumeration(RefArrayVectorOf<XMLCh>* enums
, bool inherited)
{
if (enums)
{
if ( !fEnumerationInherited && fEnumeration)
delete fEnumeration;
fEnumeration = enums;
fEnumerationInherited = inherited;
setFacetsDefined(DatatypeValidator::FACET_ENUMERATION);
}
}
XERCES_CPP_NAMESPACE_END
#endif
/**
* End of file AbstractStringValidator.hpp
*/

View File

@@ -0,0 +1,180 @@
/*
* 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: AnySimpleTypeDatatypeValidator.hpp 637054 2008-03-14 11:08:37Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_ANYSIMPLETYPEDATATYPEVALIDATOR_HPP)
#define XERCESC_INCLUDE_GUARD_ANYSIMPLETYPEDATATYPEVALIDATOR_HPP
#include <xercesc/validators/datatype/DatatypeValidator.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class VALIDATORS_EXPORT AnySimpleTypeDatatypeValidator : public DatatypeValidator
{
public:
// -----------------------------------------------------------------------
// Public Constructor
// -----------------------------------------------------------------------
/** @name Constructor */
//@{
AnySimpleTypeDatatypeValidator
(
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
//@}
// -----------------------------------------------------------------------
// Public Destructor
// -----------------------------------------------------------------------
/** @name Destructor. */
//@{
virtual ~AnySimpleTypeDatatypeValidator();
//@}
virtual const RefArrayVectorOf<XMLCh>* getEnumString() const;
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
/** @name Getter Functions */
//@{
/**
* Returns whether the type is atomic or not
*/
virtual bool isAtomic() const;
//@}
// -----------------------------------------------------------------------
// Validation methods
// -----------------------------------------------------------------------
/** @name Validation Function */
//@{
/**
* Checks that the "content" string is valid datatype.
* If invalid, a Datatype validation exception is thrown.
*
* @param content A string containing the content to be validated
*
*/
virtual void validate
(
const XMLCh* const content
, ValidationContext* const context = 0
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
/**
* Checks whether a given type can be used as a substitute
*
* @param toCheck A datatype validator of the type to be used as a
* substitute
*
*/
virtual bool isSubstitutableBy(const DatatypeValidator* const toCheck);
//@}
// -----------------------------------------------------------------------
// Compare methods
// -----------------------------------------------------------------------
/** @name Compare Function */
//@{
/**
* Compares content in the Domain value vs. lexical value.
*
* @param value1 string to compare
*
* @param value2 string to compare
*
*/
virtual int compare(const XMLCh* const value1, const XMLCh* const value2
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
//@}
/**
* Returns an instance of the base datatype validator class
* Used by the DatatypeValidatorFactory.
*/
virtual DatatypeValidator* newInstance
(
RefHashTableOf<KVStringPair>* const facets
, RefArrayVectorOf<XMLCh>* const enums
, const int finalSet
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
/***
* Support for Serialization/De-serialization
***/
DECL_XSERIALIZABLE(AnySimpleTypeDatatypeValidator)
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
AnySimpleTypeDatatypeValidator(const AnySimpleTypeDatatypeValidator&);
AnySimpleTypeDatatypeValidator& operator=(const AnySimpleTypeDatatypeValidator&);
};
// ---------------------------------------------------------------------------
// DatatypeValidator: Getters
// ---------------------------------------------------------------------------
inline bool AnySimpleTypeDatatypeValidator::isAtomic() const {
return false;
}
// ---------------------------------------------------------------------------
// DatatypeValidators: Validation methods
// ---------------------------------------------------------------------------
inline bool
AnySimpleTypeDatatypeValidator::isSubstitutableBy(const DatatypeValidator* const)
{
return true;
}
inline void
AnySimpleTypeDatatypeValidator::validate(const XMLCh* const
, ValidationContext* const
, MemoryManager* const)
{
return;
}
XERCES_CPP_NAMESPACE_END
#endif
/**
* End of file AnySimpleTypeDatatypeValidator.hpp
*/

View File

@@ -0,0 +1,95 @@
/*
* 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: AnyURIDatatypeValidator.hpp 608951 2008-01-04 18:21:22Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_ANYURI_DATATYPEVALIDATOR_HPP)
#define XERCESC_INCLUDE_GUARD_ANYURI_DATATYPEVALIDATOR_HPP
#include <xercesc/validators/datatype/AbstractStringValidator.hpp>
#include <xercesc/util/XMLUri.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class XMLBuffer;
class VALIDATORS_EXPORT AnyURIDatatypeValidator : public AbstractStringValidator
{
public:
// -----------------------------------------------------------------------
// Public ctor/dtor
// -----------------------------------------------------------------------
/** @name Constructors and Destructor */
//@{
AnyURIDatatypeValidator
(
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
AnyURIDatatypeValidator
(
DatatypeValidator* const baseValidator
, RefHashTableOf<KVStringPair>* const facets
, RefArrayVectorOf<XMLCh>* const enums
, const int finalSet
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
virtual ~AnyURIDatatypeValidator();
//@}
/**
* Returns an instance of the base datatype validator class
* Used by the DatatypeValidatorFactory.
*/
virtual DatatypeValidator* newInstance
(
RefHashTableOf<KVStringPair>* const facets
, RefArrayVectorOf<XMLCh>* const enums
, const int finalSet
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
/***
* Support for Serialization/De-serialization
***/
DECL_XSERIALIZABLE(AnyURIDatatypeValidator)
protected:
virtual void checkValueSpace(const XMLCh* const content
, MemoryManager* const manager);
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
AnyURIDatatypeValidator(const AnyURIDatatypeValidator&);
AnyURIDatatypeValidator& operator=(const AnyURIDatatypeValidator&);
void encode(const XMLCh* const content, const XMLSize_t len, XMLBuffer& encoded, MemoryManager* const manager);
};
XERCES_CPP_NAMESPACE_END
#endif
/**
* End of file AnyURIDatatypeValidator.hpp
*/

View File

@@ -0,0 +1,100 @@
/*
* 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: Base64BinaryDatatypeValidator.hpp 695949 2008-09-16 15:57:44Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_BASE64BINARY_DATATYPEVALIDATOR_HPP)
#define XERCESC_INCLUDE_GUARD_BASE64BINARY_DATATYPEVALIDATOR_HPP
#include <xercesc/validators/datatype/AbstractStringValidator.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class VALIDATORS_EXPORT Base64BinaryDatatypeValidator : public AbstractStringValidator
{
public:
// -----------------------------------------------------------------------
// Public ctor/dtor
// -----------------------------------------------------------------------
/** @name Constructors and Destructor */
//@{
Base64BinaryDatatypeValidator
(
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
Base64BinaryDatatypeValidator
(
DatatypeValidator* const baseValidator
, RefHashTableOf<KVStringPair>* const facets
, RefArrayVectorOf<XMLCh>* const enums
, const int finalSet
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
virtual ~Base64BinaryDatatypeValidator();
//@}
/**
* Returns an instance of the base datatype validator class
* Used by the DatatypeValidatorFactory.
*/
virtual DatatypeValidator* newInstance
(
RefHashTableOf<KVStringPair>* const facets
, RefArrayVectorOf<XMLCh>* const enums
, const int finalSet
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
/***
* Support for Serialization/De-serialization
***/
DECL_XSERIALIZABLE(Base64BinaryDatatypeValidator)
protected:
virtual void checkValueSpace(const XMLCh* const content
, MemoryManager* const manager);
virtual XMLSize_t getLength(const XMLCh* const content
, MemoryManager* const manager) const;
virtual void normalizeEnumeration(MemoryManager* const manager);
virtual void normalizeContent(XMLCh* const, MemoryManager* const manager) const;
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
Base64BinaryDatatypeValidator(const Base64BinaryDatatypeValidator&);
Base64BinaryDatatypeValidator& operator=(const Base64BinaryDatatypeValidator&);
};
XERCES_CPP_NAMESPACE_END
#endif
/**
* End of file Base64BinaryDatatypeValidator.hpp
*/

View File

@@ -0,0 +1,193 @@
/*
* 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: BooleanDatatypeValidator.hpp 527149 2007-04-10 14:56:39Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_BOOLEAN_DATATYPEVALIDATOR_HPP)
#define XERCESC_INCLUDE_GUARD_BOOLEAN_DATATYPEVALIDATOR_HPP
#include <xercesc/validators/datatype/DatatypeValidator.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class VALIDATORS_EXPORT BooleanDatatypeValidator : public DatatypeValidator
{
public:
// -----------------------------------------------------------------------
// Public ctor/dtor
// -----------------------------------------------------------------------
/** @name Constructor. */
//@{
BooleanDatatypeValidator
(
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
BooleanDatatypeValidator
(
DatatypeValidator* const baseValidator
, RefHashTableOf<KVStringPair>* const facets
, RefArrayVectorOf<XMLCh>* const enums
, const int finalSet
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
virtual ~BooleanDatatypeValidator();
//@}
virtual const RefArrayVectorOf<XMLCh>* getEnumString() const;
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
/** @name Getter Functions */
//@{
virtual const XMLCh* getCanonicalRepresentation
(
const XMLCh* const rawData
, MemoryManager* const memMgr = 0
, bool toValidate = false
) const;
//@}
// -----------------------------------------------------------------------
// Validation methods
// -----------------------------------------------------------------------
/** @name Validation Function */
//@{
/**
* validate that a string matches the boolean datatype
* @param content A string containing the content to be validated
*
* @exception throws InvalidDatatypeException if the content is
* is not valid.
*/
virtual void validate
(
const XMLCh* const content
, ValidationContext* const context = 0
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
//@}
// -----------------------------------------------------------------------
// Compare methods
// -----------------------------------------------------------------------
/** @name Compare Function */
//@{
/**
* Compare two boolean data types
*
* @param content1
* @param content2
* @return
*/
int compare(const XMLCh* const, const XMLCh* const
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
//@}
/**
* Returns an instance of the base datatype validator class
* Used by the DatatypeValidatorFactory.
*/
DatatypeValidator* newInstance
(
RefHashTableOf<KVStringPair>* const facets
, RefArrayVectorOf<XMLCh>* const enums
, const int finalSet
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
/***
* Support for Serialization/De-serialization
***/
DECL_XSERIALIZABLE(BooleanDatatypeValidator)
private:
virtual void checkContent(const XMLCh* const content
, ValidationContext* const context
, bool asBase
, MemoryManager* const manager);
// -----------------------------------------------------------------------
// Unimplemented methods.
// -----------------------------------------------------------------------
BooleanDatatypeValidator(const BooleanDatatypeValidator&);
BooleanDatatypeValidator& operator=(const BooleanDatatypeValidator&);
};
// ---------------------------------------------------------------------------
// Constructors and Destructor
// ---------------------------------------------------------------------------
inline BooleanDatatypeValidator::BooleanDatatypeValidator(MemoryManager* const manager)
:DatatypeValidator(0, 0, 0, DatatypeValidator::Boolean, manager)
{
setFinite(true);
}
inline BooleanDatatypeValidator::~BooleanDatatypeValidator()
{
}
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
// Compare methods
// -----------------------------------------------------------------------
inline DatatypeValidator* BooleanDatatypeValidator::newInstance
(
RefHashTableOf<KVStringPair>* const facets
, RefArrayVectorOf<XMLCh>* const enums
, const int finalSet
, MemoryManager* const manager
)
{
return (DatatypeValidator*) new (manager) BooleanDatatypeValidator(this, facets, enums, finalSet, manager);
}
inline void BooleanDatatypeValidator::validate( const XMLCh* const content
, ValidationContext* const context
, MemoryManager* const manager)
{
checkContent(content, context, false, manager);
}
XERCES_CPP_NAMESPACE_END
#endif
/**
* End of file BooleanDatatypeValidator.hpp
*/

View File

@@ -0,0 +1,750 @@
/*
* 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: DatatypeValidator.hpp 932887 2010-04-11 13:04:59Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_DATATYPEVALIDATOR_HPP)
#define XERCESC_INCLUDE_GUARD_DATATYPEVALIDATOR_HPP
#include <xercesc/util/PlatformUtils.hpp>
#include <xercesc/util/RefHashTableOf.hpp>
#include <xercesc/util/KVStringPair.hpp>
#include <xercesc/util/XMLUniDefs.hpp>
#include <xercesc/util/regx/RegularExpression.hpp>
#include <xercesc/validators/schema/SchemaSymbols.hpp>
#include <xercesc/internal/XSerializable.hpp>
#include <xercesc/framework/psvi/XSSimpleTypeDefinition.hpp>
#include <xercesc/framework/ValidationContext.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class MemoryManager;
/**
* DataTypeValidator defines the interface that data type validators must
* obey. These validators can be supplied by the application writer and may
* be useful as standalone code as well as plugins to the validator
* architecture.
*
* Notice:
* The datatype validator will own the facets hashtable passed to it during
* construction, which means that the datatype validator will be responsible
* for the deletion. The facets hashtable will be created during parsing and
* passed to the appropriate datatype validator which in turn will delete it
* upon its destruction.
*
*/
class VALIDATORS_EXPORT DatatypeValidator : public XSerializable, public XMemory
{
public:
// -----------------------------------------------------------------------
// Constant data
// -----------------------------------------------------------------------
//facets
enum {
FACET_LENGTH = 1,
FACET_MINLENGTH = 1<<1,
FACET_MAXLENGTH = 1<<2,
FACET_PATTERN = 1<<3,
FACET_ENUMERATION = 1<<4,
FACET_MAXINCLUSIVE = 1<<5,
FACET_MAXEXCLUSIVE = 1<<6,
FACET_MININCLUSIVE = 1<<7,
FACET_MINEXCLUSIVE = 1<<8,
FACET_TOTALDIGITS = 1<<9,
FACET_FRACTIONDIGITS = 1<<10,
FACET_ENCODING = 1<<11,
FACET_DURATION = 1<<12,
FACET_PERIOD = 1<<13,
FACET_WHITESPACE = 1<<14
};
//2.4.2.6 whiteSpace - Datatypes
enum {
PRESERVE = 0,
REPLACE = 1,
COLLAPSE = 2
};
enum ValidatorType {
String,
AnyURI,
QName,
Name,
NCName,
Boolean,
Float,
Double,
Decimal,
HexBinary,
Base64Binary,
Duration,
DateTime,
Date,
Time,
MonthDay,
YearMonth,
Year,
Month,
Day,
ID,
IDREF,
ENTITY,
NOTATION,
List,
Union,
AnySimpleType,
UnKnown
};
// -----------------------------------------------------------------------
// Public Destructor
// -----------------------------------------------------------------------
/** @name Destructor. */
//@{
virtual ~DatatypeValidator();
//@}
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
/** @name Getter Functions */
//@{
/**
* Returns the final values of the simpleType
*/
int getFinalSet() const;
/**
* Returns the datatype facet if any is set.
*/
RefHashTableOf<KVStringPair>* getFacets() const;
/**
* Returns default value (collapse) for whiteSpace facet.
* This function is overwritten in StringDatatypeValidator.
*/
short getWSFacet () const;
/**
* Returns the base datatype validator if set.
*/
DatatypeValidator* getBaseValidator() const;
/**
* Returns the 'class' type of datatype validator
*/
ValidatorType getType() const;
/**
* Returns whether the type is atomic or not
*
* To be redefined in List/Union validators
*/
virtual bool isAtomic() const;
/**
* Returns the datatype enumeration if any is set.
* Derived class shall provide their own copy.
*/
virtual const RefArrayVectorOf<XMLCh>* getEnumString() const = 0;
/**
* returns true if this type is anonymous
**/
bool getAnonymous() const;
/**
* sets this type to be anonymous
**/
void setAnonymous();
/**
* Fundamental Facet: ordered
*/
XSSimpleTypeDefinition::ORDERING getOrdered() const;
/**
* Fundamental Facet: cardinality.
*/
bool getFinite() const;
/**
* Fundamental Facet: bounded.
*/
bool getBounded() const;
/**
* Fundamental Facet: numeric.
*/
bool getNumeric() const;
/**
* Canonical Representation
*
* Derivative datatype may overwrite this method once
* it has its own canonical representation other than
* the default one.
*
* @param rawData: data in raw string
* @param memMgr: memory manager
* @param toValiate: to validate the raw string or not
*
* @return: canonical representation of the data
*
* Note:
*
* 1. the return value is kept in memory allocated
* by the memory manager passed in or by dv's
* if no memory manager is provided.
*
* 2. client application is responsible for the
* proper deallocation of the memory allocated
* for the returned value.
*
* 3. In the case where the rawData is not valid
* with regards to the fundamental datatype,
* a null string is returned.
*
*/
virtual const XMLCh* getCanonicalRepresentation
(
const XMLCh* const rawData
, MemoryManager* const memMgr = 0
, bool toValidate = false
) const;
//@}
// -----------------------------------------------------------------------
// Validation methods
// -----------------------------------------------------------------------
/** @name Validation Function */
//@{
/**
* Checks that the "content" string is valid datatype.
* If invalid, a Datatype validation exception is thrown.
*
* @param content A string containing the content to be validated
*
*/
virtual void validate
(
const XMLCh* const content
, ValidationContext* const context = 0
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
) = 0;
/**
* Checks whether a given type can be used as a substitute
*
* @param toCheck A datatype validator of the type to be used as a
* substitute
*
* To be redefined in UnionDatatypeValidator
*/
virtual bool isSubstitutableBy(const DatatypeValidator* const toCheck);
//@}
// -----------------------------------------------------------------------
// Compare methods
// -----------------------------------------------------------------------
/** @name Compare Function */
//@{
/**
* Compares content in the Domain value vs. lexical value.
*
* e.g. If type is a float then 1.0 may be equivalent to 1 even though
* both are lexically different.
*
* @param value1 string to compare
*
* @param value2 string to compare
*
* We will provide a default behavior that should be redefined at the
* children level, if necessary (i.e. boolean case).
*/
virtual int compare(const XMLCh* const value1, const XMLCh* const value2
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
//@}
/**
* Returns an instance of the base datatype validator class
* Used by the DatatypeValidatorFactory.
*/
virtual DatatypeValidator* newInstance
(
RefHashTableOf<KVStringPair>* const facets
, RefArrayVectorOf<XMLCh>* const enums
, const int finalSet
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
) = 0;
/**
* Returns the uri,name of the type this validator is for
*/
const XMLCh* getTypeName() const;
/**
* sets the uri,name that this validator is for - typeName is uri,name string.
* due to the internals of xerces this will set the uri to be the schema uri if
* there is no comma in typeName
*/
void setTypeName(const XMLCh* const typeName);
/**
* sets the uri,name that this validator is for
*/
void setTypeName(const XMLCh* const name, const XMLCh* const uri);
/**
* Returns the uri of the type this validator is for
*/
const XMLCh* getTypeUri() const;
/**
* Returns the name of the type this validator is for
*/
const XMLCh* getTypeLocalName() const;
/**
* Returns the plugged-in memory manager
*/
MemoryManager* getMemoryManager() const;
/***
* Support for Serialization/De-serialization
***/
DECL_XSERIALIZABLE(DatatypeValidator)
/***
*
* Serialize DatatypeValidator derivative
*
* Param
* serEng: serialize engine
* dv: DatatypeValidator derivative
*
* Return:
*
***/
static void storeDV(XSerializeEngine& serEng
, DatatypeValidator* const dv);
/***
*
* Create a DatatypeValidator derivative from the binary
* stream.
*
* Param
* serEng: serialize engine
*
* Return:
* DatatypeValidator derivative
*
***/
static DatatypeValidator* loadDV(XSerializeEngine& serEng);
protected:
// -----------------------------------------------------------------------
// Protected Constructors
// -----------------------------------------------------------------------
/** @name Constructors */
//@{
/**
*
* @param baseValidator The base datatype validator for derived
* validators. Null if native validator.
*
* @param facets A hashtable of datatype facets (except enum).
*
* @param finalSet 'final' value of the simpleType
*/
DatatypeValidator(DatatypeValidator* const baseValidator,
RefHashTableOf<KVStringPair>* const facets,
const int finalSet,
const ValidatorType type,
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
//@}
friend class DatatypeValidatorFactory;
friend class XSObjectFactory;
/**
* facetDefined
*/
int getFacetsDefined() const;
void setFacetsDefined(int);
/**
* fixed
*/
int getFixed() const;
void setFixed(int);
/**
* fPattern
*/
const XMLCh* getPattern() const;
void setPattern(const XMLCh* );
/**
* fRegex
*/
RegularExpression* getRegex() const;
void setRegex(RegularExpression* const);
/**
* set fType
*/
void setType(ValidatorType);
/**
* set fWhiteSpace
*/
void setWhiteSpace(short);
/**
* get WSString
*/
const XMLCh* getWSstring(const short WSType) const;
/**
* Fundamental Facet: ordered
*/
void setOrdered(XSSimpleTypeDefinition::ORDERING ordered);
/**
* Fundamental Facet: cardinality.
*/
void setFinite(bool finite);
/**
* Fundamental Facet: bounded.
*/
void setBounded(bool bounded);
/**
* Fundamental Facet: numeric.
*/
void setNumeric(bool numeric);
private:
// -----------------------------------------------------------------------
// CleanUp methods
// -----------------------------------------------------------------------
void cleanUp();
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
DatatypeValidator(const DatatypeValidator&);
DatatypeValidator& operator=(const DatatypeValidator&);
// -----------------------------------------------------------------------
// Private data members
//
// fFinalSet
// stores "final" values of simpleTypes
//
// fBaseValidator
// This is a pointer to a base datatype validator. If value is null,
// it means we have a native datatype validator not a derived one.
//
// fFacets
// This is a hashtable of dataype facets.
//
// fType
// Stores the class type of datatype validator
//
// fFacetsDefined
// Stores the constaiting facets flag
//
// fPattern
// the pointer to the String of the pattern. The actual data is
// in the Facets.
//
// fRegex
// pointer to the RegularExpress object
//
//
// fFixed
// if {fixed} is true, then types for which this type is the
// {base type definition} cannot specify a value for a specific
// facet.
//
// fTypeName
// the uri,name of the type this validator will validate
//
// fTypeLocalName
// the name of the type this validator will validate
//
// fTypeUri
// the uri of the type this validator will validate
// fAnonymous
// true if this type is anonynous
//
// -----------------------------------------------------------------------
bool fAnonymous;
bool fFinite;
bool fBounded;
bool fNumeric;
short fWhiteSpace;
int fFinalSet;
int fFacetsDefined;
int fFixed;
ValidatorType fType;
XSSimpleTypeDefinition::ORDERING fOrdered;
DatatypeValidator* fBaseValidator;
RefHashTableOf<KVStringPair>* fFacets;
XMLCh* fPattern;
RegularExpression* fRegex;
XMLCh* fTypeName;
const XMLCh* fTypeLocalName;
const XMLCh* fTypeUri;
protected:
// -----------------------------------------------------------------------
// Protected data members
//
// fMemoryManager
// Pluggable memory manager for dynamic allocation/deallocation.
// -----------------------------------------------------------------------
MemoryManager* fMemoryManager;
};
// ---------------------------------------------------------------------------
// DatatypeValidator: Getters
// ---------------------------------------------------------------------------
inline int DatatypeValidator::getFinalSet() const {
return fFinalSet;
}
inline RefHashTableOf<KVStringPair>* DatatypeValidator::getFacets() const {
return fFacets;
}
inline DatatypeValidator* DatatypeValidator::getBaseValidator() const {
return fBaseValidator;
}
inline short DatatypeValidator::getWSFacet() const {
return fWhiteSpace;
}
inline DatatypeValidator::ValidatorType DatatypeValidator::getType() const
{
return fType;
}
inline int DatatypeValidator::getFacetsDefined() const
{
return fFacetsDefined;
}
inline int DatatypeValidator::getFixed() const
{
return fFixed;
}
inline const XMLCh* DatatypeValidator::getPattern() const
{
return fPattern;
}
inline RegularExpression* DatatypeValidator::getRegex() const
{
return fRegex;
}
inline const XMLCh* DatatypeValidator::getTypeName() const
{
return fTypeName;
}
inline bool DatatypeValidator::getAnonymous() const
{
return fAnonymous;
}
inline const XMLCh* DatatypeValidator::getTypeLocalName() const
{
return fTypeLocalName;
}
inline const XMLCh* DatatypeValidator::getTypeUri() const
{
return fTypeUri;
}
inline MemoryManager* DatatypeValidator::getMemoryManager() const
{
return fMemoryManager;
}
inline XSSimpleTypeDefinition::ORDERING DatatypeValidator::getOrdered() const
{
return fOrdered;
}
inline bool DatatypeValidator::getFinite() const
{
return fFinite;
}
inline bool DatatypeValidator::getBounded() const
{
return fBounded;
}
inline bool DatatypeValidator::getNumeric() const
{
return fNumeric;
}
// ---------------------------------------------------------------------------
// DatatypeValidator: Setters
// ---------------------------------------------------------------------------
inline void DatatypeValidator::setType(ValidatorType theType)
{
fType = theType;
}
inline void DatatypeValidator::setWhiteSpace(short newValue)
{
fWhiteSpace = newValue;
}
inline void DatatypeValidator::setFacetsDefined(int facets)
{
fFacetsDefined |= facets;
}
inline void DatatypeValidator::setFixed(int fixed)
{
fFixed |= fixed;
}
inline void DatatypeValidator::setPattern(const XMLCh* pattern)
{
if (fPattern) {
fMemoryManager->deallocate(fPattern);//delete [] fPattern;
delete fRegex;
}
fPattern = XMLString::replicate(pattern, fMemoryManager);
fRegex = new (fMemoryManager) RegularExpression(fPattern, SchemaSymbols::fgRegEx_XOption, fMemoryManager);
}
inline void DatatypeValidator::setRegex(RegularExpression* const regex)
{
fRegex = regex;
}
inline bool DatatypeValidator::isAtomic() const {
return true;
}
inline void DatatypeValidator::setAnonymous() {
fAnonymous = true;
}
inline void DatatypeValidator::setOrdered(XSSimpleTypeDefinition::ORDERING ordered)
{
fOrdered = ordered;
}
inline void DatatypeValidator::setFinite(bool finite)
{
fFinite = finite;
}
inline void DatatypeValidator::setBounded(bool bounded)
{
fBounded = bounded;
}
inline void DatatypeValidator::setNumeric(bool numeric)
{
fNumeric = numeric;
}
// ---------------------------------------------------------------------------
// DatatypeValidators: Compare methods
// ---------------------------------------------------------------------------
inline int DatatypeValidator::compare(const XMLCh* const lValue,
const XMLCh* const rValue
, MemoryManager* const)
{
return XMLString::compareString(lValue, rValue);
}
// ---------------------------------------------------------------------------
// DatatypeValidators: Validation methods
// ---------------------------------------------------------------------------
inline bool
DatatypeValidator::isSubstitutableBy(const DatatypeValidator* const toCheck)
{
const DatatypeValidator* dv = toCheck;
while (dv != 0) {
if (dv == this) {
return true;
}
dv = dv->getBaseValidator();
}
return false;
}
XERCES_CPP_NAMESPACE_END
#endif
/**
* End of file DatatypeValidator.hpp
*/

View File

@@ -0,0 +1,285 @@
/*
* 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: DatatypeValidatorFactory.hpp 932887 2010-04-11 13:04:59Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_DATATYPEVALIDATORFACTORY_HPP)
#define XERCESC_INCLUDE_GUARD_DATATYPEVALIDATORFACTORY_HPP
/**
* This class implements a factory of Datatype Validators. Internally the
* DatatypeValidators are kept in a registry.
* There is one instance of DatatypeValidatorFactory per Parser.
* There is one datatype Registry per instance of DatatypeValidatorFactory,
* such registry is first allocated with the number DatatypeValidators needed.
* e.g.
* If Parser finds an XML document with a DTD, a registry of DTD validators (only
* 9 validators) get initialized in the registry.
* The initialization process consist of instantiating the Datatype and
* facets and registering the Datatype into registry table.
* This implementation uses a Hashtable as a registry. The datatype validators created
* by the factory will be deleted by the registry.
*
* As the Parser parses an instance document it knows if validation needs
* to be checked. If no validation is necessary we should not instantiate a
* DatatypeValidatorFactory.
* If validation is needed, we need to instantiate a DatatypeValidatorFactory.
*/
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <xercesc/validators/datatype/DatatypeValidator.hpp>
#include <xercesc/validators/datatype/XMLCanRepGroup.hpp>
#include <xercesc/util/RefVectorOf.hpp>
#include <xercesc/internal/XSerializable.hpp>
XERCES_CPP_NAMESPACE_BEGIN
// ---------------------------------------------------------------------------
// DatatypeValidatorFactory: Local declaration
// ---------------------------------------------------------------------------
typedef RefHashTableOf<KVStringPair> KVStringPairHashTable;
typedef RefHashTableOf<DatatypeValidator> DVHashTable;
typedef RefArrayVectorOf<XMLCh> XMLChRefVector;
class VALIDATORS_EXPORT DatatypeValidatorFactory : public XSerializable, public XMemory
{
public:
// -----------------------------------------------------------------------
// Public Constructors and Destructor
// -----------------------------------------------------------------------
/** @name Constructors */
//@{
DatatypeValidatorFactory
(
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
//@}
/** @name Destructor. */
//@{
~DatatypeValidatorFactory();
//@}
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
/** @name Getter Functions */
//@{
/**
* Returns the datatype validator
*
* @param dvType Datatype validator name/type
*/
DatatypeValidator* getDatatypeValidator(const XMLCh* const dvType) const;
/**
* Returns the user defined registry of types
**/
DVHashTable* getUserDefinedRegistry() const;
/**
* Returns the built in registry of types
**/
static DVHashTable* getBuiltInRegistry();
//@}
private:
/**
* Initializes registry with primitive and derived Simple types.
*
* This method does not clear the registry to clear the registry you
* have to call resetRegistry.
*
* The net effect of this method is to start with the smallest set of
* datatypes needed by the validator.
*
* If we start with Schema's then we initialize to full set of
* validators.
*/
void expandRegistryToFullSchemaSet();
public:
// -----------------------------------------------------------------------
// Canonical Representation Group
// -----------------------------------------------------------------------
void initCanRepRegistory();
static XMLCanRepGroup::CanRepGroup getCanRepGroup(const DatatypeValidator* const);
static DatatypeValidator* getBuiltInBaseValidator(const DatatypeValidator* const);
// -----------------------------------------------------------------------
// Validator Factory methods
// -----------------------------------------------------------------------
/** @name Validator Factory Functions */
//@{
/**
* Creates a new datatype validator of type baseValidator's class and
* adds it to the registry
*
* @param typeName Datatype validator name
*
* @param baseValidator Base datatype validator
*
* @param facets datatype facets if any
*
* @param enums vector of values for enum facet
*
* @param isDerivedByList Indicates whether the datatype is derived by
* list or not
*
* @param finalSet 'final' values of the simpleType
*
* @param isUserDefined Indicates whether the datatype is built-in or
* user defined
*/
DatatypeValidator* createDatatypeValidator
(
const XMLCh* const typeName
, DatatypeValidator* const baseValidator
, RefHashTableOf<KVStringPair>* const facets
, RefArrayVectorOf<XMLCh>* const enums
, const bool isDerivedByList
, const int finalSet = 0
, const bool isUserDefined = true
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
/**
* Creates a new datatype validator of type UnionDatatypeValidator and
* adds it to the registry
*
* @param typeName Datatype validator name
*
* @param validators Vector of datatype validators
*
* @param finalSet 'final' values of the simpleType
*
* @param isUserDefined Indicates whether the datatype is built-in or
* user defined
*/
DatatypeValidator* createDatatypeValidator
(
const XMLCh* const typeName
, RefVectorOf<DatatypeValidator>* const validators
, const int finalSet
, const bool isUserDefined = true
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
//@}
/**
* Reset datatype validator registry
*/
void resetRegistry();
/***
* Support for Serialization/De-serialization
***/
DECL_XSERIALIZABLE(DatatypeValidatorFactory)
private:
// -----------------------------------------------------------------------
// CleanUp methods
// -----------------------------------------------------------------------
void cleanUp();
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
DatatypeValidatorFactory(const DatatypeValidatorFactory&);
DatatypeValidatorFactory& operator=(const DatatypeValidatorFactory&);
// -----------------------------------------------------------------------
// Private data members
//
// fUserDefinedRegistry
// This is a hashtable of user defined dataype validators.
//
// fBuiltInRegistry
// This is a hashtable of built-in primitive datatype validators.
// -----------------------------------------------------------------------
XERCES_CPP_NAMESPACE_QUALIFIER RefHashTableOf<XERCES_CPP_NAMESPACE_QUALIFIER DatatypeValidator>* fUserDefinedRegistry;
static XERCES_CPP_NAMESPACE_QUALIFIER RefHashTableOf<DatatypeValidator>* fBuiltInRegistry;
static XERCES_CPP_NAMESPACE_QUALIFIER RefHashTableOf<XMLCanRepGroup, PtrHasher>* fCanRepRegistry;
XERCES_CPP_NAMESPACE_QUALIFIER MemoryManager* const fMemoryManager;
friend class XPath2ContextImpl;
friend class XMLInitializer;
};
inline DatatypeValidator*
DatatypeValidatorFactory::getDatatypeValidator(const XMLCh* const dvType) const
{
if (dvType) {
if (fBuiltInRegistry && fBuiltInRegistry->containsKey(dvType)) {
return fBuiltInRegistry->get(dvType);
}
if (fUserDefinedRegistry && fUserDefinedRegistry->containsKey(dvType)) {
return fUserDefinedRegistry->get(dvType);
}
}
return 0;
}
inline DVHashTable*
DatatypeValidatorFactory::getUserDefinedRegistry() const {
return fUserDefinedRegistry;
}
inline DVHashTable*
DatatypeValidatorFactory::getBuiltInRegistry() {
return fBuiltInRegistry;
}
// ---------------------------------------------------------------------------
// DatatypeValidator: CleanUp methods
// ---------------------------------------------------------------------------
inline void DatatypeValidatorFactory::cleanUp() {
if (fUserDefinedRegistry)
{
delete fUserDefinedRegistry;
fUserDefinedRegistry = 0;
}
}
XERCES_CPP_NAMESPACE_END
#endif
/**
* End of file DatatypeValidatorFactory.hpp
*/

View File

@@ -0,0 +1,101 @@
/*
* 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: DateDatatypeValidator.hpp 527149 2007-04-10 14:56:39Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_DATE_DATATYPE_VALIDATOR_HPP)
#define XERCESC_INCLUDE_GUARD_DATE_DATATYPE_VALIDATOR_HPP
#include <xercesc/validators/datatype/DateTimeValidator.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class VALIDATORS_EXPORT DateDatatypeValidator : public DateTimeValidator
{
public:
// -----------------------------------------------------------------------
// Public ctor/dtor
// -----------------------------------------------------------------------
/** @name Constructors and Destructor */
//@{
DateDatatypeValidator
(
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
DateDatatypeValidator
(
DatatypeValidator* const baseValidator
, RefHashTableOf<KVStringPair>* const facets
, RefArrayVectorOf<XMLCh>* const enums
, const int finalSet
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
~DateDatatypeValidator();
//@}
/**
* Returns an instance of the base datatype validator class
* Used by the DatatypeValidatorFactory.
*/
virtual DatatypeValidator* newInstance
(
RefHashTableOf<KVStringPair>* const facets
, RefArrayVectorOf<XMLCh>* const enums
, const int finalSet
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
virtual const XMLCh* getCanonicalRepresentation
(
const XMLCh* const rawData
, MemoryManager* const memMgr = 0
, bool toValidate = false
) const;
/***
* Support for Serialization/De-serialization
***/
DECL_XSERIALIZABLE(DateDatatypeValidator)
protected:
// -----------------------------------------------------------------------
// implementation of (DateTimeValidator's) virtual interface
// -----------------------------------------------------------------------
virtual XMLDateTime* parse(const XMLCh* const, MemoryManager* const manager);
virtual void parse(XMLDateTime* const);
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
DateDatatypeValidator(const DateDatatypeValidator&);
DateDatatypeValidator& operator=(const DateDatatypeValidator&);
};
XERCES_CPP_NAMESPACE_END
#endif
/**
* End of file DateDatatypeValidator.hpp
*/

View File

@@ -0,0 +1,102 @@
/*
* 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: DateTimeDatatypeValidator.hpp 527149 2007-04-10 14:56:39Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_DATETIME_DATATYPE_VALIDATOR_HPP)
#define XERCESC_INCLUDE_GUARD_DATETIME_DATATYPE_VALIDATOR_HPP
#include <xercesc/validators/datatype/DateTimeValidator.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class VALIDATORS_EXPORT DateTimeDatatypeValidator : public DateTimeValidator
{
public:
// -----------------------------------------------------------------------
// Public ctor/dtor
// -----------------------------------------------------------------------
/** @name Constructors and Destructor */
//@{
DateTimeDatatypeValidator
(
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
DateTimeDatatypeValidator
(
DatatypeValidator* const baseValidator
, RefHashTableOf<KVStringPair>* const facets
, RefArrayVectorOf<XMLCh>* const enums
, const int finalSet
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
~DateTimeDatatypeValidator();
//@}
/**
* Returns an instance of the base datatype validator class
* Used by the DatatypeValidatorFactory.
*/
virtual DatatypeValidator* newInstance
(
RefHashTableOf<KVStringPair>* const facets
, RefArrayVectorOf<XMLCh>* const enums
, const int finalSet
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
virtual const XMLCh* getCanonicalRepresentation
(
const XMLCh* const rawData
, MemoryManager* const memMgr = 0
, bool toValidate = false
) const;
/***
* Support for Serialization/De-serialization
***/
DECL_XSERIALIZABLE(DateTimeDatatypeValidator)
protected:
// -----------------------------------------------------------------------
// implementation of (DateTimeValidator's) virtual interface
// -----------------------------------------------------------------------
virtual XMLDateTime* parse(const XMLCh* const, MemoryManager* const manager);
virtual void parse(XMLDateTime* const);
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
DateTimeDatatypeValidator(const DateTimeDatatypeValidator&);
DateTimeDatatypeValidator& operator=(const DateTimeDatatypeValidator&);
};
XERCES_CPP_NAMESPACE_END
#endif
/**
* End of file DateTimeDatatypeValidator.hpp
*/

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: DateTimeValidator.hpp 527149 2007-04-10 14:56:39Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_DATETIME_VALIDATOR_HPP)
#define XERCESC_INCLUDE_GUARD_DATETIME_VALIDATOR_HPP
#include <xercesc/validators/datatype/AbstractNumericFacetValidator.hpp>
#include <xercesc/util/XMLDateTime.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class VALIDATORS_EXPORT DateTimeValidator : public AbstractNumericFacetValidator
{
public:
// -----------------------------------------------------------------------
// Public dtor
// -----------------------------------------------------------------------
/** @name Constructor. */
//@{
virtual ~DateTimeValidator();
//@}
virtual void validate
(
const XMLCh* const content
, ValidationContext* const context = 0
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
virtual int compare(const XMLCh* const value1
, const XMLCh* const value2
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
/***
* Support for Serialization/De-serialization
***/
DECL_XSERIALIZABLE(DateTimeValidator)
protected:
// -----------------------------------------------------------------------
// ctor used by derived class
// -----------------------------------------------------------------------
DateTimeValidator
(
DatatypeValidator* const baseValidator
, RefHashTableOf<KVStringPair>* const facets
, const int finalSet
, const ValidatorType type
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
//
// Abstract interface
//
virtual int compareValues(const XMLNumber* const lValue
, const XMLNumber* const rValue);
virtual void checkContent(const XMLCh* const content
, ValidationContext* const context
, bool asBase
, MemoryManager* const manager);
virtual void setMaxInclusive(const XMLCh* const);
virtual void setMaxExclusive(const XMLCh* const);
virtual void setMinInclusive(const XMLCh* const);
virtual void setMinExclusive(const XMLCh* const);
virtual void setEnumeration(MemoryManager* const manager);
protected:
// -----------------------------------------------------------------------
// helper interface: to be implemented/overwritten by derived class
// -----------------------------------------------------------------------
virtual XMLDateTime* parse(const XMLCh* const, MemoryManager* const manager) = 0;
virtual void parse(XMLDateTime* const) = 0;
// to be overwritten by duration
virtual int compareDates(const XMLDateTime* const lValue
, const XMLDateTime* const rValue
, bool strict);
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
DateTimeValidator(const DateTimeValidator&);
DateTimeValidator& operator=(const DateTimeValidator&);
};
XERCES_CPP_NAMESPACE_END
#endif
/**
* End of file DateTimeValidator.hpp
*/

View File

@@ -0,0 +1,95 @@
/*
* 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: DayDatatypeValidator.hpp 527149 2007-04-10 14:56:39Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_DAY_DATATYPE_VALIDATOR_HPP)
#define XERCESC_INCLUDE_GUARD_DAY_DATATYPE_VALIDATOR_HPP
#include <xercesc/validators/datatype/DateTimeValidator.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class VALIDATORS_EXPORT DayDatatypeValidator : public DateTimeValidator
{
public:
// -----------------------------------------------------------------------
// Public ctor/dtor
// -----------------------------------------------------------------------
/** @name Constructors and Destructor*/
//@{
DayDatatypeValidator
(
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
DayDatatypeValidator
(
DatatypeValidator* const baseValidator
, RefHashTableOf<KVStringPair>* const facets
, RefArrayVectorOf<XMLCh>* const enums
, const int finalSet
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
~DayDatatypeValidator();
//@}
/**
* Returns an instance of the base datatype validator class
* Used by the DatatypeValidatorFactory.
*/
virtual DatatypeValidator* newInstance
(
RefHashTableOf<KVStringPair>* const facets
, RefArrayVectorOf<XMLCh>* const enums
, const int finalSet
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
/***
* Support for Serialization/De-serialization
***/
DECL_XSERIALIZABLE(DayDatatypeValidator)
protected:
// -----------------------------------------------------------------------
// implementation of (DateTimeValidator's) virtual interface
// -----------------------------------------------------------------------
virtual XMLDateTime* parse(const XMLCh* const, MemoryManager* const manager);
virtual void parse(XMLDateTime* const);
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
DayDatatypeValidator(const DayDatatypeValidator&);
DayDatatypeValidator& operator=(const DayDatatypeValidator&);
};
XERCES_CPP_NAMESPACE_END
#endif
/**
* End of file DayDatatypeValidator.hpp
*/

View File

@@ -0,0 +1,218 @@
/*
* 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: DecimalDatatypeValidator.hpp 527149 2007-04-10 14:56:39Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_DECIMAL_DATATYPEVALIDATOR_HPP)
#define XERCESC_INCLUDE_GUARD_DECIMAL_DATATYPEVALIDATOR_HPP
#include <xercesc/validators/datatype/AbstractNumericValidator.hpp>
#include <xercesc/util/RefVectorOf.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class XMLBigDecimal;
class VALIDATORS_EXPORT DecimalDatatypeValidator : public AbstractNumericValidator
{
public:
// -----------------------------------------------------------------------
// Public ctor/dtor
// -----------------------------------------------------------------------
/** @name Constructors and Destructor */
//@{
DecimalDatatypeValidator
(
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
DecimalDatatypeValidator
(
DatatypeValidator* const baseValidator
, RefHashTableOf<KVStringPair>* const facets
, RefArrayVectorOf<XMLCh>* const enums
, const int finalSet
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
virtual ~DecimalDatatypeValidator();
//@}
// -----------------------------------------------------------------------
// Compare methods
// -----------------------------------------------------------------------
/** @name Compare Function */
//@{
/**
* Compare two boolean data types
*
* @param content1
* @param content2
* @return
*/
virtual int compare(const XMLCh* const, const XMLCh* const
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
//@}
/**
* Returns an instance of the base datatype validator class
* Used by the DatatypeValidatorFactory.
*/
virtual DatatypeValidator* newInstance
(
RefHashTableOf<KVStringPair>* const facets
, RefArrayVectorOf<XMLCh>* const enums
, const int finalSet
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
virtual const XMLCh* getCanonicalRepresentation
(
const XMLCh* const rawData
, MemoryManager* const memMgr = 0
, bool toValidate = false
) const;
/***
* Support for Serialization/De-serialization
***/
DECL_XSERIALIZABLE(DecimalDatatypeValidator)
protected:
// -----------------------------------------------------------------------
// ctor provided to be used by derived classes
// -----------------------------------------------------------------------
DecimalDatatypeValidator
(
DatatypeValidator* const baseValidator
, RefHashTableOf<KVStringPair>* const facets
, const int finalSet
, const ValidatorType type
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
// -----------------------------------------------------------------------
// Abstract interface from AbstractNumericFacetValidator
// -----------------------------------------------------------------------
virtual void assignAdditionalFacet(const XMLCh* const key
, const XMLCh* const value
, MemoryManager* const manager);
virtual void inheritAdditionalFacet();
virtual void checkAdditionalFacetConstraints(MemoryManager* const manager) const;
virtual void checkAdditionalFacetConstraintsBase(MemoryManager* const manager) const;
virtual int compareValues(const XMLNumber* const lValue
, const XMLNumber* const rValue);
virtual void setMaxInclusive(const XMLCh* const);
virtual void setMaxExclusive(const XMLCh* const);
virtual void setMinInclusive(const XMLCh* const);
virtual void setMinExclusive(const XMLCh* const);
virtual void setEnumeration(MemoryManager* const manager);
// -----------------------------------------------------------------------
// Abstract interface from AbstractNumericValidator
// -----------------------------------------------------------------------
virtual void checkContent(const XMLCh* const content
, ValidationContext* const context
, bool asBase
, MemoryManager* const manager);
public:
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
inline unsigned int getTotalDigits() const;
inline unsigned int getFractionDigits() const;
private:
// -----------------------------------------------------------------------
// Setter methods
// -----------------------------------------------------------------------
inline void setTotalDigits(unsigned int);
inline void setFractionDigits(unsigned int);
// -----------------------------------------------------------------------
// Private data members
//
// -----------------------------------------------------------------------
unsigned int fTotalDigits;
unsigned int fFractionDigits;
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
DecimalDatatypeValidator(const DecimalDatatypeValidator&);
DecimalDatatypeValidator& operator=(const DecimalDatatypeValidator&);
};
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
inline unsigned int DecimalDatatypeValidator::getTotalDigits() const
{
return fTotalDigits;
}
inline unsigned int DecimalDatatypeValidator::getFractionDigits() const
{
return fFractionDigits;
}
// -----------------------------------------------------------------------
// Setter methods
// -----------------------------------------------------------------------
inline void DecimalDatatypeValidator::setTotalDigits(unsigned int newTotalDigits)
{
fTotalDigits = newTotalDigits;
}
inline void DecimalDatatypeValidator::setFractionDigits(unsigned int newFractionDigits)
{
fFractionDigits = newFractionDigits;
}
XERCES_CPP_NAMESPACE_END
#endif
/**
* End of file DecimalDatatypeValidator.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: DoubleDatatypeValidator.hpp 527149 2007-04-10 14:56:39Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_DOUBLE_DATATYPEVALIDATOR_HPP)
#define XERCESC_INCLUDE_GUARD_DOUBLE_DATATYPEVALIDATOR_HPP
#include <xercesc/validators/datatype/AbstractNumericValidator.hpp>
#include <xercesc/util/RefVectorOf.hpp>
#include <xercesc/util/XMLDouble.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class VALIDATORS_EXPORT DoubleDatatypeValidator : public AbstractNumericValidator
{
public:
// -----------------------------------------------------------------------
// Public ctor/dtor
// -----------------------------------------------------------------------
/** @name Constructors and Destructor */
//@{
DoubleDatatypeValidator
(
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
DoubleDatatypeValidator
(
DatatypeValidator* const baseValidator
, RefHashTableOf<KVStringPair>* const facets
, RefArrayVectorOf<XMLCh>* const enums
, const int finalSet
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
virtual ~DoubleDatatypeValidator();
//@}
// -----------------------------------------------------------------------
// Compare methods
// -----------------------------------------------------------------------
/** @name Compare Function */
//@{
/**
* Compare two boolean data types
*
* @param content1
* @param content2
* @return
*/
virtual int compare(const XMLCh* const, const XMLCh* const
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
//@}
/**
* Returns an instance of the base datatype validator class
* Used by the DatatypeValidatorFactory.
*/
virtual DatatypeValidator* newInstance
(
RefHashTableOf<KVStringPair>* const facets
, RefArrayVectorOf<XMLCh>* const enums
, const int finalSet
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
/***
* Support for Serialization/De-serialization
***/
DECL_XSERIALIZABLE(DoubleDatatypeValidator)
protected:
// -----------------------------------------------------------------------
// ctor provided to be used by derived classes
// -----------------------------------------------------------------------
DoubleDatatypeValidator
(
DatatypeValidator* const baseValidator
, RefHashTableOf<KVStringPair>* const facets
, const int finalSet
, const ValidatorType type
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
// -----------------------------------------------------------------------
// Abstract interface from AbstractNumericFacetValidator
// -----------------------------------------------------------------------
virtual int compareValues(const XMLNumber* const lValue
, const XMLNumber* const rValue);
virtual void setMaxInclusive(const XMLCh* const);
virtual void setMaxExclusive(const XMLCh* const);
virtual void setMinInclusive(const XMLCh* const);
virtual void setMinExclusive(const XMLCh* const);
virtual void setEnumeration(MemoryManager* const manager);
// -----------------------------------------------------------------------
// Abstract interface from AbstractNumericValidator
// -----------------------------------------------------------------------
virtual void checkContent(const XMLCh* const content
, ValidationContext* const context
, bool asBase
, MemoryManager* const manager);
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
DoubleDatatypeValidator(const DoubleDatatypeValidator &);
DoubleDatatypeValidator& operator = (const DoubleDatatypeValidator&);
};
XERCES_CPP_NAMESPACE_END
#endif
/**
* End of file DoubleDatatypeValidator.hpp
*/

View File

@@ -0,0 +1,98 @@
/*
* 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: DurationDatatypeValidator.hpp 527149 2007-04-10 14:56:39Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_DURATION_DATATYPE_VALIDATOR_HPP)
#define XERCESC_INCLUDE_GUARD_DURATION_DATATYPE_VALIDATOR_HPP
#include <xercesc/validators/datatype/DateTimeValidator.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class VALIDATORS_EXPORT DurationDatatypeValidator : public DateTimeValidator
{
public:
// -----------------------------------------------------------------------
// Public ctor/dtor
// -----------------------------------------------------------------------
/** @name Constructors and Destructor. */
//@{
DurationDatatypeValidator
(
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
DurationDatatypeValidator
(
DatatypeValidator* const baseValidator
, RefHashTableOf<KVStringPair>* const facets
, RefArrayVectorOf<XMLCh>* const enums
, const int finalSet
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
~DurationDatatypeValidator();
//@}
/**
* Returns an instance of the base datatype validator class
* Used by the DatatypeValidatorFactory.
*/
virtual DatatypeValidator* newInstance
(
RefHashTableOf<KVStringPair>* const facets
, RefArrayVectorOf<XMLCh>* const enums
, const int finalSet
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
/***
* Support for Serialization/De-serialization
***/
DECL_XSERIALIZABLE(DurationDatatypeValidator)
protected:
// -----------------------------------------------------------------------
// implementation of (DateTimeValidator's) virtual interface
// -----------------------------------------------------------------------
virtual XMLDateTime* parse(const XMLCh* const, MemoryManager* const manager);
virtual void parse(XMLDateTime* const);
virtual int compareDates(const XMLDateTime* const
, const XMLDateTime* const
, bool );
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
DurationDatatypeValidator(const DurationDatatypeValidator &);
DurationDatatypeValidator& operator = (const DurationDatatypeValidator&);
};
XERCES_CPP_NAMESPACE_END
#endif
/**
* End of file DurationDatatypeValidator.hpp
*/

View File

@@ -0,0 +1,144 @@
/*
* 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: ENTITYDatatypeValidator.hpp 527149 2007-04-10 14:56:39Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_ENTITY_DATATYPEVALIDATOR_HPP)
#define XERCESC_INCLUDE_GUARD_ENTITY_DATATYPEVALIDATOR_HPP
#include <xercesc/validators/datatype/StringDatatypeValidator.hpp>
#include <xercesc/util/NameIdPool.hpp>
#include <xercesc/validators/DTD/DTDEntityDecl.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class VALIDATORS_EXPORT ENTITYDatatypeValidator : public StringDatatypeValidator
{
public:
// -----------------------------------------------------------------------
// Public ctor/dtor
// -----------------------------------------------------------------------
/** @name Constructors and Destructor. */
//@{
ENTITYDatatypeValidator
(
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
ENTITYDatatypeValidator
(
DatatypeValidator* const baseValidator
, RefHashTableOf<KVStringPair>* const facets
, RefArrayVectorOf<XMLCh>* const enums
, const int finalSet
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
virtual ~ENTITYDatatypeValidator();
//@}
// -----------------------------------------------------------------------
// Validation methods
// -----------------------------------------------------------------------
/** @name Validation Function */
//@{
/**
* validate that a string matches the boolean datatype
* @param content A string containing the content to be validated
*
* @exception throws InvalidDatatypeException if the content is
* is not valid.
*/
virtual void validate
(
const XMLCh* const content
, ValidationContext* const context = 0
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
//@}
// -----------------------------------------------------------------------
// Compare methods
// -----------------------------------------------------------------------
/** @name Compare Function */
//@{
/**
* Compare two boolean data types
*
* @param content1
* @param content2
* @return
*/
virtual int compare(const XMLCh* const, const XMLCh* const
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
//@}
/**
* Returns an instance of the base datatype validator class
* Used by the DatatypeValidatorFactory.
*/
virtual DatatypeValidator* newInstance
(
RefHashTableOf<KVStringPair>* const facets
, RefArrayVectorOf<XMLCh>* const enums
, const int finalSet
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
/***
* Support for Serialization/De-serialization
***/
DECL_XSERIALIZABLE(ENTITYDatatypeValidator)
protected:
//
// ctor provided to be used by derived classes
//
ENTITYDatatypeValidator(DatatypeValidator* const baseValidator
, RefHashTableOf<KVStringPair>* const facets
, const int finalSet
, const ValidatorType type);
virtual void checkValueSpace(const XMLCh* const content
, MemoryManager* const manager);
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
ENTITYDatatypeValidator(const ENTITYDatatypeValidator&);
ENTITYDatatypeValidator& operator = (const ENTITYDatatypeValidator&);
};
XERCES_CPP_NAMESPACE_END
#endif
/**
* End of file ENTITYDatatypeValidator.hpp
*/

View File

@@ -0,0 +1,145 @@
/*
* 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: FloatDatatypeValidator.hpp 527149 2007-04-10 14:56:39Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_FLOAT_DATATYPEVALIDATOR_HPP)
#define XERCESC_INCLUDE_GUARD_FLOAT_DATATYPEVALIDATOR_HPP
#include <xercesc/validators/datatype/AbstractNumericValidator.hpp>
#include <xercesc/util/RefVectorOf.hpp>
#include <xercesc/util/XMLFloat.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class VALIDATORS_EXPORT FloatDatatypeValidator : public AbstractNumericValidator
{
public:
// -----------------------------------------------------------------------
// Public ctor/dtor
// -----------------------------------------------------------------------
/** @name Constructors and Destructor */
//@{
FloatDatatypeValidator
(
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
FloatDatatypeValidator
(
DatatypeValidator* const baseValidator
, RefHashTableOf<KVStringPair>* const facets
, RefArrayVectorOf<XMLCh>* const enums
, const int finalSet
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
virtual ~FloatDatatypeValidator();
//@}
// -----------------------------------------------------------------------
// Compare methods
// -----------------------------------------------------------------------
/** @name Compare Function */
//@{
/**
* Compare two boolean data types
*
* @param content1
* @param content2
* @return
*/
virtual int compare(const XMLCh* const, const XMLCh* const
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
//@}
/**
* Returns an instance of the base datatype validator class
* Used by the DatatypeValidatorFactory.
*/
virtual DatatypeValidator* newInstance
(
RefHashTableOf<KVStringPair>* const facets
, RefArrayVectorOf<XMLCh>* const enums
, const int finalSet
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
/***
* Support for Serialization/De-serialization
***/
DECL_XSERIALIZABLE(FloatDatatypeValidator)
protected:
// -----------------------------------------------------------------------
// ctor provided to be used by derived classes
// -----------------------------------------------------------------------
FloatDatatypeValidator
(
DatatypeValidator* const baseValidator
, RefHashTableOf<KVStringPair>* const facets
, const int finalSet
, const ValidatorType type
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
// -----------------------------------------------------------------------
// Abstract interface from AbstractNumericFacetValidator
// -----------------------------------------------------------------------
virtual int compareValues(const XMLNumber* const lValue
, const XMLNumber* const rValue);
virtual void setMaxInclusive(const XMLCh* const);
virtual void setMaxExclusive(const XMLCh* const);
virtual void setMinInclusive(const XMLCh* const);
virtual void setMinExclusive(const XMLCh* const);
virtual void setEnumeration(MemoryManager* const manager);
// -----------------------------------------------------------------------
// Abstract interface from AbstractNumericValidator
// -----------------------------------------------------------------------
virtual void checkContent(const XMLCh* const content
, ValidationContext* const context
, bool asBase
, MemoryManager* const manager);
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
FloatDatatypeValidator(const FloatDatatypeValidator&);
FloatDatatypeValidator& operator = (const FloatDatatypeValidator&);
};
XERCES_CPP_NAMESPACE_END
#endif
/**
* End of file FloatDatatypeValidator.hpp
*/

View File

@@ -0,0 +1,101 @@
/*
* 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: HexBinaryDatatypeValidator.hpp 695949 2008-09-16 15:57:44Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_HEXBINARY_DATATYPEVALIDATOR_HPP)
#define XERCESC_INCLUDE_GUARD_HEXBINARY_DATATYPEVALIDATOR_HPP
#include <xercesc/validators/datatype/AbstractStringValidator.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class VALIDATORS_EXPORT HexBinaryDatatypeValidator : public AbstractStringValidator
{
public:
// -----------------------------------------------------------------------
// Public ctor/dtor
// -----------------------------------------------------------------------
/** @name Constructors and Destructor */
//@{
HexBinaryDatatypeValidator
(
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
HexBinaryDatatypeValidator
(
DatatypeValidator* const baseValidator
, RefHashTableOf<KVStringPair>* const facets
, RefArrayVectorOf<XMLCh>* const enums
, const int finalSet
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
virtual ~HexBinaryDatatypeValidator();
//@}
/**
* Returns an instance of the base datatype validator class
* Used by the DatatypeValidatorFactory.
*/
virtual DatatypeValidator* newInstance
(
RefHashTableOf<KVStringPair>* const facets
, RefArrayVectorOf<XMLCh>* const enums
, const int finalSet
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
/***
* Support for Serialization/De-serialization
***/
DECL_XSERIALIZABLE(HexBinaryDatatypeValidator)
protected:
virtual void checkValueSpace(const XMLCh* const content
, MemoryManager* const manager);
virtual XMLSize_t getLength(const XMLCh* const content
, MemoryManager* const manager) const;
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
HexBinaryDatatypeValidator(const HexBinaryDatatypeValidator&);
HexBinaryDatatypeValidator& operator=(const HexBinaryDatatypeValidator&);
// -----------------------------------------------------------------------
// Private data members
//
// Nil.
// -----------------------------------------------------------------------
};
XERCES_CPP_NAMESPACE_END
#endif
/**
* End of file HexBinaryDatatypeValidator.hpp
*/

View File

@@ -0,0 +1,132 @@
/*
* 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: IDDatatypeValidator.hpp 527149 2007-04-10 14:56:39Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_ID_DATATYPEVALIDATOR_HPP)
#define XERCESC_INCLUDE_GUARD_ID_DATATYPEVALIDATOR_HPP
#include <xercesc/validators/datatype/StringDatatypeValidator.hpp>
#include <xercesc/framework/XMLRefInfo.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class VALIDATORS_EXPORT IDDatatypeValidator : public StringDatatypeValidator
{
public:
// -----------------------------------------------------------------------
// Public ctor/dtor
// -----------------------------------------------------------------------
/** @name Constructors and Destructor */
//@{
IDDatatypeValidator
(
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
IDDatatypeValidator
(
DatatypeValidator* const baseValidator
, RefHashTableOf<KVStringPair>* const facets
, RefArrayVectorOf<XMLCh>* const enums
, const int finalSet
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
virtual ~IDDatatypeValidator();
//@}
// -----------------------------------------------------------------------
// Validation methods
// -----------------------------------------------------------------------
/** @name Validation Function */
//@{
/**
* validate that a string matches the boolean datatype
* @param content A string containing the content to be validated
*
* @exception throws InvalidDatatypeException if the content is
* is not valid.
*/
virtual void validate
(
const XMLCh* const content
, ValidationContext* const context = 0
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
/**
* Returns an instance of the base datatype validator class
* Used by the DatatypeValidatorFactory.
*/
virtual DatatypeValidator* newInstance
(
RefHashTableOf<KVStringPair>* const facets
, RefArrayVectorOf<XMLCh>* const enums
, const int finalSet
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
//@}
/***
* Support for Serialization/De-serialization
***/
DECL_XSERIALIZABLE(IDDatatypeValidator)
protected:
//
// ctor provided to be used by derived classes
//
IDDatatypeValidator
(
DatatypeValidator* const baseValidator
, RefHashTableOf<KVStringPair>* const facets
, const int finalSet
, const ValidatorType type
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
virtual void checkValueSpace(const XMLCh* const content
, MemoryManager* const manager);
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
IDDatatypeValidator(const IDDatatypeValidator&);
IDDatatypeValidator& operator=(const IDDatatypeValidator&);
// -----------------------------------------------------------------------
// Private data members
//
//
// -----------------------------------------------------------------------
};
XERCES_CPP_NAMESPACE_END
#endif
/**
* End of file IDDatatypeValidator.hpp
*/

View File

@@ -0,0 +1,135 @@
/*
* 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: IDREFDatatypeValidator.hpp 527149 2007-04-10 14:56:39Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_IDREF_DATATYPEVALIDATOR_HPP)
#define XERCESC_INCLUDE_GUARD_IDREF_DATATYPEVALIDATOR_HPP
#include <xercesc/validators/datatype/StringDatatypeValidator.hpp>
#include <xercesc/framework/XMLRefInfo.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class VALIDATORS_EXPORT IDREFDatatypeValidator : public StringDatatypeValidator
{
public:
// -----------------------------------------------------------------------
// Public ctor/dtor
// -----------------------------------------------------------------------
/** @name Constructors and Destructor */
//@{
IDREFDatatypeValidator
(
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
IDREFDatatypeValidator
(
DatatypeValidator* const baseValidator
, RefHashTableOf<KVStringPair>* const facets
, RefArrayVectorOf<XMLCh>* const enums
, const int finalSet
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
virtual ~IDREFDatatypeValidator();
//@}
// -----------------------------------------------------------------------
// Validation methods
// -----------------------------------------------------------------------
/** @name Validation Function */
//@{
/**
* validate that a string matches the boolean datatype
* @param content A string containing the content to be validated
*
* @exception throws InvalidDatatypeException if the content is
* is not valid.
*/
virtual void validate
(
const XMLCh* const content
, ValidationContext* const context = 0
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
//@}
/**
* Returns an instance of the base datatype validator class
* Used by the DatatypeValidatorFactory.
*/
virtual DatatypeValidator* newInstance
(
RefHashTableOf<KVStringPair>* const facets
, RefArrayVectorOf<XMLCh>* const enums
, const int finalSet
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
/***
* Support for Serialization/De-serialization
***/
DECL_XSERIALIZABLE(IDREFDatatypeValidator)
protected:
//
// ctor provided to be used by derived classes
//
IDREFDatatypeValidator
(
DatatypeValidator* const baseValidator
, RefHashTableOf<KVStringPair>* const facets
, const int finalSet
, const ValidatorType type
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
virtual void checkValueSpace(const XMLCh* const content
, MemoryManager* const manager);
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
IDREFDatatypeValidator(const IDREFDatatypeValidator&);
IDREFDatatypeValidator& operator=(const IDREFDatatypeValidator&);
// -----------------------------------------------------------------------
// Private data members
//
//
// -----------------------------------------------------------------------
};
XERCES_CPP_NAMESPACE_END
#endif
/**
* End of file IDREFDatatypeValidator.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: InvalidDatatypeFacetException.hpp 527149 2007-04-10 14:56:39Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_INVALIDDATATYPEFACETEXCEPTION_HPP)
#define XERCESC_INCLUDE_GUARD_INVALIDDATATYPEFACETEXCEPTION_HPP
#include <xercesc/util/XercesDefs.hpp>
#include <xercesc/util/XMLException.hpp>
XERCES_CPP_NAMESPACE_BEGIN
MakeXMLException(InvalidDatatypeFacetException, XMLUTIL_EXPORT)
XERCES_CPP_NAMESPACE_END
#endif

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: InvalidDatatypeValueException.hpp 527149 2007-04-10 14:56:39Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_INVALIDDATATYPEVALUEEXCEPTION_HPP)
#define XERCESC_INCLUDE_GUARD_INVALIDDATATYPEVALUEEXCEPTION_HPP
#include <xercesc/util/XercesDefs.hpp>
#include <xercesc/util/XMLException.hpp>
XERCES_CPP_NAMESPACE_BEGIN
MakeXMLException(InvalidDatatypeValueException, XMLUTIL_EXPORT)
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,226 @@
/*
* 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: ListDatatypeValidator.hpp 932887 2010-04-11 13:04:59Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_LIST_DATATYPEVALIDATOR_HPP)
#define XERCESC_INCLUDE_GUARD_LIST_DATATYPEVALIDATOR_HPP
#include <xercesc/validators/datatype/AbstractStringValidator.hpp>
#include <xercesc/validators/schema/SchemaSymbols.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class VALIDATORS_EXPORT ListDatatypeValidator : public AbstractStringValidator
{
public:
// -----------------------------------------------------------------------
// Public ctor/dtor
// -----------------------------------------------------------------------
/** @name Constructors and Destructor */
//@{
ListDatatypeValidator
(
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
ListDatatypeValidator
(
DatatypeValidator* const baseValidator
, RefHashTableOf<KVStringPair>* const facets
, RefArrayVectorOf<XMLCh>* const enums
, const int finalSet
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
virtual ~ListDatatypeValidator();
//@}
/** @name Getter Functions */
//@{
/**
* Returns whether the type is atomic or not
*/
virtual bool isAtomic() const;
virtual const XMLCh* getCanonicalRepresentation
(
const XMLCh* const rawData
, MemoryManager* const memMgr = 0
, bool toValidate = false
) const;
//@}
// -----------------------------------------------------------------------
// Validation methods
// -----------------------------------------------------------------------
/** @name Validation Function */
//@{
/**
* validate that a string matches the boolean datatype
* @param content A string containing the content to be validated
*
* @exception throws InvalidDatatypeException if the content is
* is not valid.
*/
virtual void validate
(
const XMLCh* const content
, ValidationContext* const context = 0
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
//@}
// -----------------------------------------------------------------------
// Compare methods
// -----------------------------------------------------------------------
/** @name Compare Function */
//@{
/**
* Compare two boolean data types
*
* @param content1
* @param content2
* @return
*/
int compare(const XMLCh* const, const XMLCh* const
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
//@}
/**
* Returns an instance of the base datatype validator class
* Used by the DatatypeValidatorFactory.
*/
virtual DatatypeValidator* newInstance
(
RefHashTableOf<KVStringPair>* const facets
, RefArrayVectorOf<XMLCh>* const enums
, const int finalSet
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
DatatypeValidator* getItemTypeDTV() const;
/***
* Support for Serialization/De-serialization
***/
DECL_XSERIALIZABLE(ListDatatypeValidator)
protected:
//
// ctor provided to be used by derived classes: No
//
virtual void checkValueSpace(const XMLCh* const content
, MemoryManager* const manager);
virtual XMLSize_t getLength(const XMLCh* const content
, MemoryManager* const manager) const;
//
// Overwrite AbstractStringValidator's
//
virtual void inspectFacetBase(MemoryManager* const manager);
virtual void inheritFacet();
virtual void checkContent(const XMLCh* const content
, ValidationContext* const context
, bool asBase
, MemoryManager* const manager);
private:
void checkContent( BaseRefVectorOf<XMLCh>* tokenVector
, const XMLCh* const content
, ValidationContext* const context
, bool asBase
, MemoryManager* const manager
);
bool valueSpaceCheck(BaseRefVectorOf<XMLCh>* tokenVector
, const XMLCh* const enumStr
, MemoryManager* const manager) const;
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
inline const XMLCh* getContent() const;
// -----------------------------------------------------------------------
// Setter methods
// -----------------------------------------------------------------------
inline void setContent(const XMLCh* const content);
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
ListDatatypeValidator(const ListDatatypeValidator&);
ListDatatypeValidator& operator=(const ListDatatypeValidator&);
// -----------------------------------------------------------------------
// Private data members
//
// fContent
// temporary var referencing the content to be validated,
// for error reporting purpose.
//
// -----------------------------------------------------------------------
const XMLCh* fContent;
};
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
inline const XMLCh* ListDatatypeValidator::getContent() const
{
return fContent;
}
inline bool ListDatatypeValidator::isAtomic() const
{
return false;
}
// -----------------------------------------------------------------------
// Setter methods
// -----------------------------------------------------------------------
inline void ListDatatypeValidator::setContent(const XMLCh* const content)
{
fContent = content;
}
XERCES_CPP_NAMESPACE_END
#endif
/**
* End of file ListDatatypeValidator.hpp
*/

View File

@@ -0,0 +1,95 @@
/*
* 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: MonthDatatypeValidator.hpp 527149 2007-04-10 14:56:39Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_MONTH_DATATYPE_VALIDATOR_HPP)
#define XERCESC_INCLUDE_GUARD_MONTH_DATATYPE_VALIDATOR_HPP
#include <xercesc/validators/datatype/DateTimeValidator.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class VALIDATORS_EXPORT MonthDatatypeValidator : public DateTimeValidator
{
public:
// -----------------------------------------------------------------------
// Public ctor/dtor
// -----------------------------------------------------------------------
/** @name Constructors and Destructor */
//@{
MonthDatatypeValidator
(
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
MonthDatatypeValidator
(
DatatypeValidator* const baseValidator
, RefHashTableOf<KVStringPair>* const facets
, RefArrayVectorOf<XMLCh>* const enums
, const int finalSet
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
~MonthDatatypeValidator();
//@}
/**
* Returns an instance of the base datatype validator class
* Used by the DatatypeValidatorFactory.
*/
virtual DatatypeValidator* newInstance
(
RefHashTableOf<KVStringPair>* const facets
, RefArrayVectorOf<XMLCh>* const enums
, const int finalSet
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
/***
* Support for Serialization/De-serialization
***/
DECL_XSERIALIZABLE(MonthDatatypeValidator)
protected:
// -----------------------------------------------------------------------
// implementation of (DateTimeValidator's) virtual interface
// -----------------------------------------------------------------------
virtual XMLDateTime* parse(const XMLCh* const, MemoryManager* const manager);
virtual void parse(XMLDateTime* const);
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
MonthDatatypeValidator(const MonthDatatypeValidator&);
MonthDatatypeValidator& operator=(const MonthDatatypeValidator&);
};
XERCES_CPP_NAMESPACE_END
#endif
/**
* End of file MonthDatatypeValidator.hpp
*/

View File

@@ -0,0 +1,95 @@
/*
* 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: MonthDayDatatypeValidator.hpp 527149 2007-04-10 14:56:39Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_MONTHDAY_DATATYPE_VALIDATOR_HPP)
#define XERCESC_INCLUDE_GUARD_MONTHDAY_DATATYPE_VALIDATOR_HPP
#include <xercesc/validators/datatype/DateTimeValidator.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class VALIDATORS_EXPORT MonthDayDatatypeValidator : public DateTimeValidator
{
public:
// -----------------------------------------------------------------------
// Public ctor/dtor
// -----------------------------------------------------------------------
/** @name Constructors and Destructor */
//@{
MonthDayDatatypeValidator
(
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
MonthDayDatatypeValidator
(
DatatypeValidator* const baseValidator
, RefHashTableOf<KVStringPair>* const facets
, RefArrayVectorOf<XMLCh>* const enums
, const int finalSet
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
~MonthDayDatatypeValidator();
//@}
/**
* Returns an instance of the base datatype validator class
* Used by the DatatypeValidatorFactory.
*/
virtual DatatypeValidator* newInstance
(
RefHashTableOf<KVStringPair>* const facets
, RefArrayVectorOf<XMLCh>* const enums
, const int finalSet
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
/***
* Support for Serialization/De-serialization
***/
DECL_XSERIALIZABLE(MonthDayDatatypeValidator)
protected:
// -----------------------------------------------------------------------
// implementation of (DateTimeValidator's) virtual interface
// -----------------------------------------------------------------------
virtual XMLDateTime* parse(const XMLCh* const, MemoryManager* const manager);
virtual void parse(XMLDateTime* const);
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
MonthDayDatatypeValidator(const MonthDayDatatypeValidator&);
MonthDayDatatypeValidator& operator=(const MonthDayDatatypeValidator&);
};
XERCES_CPP_NAMESPACE_END
#endif
/**
* End of file MonthDayDatatypeValidator.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: NCNameDatatypeValidator.hpp 527149 2007-04-10 14:56:39Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_NCNAME_DATATYPEVALIDATOR_HPP)
#define XERCESC_INCLUDE_GUARD_NCNAME_DATATYPEVALIDATOR_HPP
#include <xercesc/validators/datatype/StringDatatypeValidator.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class VALIDATORS_EXPORT NCNameDatatypeValidator : public StringDatatypeValidator
{
public:
// -----------------------------------------------------------------------
// Public ctor/dtor
// -----------------------------------------------------------------------
/** @name Constructors and Destructor */
//@{
NCNameDatatypeValidator
(
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
NCNameDatatypeValidator
(
DatatypeValidator* const baseValidator
, RefHashTableOf<KVStringPair>* const facets
, RefArrayVectorOf<XMLCh>* const enums
, const int finalSet
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
virtual ~NCNameDatatypeValidator();
//@}
// -----------------------------------------------------------------------
// Validation methods
// -----------------------------------------------------------------------
/** @name Validation Function */
//@{
/**
* validate that a string matches the boolean datatype
* @param content A string containing the content to be validated
*
* @exception throws InvalidDatatypeException if the content is
* is not valid.
*/
virtual void validate
(
const XMLCh* const content
, ValidationContext* const context = 0
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
//@}
// -----------------------------------------------------------------------
// Compare methods
// -----------------------------------------------------------------------
/** @name Compare Function */
//@{
/**
* Compare two boolean data types
*
* @param content1
* @param content2
* @return
*/
virtual int compare(const XMLCh* const, const XMLCh* const
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
//@}
/**
* Returns an instance of the base datatype validator class
* Used by the DatatypeValidatorFactory.
*/
virtual DatatypeValidator* newInstance
(
RefHashTableOf<KVStringPair>* const facets
, RefArrayVectorOf<XMLCh>* const enums
, const int finalSet
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
/***
* Support for Serialization/De-serialization
***/
DECL_XSERIALIZABLE(NCNameDatatypeValidator)
protected:
//
// ctor provided to be used by derived classes
//
NCNameDatatypeValidator
(
DatatypeValidator* const baseValidator
, RefHashTableOf<KVStringPair>* const facets
, const int finalSet
, const ValidatorType type
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
virtual void checkValueSpace(const XMLCh* const content
, MemoryManager* const manager);
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
NCNameDatatypeValidator(const NCNameDatatypeValidator&);
NCNameDatatypeValidator& operator=(const NCNameDatatypeValidator&);
// -----------------------------------------------------------------------
// Private data members
//
//
// -----------------------------------------------------------------------
};
XERCES_CPP_NAMESPACE_END
#endif
/**
* End of file NCNameDatatypeValidator.hpp
*/

View File

@@ -0,0 +1,103 @@
/*
* 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: NOTATIONDatatypeValidator.hpp 527149 2007-04-10 14:56:39Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_NOTATION_DATATYPEVALIDATOR_HPP)
#define XERCESC_INCLUDE_GUARD_NOTATION_DATATYPEVALIDATOR_HPP
#include <xercesc/validators/datatype/AbstractStringValidator.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class VALIDATORS_EXPORT NOTATIONDatatypeValidator : public AbstractStringValidator
{
public:
// -----------------------------------------------------------------------
// Public ctor/dtor
// -----------------------------------------------------------------------
/** @name Constructors and Destructor */
//@{
NOTATIONDatatypeValidator
(
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
NOTATIONDatatypeValidator
(
DatatypeValidator* const baseValidator
, RefHashTableOf<KVStringPair>* const facets
, RefArrayVectorOf<XMLCh>* const enums
, const int finalSet
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
virtual ~NOTATIONDatatypeValidator();
//@}
/**
* Returns an instance of the base datatype validator class
* Used by the DatatypeValidatorFactory.
*/
virtual DatatypeValidator* newInstance
(
RefHashTableOf<KVStringPair>* const facets
, RefArrayVectorOf<XMLCh>* const enums
, const int finalSet
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
/***
* Support for Serialization/De-serialization
***/
DECL_XSERIALIZABLE(NOTATIONDatatypeValidator)
protected:
virtual void checkValueSpace(const XMLCh* const content
, MemoryManager* const manager);
virtual void checkContent(const XMLCh* const content
, ValidationContext* const context
, bool asBase
, MemoryManager* const manager);
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
NOTATIONDatatypeValidator(const NOTATIONDatatypeValidator&);
NOTATIONDatatypeValidator& operator=(const NOTATIONDatatypeValidator&);
// -----------------------------------------------------------------------
// Private data members
//
// Nil
// -----------------------------------------------------------------------
};
XERCES_CPP_NAMESPACE_END
#endif
/**
* End of file NOTATIONDatatypeValidator.hpp
*/

View File

@@ -0,0 +1,151 @@
/*
* 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: NameDatatypeValidator.hpp 527149 2007-04-10 14:56:39Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_NAME_DATATYPEVALIDATOR_HPP)
#define XERCESC_INCLUDE_GUARD_NAME_DATATYPEVALIDATOR_HPP
#include <xercesc/validators/datatype/StringDatatypeValidator.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class VALIDATORS_EXPORT NameDatatypeValidator : public StringDatatypeValidator
{
public:
// -----------------------------------------------------------------------
// Public ctor/dtor
// -----------------------------------------------------------------------
/** @name Constructors and Destructor */
//@{
NameDatatypeValidator
(
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
NameDatatypeValidator
(
DatatypeValidator* const baseValidator
, RefHashTableOf<KVStringPair>* const facets
, RefArrayVectorOf<XMLCh>* const enums
, const int finalSet
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
virtual ~NameDatatypeValidator();
//@}
// -----------------------------------------------------------------------
// Validation methods
// -----------------------------------------------------------------------
/** @name Validation Function */
//@{
/**
* validate that a string matches the boolean datatype
* @param content A string containing the content to be validated
*
* @exception throws InvalidDatatypeException if the content is
* is not valid.
*/
virtual void validate
(
const XMLCh* const content
, ValidationContext* const context = 0
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
//@}
// -----------------------------------------------------------------------
// Compare methods
// -----------------------------------------------------------------------
/** @name Compare Function */
//@{
/**
* Compare two boolean data types
*
* @param content1
* @param content2
* @return
*/
virtual int compare(const XMLCh* const, const XMLCh* const
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
//@}
/**
* Returns an instance of the base datatype validator class
* Used by the DatatypeValidatorFactory.
*/
virtual DatatypeValidator* newInstance
(
RefHashTableOf<KVStringPair>* const facets
, RefArrayVectorOf<XMLCh>* const enums
, const int finalSet
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
/***
* Support for Serialization/De-serialization
***/
DECL_XSERIALIZABLE(NameDatatypeValidator)
protected:
//
// ctor provided to be used by derived classes
//
NameDatatypeValidator
(
DatatypeValidator* const baseValidator
, RefHashTableOf<KVStringPair>* const facets
, const int finalSet
, const ValidatorType type
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
virtual void checkValueSpace(const XMLCh* const content
, MemoryManager* const manager);
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
NameDatatypeValidator(const NameDatatypeValidator&);
NameDatatypeValidator& operator=(const NameDatatypeValidator&);
// -----------------------------------------------------------------------
// Private data members
//
//
// -----------------------------------------------------------------------
};
XERCES_CPP_NAMESPACE_END
#endif
/**
* End of file NameDatatypeValidator.hpp
*/

View File

@@ -0,0 +1,106 @@
/*
* 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: QNameDatatypeValidator.hpp 577322 2007-09-19 14:58:04Z cargilld $
*/
#if !defined(XERCESC_INCLUDE_GUARD_QNAME_DATATYPEVALIDATOR_HPP)
#define XERCESC_INCLUDE_GUARD_QNAME_DATATYPEVALIDATOR_HPP
#include <xercesc/validators/datatype/AbstractStringValidator.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class VALIDATORS_EXPORT QNameDatatypeValidator : public AbstractStringValidator
{
public:
// -----------------------------------------------------------------------
// Public ctor/dtor
// -----------------------------------------------------------------------
/** @name Constructors and Destructor */
//@{
QNameDatatypeValidator
(
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
QNameDatatypeValidator
(
DatatypeValidator* const baseValidator
, RefHashTableOf<KVStringPair>* const facets
, RefArrayVectorOf<XMLCh>* const enums
, const int finalSet
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
virtual ~QNameDatatypeValidator();
//@}
/**
* Returns an instance of the base datatype validator class
* Used by the DatatypeValidatorFactory.
*/
virtual DatatypeValidator* newInstance
(
RefHashTableOf<KVStringPair>* const facets
, RefArrayVectorOf<XMLCh>* const enums
, const int finalSet
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
/***
* Support for Serialization/De-serialization
***/
DECL_XSERIALIZABLE(QNameDatatypeValidator)
protected:
virtual void checkValueSpace(const XMLCh* const content
, MemoryManager* const manager);
virtual void checkContent(const XMLCh* const content
, ValidationContext* const context
, bool asBase
, MemoryManager* const manager);
virtual void inspectFacetBase(MemoryManager* const manager);
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
QNameDatatypeValidator(const QNameDatatypeValidator&);
QNameDatatypeValidator& operator=(const QNameDatatypeValidator&);
// -----------------------------------------------------------------------
// Private data members
//
// Nil
// -----------------------------------------------------------------------
};
XERCES_CPP_NAMESPACE_END
#endif
/**
* End of file QNameDatatypeValidator.hpp
*/

View File

@@ -0,0 +1,114 @@
/*
* 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: StringDatatypeValidator.hpp 527149 2007-04-10 14:56:39Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_STRING_DATATYPEVALIDATOR_HPP)
#define XERCESC_INCLUDE_GUARD_STRING_DATATYPEVALIDATOR_HPP
#include <xercesc/validators/datatype/AbstractStringValidator.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class VALIDATORS_EXPORT StringDatatypeValidator : public AbstractStringValidator
{
public:
// -----------------------------------------------------------------------
// Public ctor/dtor
// -----------------------------------------------------------------------
/** @name Constructors and Destructor */
//@{
StringDatatypeValidator
(
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
StringDatatypeValidator
(
DatatypeValidator* const baseValidator
, RefHashTableOf<KVStringPair>* const facets
, RefArrayVectorOf<XMLCh>* const enums
, const int finalSet
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
virtual ~StringDatatypeValidator();
//@}
/**
* Returns an instance of the base datatype validator class
* Used by the DatatypeValidatorFactory.
*/
virtual DatatypeValidator* newInstance
(
RefHashTableOf<KVStringPair>* const facets
, RefArrayVectorOf<XMLCh>* const enums
, const int finalSet
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
/***
* Support for Serialization/De-serialization
***/
DECL_XSERIALIZABLE(StringDatatypeValidator)
protected:
//
// ctor provided to be used by derived classes
//
StringDatatypeValidator
(
DatatypeValidator* const baseValidator
, RefHashTableOf<KVStringPair>* const facets
, const int finalSet
, const ValidatorType type
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
virtual void assignAdditionalFacet(const XMLCh* const key
, const XMLCh* const value
, MemoryManager* const manager);
virtual void inheritAdditionalFacet();
virtual void checkAdditionalFacetConstraints(MemoryManager* const manager) const;
virtual void checkAdditionalFacet(const XMLCh* const content
, MemoryManager* const manager) const;
virtual void checkValueSpace(const XMLCh* const content
, MemoryManager* const manager);
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
StringDatatypeValidator(const StringDatatypeValidator&);
StringDatatypeValidator& operator=(const StringDatatypeValidator&);
};
XERCES_CPP_NAMESPACE_END
#endif
/**
* End of file StringDatatypeValidator.hpp
*/

View File

@@ -0,0 +1,104 @@
/*
* 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: TimeDatatypeValidator.hpp 527149 2007-04-10 14:56:39Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_TIME_DATATYPE_VALIDATOR_HPP)
#define XERCESC_INCLUDE_GUARD_TIME_DATATYPE_VALIDATOR_HPP
#include <xercesc/validators/datatype/DateTimeValidator.hpp>
#include <xercesc/util/RefVectorOf.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class VALIDATORS_EXPORT TimeDatatypeValidator : public DateTimeValidator
{
public:
// -----------------------------------------------------------------------
// Public ctor/dtor
// -----------------------------------------------------------------------
/** @name Constructors and Destructor */
//@{
TimeDatatypeValidator
(
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
TimeDatatypeValidator
(
DatatypeValidator* const baseValidator
, RefHashTableOf<KVStringPair>* const facets
, RefArrayVectorOf<XMLCh>* const enums
, const int finalSet
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
~TimeDatatypeValidator();
//@}
/**
* Returns an instance of the base datatype validator class
* Used by the DatatypeValidatorFactory.
*/
virtual DatatypeValidator* newInstance
(
RefHashTableOf<KVStringPair>* const facets
, RefArrayVectorOf<XMLCh>* const enums
, const int finalSet
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
virtual const XMLCh* getCanonicalRepresentation
(
const XMLCh* const rawData
, MemoryManager* const memMgr = 0
, bool toValidate = false
) const;
/***
* Support for Serialization/De-serialization
***/
DECL_XSERIALIZABLE(TimeDatatypeValidator)
protected:
// -----------------------------------------------------------------------
// implementation of (DateTimeValidator's) virtual interface
// -----------------------------------------------------------------------
virtual XMLDateTime* parse(const XMLCh* const, MemoryManager* const manager);
virtual void parse(XMLDateTime* const);
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
TimeDatatypeValidator(const TimeDatatypeValidator&);
TimeDatatypeValidator& operator=(const TimeDatatypeValidator&);
};
XERCES_CPP_NAMESPACE_END
#endif
/**
* End of file TimeDatatypeValidator.hpp
*/

View File

@@ -0,0 +1,320 @@
/*
* 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: UnionDatatypeValidator.hpp 676911 2008-07-15 13:27:32Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_UNION_DATATYPEVALIDATOR_HPP)
#define XERCESC_INCLUDE_GUARD_UNION_DATATYPEVALIDATOR_HPP
#include <xercesc/validators/datatype/DatatypeValidator.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class VALIDATORS_EXPORT UnionDatatypeValidator : public DatatypeValidator
{
public:
// -----------------------------------------------------------------------
// Public ctor/dtor
// -----------------------------------------------------------------------
/** @name Constructors and Destructor. */
//@{
UnionDatatypeValidator
(
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
//
// constructor for native Union datatype validator
// <simpleType name="nativeUnion">
// <union memberTypes="member1 member2 ...">
// </simpleType>
//
UnionDatatypeValidator
(
RefVectorOf<DatatypeValidator>* const memberTypeValidators
, const int finalSet
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
//
// constructor for derived Union datatype validator
// <simpleType name="derivedUnion">
// <restriction base="nativeUnion">
// <pattern value="patter_value"/>
// <enumeration value="enum_value"/>
// </restriction>
// </simpleType>
//
UnionDatatypeValidator
(
DatatypeValidator* const baseValidator
, RefHashTableOf<KVStringPair>* const facets
, RefArrayVectorOf<XMLCh>* const enums
, const int finalSet
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
, RefVectorOf<DatatypeValidator>* const memberTypeValidators = 0
, const bool memberTypesInherited = true
);
virtual ~UnionDatatypeValidator();
//@}
virtual const RefArrayVectorOf<XMLCh>* getEnumString() const;
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
/** @name Getter Functions */
//@{
/**
* Returns whether the type is atomic or not
*/
virtual bool isAtomic() const;
virtual const XMLCh* getCanonicalRepresentation
(
const XMLCh* const rawData
, MemoryManager* const memMgr = 0
, bool toValidate = false
) const;
//@}
// -----------------------------------------------------------------------
// Validation methods
// -----------------------------------------------------------------------
/** @name Validation Function */
//@{
/**
* validate that a string matches the boolean datatype
* @param content A string containing the content to be validated
*
* @exception throws InvalidDatatypeException if the content is
* is not valid.
*/
virtual void validate
(
const XMLCh* const content
, ValidationContext* const context = 0
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
/**
* Checks whether a given type can be used as a substitute
*
* @param toCheck A datatype validator of the type to be used as a
* substitute
*
* To be redefined in UnionDatatypeValidator
*/
virtual bool isSubstitutableBy(const DatatypeValidator* const toCheck);
//@}
// -----------------------------------------------------------------------
// Compare methods
// -----------------------------------------------------------------------
/** @name Compare Function */
//@{
/**
* Compare two boolean data types
*
* @param content1
* @param content2
* @return
*/
int compare(const XMLCh* const, const XMLCh* const
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
//@}
/**
* Returns an instance of the base datatype validator class
* Used by the DatatypeValidatorFactory.
*/
virtual DatatypeValidator* newInstance
(
RefHashTableOf<KVStringPair>* const facets
, RefArrayVectorOf<XMLCh>* const enums
, const int finalSet
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
/***
* Support for Serialization/De-serialization
***/
DECL_XSERIALIZABLE(UnionDatatypeValidator)
RefVectorOf<DatatypeValidator>* getMemberTypeValidators() const;
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
UnionDatatypeValidator(const UnionDatatypeValidator&);
UnionDatatypeValidator& operator=(const UnionDatatypeValidator&);
virtual void checkContent(const XMLCh* const content
, ValidationContext* const context
, bool asBase
, MemoryManager* const manager);
void init(DatatypeValidator* const baseValidator
, RefHashTableOf<KVStringPair>* const facets
, RefArrayVectorOf<XMLCh>* const enums
, MemoryManager* const manager);
void cleanUp();
RefArrayVectorOf<XMLCh>* getEnumeration() const;
void setEnumeration(RefArrayVectorOf<XMLCh>*, bool);
// -----------------------------------------------------------------------
// Private data members
//
// fEnumeration
// we own it (or not, depending on state of fEnumerationInherited).
//
// fMemberTypeValidators
// we own it (or not, depending on the state of fMemberTypesInherited).
//
// -----------------------------------------------------------------------
bool fEnumerationInherited;
bool fMemberTypesInherited;
RefArrayVectorOf<XMLCh>* fEnumeration;
RefVectorOf<DatatypeValidator>* fMemberTypeValidators;
};
inline DatatypeValidator* UnionDatatypeValidator::newInstance
(
RefHashTableOf<KVStringPair>* const facets
, RefArrayVectorOf<XMLCh>* const enums
, const int finalSet
, MemoryManager* const manager
)
{
return (DatatypeValidator*) new (manager) UnionDatatypeValidator(this, facets, enums, finalSet, manager, fMemberTypeValidators, true);
}
inline void UnionDatatypeValidator::validate( const XMLCh* const content
, ValidationContext* const context
, MemoryManager* const manager)
{
checkContent(content, context, false, manager);
}
inline void UnionDatatypeValidator::cleanUp()
{
//~RefVectorOf will delete all adopted elements
if ( !fEnumerationInherited && fEnumeration)
delete fEnumeration;
if (!fMemberTypesInherited && fMemberTypeValidators)
delete fMemberTypeValidators;
}
inline RefArrayVectorOf<XMLCh>* UnionDatatypeValidator:: getEnumeration() const
{
return fEnumeration;
}
inline void UnionDatatypeValidator::setEnumeration(RefArrayVectorOf<XMLCh>* enums
, bool inherited)
{
if (enums)
{
if ( !fEnumerationInherited && fEnumeration)
delete fEnumeration;
fEnumeration = enums;
fEnumerationInherited = inherited;
setFacetsDefined(DatatypeValidator::FACET_ENUMERATION);
}
}
//
// get the native UnionDTV's fMemberTypeValidators
//
inline
RefVectorOf<DatatypeValidator>* UnionDatatypeValidator::getMemberTypeValidators() const
{
return this->fMemberTypeValidators;
}
inline bool UnionDatatypeValidator::isAtomic() const {
if (!fMemberTypeValidators) {
return false;
}
XMLSize_t memberSize = fMemberTypeValidators->size();
for (XMLSize_t i=0; i < memberSize; i++) {
if (!fMemberTypeValidators->elementAt(i)->isAtomic()) {
return false;
}
}
return true;
}
inline bool UnionDatatypeValidator::isSubstitutableBy(const DatatypeValidator* const toCheck) {
if (toCheck == this) {
return true;
}
if (fMemberTypeValidators) {
XMLSize_t memberSize = fMemberTypeValidators->size();
for (XMLSize_t i=0; i < memberSize; i++) {
if ((fMemberTypeValidators->elementAt(i)->getType() == DatatypeValidator::Union) &&
(fMemberTypeValidators->elementAt(i) == toCheck))
return false;
if (fMemberTypeValidators->elementAt(i)->isSubstitutableBy(toCheck)) {
return true;
}
}
}
return false;
}
XERCES_CPP_NAMESPACE_END
#endif
/**
* End of file UnionDatatypeValidator.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: XMLCanRepGroup.hpp 932887 2010-04-11 13:04:59Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_XMLCANREPGROUP_HPP)
#define XERCESC_INCLUDE_GUARD_XMLCANREPGROUP_HPP
#include <xercesc/util/PlatformUtils.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class VALIDATORS_EXPORT XMLCanRepGroup : public XMemory
{
public:
enum CanRepGroup {
Boolean,
DoubleFloat,
DateTime,
Time,
Decimal,
Decimal_Derived_signed,
Decimal_Derived_unsigned,
Decimal_Derived_npi,
String
};
~XMLCanRepGroup();
XMLCanRepGroup(CanRepGroup val);
inline CanRepGroup getGroup() const;
private:
CanRepGroup fData;
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
XMLCanRepGroup(const XMLCanRepGroup&);
XMLCanRepGroup& operator=(const XMLCanRepGroup&);
};
inline XMLCanRepGroup::CanRepGroup XMLCanRepGroup::getGroup() const
{
return fData;
}
XERCES_CPP_NAMESPACE_END
#endif
/**
* End of file XMLCanRepGroup.hpp
*/

View File

@@ -0,0 +1,95 @@
/*
* 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: YearDatatypeValidator.hpp 527149 2007-04-10 14:56:39Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_YEAR_DATATYPE_VALIDATOR_HPP)
#define XERCESC_INCLUDE_GUARD_YEAR_DATATYPE_VALIDATOR_HPP
#include <xercesc/validators/datatype/DateTimeValidator.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class VALIDATORS_EXPORT YearDatatypeValidator : public DateTimeValidator
{
public:
// -----------------------------------------------------------------------
// Public ctor/dtor
// -----------------------------------------------------------------------
/** @name Constructors and Destructor */
//@{
YearDatatypeValidator
(
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
YearDatatypeValidator
(
DatatypeValidator* const baseValidator
, RefHashTableOf<KVStringPair>* const facets
, RefArrayVectorOf<XMLCh>* const enums
, const int finalSet
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
~YearDatatypeValidator();
//@}
/**
* Returns an instance of the base datatype validator class
* Used by the DatatypeValidatorFactory.
*/
virtual DatatypeValidator* newInstance
(
RefHashTableOf<KVStringPair>* const facets
, RefArrayVectorOf<XMLCh>* const enums
, const int finalSet
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
/***
* Support for Serialization/De-serialization
***/
DECL_XSERIALIZABLE(YearDatatypeValidator)
protected:
// -----------------------------------------------------------------------
// implementation of (DateTimeValidator's) virtual interface
// -----------------------------------------------------------------------
virtual XMLDateTime* parse(const XMLCh* const, MemoryManager* const manager);
virtual void parse(XMLDateTime* const);
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
YearDatatypeValidator(const YearDatatypeValidator&);
YearDatatypeValidator& operator=(const YearDatatypeValidator&);
};
XERCES_CPP_NAMESPACE_END
#endif
/**
* End of file YearDatatypeValidator.hpp
*/

View File

@@ -0,0 +1,95 @@
/*
* 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: YearMonthDatatypeValidator.hpp 527149 2007-04-10 14:56:39Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_YEARMONTH_DATATYPE_VALIDATOR_HPP)
#define XERCESC_INCLUDE_GUARD_YEARMONTH_DATATYPE_VALIDATOR_HPP
#include <xercesc/validators/datatype/DateTimeValidator.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class VALIDATORS_EXPORT YearMonthDatatypeValidator : public DateTimeValidator
{
public:
// -----------------------------------------------------------------------
// Public ctor/dtor
// -----------------------------------------------------------------------
/** @name Constructors and Destructor */
//@{
YearMonthDatatypeValidator
(
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
YearMonthDatatypeValidator
(
DatatypeValidator* const baseValidator
, RefHashTableOf<KVStringPair>* const facets
, RefArrayVectorOf<XMLCh>* const enums
, const int finalSet
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
~YearMonthDatatypeValidator();
//@}
/**
* Returns an instance of the base datatype validator class
* Used by the DatatypeValidatorFactory.
*/
virtual DatatypeValidator* newInstance
(
RefHashTableOf<KVStringPair>* const facets
, RefArrayVectorOf<XMLCh>* const enums
, const int finalSet
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
/***
* Support for Serialization/De-serialization
***/
DECL_XSERIALIZABLE(YearMonthDatatypeValidator)
protected:
// -----------------------------------------------------------------------
// implementation of (DateTimeValidator's) virtual interface
// -----------------------------------------------------------------------
virtual XMLDateTime* parse(const XMLCh* const, MemoryManager* const manager);
virtual void parse(XMLDateTime* const);
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
YearMonthDatatypeValidator(const YearMonthDatatypeValidator&);
YearMonthDatatypeValidator& operator=(const YearMonthDatatypeValidator&);
};
XERCES_CPP_NAMESPACE_END
#endif
/**
* End of file YearMonthDatatypeValidator.hpp
*/

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
*/