Added Xerces-C++ 3.1.2

This commit is contained in:
sippeangelo
2015-12-01 10:23:50 +01:00
parent 65d3f3bc31
commit 1b478d3159
815 changed files with 262638 additions and 0 deletions
@@ -0,0 +1,124 @@
/*
* 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.cpp 679340 2008-07-24 10:28:29Z borisk $
*/
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <xercesc/validators/schema/identity/FieldActivator.hpp>
#include <xercesc/validators/schema/identity/ValueStore.hpp>
#include <xercesc/validators/schema/identity/ValueStoreCache.hpp>
#include <xercesc/validators/schema/identity/XPathMatcherStack.hpp>
XERCES_CPP_NAMESPACE_BEGIN
// ---------------------------------------------------------------------------
// FieldActivator: Constructors and Destructor
// ---------------------------------------------------------------------------
FieldActivator::FieldActivator(ValueStoreCache* const valueStoreCache,
XPathMatcherStack* const matcherStack,
MemoryManager* const manager)
: fValueStoreCache(valueStoreCache)
, fMatcherStack(matcherStack)
, fMayMatch(0)
, fMemoryManager(manager)
{
fMayMatch = new (manager) ValueHashTableOf<bool, PtrHasher>(29, manager);
}
FieldActivator::FieldActivator(const FieldActivator& other)
: XMemory(other)
, fValueStoreCache(other.fValueStoreCache)
, fMatcherStack(other.fMatcherStack)
, fMayMatch(0)
, fMemoryManager(other.fMemoryManager)
{
fMayMatch = new (fMemoryManager) ValueHashTableOf<bool, PtrHasher>(29, fMemoryManager);
ValueHashTableOfEnumerator<bool, PtrHasher> mayMatchEnum(other.fMayMatch, false, fMemoryManager);
// Build key set
while (mayMatchEnum.hasMoreElements())
{
IC_Field* field = (IC_Field*) mayMatchEnum.nextElementKey();
fMayMatch->put(field, other.fMayMatch->get(field));
}
}
FieldActivator::~FieldActivator()
{
delete fMayMatch;
}
// ---------------------------------------------------------------------------
// FieldActivator: Operator methods
// ---------------------------------------------------------------------------
FieldActivator& FieldActivator::operator =(const FieldActivator& other) {
if (this == &other) {
return *this;
}
fValueStoreCache = other.fValueStoreCache;
fMatcherStack = other.fMatcherStack;
return *this;
}
// ---------------------------------------------------------------------------
// FieldActivator: Operator methods
// ---------------------------------------------------------------------------
XPathMatcher* FieldActivator::activateField(IC_Field* const field, const int initialDepth) {
ValueStore* valueStore = fValueStoreCache->getValueStoreFor(field, initialDepth);
XPathMatcher* matcher = field->createMatcher(this, valueStore, fMemoryManager);
setMayMatch(field, true);
fMatcherStack->addMatcher(matcher);
matcher->startDocumentFragment();
return matcher;
}
void FieldActivator::startValueScopeFor(const IdentityConstraint* const ic,
const int initialDepth) {
XMLSize_t fieldCount = ic->getFieldCount();
for(XMLSize_t i=0; i<fieldCount; i++) {
const IC_Field* field = ic->getFieldAt(i);
ValueStore* valueStore = fValueStoreCache->getValueStoreFor(field, initialDepth);
valueStore->startValueScope();
}
}
void FieldActivator::endValueScopeFor(const IdentityConstraint* const ic, const int initialDepth) {
ValueStore* valueStore = fValueStoreCache->getValueStoreFor(ic, initialDepth);
valueStore->endValueScope();
}
XERCES_CPP_NAMESPACE_END
/**
* End of file FieldActivator.cpp
*/
@@ -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
*/
@@ -0,0 +1,127 @@
/*
* 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.cpp 708224 2008-10-27 16:02:26Z amassari $
*/
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <xercesc/validators/schema/identity/FieldValueMap.hpp>
#include <xercesc/util/Janitor.hpp>
#include <xercesc/util/OutOfMemoryException.hpp>
XERCES_CPP_NAMESPACE_BEGIN
typedef JanitorMemFunCall<FieldValueMap> CleanupType;
// ---------------------------------------------------------------------------
// FieldValueMap: Constructors and Destructor
// ---------------------------------------------------------------------------
FieldValueMap::FieldValueMap(MemoryManager* const manager)
: fFields(0)
, fValidators(0)
, fValues(0)
, fMemoryManager(manager)
{
}
FieldValueMap::FieldValueMap(const FieldValueMap& other)
: XMemory(other)
, fFields(0)
, fValidators(0)
, fValues(0)
, fMemoryManager(other.fMemoryManager)
{
if (other.fFields) {
CleanupType cleanup(this, &FieldValueMap::cleanUp);
try {
XMLSize_t valuesSize = other.fValues->size();
fFields = new (fMemoryManager) ValueVectorOf<IC_Field*>(*(other.fFields));
fValidators = new (fMemoryManager) ValueVectorOf<DatatypeValidator*>(*(other.fValidators));
fValues = new (fMemoryManager) RefArrayVectorOf<XMLCh>(other.fFields->curCapacity(), true, fMemoryManager);
for (XMLSize_t i=0; i<valuesSize; i++) {
fValues->addElement(XMLString::replicate(other.fValues->elementAt(i), fMemoryManager));
}
}
catch(const OutOfMemoryException&)
{
cleanup.release();
throw;
}
cleanup.release();
}
}
FieldValueMap::~FieldValueMap()
{
cleanUp();
}
// ---------------------------------------------------------------------------
// FieldValueMap: Private helper methods.
// ---------------------------------------------------------------------------
void FieldValueMap::cleanUp()
{
delete fFields;
delete fValidators;
delete fValues;
}
// ---------------------------------------------------------------------------
// FieldValueMap: Helper methods
// ---------------------------------------------------------------------------
bool FieldValueMap::indexOf(const IC_Field* const key, XMLSize_t& location) const {
if (fFields) {
XMLSize_t fieldSize = fFields->size();
for (XMLSize_t i=0; i < fieldSize; i++) {
if (fFields->elementAt(i) == key) {
location=i;
return true;
}
}
}
return false;
}
void FieldValueMap::clear()
{
if(fFields)
fFields->removeAllElements();
if(fValidators)
fValidators->removeAllElements();
if(fValues)
fValues->removeAllElements();
}
XERCES_CPP_NAMESPACE_END
/**
* End of file FieldValueMap.cpp
*/
@@ -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
*/
@@ -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: IC_Field.cpp 471747 2006-11-06 14:31:56Z amassari $
*/
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <xercesc/validators/schema/identity/FieldActivator.hpp>
#include <xercesc/validators/schema/identity/IC_Field.hpp>
#include <xercesc/validators/schema/identity/ValueStore.hpp>
#include <xercesc/validators/schema/identity/XercesXPath.hpp>
#include <xercesc/validators/schema/identity/IdentityConstraint.hpp>
XERCES_CPP_NAMESPACE_BEGIN
// ---------------------------------------------------------------------------
// FieldMatcher: Constructors and Destructor
// ---------------------------------------------------------------------------
FieldMatcher::FieldMatcher(XercesXPath* const xpath,
IC_Field* const aField,
ValueStore* const valueStore,
FieldActivator* const fieldActivator,
MemoryManager* const manager)
: XPathMatcher(xpath, (IdentityConstraint*) 0, manager)
, fValueStore(valueStore)
, fField(aField)
, fFieldActivator(fieldActivator)
{
}
// ---------------------------------------------------------------------------
// FieldMatcher: Match methods
// ---------------------------------------------------------------------------
void FieldMatcher::matched(const XMLCh* const content,
DatatypeValidator* const dv,
const bool isNil) {
if(isNil) {
fValueStore->reportNilError(fField->getIdentityConstraint());
}
fValueStore->addValue(fFieldActivator, fField, dv, content);
// once we've stored the value for this field, we set the mayMatch
// member to false so that, in the same scope, we don't match any more
// values (and throw an error instead).
fFieldActivator->setMayMatch(fField, false);
}
// ---------------------------------------------------------------------------
// IC_Field: Constructors and Destructor
// ---------------------------------------------------------------------------
IC_Field::IC_Field(XercesXPath* const xpath,
IdentityConstraint* const identityConstraint)
: fXPath(xpath)
, fIdentityConstraint(identityConstraint)
{
}
IC_Field::~IC_Field()
{
delete fXPath;
}
// ---------------------------------------------------------------------------
// IC_Field: operators
// ---------------------------------------------------------------------------
bool IC_Field::operator== (const IC_Field& other) const {
return (*fXPath == *(other.fXPath));
}
bool IC_Field::operator!= (const IC_Field& other) const {
return !operator==(other);
}
// ---------------------------------------------------------------------------
// IC_Field: Factory methods
// ---------------------------------------------------------------------------
XPathMatcher* IC_Field::createMatcher(FieldActivator* const fieldActivator,
ValueStore* const valueStore,
MemoryManager* const manager)
{
return new (manager) FieldMatcher(fXPath, this, valueStore, fieldActivator, manager);
}
/***
* Support for Serialization/De-serialization
***/
IMPL_XSERIALIZABLE_TOCREATE(IC_Field)
void IC_Field::serialize(XSerializeEngine& serEng)
{
if (serEng.isStoring())
{
serEng<<fXPath;
IdentityConstraint::storeIC(serEng, fIdentityConstraint);
}
else
{
serEng>>fXPath;
fIdentityConstraint = IdentityConstraint::loadIC(serEng);
}
}
IC_Field::IC_Field(MemoryManager* const )
:fXPath(0)
,fIdentityConstraint(0)
{
}
XERCES_CPP_NAMESPACE_END
/**
* End of file IC_Field.cpp
*/
@@ -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
*/
@@ -0,0 +1,67 @@
/*
* 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.cpp 471747 2006-11-06 14:31:56Z amassari $
*/
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <xercesc/validators/schema/identity/IC_Key.hpp>
XERCES_CPP_NAMESPACE_BEGIN
// ---------------------------------------------------------------------------
// IC_Key: Constructors and Destructor
// ---------------------------------------------------------------------------
IC_Key::IC_Key(const XMLCh* const identityConstraintName,
const XMLCh* const elemName,
MemoryManager* const manager)
:IdentityConstraint(identityConstraintName, elemName, manager)
{
}
IC_Key::~IC_Key()
{
}
/***
* Support for Serialization/De-serialization
***/
IMPL_XSERIALIZABLE_TOCREATE(IC_Key)
void IC_Key::serialize(XSerializeEngine& serEng)
{
IdentityConstraint::serialize(serEng);
//no data
}
IC_Key::IC_Key(MemoryManager* const manager)
:IdentityConstraint(0, 0, manager)
{
}
XERCES_CPP_NAMESPACE_END
/**
* End of file IC_Key.cpp
*/
@@ -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
*/
@@ -0,0 +1,79 @@
/*
* 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.cpp 471747 2006-11-06 14:31:56Z amassari $
*/
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <xercesc/validators/schema/identity/IC_KeyRef.hpp>
XERCES_CPP_NAMESPACE_BEGIN
// ---------------------------------------------------------------------------
// IC_KeyRef: Constructors and Destructor
// ---------------------------------------------------------------------------
IC_KeyRef::IC_KeyRef(const XMLCh* const identityConstraintName,
const XMLCh* const elemName,
IdentityConstraint* const icKey,
MemoryManager* const manager)
: IdentityConstraint(identityConstraintName, elemName, manager)
, fKey(icKey)
{
}
IC_KeyRef::~IC_KeyRef()
{
}
/***
* Support for Serialization/De-serialization
***/
IMPL_XSERIALIZABLE_TOCREATE(IC_KeyRef)
void IC_KeyRef::serialize(XSerializeEngine& serEng)
{
IdentityConstraint::serialize(serEng);
if (serEng.isStoring())
{
IdentityConstraint::storeIC(serEng, fKey);
}
else
{
fKey = IdentityConstraint::loadIC(serEng);
}
}
IC_KeyRef::IC_KeyRef(MemoryManager* const manager)
:IdentityConstraint(0, 0, manager)
,fKey(0)
{
}
XERCES_CPP_NAMESPACE_END
/**
* End of file IC_KeyRef.cpp
*/
@@ -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
*/
@@ -0,0 +1,178 @@
/*
* 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.cpp 803869 2009-08-13 12:56:21Z amassari $
*/
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <xercesc/framework/XMLAttr.hpp>
#include <xercesc/validators/schema/identity/IC_Selector.hpp>
#include <xercesc/validators/schema/identity/XercesXPath.hpp>
#include <xercesc/validators/schema/identity/IdentityConstraint.hpp>
#include <xercesc/validators/schema/identity/FieldActivator.hpp>
XERCES_CPP_NAMESPACE_BEGIN
// ---------------------------------------------------------------------------
// SelectorMatcher: Constructors and Destructor
// ---------------------------------------------------------------------------
SelectorMatcher::SelectorMatcher(XercesXPath* const xpath,
IC_Selector* const selector,
FieldActivator* const fieldActivator,
const int initialDepth,
MemoryManager* const manager)
: XPathMatcher(xpath, selector->getIdentityConstraint(), manager)
, fInitialDepth(initialDepth)
, fElementDepth(0)
, fMatchedDepth(-1)
, fSelector(selector)
, fFieldActivator(fieldActivator)
{
}
// ---------------------------------------------------------------------------
// FieldMatcher: XMLDocumentHandler methods
// ---------------------------------------------------------------------------
void SelectorMatcher::startDocumentFragment() {
XPathMatcher::startDocumentFragment();
fElementDepth = 0;
fMatchedDepth = -1;
}
void SelectorMatcher::startElement(const XMLElementDecl& elemDecl,
const unsigned int urlId,
const XMLCh* const elemPrefix,
const RefVectorOf<XMLAttr>& attrList,
const XMLSize_t attrCount,
ValidationContext* validationContext /*=0*/)
{
XPathMatcher::startElement(elemDecl, urlId, elemPrefix, attrList, attrCount, validationContext);
fElementDepth++;
// activate the fields, if selector is matched
unsigned char matched = isMatched();
if ((fMatchedDepth == -1 && ((matched & XP_MATCHED) == XP_MATCHED))
|| ((matched & XP_MATCHED_D) == XP_MATCHED_D)) {
IdentityConstraint* ic = fSelector->getIdentityConstraint();
XMLSize_t count = ic->getFieldCount();
fMatchedDepth = fElementDepth;
fFieldActivator->startValueScopeFor(ic, fInitialDepth);
for (XMLSize_t i = 0; i < count; i++) {
XPathMatcher* matcher = fFieldActivator->activateField(ic->getFieldAt(i), fInitialDepth);
matcher->startElement(elemDecl, urlId, elemPrefix, attrList, attrCount, validationContext);
}
}
}
void SelectorMatcher::endElement(const XMLElementDecl& elemDecl,
const XMLCh* const elemContent,
ValidationContext* validationContext /*=0*/,
DatatypeValidator* actualValidator /*=0*/)
{
XPathMatcher::endElement(elemDecl, elemContent, validationContext, actualValidator);
if (fElementDepth-- == fMatchedDepth) {
fMatchedDepth = -1;
fFieldActivator->endValueScopeFor(fSelector->getIdentityConstraint(), fInitialDepth);
}
}
// ---------------------------------------------------------------------------
// IC_Selector: Constructors and Destructor
// ---------------------------------------------------------------------------
IC_Selector::IC_Selector(XercesXPath* const xpath,
IdentityConstraint* const identityConstraint)
: fXPath(xpath)
, fIdentityConstraint(identityConstraint)
{
}
IC_Selector::~IC_Selector()
{
delete fXPath;
}
// ---------------------------------------------------------------------------
// IC_Selector: operators
// ---------------------------------------------------------------------------
bool IC_Selector::operator ==(const IC_Selector& other) const {
return (*fXPath == *(other.fXPath));
}
bool IC_Selector::operator !=(const IC_Selector& other) const {
return !operator==(other);
}
// ---------------------------------------------------------------------------
// IC_Selector: Factory methods
// ---------------------------------------------------------------------------
XPathMatcher* IC_Selector::createMatcher(FieldActivator* const fieldActivator,
const int initialDepth,
MemoryManager* const manager) {
return new (manager) SelectorMatcher(fXPath, this, fieldActivator, initialDepth, manager);
}
/***
* Support for Serialization/De-serialization
***/
IMPL_XSERIALIZABLE_TOCREATE(IC_Selector)
void IC_Selector::serialize(XSerializeEngine& serEng)
{
if (serEng.isStoring())
{
serEng<<fXPath;
IdentityConstraint::storeIC(serEng, fIdentityConstraint);
}
else
{
serEng>>fXPath;
fIdentityConstraint = IdentityConstraint::loadIC(serEng);
}
}
IC_Selector::IC_Selector(MemoryManager* const )
:fXPath(0)
,fIdentityConstraint(0)
{
}
XERCES_CPP_NAMESPACE_END
/**
* End of file IC_Selector.cpp
*/
@@ -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
*/
@@ -0,0 +1,68 @@
/*
* 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.cpp 471747 2006-11-06 14:31:56Z amassari $
*/
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <xercesc/validators/schema/identity/IC_Unique.hpp>
XERCES_CPP_NAMESPACE_BEGIN
// ---------------------------------------------------------------------------
// IC_Unique: Constructors and Destructor
// ---------------------------------------------------------------------------
IC_Unique::IC_Unique(const XMLCh* const identityConstraintName,
const XMLCh* const elemName,
MemoryManager* const manager)
: IdentityConstraint(identityConstraintName, elemName, manager)
{
}
IC_Unique::~IC_Unique()
{
}
/***
* Support for Serialization/De-serialization
***/
IMPL_XSERIALIZABLE_TOCREATE(IC_Unique)
void IC_Unique::serialize(XSerializeEngine& serEng)
{
IdentityConstraint::serialize(serEng);
//no data
}
IC_Unique::IC_Unique(MemoryManager* const manager)
:IdentityConstraint(0, 0, manager)
{
}
XERCES_CPP_NAMESPACE_END
/**
* End of file IC_Unique.cpp
*/
@@ -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
*/
@@ -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: IdentityConstraint.cpp 676911 2008-07-15 13:27:32Z amassari $
*/
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <xercesc/validators/schema/identity/IdentityConstraint.hpp>
#include <xercesc/validators/schema/identity/IC_Selector.hpp>
#include <xercesc/validators/schema/identity/IC_Field.hpp>
#include <xercesc/util/XMLString.hpp>
#include <xercesc/util/OutOfMemoryException.hpp>
//since we need to dynamically created each and every derivatives
//during deserialization by XSerializeEngine>>Derivative, we got
//to include all hpp
#include <xercesc/validators/schema/identity/IC_Unique.hpp>
#include <xercesc/validators/schema/identity/IC_Key.hpp>
#include <xercesc/validators/schema/identity/IC_KeyRef.hpp>
#include <xercesc/internal/XTemplateSerializer.hpp>
XERCES_CPP_NAMESPACE_BEGIN
typedef JanitorMemFunCall<IdentityConstraint> CleanupType;
// ---------------------------------------------------------------------------
// IdentityConstraint: Constructors and Destructor
// ---------------------------------------------------------------------------
IdentityConstraint::IdentityConstraint(const XMLCh* const identityConstraintName,
const XMLCh* const elemName,
MemoryManager* const manager)
: fIdentityConstraintName(0)
, fElemName(0)
, fSelector(0)
, fFields(0)
, fMemoryManager(manager)
, fNamespaceURI(-1)
{
CleanupType cleanup(this, &IdentityConstraint::cleanUp);
try {
fIdentityConstraintName = XMLString::replicate(identityConstraintName, fMemoryManager);
fElemName = XMLString::replicate(elemName, fMemoryManager);
}
catch(const OutOfMemoryException&)
{
cleanup.release();
throw;
}
cleanup.release();
}
IdentityConstraint::~IdentityConstraint()
{
cleanUp();
}
// ---------------------------------------------------------------------------
// IdentityConstraint: operators
// ---------------------------------------------------------------------------
bool IdentityConstraint::operator ==(const IdentityConstraint& other) const {
if (getType() != other.getType())
return false;
if (!XMLString::equals(fIdentityConstraintName, other.fIdentityConstraintName))
return false;
if (*fSelector != *(other.fSelector))
return false;
XMLSize_t fieldCount = fFields->size();
if (fieldCount != other.fFields->size())
return false;
for (XMLSize_t i = 0; i < fieldCount; i++) {
if (*(fFields->elementAt(i)) != *(other.fFields->elementAt(i)))
return false;
}
return true;
}
bool IdentityConstraint::operator !=(const IdentityConstraint& other) const {
return !operator==(other);
}
// ---------------------------------------------------------------------------
// IdentityConstraint: Setter methods
// ---------------------------------------------------------------------------
void IdentityConstraint::setSelector(IC_Selector* const selector) {
if (fSelector) {
delete fSelector;
}
fSelector = selector;
}
// ---------------------------------------------------------------------------
// IdentityConstraint: cleanUp methods
// ---------------------------------------------------------------------------
void IdentityConstraint::cleanUp() {
fMemoryManager->deallocate(fIdentityConstraintName);//delete [] fIdentityConstraintName;
fMemoryManager->deallocate(fElemName);//delete [] fElemName;
delete fFields;
delete fSelector;
}
/***
* Support for Serialization/De-serialization
***/
IMPL_XSERIALIZABLE_NOCREATE(IdentityConstraint)
void IdentityConstraint::serialize(XSerializeEngine& serEng)
{
if (serEng.isStoring())
{
serEng.writeString(fIdentityConstraintName);
serEng.writeString(fElemName);
serEng<<fSelector;
serEng<<fNamespaceURI;
/***
*
* Serialize RefVectorOf<IC_Field>* fFields;
*
***/
XTemplateSerializer::storeObject(fFields, serEng);
}
else
{
serEng.readString(fIdentityConstraintName);
serEng.readString(fElemName);
serEng>>fSelector;
serEng>>fNamespaceURI;
/***
*
* Deserialize RefVectorOf<IC_Field>* fFields;
*
***/
XTemplateSerializer::loadObject(&fFields, 4, true, serEng);
}
}
void IdentityConstraint::storeIC(XSerializeEngine& serEng
, IdentityConstraint* const ic)
{
if (ic)
{
serEng<<(int) ic->getType();
serEng<<ic;
}
else
{
serEng<<(int) ICType_UNKNOWN;
}
}
IdentityConstraint* IdentityConstraint::loadIC(XSerializeEngine& serEng)
{
int type;
serEng>>type;
switch((ICType)type)
{
case ICType_UNIQUE:
IC_Unique* ic_unique;
serEng>>ic_unique;
return ic_unique;
case ICType_KEY:
IC_Key* ic_key;
serEng>>ic_key;
return ic_key;
case ICType_KEYREF:
IC_KeyRef* ic_keyref;
serEng>>ic_keyref;
return ic_keyref;
case ICType_UNKNOWN:
return 0;
default: //we treat this same as UnKnown
return 0;
}
}
XERCES_CPP_NAMESPACE_END
/**
* End of file IdentityConstraint.cpp
*/
@@ -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
*/
@@ -0,0 +1,215 @@
/*
* 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.cpp 803869 2009-08-13 12:56:21Z amassari $
*/
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include "IdentityConstraintHandler.hpp"
#include <xercesc/validators/schema/SchemaElementDecl.hpp>
#include <xercesc/validators/schema/identity/FieldActivator.hpp>
#include <xercesc/validators/schema/identity/ValueStore.hpp>
#include <xercesc/validators/schema/identity/IC_Selector.hpp>
#include <xercesc/util/OutOfMemoryException.hpp>
XERCES_CPP_NAMESPACE_BEGIN
typedef JanitorMemFunCall<IdentityConstraintHandler> CleanupType;
// ---------------------------------------------------------------------------
// IdentityConstraintHandler: Constructors and Destructor
// ---------------------------------------------------------------------------
IdentityConstraintHandler::IdentityConstraintHandler(XMLScanner* const scanner
, MemoryManager* const manager)
: fScanner(scanner)
, fMemoryManager(manager)
, fMatcherStack(0)
, fValueStoreCache(0)
, fFieldActivator(0)
{
CleanupType cleanup(this, &IdentityConstraintHandler::cleanUp);
try {
fMatcherStack = new (fMemoryManager) XPathMatcherStack(fMemoryManager);
fValueStoreCache = new (fMemoryManager) ValueStoreCache(fMemoryManager);
fFieldActivator = new (fMemoryManager) FieldActivator(fValueStoreCache, fMatcherStack, fMemoryManager);
fValueStoreCache->setScanner(scanner);
}
catch(const OutOfMemoryException&)
{
cleanup.release();
throw;
}
cleanup.release();
}
IdentityConstraintHandler::~IdentityConstraintHandler()
{
cleanUp();
}
// ---------------------------------------------------------------------------
// IdentityConstraintHandler: methods
// ---------------------------------------------------------------------------
void IdentityConstraintHandler::deactivateContext( SchemaElementDecl* const elem
, const XMLCh* const content
, ValidationContext* validationContext /*=0*/
, DatatypeValidator* actualValidator /*=0*/)
{
XMLSize_t oldCount = fMatcherStack->getMatcherCount();
if (oldCount || elem->getIdentityConstraintCount())
{
for (XMLSize_t i = oldCount; i > 0; i--)
{
XPathMatcher* matcher = fMatcherStack->getMatcherAt(i-1);
matcher->endElement(*(elem), content, validationContext, actualValidator);
}
if (fMatcherStack->size() > 0)
{
fMatcherStack->popContext();
}
// handle everything *but* keyref's.
XMLSize_t newCount = fMatcherStack->getMatcherCount();
for (XMLSize_t j = oldCount; j > newCount; j--)
{
XPathMatcher* matcher = fMatcherStack->getMatcherAt(j-1);
IdentityConstraint* ic = matcher->getIdentityConstraint();
if (ic && (ic->getType() != IdentityConstraint::ICType_KEYREF))
fValueStoreCache->transplant(ic, matcher->getInitialDepth());
}
// now handle keyref's...
for (XMLSize_t k = oldCount; k > newCount; k--)
{
XPathMatcher* matcher = fMatcherStack->getMatcherAt(k-1);
IdentityConstraint* ic = matcher->getIdentityConstraint();
if (ic && (ic->getType() == IdentityConstraint::ICType_KEYREF))
{
ValueStore* values = fValueStoreCache->getValueStoreFor(ic, matcher->getInitialDepth());
if (values) { // nothing to do if nothing matched!
values->endDocumentFragment(fValueStoreCache);
}
}
}
fValueStoreCache->endElement();
}
}
void IdentityConstraintHandler::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*/)
{
XMLSize_t count = elem->getIdentityConstraintCount();
if (count || fMatcherStack->getMatcherCount())
{
fValueStoreCache->startElement();
fMatcherStack->pushContext();
fValueStoreCache->initValueStoresFor( elem, elemDepth);
for (XMLSize_t i = 0; i < count; i++)
{
activateSelectorFor(elem->getIdentityConstraintAt(i), elemDepth);
}
// call all active identity constraints
count = fMatcherStack->getMatcherCount();
for (XMLSize_t j = 0; j < count; j++)
{
XPathMatcher* matcher = fMatcherStack->getMatcherAt(j);
matcher->startElement(*elem, uriId, elemPrefix, attrList, attrCount, validationContext);
}
}
}
void IdentityConstraintHandler::activateSelectorFor( IdentityConstraint* const ic
, const int initialDepth)
{
IC_Selector* selector = ic->getSelector();
if (!selector)
return;
XPathMatcher* matcher = selector->createMatcher(fFieldActivator, initialDepth, fMemoryManager);
fMatcherStack->addMatcher(matcher);
matcher->startDocumentFragment();
}
// ---------------------------------------------------------------------------
// IdentityConstraintHandler: Getter methods
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
// IdentityConstraintHandler: cleanUp methods
// ---------------------------------------------------------------------------
void IdentityConstraintHandler::cleanUp()
{
if (fMatcherStack)
delete fMatcherStack;
if (fValueStoreCache)
delete fValueStoreCache;
if (fFieldActivator)
delete fFieldActivator;
}
void IdentityConstraintHandler::reset()
{
fValueStoreCache->startDocument();
fMatcherStack->clear();
}
XERCES_CPP_NAMESPACE_END
/**
* End of file IdentityConstraintHandler.cpp
*/
@@ -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
*/
@@ -0,0 +1,352 @@
/*
* 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.cpp 804209 2009-08-14 13:15:05Z amassari $
*/
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <xercesc/internal/XMLScanner.hpp>
#include <xercesc/framework/XMLValidator.hpp>
#include <xercesc/validators/datatype/DatatypeValidator.hpp>
#include <xercesc/validators/schema/identity/FieldActivator.hpp>
#include <xercesc/validators/schema/identity/ValueStore.hpp>
#include <xercesc/validators/schema/identity/IC_Field.hpp>
#include <xercesc/validators/schema/identity/IC_KeyRef.hpp>
#include <xercesc/validators/schema/identity/ValueStoreCache.hpp>
XERCES_CPP_NAMESPACE_BEGIN
//
// ---------------------------------------------------------------------------
// ICValueHasher: the hasher for identity constraints values
// ---------------------------------------------------------------------------
XMLSize_t ICValueHasher::getHashVal(const void* key, XMLSize_t mod) const
{
const FieldValueMap* valueMap=(const FieldValueMap*)key;
XMLSize_t hashVal = 0;
XMLSize_t size = valueMap->size();
for (XMLSize_t j=0; j<size; j++) {
// reach the most generic datatype validator
DatatypeValidator* dv = valueMap->getDatatypeValidatorAt(j);
while(dv && dv->getBaseValidator())
dv = dv->getBaseValidator();
const XMLCh* const val = valueMap->getValueAt(j);
const XMLCh* canonVal = (dv && val)?dv->getCanonicalRepresentation(val, fMemoryManager):0;
if(canonVal)
{
hashVal += XMLString::hash(canonVal, mod);
fMemoryManager->deallocate((void*)canonVal);
}
else if(val)
hashVal += XMLString::hash(val, mod);
}
return hashVal % mod;
}
bool ICValueHasher::equals(const void *const key1, const void *const key2) const
{
const FieldValueMap* left=(const FieldValueMap*)key1;
const FieldValueMap* right=(const FieldValueMap*)key2;
XMLSize_t lSize = left->size();
XMLSize_t rSize = right->size();
if (lSize == rSize)
{
bool matchFound = true;
for (XMLSize_t j=0; j<rSize; j++) {
if (!isDuplicateOf(left->getDatatypeValidatorAt(j), left->getValueAt(j),
right->getDatatypeValidatorAt(j), right->getValueAt(j))) {
matchFound = false;
break;
}
}
if (matchFound) { // found it
return true;
}
}
return false;
}
bool ICValueHasher::isDuplicateOf(DatatypeValidator* const dv1, const XMLCh* const val1,
DatatypeValidator* const dv2, const XMLCh* const val2) const
{
// if either validator's null, fall back on string comparison
if(!dv1 || !dv2) {
return (XMLString::equals(val1, val2));
}
bool val1IsEmpty = (val1==0 || *val1==0);
bool val2IsEmpty = (val2==0 || *val2==0);
if (val1IsEmpty && val2IsEmpty) {
if (dv1 == dv2) {
return true;
}
return false;
}
if (val1IsEmpty || val2IsEmpty) {
return false;
}
// find the common ancestor, if there is one
DatatypeValidator* tempVal1 = dv1;
while(tempVal1)
{
DatatypeValidator* tempVal2 = dv2;
for(; tempVal2 != NULL && tempVal2 != tempVal1; tempVal2 = tempVal2->getBaseValidator()) ;
if (tempVal2)
return ((tempVal2->compare(val1, val2, fMemoryManager)) == 0);
tempVal1=tempVal1->getBaseValidator();
}
// if we're here it means the types weren't related. They are different:
return false;
}
// ---------------------------------------------------------------------------
// ValueStore: Constructors and Destructor
// ---------------------------------------------------------------------------
ValueStore::ValueStore(IdentityConstraint* const ic,
XMLScanner* const scanner,
MemoryManager* const manager)
: fDoReportError(false)
, fValuesCount(0)
, fIdentityConstraint(ic)
, fValues(manager)
, fValueTuples(0)
, fScanner(scanner)
, fMemoryManager(manager)
{
fDoReportError = (scanner && (scanner->getValidationScheme() == XMLScanner::Val_Always));
}
ValueStore::~ValueStore()
{
delete fValueTuples;
}
// ---------------------------------------------------------------------------
// ValueStore: Helper methods
// ---------------------------------------------------------------------------
void ValueStore::addValue(FieldActivator* const fieldActivator,
IC_Field* const field,
DatatypeValidator* const dv,
const XMLCh* const value) {
if (!fieldActivator->getMayMatch(field) && fDoReportError) {
fScanner->getValidator()->emitError(XMLValid::IC_FieldMultipleMatch);
}
// do we even know this field?
XMLSize_t index;
bool bFound = fValues.indexOf(field, index);
if (!bFound) {
if (fDoReportError) {
fScanner->getValidator()->emitError(XMLValid::IC_UnknownField);
}
return;
}
// store value
if (!fValues.getDatatypeValidatorAt(index) &&
!fValues.getValueAt(index)) {
fValuesCount++;
}
fValues.put(field, dv, value);
if (fValuesCount == fValues.size()) {
// is this value as a group duplicated?
if (contains(&fValues)) {
duplicateValue();
}
// store values
if (!fValueTuples) {
fValueTuples = new (fMemoryManager) RefHashTableOf<FieldValueMap, ICValueHasher>(107, true, ICValueHasher(fMemoryManager), fMemoryManager);
}
FieldValueMap* pICItem = new (fMemoryManager) FieldValueMap(fValues);
fValueTuples->put(pICItem, pICItem);
}
}
void ValueStore::append(const ValueStore* const other) {
if (!other->fValueTuples) {
return;
}
RefHashTableOfEnumerator<FieldValueMap, ICValueHasher> iter(other->fValueTuples, false, fMemoryManager);
while(iter.hasMoreElements())
{
FieldValueMap& valueMap = iter.nextElement();
if (!contains(&valueMap)) {
if (!fValueTuples) {
fValueTuples = new (fMemoryManager) RefHashTableOf<FieldValueMap, ICValueHasher>(107, true, ICValueHasher(fMemoryManager), fMemoryManager);
}
FieldValueMap* pICItem = new (fMemoryManager) FieldValueMap(valueMap);
fValueTuples->put(pICItem, pICItem);
}
}
}
void ValueStore::startValueScope() {
fValuesCount = 0;
XMLSize_t count = fIdentityConstraint->getFieldCount();
for (XMLSize_t i = 0; i < count; i++) {
fValues.put(fIdentityConstraint->getFieldAt(i), 0, 0);
}
}
void ValueStore::endValueScope() {
if (fValuesCount == 0) {
if (fIdentityConstraint->getType() == IdentityConstraint::ICType_KEY && fDoReportError) {
fScanner->getValidator()->emitError(XMLValid::IC_AbsentKeyValue,
fIdentityConstraint->getElementName());
}
return;
}
// do we have enough values?
if ((fValuesCount != fIdentityConstraint->getFieldCount()) && fDoReportError) {
if(fIdentityConstraint->getType()==IdentityConstraint::ICType_KEY)
{
fScanner->getValidator()->emitError(XMLValid::IC_KeyNotEnoughValues,
fIdentityConstraint->getElementName(), fIdentityConstraint->getIdentityConstraintName());
}
}
}
bool ValueStore::contains(const FieldValueMap* const other) {
if (fValueTuples)
return fValueTuples->get(other)!=0;
return false;
}
void ValueStore::clear()
{
fValuesCount=0;
fValues.clear();
if(fValueTuples)
fValueTuples->removeAll();
}
// ---------------------------------------------------------------------------
// ValueStore: Document handling methods
// ---------------------------------------------------------------------------
void ValueStore::endDocumentFragment(ValueStoreCache* const valueStoreCache) {
if (fIdentityConstraint->getType() == IdentityConstraint::ICType_KEYREF) {
// verify references
// get the key store corresponding (if it exists):
ValueStore* keyValueStore = valueStoreCache->getGlobalValueStoreFor(((IC_KeyRef*) fIdentityConstraint)->getKey());
if (!keyValueStore) {
if (fDoReportError) {
fScanner->getValidator()->emitError(XMLValid::IC_KeyRefOutOfScope,
fIdentityConstraint->getIdentityConstraintName());
}
return;
}
if(fValueTuples)
{
RefHashTableOfEnumerator<FieldValueMap, ICValueHasher> iter(fValueTuples, false, fMemoryManager);
while(iter.hasMoreElements())
{
FieldValueMap& valueMap = iter.nextElement();
if (!keyValueStore->contains(&valueMap) && fDoReportError) {
fScanner->getValidator()->emitError(XMLValid::IC_KeyNotFound,
fIdentityConstraint->getElementName());
}
}
}
}
}
// ---------------------------------------------------------------------------
// ValueStore: Error reporting methods
// ---------------------------------------------------------------------------
void ValueStore::reportNilError(IdentityConstraint* const ic) {
if (fDoReportError && ic->getType() == IdentityConstraint::ICType_KEY) {
fScanner->getValidator()->emitError(XMLValid::IC_KeyMatchesNillable,
ic->getElementName());
}
}
void ValueStore::duplicateValue() {
if (fDoReportError) {
switch (fIdentityConstraint->getType()) {
case IdentityConstraint::ICType_UNIQUE:
{
fScanner->getValidator()->emitError(XMLValid::IC_DuplicateUnique,
fIdentityConstraint->getElementName());
break;
}
case IdentityConstraint::ICType_KEY:
{
fScanner->getValidator()->emitError(XMLValid::IC_DuplicateKey,
fIdentityConstraint->getElementName());
break;
}
}
}
}
XERCES_CPP_NAMESPACE_END
/**
* End of file ValueStore.cpp
*/
@@ -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
*/
@@ -0,0 +1,184 @@
/*
* 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.cpp 708224 2008-10-27 16:02:26Z amassari $
*/
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <xercesc/validators/schema/identity/ValueStoreCache.hpp>
#include <xercesc/validators/schema/identity/ValueStore.hpp>
#include <xercesc/validators/schema/SchemaElementDecl.hpp>
#include <xercesc/util/OutOfMemoryException.hpp>
XERCES_CPP_NAMESPACE_BEGIN
typedef JanitorMemFunCall<ValueStoreCache> CleanupType;
// ---------------------------------------------------------------------------
// ValueStoreCache: Constructors and Destructor
// ---------------------------------------------------------------------------
ValueStoreCache::ValueStoreCache(MemoryManager* const manager)
: fValueStores(0)
, fGlobalICMap(0)
, fIC2ValueStoreMap(0)
, fGlobalMapStack(0)
, fScanner(0)
, fMemoryManager(manager)
{
CleanupType cleanup(this, &ValueStoreCache::cleanUp);
try {
init();
}
catch(const OutOfMemoryException&)
{
cleanup.release();
throw;
}
cleanup.release();
}
ValueStoreCache::~ValueStoreCache()
{
cleanUp();
}
// ---------------------------------------------------------------------------
// ValueStoreCache: Document handling methods
// ---------------------------------------------------------------------------
void ValueStoreCache::startDocument() {
fIC2ValueStoreMap->removeAll();
fGlobalICMap->removeAll();
fValueStores->removeAllElements();
fGlobalMapStack->removeAllElements();
}
void ValueStoreCache::startElement() {
fGlobalMapStack->push(fGlobalICMap);
fGlobalICMap = new (fMemoryManager) RefHashTableOf<ValueStore, PtrHasher>
(
13
, false
, fMemoryManager
);
}
void ValueStoreCache::endElement() {
if (fGlobalMapStack->empty()) {
return; // must be an invalid doc!
}
RefHashTableOf<ValueStore, PtrHasher>* oldMap = fGlobalMapStack->pop();
RefHashTableOfEnumerator<ValueStore, PtrHasher> mapEnum(oldMap, false, fMemoryManager);
// Janitor<RefHashTableOf<ValueStore> > janMap(oldMap);
while (mapEnum.hasMoreElements()) {
ValueStore& oldVal = mapEnum.nextElement();
IdentityConstraint* ic = oldVal.getIdentityConstraint();
ValueStore* currVal = fGlobalICMap->get(ic);
if (!currVal) {
fGlobalICMap->put(ic, &oldVal);
}
else {
currVal->append(&oldVal);
}
}
delete oldMap;
}
// ---------------------------------------------------------------------------
// ValueStoreCache: Helper methods
// ---------------------------------------------------------------------------
void ValueStoreCache::cleanUp() {
delete fIC2ValueStoreMap;
delete fGlobalICMap;
delete fGlobalMapStack;
delete fValueStores;
}
void ValueStoreCache::init() {
fValueStores = new (fMemoryManager) RefVectorOf<ValueStore>(8, false, fMemoryManager);
fGlobalICMap = new (fMemoryManager) RefHashTableOf<ValueStore, PtrHasher>
(
13
, false
, fMemoryManager
);
fIC2ValueStoreMap = new (fMemoryManager) RefHash2KeysTableOf<ValueStore, PtrHasher>
(
13
, true
, fMemoryManager
);
fGlobalMapStack = new (fMemoryManager) RefStackOf<RefHashTableOf<ValueStore, PtrHasher> >(8, true, fMemoryManager);
}
void ValueStoreCache::initValueStoresFor(SchemaElementDecl* const elemDecl,
const int initialDepth) {
// initialize value stores for unique fields
XMLSize_t icCount = elemDecl->getIdentityConstraintCount();
for (XMLSize_t i=0; i<icCount; i++) {
IdentityConstraint* ic = elemDecl->getIdentityConstraintAt(i);
ValueStore* valueStore=fIC2ValueStoreMap->get(ic, initialDepth);
if(valueStore==0)
{
valueStore = new (fMemoryManager) ValueStore(ic, fScanner, fMemoryManager);
fIC2ValueStoreMap->put(ic, initialDepth, valueStore);
}
else
valueStore->clear();
fValueStores->addElement(valueStore);
}
}
void ValueStoreCache::transplant(IdentityConstraint* const ic, const int initialDepth) {
if (ic->getType() == IdentityConstraint::ICType_KEYREF) {
return;
}
ValueStore* newVals = fIC2ValueStoreMap->get(ic, initialDepth);
ValueStore* currVals = fGlobalICMap->get(ic);
if (currVals) {
currVals->append(newVals);
} else {
fGlobalICMap->put(ic, newVals);
}
}
XERCES_CPP_NAMESPACE_END
/**
* End of file ValueStoreCache.cpp
*/
@@ -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
*/
@@ -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
@@ -0,0 +1,413 @@
/*
* 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.cpp 804234 2009-08-14 14:20:16Z amassari $
*/
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <xercesc/validators/schema/identity/XPathMatcher.hpp>
#include <xercesc/validators/schema/identity/XercesXPath.hpp>
#include <xercesc/validators/schema/SchemaElementDecl.hpp>
#include <xercesc/validators/schema/SchemaAttDef.hpp>
#include <xercesc/validators/schema/SchemaSymbols.hpp>
#include <xercesc/util/RuntimeException.hpp>
#include <xercesc/util/OutOfMemoryException.hpp>
#include <xercesc/framework/ValidationContext.hpp>
XERCES_CPP_NAMESPACE_BEGIN
typedef JanitorMemFunCall<XPathMatcher> CleanupType;
// ---------------------------------------------------------------------------
// XPathMatcher: Constructors and Destructor
// ---------------------------------------------------------------------------
XPathMatcher::XPathMatcher( XercesXPath* const xpath
, MemoryManager* const manager)
: fLocationPathSize(0)
, fMatched(0)
, fNoMatchDepth(0)
, fCurrentStep(0)
, fStepIndexes(0)
, fLocationPaths(0)
, fIdentityConstraint(0)
, fMemoryManager(manager)
{
CleanupType cleanup(this, &XPathMatcher::cleanUp);
try {
init(xpath);
}
catch(const OutOfMemoryException&)
{
cleanup.release();
throw;
}
cleanup.release();
}
XPathMatcher::XPathMatcher(XercesXPath* const xpath,
IdentityConstraint* const ic,
MemoryManager* const manager)
: fLocationPathSize(0)
, fMatched(0)
, fNoMatchDepth(0)
, fCurrentStep(0)
, fStepIndexes(0)
, fLocationPaths(0)
, fIdentityConstraint(ic)
, fMemoryManager(manager)
{
CleanupType cleanup(this, &XPathMatcher::cleanUp);
try {
init(xpath);
}
catch(const OutOfMemoryException&)
{
cleanup.release();
throw;
}
cleanup.release();
}
XPathMatcher::~XPathMatcher()
{
cleanUp();
}
// ---------------------------------------------------------------------------
// XPathMatcher: Helper methods
// ---------------------------------------------------------------------------
void XPathMatcher::init(XercesXPath* const xpath) {
if (xpath) {
fLocationPaths = xpath->getLocationPaths();
fLocationPathSize = (fLocationPaths ? fLocationPaths->size() : 0);
if (fLocationPathSize) {
fStepIndexes = new (fMemoryManager) RefVectorOf<ValueStackOf<XMLSize_t> >(fLocationPathSize, true, fMemoryManager);
fCurrentStep = (XMLSize_t*) fMemoryManager->allocate
(
fLocationPathSize * sizeof(XMLSize_t)
);//new int[fLocationPathSize];
fNoMatchDepth = (XMLSize_t*) fMemoryManager->allocate
(
fLocationPathSize * sizeof(XMLSize_t)
);//new int[fLocationPathSize];
fMatched = (unsigned char*) fMemoryManager->allocate
(
fLocationPathSize * sizeof(unsigned char)
);//new int[fLocationPathSize];
for(XMLSize_t i=0; i < fLocationPathSize; i++) {
fStepIndexes->addElement(new (fMemoryManager) ValueStackOf<XMLSize_t>(8, fMemoryManager));
}
}
}
}
// ---------------------------------------------------------------------------
// XPathMatcher: XMLDocumentHandler methods
// ---------------------------------------------------------------------------
void XPathMatcher::startDocumentFragment() {
for(XMLSize_t i = 0; i < fLocationPathSize; i++) {
fStepIndexes->elementAt(i)->removeAllElements();
fCurrentStep[i] = 0;
fNoMatchDepth[i] = 0;
fMatched[i] = 0;
}
}
void XPathMatcher::startElement(const XMLElementDecl& elemDecl,
const unsigned int urlId,
const XMLCh* const elemPrefix,
const RefVectorOf<XMLAttr>& attrList,
const XMLSize_t attrCount,
ValidationContext* validationContext /*=0*/) {
for (XMLSize_t i = 0; i < fLocationPathSize; i++) {
// push context
XMLSize_t startStep = fCurrentStep[i];
fStepIndexes->elementAt(i)->push(startStep);
// try next xpath, if not matching
if ((fMatched[i] & XP_MATCHED_D) == XP_MATCHED || fNoMatchDepth[i] > 0) {
fNoMatchDepth[i]++;
continue;
}
if((fMatched[i] & XP_MATCHED_D) == XP_MATCHED_D) {
fMatched[i] = XP_MATCHED_DP;
}
// consume self::node() steps
XercesLocationPath* locPath = fLocationPaths->elementAt(i);
XMLSize_t stepSize = locPath->getStepSize();
while (fCurrentStep[i] < stepSize &&
locPath->getStep(fCurrentStep[i])->getAxisType() == XercesStep::AxisType_SELF) {
fCurrentStep[i]++;
}
if (fCurrentStep[i] == stepSize) {
fMatched[i] = XP_MATCHED;
continue;
}
// now if the current step is a descendant step, we let the next
// step do its thing; if it fails, we reset ourselves
// to look at this step for next time we're called.
// so first consume all descendants:
XMLSize_t descendantStep = fCurrentStep[i];
while (fCurrentStep[i] < stepSize &&
locPath->getStep(fCurrentStep[i])->getAxisType() == XercesStep::AxisType_DESCENDANT) {
fCurrentStep[i]++;
}
bool sawDescendant = fCurrentStep[i] > descendantStep;
if (fCurrentStep[i] == stepSize) {
fNoMatchDepth[i]++;
continue;
}
// match child::... step, if haven't consumed any self::node()
if ((fCurrentStep[i] == startStep || fCurrentStep[i] > descendantStep) &&
locPath->getStep(fCurrentStep[i])->getAxisType() == XercesStep::AxisType_CHILD) {
XercesStep* step = locPath->getStep(fCurrentStep[i]);
XercesNodeTest* nodeTest = step->getNodeTest();
QName elemQName(elemPrefix, elemDecl.getElementName()->getLocalPart(), urlId, fMemoryManager);
if (!matches(nodeTest, &elemQName)) {
if(fCurrentStep[i] > descendantStep) {
fCurrentStep[i] = descendantStep;
continue;
}
fNoMatchDepth[i]++;
continue;
}
fCurrentStep[i]++;
}
if (fCurrentStep[i] == stepSize) {
if (sawDescendant) {
fCurrentStep[i] = descendantStep;
fMatched[i] = XP_MATCHED_D;
}
else {
fMatched[i] = XP_MATCHED;
}
continue;
}
// match attribute::... step
if (fCurrentStep[i] < stepSize &&
locPath->getStep(fCurrentStep[i])->getAxisType() == XercesStep::AxisType_ATTRIBUTE) {
if (attrCount) {
XercesNodeTest* nodeTest = locPath->getStep(fCurrentStep[i])->getNodeTest();
for (XMLSize_t attrIndex = 0; attrIndex < attrCount; attrIndex++) {
const XMLAttr* curDef = attrList.elementAt(attrIndex);
if (matches(nodeTest, curDef->getAttName())) {
fCurrentStep[i]++;
if (fCurrentStep[i] == stepSize) {
fMatched[i] = XP_MATCHED_A;
SchemaAttDef* attDef = ((SchemaElementDecl&) elemDecl).getAttDef(curDef->getName(), curDef->getURIId());
DatatypeValidator* dv = (attDef) ? attDef->getDatatypeValidator() : 0;
const XMLCh* value = curDef->getValue();
// store QName using their Clark name
if(dv && dv->getType()==DatatypeValidator::QName)
{
int index=XMLString::indexOf(value, chColon);
if(index==-1)
matched(value, dv, false);
else
{
XMLBuffer buff(1023, fMemoryManager);
buff.append(chOpenCurly);
if(validationContext)
{
XMLCh* prefix=(XMLCh*)fMemoryManager->allocate((index+1)*sizeof(XMLCh));
ArrayJanitor<XMLCh> janPrefix(prefix, fMemoryManager);
XMLString::subString(prefix, value, 0, (XMLSize_t)index, fMemoryManager);
buff.append(validationContext->getURIForPrefix(prefix));
}
buff.append(chCloseCurly);
buff.append(value+index+1);
matched(buff.getRawBuffer(), dv, false);
}
}
else
matched(value, dv, false);
}
break;
}
}
}
if ((fMatched[i] & XP_MATCHED) != XP_MATCHED) {
if(fCurrentStep[i] > descendantStep) {
fCurrentStep[i] = descendantStep;
continue;
}
fNoMatchDepth[i]++;
}
}
}
}
void XPathMatcher::endElement(const XMLElementDecl& elemDecl,
const XMLCh* const elemContent,
ValidationContext* validationContext /*=0*/,
DatatypeValidator* actualValidator /*=0*/) {
for(XMLSize_t i = 0; i < fLocationPathSize; i++) {
// go back a step
fCurrentStep[i] = fStepIndexes->elementAt(i)->pop();
// don't do anything, if not matching
if (fNoMatchDepth[i] > 0) {
fNoMatchDepth[i]--;
}
// signal match, if appropriate
else {
if (fMatched[i] == 0)
continue;
if ((fMatched[i] & XP_MATCHED_A) == XP_MATCHED_A) {
fMatched[i] = 0;
continue;
}
DatatypeValidator* dv = actualValidator?actualValidator:((SchemaElementDecl*) &elemDecl)->getDatatypeValidator();
bool isNillable = (((SchemaElementDecl *) &elemDecl)->getMiscFlags() & SchemaSymbols::XSD_NILLABLE) != 0;
// store QName using their Clark name
if(dv && dv->getType()==DatatypeValidator::QName)
{
int index=XMLString::indexOf(elemContent, chColon);
if(index==-1)
matched(elemContent, dv, isNillable);
else
{
XMLBuffer buff(1023, fMemoryManager);
buff.append(chOpenCurly);
if(validationContext)
{
XMLCh* prefix=(XMLCh*)fMemoryManager->allocate((index+1)*sizeof(XMLCh));
ArrayJanitor<XMLCh> janPrefix(prefix, fMemoryManager);
XMLString::subString(prefix, elemContent, 0, (XMLSize_t)index, fMemoryManager);
buff.append(validationContext->getURIForPrefix(prefix));
}
buff.append(chCloseCurly);
buff.append(elemContent+index+1);
matched(buff.getRawBuffer(), dv, isNillable);
}
}
else
matched(elemContent, dv, isNillable);
fMatched[i] = 0;
}
}
}
// ---------------------------------------------------------------------------
// XPathMatcher: Match methods
// ---------------------------------------------------------------------------
unsigned char XPathMatcher::isMatched() {
// xpath has been matched if any one of the members of the union have matched.
for (XMLSize_t i=0; i < fLocationPathSize; i++) {
if (((fMatched[i] & XP_MATCHED) == XP_MATCHED)
&& ((fMatched[i] & XP_MATCHED_DP) != XP_MATCHED_DP))
return fMatched[i];
}
return 0;
}
void XPathMatcher::matched(const XMLCh* const,
DatatypeValidator* const,
const bool) {
return;
}
bool XPathMatcher::matches(const XercesNodeTest* nodeTest, const QName* qName)
{
if (nodeTest->getType() == XercesNodeTest::NodeType_QNAME) {
return (*nodeTest->getName())==(*qName);
}
if (nodeTest->getType() == XercesNodeTest::NodeType_NAMESPACE) {
return nodeTest->getName()->getURI() == qName->getURI();
}
// NodeType_WILDCARD
return true;
}
// ---------------------------------------------------------------------------
// XPathMatcher: Match methods
// ---------------------------------------------------------------------------
int XPathMatcher::getInitialDepth() const
{
ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Regex_NotSupported, fMemoryManager);
return 0; // to make some compilers happy
}
XERCES_CPP_NAMESPACE_END
/**
* End of file XPathMatcher.cpp
*/
@@ -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
*/
@@ -0,0 +1,86 @@
/*
* 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.cpp 471747 2006-11-06 14:31:56Z amassari $
*/
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <xercesc/validators/schema/identity/XPathMatcherStack.hpp>
#include <xercesc/util/Janitor.hpp>
#include <xercesc/util/OutOfMemoryException.hpp>
XERCES_CPP_NAMESPACE_BEGIN
typedef JanitorMemFunCall<XPathMatcherStack> CleanupType;
// ---------------------------------------------------------------------------
// XPathMatherStack: Constructors and Destructor
// ---------------------------------------------------------------------------
XPathMatcherStack::XPathMatcherStack(MemoryManager* const manager)
: fMatchersCount(0)
, fContextStack(0)
, fMatchers(0)
{
CleanupType cleanup(this, &XPathMatcherStack::cleanUp);
try {
fContextStack = new (manager) ValueStackOf<int>(8, manager);
fMatchers = new (manager) RefVectorOf<XPathMatcher>(8, true, manager);
}
catch(const OutOfMemoryException&)
{
cleanup.release();
throw;
}
cleanup.release();
}
XPathMatcherStack::~XPathMatcherStack() {
cleanUp();
}
// ---------------------------------------------------------------------------
// XPathMatcherStack: Private helper methods.
// ---------------------------------------------------------------------------
void XPathMatcherStack::cleanUp()
{
delete fContextStack;
delete fMatchers;
}
// ---------------------------------------------------------------------------
// XPathMatherStack: Clear methods
// ---------------------------------------------------------------------------
void XPathMatcherStack::clear() {
fContextStack->removeAllElements();
fMatchers->removeAllElements();
fMatchersCount = 0;
}
XERCES_CPP_NAMESPACE_END
/**
* End of file XPathMatcherStack.cpp
*/
@@ -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
*/
@@ -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: XPathSymbols.cpp 471747 2006-11-06 14:31:56Z amassari $
*/
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <xercesc/util/XMLUniDefs.hpp>
#include <xercesc/validators/schema/identity/XPathSymbols.hpp>
XERCES_CPP_NAMESPACE_BEGIN
// ---------------------------------------------------------------------------
// SchemaSymbols: Static data
// ---------------------------------------------------------------------------
const XMLCh XPathSymbols::fgSYMBOL_AND[] =
{
chLatin_a, chLatin_n, chLatin_d, chNull
};
const XMLCh XPathSymbols::fgSYMBOL_OR[] =
{
chLatin_o, chLatin_r, chNull
};
const XMLCh XPathSymbols::fgSYMBOL_MOD[] =
{
chLatin_m, chLatin_o, chLatin_d, chNull
};
const XMLCh XPathSymbols::fgSYMBOL_DIV[] =
{
chLatin_d, chLatin_i, chLatin_v, chNull
};
const XMLCh XPathSymbols::fgSYMBOL_COMMENT[] =
{
chLatin_c, chLatin_o, chLatin_m, chLatin_m, chLatin_e, chLatin_n, chLatin_t, chNull
};
const XMLCh XPathSymbols::fgSYMBOL_TEXT[] =
{
chLatin_t, chLatin_e, chLatin_x, chLatin_t, chNull
};
const XMLCh XPathSymbols::fgSYMBOL_PI[] =
{
chLatin_p, chLatin_r, chLatin_o, chLatin_c, chLatin_e, chLatin_s, chLatin_s,
chLatin_i, chLatin_n, chLatin_g, chDash, chLatin_i, chLatin_n, chLatin_s, chLatin_t,
chLatin_r, chLatin_u, chLatin_c, chLatin_t, chLatin_i, chLatin_o, chLatin_n, chNull
};
const XMLCh XPathSymbols::fgSYMBOL_NODE[] =
{
chLatin_n, chLatin_o, chLatin_d, chLatin_e, chNull
};
const XMLCh XPathSymbols::fgSYMBOL_ANCESTOR[] =
{
chLatin_a, chLatin_n, chLatin_c, chLatin_e, chLatin_s, chLatin_t, chLatin_o,
chLatin_r, chNull
};
const XMLCh XPathSymbols::fgSYMBOL_ANCESTOR_OR_SELF[] =
{
chLatin_a, chLatin_n, chLatin_c, chLatin_e, chLatin_s, chLatin_t, chLatin_o,
chLatin_r, chDash, chLatin_o, chLatin_r, chDash, chLatin_s, chLatin_e,
chLatin_l, chLatin_f, chNull
};
const XMLCh XPathSymbols::fgSYMBOL_ATTRIBUTE[] =
{
chLatin_a, chLatin_t, chLatin_t, chLatin_r, chLatin_i, chLatin_b, chLatin_u,
chLatin_t, chLatin_e, chNull
};
const XMLCh XPathSymbols::fgSYMBOL_CHILD[] =
{
chLatin_c, chLatin_h, chLatin_i, chLatin_l, chLatin_d, chNull
};
const XMLCh XPathSymbols::fgSYMBOL_DESCENDANT[] =
{
chLatin_d, chLatin_e, chLatin_s, chLatin_c, chLatin_e, chLatin_n, chLatin_d,
chLatin_a, chLatin_n, chLatin_t, chNull
};
const XMLCh XPathSymbols::fgSYMBOL_DESCENDANT_OR_SELF[] =
{
chLatin_d, chLatin_e, chLatin_s, chLatin_c, chLatin_e, chLatin_n, chLatin_d,
chLatin_a, chLatin_n, chLatin_t, chDash, chLatin_o, chLatin_r, chDash, chLatin_s,
chLatin_e, chLatin_l, chLatin_f, chNull
};
const XMLCh XPathSymbols::fgSYMBOL_FOLLOWING[] =
{
chLatin_f, chLatin_o, chLatin_l, chLatin_l, chLatin_o, chLatin_w, chLatin_i,
chLatin_n, chLatin_g, chNull
};
const XMLCh XPathSymbols::fgSYMBOL_FOLLOWING_SIBLING[] =
{
chLatin_f, chLatin_o, chLatin_l, chLatin_l, chLatin_o, chLatin_w, chLatin_i,
chLatin_n, chLatin_g, chDash, chLatin_s, chLatin_i, chLatin_b, chLatin_l, chLatin_i,
chLatin_n, chLatin_g, chNull
};
const XMLCh XPathSymbols::fgSYMBOL_NAMESPACE[] =
{
chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chLatin_p, chLatin_a,
chLatin_c, chLatin_e, chNull
};
const XMLCh XPathSymbols::fgSYMBOL_PARENT[] =
{
chLatin_p, chLatin_a, chLatin_r, chLatin_e, chLatin_n, chLatin_t, chNull
};
const XMLCh XPathSymbols::fgSYMBOL_PRECEDING[] =
{
chLatin_p, chLatin_r, chLatin_e, chLatin_c, chLatin_e, chLatin_d, chLatin_i,
chLatin_n, chLatin_g, chNull
};
const XMLCh XPathSymbols::fgSYMBOL_PRECEDING_SIBLING[] =
{
chLatin_p, chLatin_r, chLatin_e, chLatin_c, chLatin_e, chLatin_d, chLatin_i,
chLatin_n, chLatin_g, chDash, chLatin_s, chLatin_i, chLatin_b, chLatin_l, chLatin_i,
chLatin_n, chLatin_g, chNull
};
const XMLCh XPathSymbols::fgSYMBOL_SELF[] =
{
chLatin_s, chLatin_e, chLatin_l, chLatin_f, chNull
};
XERCES_CPP_NAMESPACE_END
/**
* End of file XPathSymbols.cpp
*/
@@ -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
*/
File diff suppressed because it is too large Load Diff
@@ -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
*/