You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by kn...@apache.org on 2001/11/02 15:08:41 UTC
cvs commit: xml-xerces/c/src/validators/schema/identity XPathSymbols.hpp XPathSymbols.cpp XPathMatcherStack.hpp XPathMatcherStack.cpp XPathMatcher.hpp XPathMatcher.cpp XPathException.hpp XercesXPath.hpp XercesXPath.cpp ValueStoreCache.hpp ValueStoreCache.cpp ValueStore.hpp ValueStore.cpp Makefile.in IdentityConstraint.hpp IdentityConstraint.cpp IC_Unique.hpp IC_Unique.cpp IC_Selector.hpp IC_Selector.cpp IC_KeyRef.hpp IC_KeyRef.cpp IC_Key.hpp IC_Key.cpp IC_Field.hpp IC_Field.cpp FieldValueMap.hpp FieldValueMap.cpp FieldActivator.hpp FieldActivator.cpp
knoaman 01/11/02 06:08:41
Added: c/src/validators/schema/identity XPathSymbols.hpp
XPathSymbols.cpp XPathMatcherStack.hpp
XPathMatcherStack.cpp XPathMatcher.hpp
XPathMatcher.cpp XPathException.hpp XercesXPath.hpp
XercesXPath.cpp ValueStoreCache.hpp
ValueStoreCache.cpp ValueStore.hpp ValueStore.cpp
Makefile.in IdentityConstraint.hpp
IdentityConstraint.cpp IC_Unique.hpp IC_Unique.cpp
IC_Selector.hpp IC_Selector.cpp IC_KeyRef.hpp
IC_KeyRef.cpp IC_Key.hpp IC_Key.cpp IC_Field.hpp
IC_Field.cpp FieldValueMap.hpp FieldValueMap.cpp
FieldActivator.hpp FieldActivator.cpp
Log:
Add support for identity constraints.
Revision Changes Path
1.1 xml-xerces/c/src/validators/schema/identity/XPathSymbols.hpp
Index: XPathSymbols.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xerces" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache\@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation, and was
* originally based on software copyright (c) 2001, International
* Business Machines, Inc., http://www.ibm.com . For more information
* on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
/*
* $Id: XPathSymbols.hpp,v 1.1 2001/11/02 14:08:40 knoaman Exp $
*/
#if !defined(SCHEMASYMBOLS_HPP)
#define SCHEMASYMBOLS_HPP
#include <util/XercesDefs.hpp>
/*
* 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[];
};
#endif
/**
* End of file XPathSymbols.hpp
*/
1.1 xml-xerces/c/src/validators/schema/identity/XPathSymbols.cpp
Index: XPathSymbols.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xerces" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache\@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation, and was
* originally based on software copyright (c) 2001, International
* Business Machines, Inc., http://www.ibm.com . For more information
* on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
/*
* $Log: XPathSymbols.cpp,v $
* Revision 1.1 2001/11/02 14:08:40 knoaman
* Add support for identity constraints.
*
*/
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <util/XMLUniDefs.hpp>
#include <validators/schema/identity/XPathSymbols.hpp>
// ---------------------------------------------------------------------------
// 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
};
/**
* End of file XPathSymbols.cpp
*/
1.1 xml-xerces/c/src/validators/schema/identity/XPathMatcherStack.hpp
Index: XPathMatcherStack.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xerces" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache\@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation, and was
* originally based on software copyright (c) 2001, International
* Business Machines, Inc., http://www.ibm.com . For more information
* on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
/*
* $Id: XPathMatcherStack.hpp,v 1.1 2001/11/02 14:08:40 knoaman Exp $
*/
#if !defined(XPATHMATCHERSTACK_HPP)
#define XPATHMATCHERSTACK_HPP
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <validators/schema/identity/XPathMatcher.hpp>
class VALIDATORS_EXPORT XPathMatcherStack
{
public:
// -----------------------------------------------------------------------
// Constructors/Destructor
// -----------------------------------------------------------------------
XPathMatcherStack();
~XPathMatcherStack();
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
XPathMatcher* getMatcherAt(const unsigned int index) const;
unsigned int getMatcherCount() const;
unsigned int size() const;
// -----------------------------------------------------------------------
// Access methods
// -----------------------------------------------------------------------
void addMatcher(XPathMatcher* const matcher);
// -----------------------------------------------------------------------
// Stack methods
// -----------------------------------------------------------------------
void pushContext();
void popContext();
// -----------------------------------------------------------------------
// Reset methods
// -----------------------------------------------------------------------
void clear();
private:
// -----------------------------------------------------------------------
// Unimplemented contstructors 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 unsigned int XPathMatcherStack::size() const {
return fContextStack->size();
}
inline unsigned int XPathMatcherStack::getMatcherCount() const {
return fMatchersCount;
}
inline XPathMatcher*
XPathMatcherStack::getMatcherAt(const unsigned int 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++);
}
}
#endif
/**
* End of file XPathMatcherStack.hpp
*/
1.1 xml-xerces/c/src/validators/schema/identity/XPathMatcherStack.cpp
Index: XPathMatcherStack.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xerces" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache\@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation, and was
* originally based on software copyright (c) 1999, International
* Business Machines, Inc., http://www.ibm.com . For more information
* on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
/*
* $Log: XPathMatcherStack.cpp,v $
* Revision 1.1 2001/11/02 14:08:40 knoaman
* Add support for identity constraints.
*
*/
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <validators/schema/identity/XPathMatcherStack.hpp>
// ---------------------------------------------------------------------------
// XPathMatherStack: Constructors and Destructor
// ---------------------------------------------------------------------------
XPathMatcherStack::XPathMatcherStack()
: fMatchersCount(0)
, fContextStack(new ValueStackOf<int>(8))
, fMatchers(0)
{
try {
fMatchers = new RefVectorOf<XPathMatcher>(8);
}
catch(...) {
delete fContextStack;
throw;
}
}
XPathMatcherStack::~XPathMatcherStack() {
delete fContextStack;
delete fMatchers;
}
// ---------------------------------------------------------------------------
// XPathMatherStack: Clear methods
// ---------------------------------------------------------------------------
void XPathMatcherStack::clear() {
fContextStack->removeAllElements();
fMatchers->removeAllElements();
fMatchersCount = 0;
}
/**
* End of file XPathMatcherStack.cpp
*/
1.1 xml-xerces/c/src/validators/schema/identity/XPathMatcher.hpp
Index: XPathMatcher.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xerces" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache\@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation, and was
* originally based on software copyright (c) 2001, International
* Business Machines, Inc., http://www.ibm.com . For more information
* on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
/*
* $Id: XPathMatcher.hpp,v 1.1 2001/11/02 14:08:40 knoaman Exp $
*/
#if !defined(XPATHMATCHER_HPP)
#define XPATHMATCHER_HPP
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <util/ValueStackOf.hpp>
#include <util/RefVectorOf.hpp>
#include <framework/XMLBuffer.hpp>
// ---------------------------------------------------------------------------
// Forward Declaration
// ---------------------------------------------------------------------------
class XMLElementDecl;
class XercesXPath;
class IdentityConstraint;
class DatatypeValidator;
class XMLStringPool;
class XercesLocationPath;
class XMLAttr;
class VALIDATORS_EXPORT XPathMatcher
{
public:
// -----------------------------------------------------------------------
// Constructors/Destructor
// -----------------------------------------------------------------------
XPathMatcher(XercesXPath* const xpath);
XPathMatcher(XercesXPath* const xpath, const bool shouldBufferContent,
IdentityConstraint* const ic);
virtual ~XPathMatcher();
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
IdentityConstraint* getIdentityConstraint() const { return fIdentityConstraint; }
// -----------------------------------------------------------------------
// Match methods
// -----------------------------------------------------------------------
/**
* Returns true if XPath has been matched.
*/
bool isMatched();
// -----------------------------------------------------------------------
// XMLDocumentHandler methods
// -----------------------------------------------------------------------
virtual void startDocumentFragment();
virtual void endDocumentFragment();
virtual void startElement(const XMLElementDecl& elemDecl,
const RefVectorOf<XMLAttr>& attrList,
const unsigned int attrCount);
virtual void endElement(const XMLElementDecl& elemDecl);
virtual void docCharacters(const XMLCh* const chars, const unsigned int length);
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);
private:
// -----------------------------------------------------------------------
// Helper methods
// -----------------------------------------------------------------------
void init(XercesXPath* const xpath);
void cleanUp();
/**
* Clears the match values.
*/
void clear();
// -----------------------------------------------------------------------
// Data members
//
// fShouldBufferContent
// Application preference to buffer content or not.
//
// fBufferContent
// True, if we should buffer character content at this time.
//
// 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.
//
// fMatchedBuffer
// To hold match text.
// -----------------------------------------------------------------------
bool fShouldBufferContent;
bool fBufferContent;
unsigned int fLocationPathSize;
bool* fMatched;
int* fNoMatchDepth;
int* fCurrentStep;
RefVectorOf<ValueStackOf<int> >* fStepIndexes;
RefVectorOf<XercesLocationPath>* fLocationPaths;
IdentityConstraint* fIdentityConstraint;
XMLBuffer fMatchedBuffer;
};
// ---------------------------------------------------------------------------
// XPathMatcher: Helper methods
// ---------------------------------------------------------------------------
inline void XPathMatcher::cleanUp() {
delete [] fMatched;
delete [] fNoMatchDepth;
delete [] fCurrentStep;
delete fStepIndexes;
}
#endif
/**
* End of file XPathMatcher.hpp
*/
1.1 xml-xerces/c/src/validators/schema/identity/XPathMatcher.cpp
Index: XPathMatcher.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xerces" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache\@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation, and was
* originally based on software copyright (c) 1999, International
* Business Machines, Inc., http://www.ibm.com . For more information
* on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
/*
* $Log: XPathMatcher.cpp,v $
* Revision 1.1 2001/11/02 14:08:40 knoaman
* Add support for identity constraints.
*
*/
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <validators/schema/identity/XPathMatcher.hpp>
#include <validators/schema/identity/XercesXPath.hpp>
#include <validators/schema/SchemaElementDecl.hpp>
#include <validators/schema/SchemaAttDef.hpp>
#include <validators/schema/SchemaSymbols.hpp>
// ---------------------------------------------------------------------------
// XPathMatcher: Constructors and Destructor
// ---------------------------------------------------------------------------
XPathMatcher::XPathMatcher(XercesXPath* const xpath)
: fShouldBufferContent(false)
, fBufferContent(false)
, fLocationPathSize(0)
, fMatched(0)
, fNoMatchDepth(0)
, fCurrentStep(0)
, fStepIndexes(0)
, fLocationPaths(0)
, fIdentityConstraint(0)
, fMatchedBuffer(128)
{
try {
init(xpath);
}
catch(...) {
cleanUp();
throw;
}
}
XPathMatcher::XPathMatcher(XercesXPath* const xpath,
const bool shouldBufferContent,
IdentityConstraint* const ic)
: fShouldBufferContent(shouldBufferContent)
, fLocationPathSize(0)
, fMatched(0)
, fNoMatchDepth(0)
, fCurrentStep(0)
, fLocationPaths(0)
, fIdentityConstraint(ic)
, fMatchedBuffer(0)
{
try {
init(xpath);
}
catch(...) {
cleanUp();
throw;
}
}
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 RefVectorOf<ValueStackOf<int> >(fLocationPathSize);
fCurrentStep = new int[fLocationPathSize];
fNoMatchDepth = new int[fLocationPathSize];
fMatched = new bool[fLocationPathSize];
for(unsigned int i=0; i < fLocationPathSize; i++) {
fStepIndexes->addElement(new ValueStackOf<int>(8));
}
}
}
}
void XPathMatcher::clear() {
fBufferContent = false;
fMatchedBuffer.reset();
for(int i = 0; i < (int) fLocationPathSize; i++)
fMatched[i] = false;
}
// ---------------------------------------------------------------------------
// XPathMatcher: XMLDocumentHandler methods
// ---------------------------------------------------------------------------
void XPathMatcher::startDocumentFragment() {
// reset state
clear();
for(unsigned int i = 0; i < fLocationPathSize; i++) {
fStepIndexes->elementAt(i)->removeAllElements();
fCurrentStep[i] = 0;
fNoMatchDepth[i] = 0;
fMatched[i] = false;
}
}
void XPathMatcher::startElement(const XMLElementDecl& elemDecl,
const RefVectorOf<XMLAttr>& attrList,
const unsigned int attrCount) {
for (int i = 0; i < (int) fLocationPathSize; i++) {
// push context
int startStep = fCurrentStep[i];
fStepIndexes->elementAt(i)->push(startStep);
// try next xpath, if not matching
if (fMatched[i] || fNoMatchDepth[i] > 0) {
fNoMatchDepth[i]++;
continue;
}
// consume self::node() steps
XercesLocationPath* locPath = fLocationPaths->elementAt(i);
int stepSize = locPath->getStepSize();
while (fCurrentStep[i] < stepSize &&
locPath->getStep(fCurrentStep[i])->getAxis()->getType() == XercesAxis::SELF) {
fCurrentStep[i]++;
}
if (fCurrentStep[i] == stepSize) {
fMatched[i] = true;
int j=0;
for(; j<i && !fMatched[j]; j++);
if(j==i)
fBufferContent = fShouldBufferContent;
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:
int descendantStep = fCurrentStep[i];
while (fCurrentStep[i] < stepSize &&
locPath->getStep(fCurrentStep[i])->getAxis()->getType() == XercesAxis::DESCENDANT) {
fCurrentStep[i]++;
}
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])->getAxis()->getType() == XercesAxis::CHILD) {
XercesStep* step = locPath->getStep(fCurrentStep[i]);
XercesNodeTest* nodeTest = step->getNodeTest();
if (nodeTest->getType() == XercesNodeTest::QNAME) {
if (!(*(nodeTest->getName()) == *(elemDecl.getElementName()))) {
if(fCurrentStep[i] > descendantStep) {
fCurrentStep[i] = descendantStep;
continue;
}
fNoMatchDepth[i]++;
continue;
}
}
fCurrentStep[i]++;
}
if (fCurrentStep[i] == stepSize) {
fMatched[i] = true;
int j=0;
for(; j<i && !fMatched[j]; j++);
if(j==i)
fBufferContent = fShouldBufferContent;
continue;
}
// match attribute::... step
if (fCurrentStep[i] < stepSize &&
locPath->getStep(fCurrentStep[i])->getAxis()->getType() == XercesAxis::ATTRIBUTE) {
if (attrCount) {
XercesNodeTest* nodeTest = locPath->getStep(fCurrentStep[i])->getNodeTest();
for (unsigned int attrIndex = 0; attrIndex < attrCount; attrIndex++) {
const XMLAttr* curDef = attrList.elementAt(attrIndex);
if (nodeTest->getType() != XercesNodeTest::QNAME ||
(*(nodeTest->getName()) == *(curDef->getAttName()))) {
fCurrentStep[i]++;
if (fCurrentStep[i] == stepSize) {
fMatched[i] = true;
int j=0;
for(; j<i && !fMatched[j]; j++);
if(j == i) {
SchemaAttDef* attDef = ((SchemaElementDecl&) elemDecl).getAttDef(curDef->getName(), curDef->getURIId());
DatatypeValidator* dv = (attDef) ? attDef->getDatatypeValidator() : 0;
matched(curDef->getValue(), dv, false);
}
}
break;
}
}
}
if (!fMatched[i]) {
if(fCurrentStep[i] > descendantStep) {
fCurrentStep[i] = descendantStep;
continue;
}
fNoMatchDepth[i]++;
}
}
}
}
void XPathMatcher::docCharacters(const XMLCh* const chars,
const unsigned int length) {
// collect match content
// so long as one of our paths is matching, store the content
for(int i=0; i < (int) fLocationPathSize; i++) {
if (fBufferContent && fNoMatchDepth[i] == 0) {
fMatchedBuffer.append(chars, length);
break;
}
}
}
void XPathMatcher::endElement(const XMLElementDecl& elemDecl) {
for(int i = 0; i < (int) fLocationPathSize; i++) {
// don't do anything, if not matching
if (fNoMatchDepth[i] > 0) {
fNoMatchDepth[i]--;
}
// signal match, if appropriate
else {
int j=0;
for(; j<i && !fMatched[j]; j++);
if (j < i)
continue;
if (fBufferContent) {
DatatypeValidator* dv = ((SchemaElementDecl*) &elemDecl)->getDatatypeValidator();
bool isNillable = (((SchemaElementDecl *) &elemDecl)->getMiscFlags() & SchemaSymbols::NILLABLE) != 0;
fBufferContent = false;
matched(fMatchedBuffer.getRawBuffer(), dv, isNillable);
}
clear();
}
// go back a step
fCurrentStep[i] = fStepIndexes->elementAt(i)->pop();
}
}
void XPathMatcher::endDocumentFragment() {
clear();
}
// ---------------------------------------------------------------------------
// XPathMatcher: Match methods
// ---------------------------------------------------------------------------
bool XPathMatcher::isMatched() {
// xpath has been matched if any one of the members of the union have matched.
for (int i=0; i < (int) fLocationPathSize; i++) {
if (fMatched[i])
return true;
}
return false;
}
void XPathMatcher::matched(const XMLCh* const content,
DatatypeValidator* const dv,
const bool isNil) {
return;
}
/**
* End of file XPathMatcher.cpp
*/
1.1 xml-xerces/c/src/validators/schema/identity/XPathException.hpp
Index: XPathException.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xerces" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache\@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation, and was
* originally based on software copyright (c) 2001, International
* Business Machines, Inc., http://www.ibm.com . For more information
* on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
/*
* $Id: XPathException.hpp,v 1.1 2001/11/02 14:08:40 knoaman Exp $
*/
#if !defined(XPATHEXCEPTION_HPP)
#define XPATHEXCEPTION_HPP
#include <util/XercesDefs.hpp>
#include <util/XMLException.hpp>
MakeXMLException(XPathException, VALIDATORS_EXPORT)
#endif
1.1 xml-xerces/c/src/validators/schema/identity/XercesXPath.hpp
Index: XercesXPath.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xerces" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache\@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation, and was
* originally based on software copyright (c) 2001, International
* Business Machines, Inc., http://www.ibm.com . For more information
* on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
/*
* $Id: XercesXPath.hpp,v 1.1 2001/11/02 14:08:40 knoaman Exp $
*/
#if !defined(XERCESXPATH_HPP)
#define XERCESXPATH_HPP
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <util/QName.hpp>
#include <util/RefVectorOf.hpp>
#include <util/ValueVectorOf.hpp>
// ---------------------------------------------------------------------------
// Forward Declarations
// ---------------------------------------------------------------------------
class XMLStringPool;
class NamespaceScope;
class VALIDATORS_EXPORT XercesAxis
{
public:
// -----------------------------------------------------------------------
// Constants
// -----------------------------------------------------------------------
enum {
CHILD = 1,
ATTRIBUTE = 2,
SELF = 3,
DESCENDANT = 4
};
// -----------------------------------------------------------------------
// Constructors/Destructor
// -----------------------------------------------------------------------
XercesAxis(const short type);
XercesAxis(const XercesAxis& other);
~XercesAxis() {}
// -----------------------------------------------------------------------
// Operators
// -----------------------------------------------------------------------
XercesAxis& operator= (const XercesAxis& other);
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
short getType() const { return fType; }
private:
// -----------------------------------------------------------------------
// Data members
// -----------------------------------------------------------------------
short fType;
};
class VALIDATORS_EXPORT XercesNodeTest
{
public:
// -----------------------------------------------------------------------
// Constants
// -----------------------------------------------------------------------
enum {
QNAME = 1,
WILDCARD = 2,
NODE = 3,
NAMESPACE= 4
};
// -----------------------------------------------------------------------
// Constructors/Destructor
// -----------------------------------------------------------------------
XercesNodeTest(const short type);
XercesNodeTest(const QName* const qName);
XercesNodeTest(const XMLCh* const prefix, const unsigned int uriId);
XercesNodeTest(const XercesNodeTest& other);
~XercesNodeTest() { delete fName; }
// -----------------------------------------------------------------------
// Operators
// -----------------------------------------------------------------------
XercesNodeTest& operator= (const XercesNodeTest& other);
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
short getType() const { return fType; }
QName* getName() const { return fName; }
private:
// -----------------------------------------------------------------------
// Data members
// -----------------------------------------------------------------------
short fType;
QName* fName;
};
/**
* A location path step comprised of an axis and node test.
*/
class VALIDATORS_EXPORT XercesStep {
public:
// -----------------------------------------------------------------------
// Constructors/Destructor
// -----------------------------------------------------------------------
XercesStep(XercesAxis* const axis, XercesNodeTest* const nodeTest);
XercesStep(const XercesStep& other);
~XercesStep() { delete fAxis; delete fNodeTest; }
// -----------------------------------------------------------------------
// Operators
// -----------------------------------------------------------------------
XercesStep& operator= (const XercesStep& other);
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
XercesAxis* getAxis() const { return fAxis; }
XercesNodeTest* getNodeTest() const { return fNodeTest; }
private:
// -----------------------------------------------------------------------
// Data members
// -----------------------------------------------------------------------
XercesAxis* fAxis;
XercesNodeTest* fNodeTest;
};
/**
* A location path representation for an XPath expression.
*/
class VALIDATORS_EXPORT XercesLocationPath
{
public:
// -----------------------------------------------------------------------
// Constructors/Destructor
// -----------------------------------------------------------------------
XercesLocationPath();
XercesLocationPath(RefVectorOf<XercesStep>* const steps);
~XercesLocationPath() { delete fSteps; }
// -----------------------------------------------------------------------
// Access methods
// -----------------------------------------------------------------------
unsigned int getStepSize() const;
void addStep(XercesStep* const aStep);
XercesStep* getStep(unsigned int index) const;
private:
// -----------------------------------------------------------------------
// Unimplemented contstructors and operators
// -----------------------------------------------------------------------
XercesLocationPath(const XercesLocationPath& other);
XercesLocationPath& operator= (const XercesLocationPath& other);
// -----------------------------------------------------------------------
// Data members
// -----------------------------------------------------------------------
RefVectorOf<XercesStep>* fSteps;
};
class VALIDATORS_EXPORT XercesXPath
{
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,
NamespaceScope* const scopeContext,
const unsigned int emptyNamespaceId,
const bool isSelector = false);
~XercesXPath();
// -----------------------------------------------------------------------
// Constructors/Destructor
// -----------------------------------------------------------------------
RefVectorOf<XercesLocationPath>* getLocationPaths() const;
private:
// -----------------------------------------------------------------------
// Unimplemented contstructors and operators
// -----------------------------------------------------------------------
XercesXPath(const XercesXPath& other);
XercesXPath& operator= (const XercesXPath& other);
// -----------------------------------------------------------------------
// Helper methods
// -----------------------------------------------------------------------
void cleanUp();
void checkForSelectedAttributes();
void parseExpression(XMLStringPool* const stringPool,
NamespaceScope* const scopeContext);
// -----------------------------------------------------------------------
// Data members
// -----------------------------------------------------------------------
unsigned int fEmptyNamespaceId;
XMLCh* fExpression;
RefVectorOf<XercesLocationPath>* fLocationPaths;
};
class VALIDATORS_EXPORT XPathScanner
{
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, int currentOffset,
const int 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 contstructors and operators
// -----------------------------------------------------------------------
XPathScanner(const XPathScanner& other);
XPathScanner& operator= (const XPathScanner& other);
// -----------------------------------------------------------------------
// Helper methods
// -----------------------------------------------------------------------
void init();
// -----------------------------------------------------------------------
// Scan methods
// -----------------------------------------------------------------------
int scanNCName(const XMLCh* const data, const int endOffset,
int currentOffset);
int scanNumber(const XMLCh* const data, const int endOffset,
int 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 contstructors and operators
// -----------------------------------------------------------------------
XPathScannerForSchema(const XPathScannerForSchema& other);
XPathScannerForSchema& operator= (const XPathScannerForSchema& other);
};
// ---------------------------------------------------------------------------
// XercesLocationPath: Access methods
// ---------------------------------------------------------------------------
inline unsigned int XercesLocationPath::getStepSize() const {
if (fSteps)
return fSteps->size();
return 0;
}
inline void XercesLocationPath::addStep(XercesStep* const aStep) {
if (!fSteps) {
fSteps = new RefVectorOf<XercesStep>(16);
}
fSteps->addElement(aStep);
}
inline XercesStep* XercesLocationPath::getStep(const unsigned int 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;
}
#endif
/**
* End of file XercesPath.hpp
*/
1.1 xml-xerces/c/src/validators/schema/identity/XercesXPath.cpp
Index: XercesXPath.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xerces" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache\@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation, and was
* originally based on software copyright (c) 1999, International
* Business Machines, Inc., http://www.ibm.com . For more information
* on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
/*
* $Log: XercesXPath.cpp,v $
* Revision 1.1 2001/11/02 14:08:40 knoaman
* Add support for identity constraints.
*
*/
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <validators/schema/identity/XercesXPath.hpp>
#include <validators/schema/identity/XPathSymbols.hpp>
#include <validators/schema/identity/XPathException.hpp>
#include <validators/schema/NamespaceScope.hpp>
#include <util/StringPool.hpp>
#include <util/Janitor.hpp>
#include <framework/XMLBuffer.hpp>
#include <internal/XMLReader.hpp>
#include <util/RuntimeException.hpp>
// ---------------------------------------------------------------------------
// Static data
// ---------------------------------------------------------------------------
const XMLByte XPathScanner::fASCIICharMap[128] =
{
0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 2, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2, 3, 4, 1, 5, 1, 1, 4, 6, 7, 8, 9, 10, 11, 12, 13,
14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 1, 16, 17, 18, 1,
19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21, 1, 22, 1, 23,
1, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 1, 24, 1, 1, 1
};
// ---------------------------------------------------------------------------
// XercesAxis: Constructors and Destructor
// ---------------------------------------------------------------------------
XercesAxis::XercesAxis(const short aType)
: fType(aType)
{
}
XercesAxis::XercesAxis(const XercesAxis& other)
: fType(other.fType)
{
}
// ---------------------------------------------------------------------------
// XercesAxis: Operators
// ---------------------------------------------------------------------------
XercesAxis& XercesAxis::operator=(const XercesAxis& other)
{
if (this == &other)
return *this;
fType = other.fType;
return *this;
}
// ---------------------------------------------------------------------------
// XercesNodeTest: Constructors and Destructor
// ---------------------------------------------------------------------------
XercesNodeTest::XercesNodeTest(const short aType)
: fType(aType)
, fName(new QName())
{
}
XercesNodeTest::XercesNodeTest(const QName* const qName)
: fType(QNAME)
, fName(new QName(qName))
{
}
XercesNodeTest::XercesNodeTest(const XMLCh* const prefix,
const unsigned int uriId)
: fType(NAMESPACE)
, fName(new QName())
{
fName->setURI(uriId);
fName->setPrefix(prefix);
}
XercesNodeTest::XercesNodeTest(const XercesNodeTest& other)
: fType(other.fType)
, fName(new QName(other.fName))
{
}
// ---------------------------------------------------------------------------
// XercesNodeTest: Operators
// ---------------------------------------------------------------------------
XercesNodeTest& XercesNodeTest::operator=(const XercesNodeTest& other)
{
if (this == &other)
return *this;
fType = other.fType;
fName->setValues(*(other.fName));
return *this;
}
// ---------------------------------------------------------------------------
// XercesStep: Constructors and Destructor
// ---------------------------------------------------------------------------
XercesStep::XercesStep(XercesAxis* const axis, XercesNodeTest* const nodeTest)
: fAxis(axis)
, fNodeTest(nodeTest)
{
}
XercesStep::XercesStep(const XercesStep& other)
: fAxis(0)
, fNodeTest(0)
{
fAxis = new XercesAxis(*(other.fAxis));
fNodeTest = new XercesNodeTest(*(other.fNodeTest));
}
// ---------------------------------------------------------------------------
// XercesStep: Operators
// ---------------------------------------------------------------------------
XercesStep& XercesStep::operator=(const XercesStep& other)
{
if (this == &other)
return *this;
*fAxis = *(other.fAxis);
*fNodeTest = *(other.fNodeTest);
return *this;
}
// ---------------------------------------------------------------------------
// XercesLocationPath: Constructors and Destructor
// ---------------------------------------------------------------------------
XercesLocationPath::XercesLocationPath()
: fSteps(0)
{
}
XercesLocationPath::XercesLocationPath(RefVectorOf<XercesStep>* const steps)
: fSteps(steps)
{
}
// ---------------------------------------------------------------------------
// XercesPath: Constructors and Destructor
// ---------------------------------------------------------------------------
XercesXPath::XercesXPath(const XMLCh* const xpathExpr,
XMLStringPool* const stringPool,
NamespaceScope* const scopeContext,
const unsigned int emptyNamespaceId,
const bool isSelector)
: fEmptyNamespaceId(emptyNamespaceId)
, fExpression(XMLString::replicate(xpathExpr))
, fLocationPaths(0)
{
try {
parseExpression(stringPool, scopeContext);
if (isSelector) {
checkForSelectedAttributes();
}
}
catch(...) {
cleanUp();
throw;
}
}
XercesXPath::~XercesXPath() {
cleanUp();
}
// ---------------------------------------------------------------------------
// XercesPath: Helper methods
// ---------------------------------------------------------------------------
void XercesXPath::cleanUp() {
delete [] fExpression;
delete fLocationPaths;
}
void XercesXPath::checkForSelectedAttributes() {
// verify that an attribute is not selected
unsigned int locSize = (fLocationPaths) ? fLocationPaths->size() : 0;
for (unsigned int i = 0; i < locSize; i++) {
XercesLocationPath* locPath = fLocationPaths->elementAt(i);
unsigned int stepSize = locPath->getStepSize();
if (stepSize) {
XercesAxis* axis = locPath->getStep(stepSize - 1)->getAxis();
if (axis->getType() == XercesAxis::ATTRIBUTE) {
ThrowXML(XPathException, XMLExcepts::XPath_NoAttrSelector);
}
}
}
}
void XercesXPath::parseExpression(XMLStringPool* const stringPool,
NamespaceScope* const scopeContext) {
unsigned int length = XMLString::stringLen(fExpression);
if (!length) {
return;
}
ValueVectorOf<int> tokens(16);
XPathScannerForSchema scanner(stringPool);
bool success = scanner.scanExpression(fExpression, 0, length, &tokens);
bool firstTokenOfLocationPath=true;
unsigned int tokenCount = tokens.size();
RefVectorOf<XercesStep>* stepsVector = new RefVectorOf<XercesStep>(16);
Janitor<RefVectorOf<XercesStep> > janSteps(stepsVector);
if (tokenCount) {
fLocationPaths = new RefVectorOf<XercesLocationPath>(8);
}
for (unsigned int i = 0; i < tokenCount; i++) {
int aToken = tokens.elementAt(i);
bool isNamespace=false;
switch (aToken) {
case XercesXPath::EXPRTOKEN_OPERATOR_UNION:
{
if (i == 0) {
ThrowXML(XPathException, XMLExcepts::XPath_NoUnionAtStart);
}
int stepsSize = stepsVector->size();
if (stepsSize == 0) {
ThrowXML(XPathException, XMLExcepts::XPath_NoMultipleUnion);
}
fLocationPaths->addElement(new XercesLocationPath(stepsVector));
janSteps.orphan();
stepsVector = new RefVectorOf<XercesStep>(16);
janSteps.reset(stepsVector);
firstTokenOfLocationPath = true;
}
break;
case XercesXPath::EXPRTOKEN_AXISNAME_ATTRIBUTE:
{
// consume "::" token and drop through
i++;
}
case XercesXPath::EXPRTOKEN_ATSIGN:
{
// consume QName token
if (i == tokenCount - 1) {
ThrowXML(XPathException, XMLExcepts::XPath_MissingAttr);
}
aToken = tokens.elementAt(++i);
if (aToken != XercesXPath::EXPRTOKEN_NAMETEST_QNAME
&& aToken!= XercesXPath::EXPRTOKEN_NAMETEST_ANY
&& aToken!= XercesXPath::EXPRTOKEN_NAMETEST_NAMESPACE) {
ThrowXML(XPathException, XMLExcepts::XPath_ExpectedToken1);
}
bool isNamespaceAtt=false;
switch (aToken) {
case XercesXPath::EXPRTOKEN_NAMETEST_ANY:
{
XercesAxis* axis = new XercesAxis(XercesAxis::ATTRIBUTE);
XercesNodeTest* nodeTest = new XercesNodeTest(XercesNodeTest::WILDCARD);
XercesStep* step = new XercesStep(axis, nodeTest);
stepsVector->addElement(step);
break;
}
case XercesXPath::EXPRTOKEN_NAMETEST_NAMESPACE:
{
isNamespaceAtt = true;
}
case XercesXPath::EXPRTOKEN_NAMETEST_QNAME:
{
aToken = tokens.elementAt(++i);
const XMLCh* prefix = XMLUni::fgZeroLenString;
unsigned int uri = fEmptyNamespaceId;
if (scopeContext && aToken != -1) {
prefix = stringPool->getValueForId(aToken);
uri = scopeContext->getNamespaceForPrefix(prefix);
}
if (aToken != -1 && scopeContext && uri == fEmptyNamespaceId) {
ThrowXML1(XPathException, XMLExcepts::XPath_PrefixNoURI, prefix);
}
if (isNamespaceAtt) {
// build step
XercesAxis* axis = new XercesAxis(XercesAxis::ATTRIBUTE);
XercesNodeTest* nodeTest = new XercesNodeTest(prefix, uri);
XercesStep* step = new XercesStep(axis, nodeTest);
stepsVector->addElement(step);
break;
}
aToken = tokens.elementAt(++i);
const XMLCh* localPart = stringPool->getValueForId(aToken);
QName aQName(prefix, localPart, uri);
// build step
XercesAxis* axis = new XercesAxis(XercesAxis::ATTRIBUTE);
XercesNodeTest* nodeTest = new XercesNodeTest(&aQName);
XercesStep* step = new XercesStep(axis, nodeTest);
stepsVector->addElement(step);
break;
}
}
firstTokenOfLocationPath=false;
break;
}
case XercesXPath::EXPRTOKEN_DOUBLE_COLON:
{
// should never have a bare double colon
ThrowXML(XPathException, XMLExcepts::XPath_NoDoubleColon);
}
case XercesXPath::EXPRTOKEN_AXISNAME_CHILD:
{
// consume "::" token and drop through
i++;
if (i == tokenCount - 1) {
ThrowXML(XPathException, XMLExcepts::XPath_ExpectedStep1);
}
firstTokenOfLocationPath=false;
break;
}
case XercesXPath::EXPRTOKEN_NAMETEST_ANY:
{
XercesAxis* axis = new XercesAxis(XercesAxis::CHILD);
XercesNodeTest* nodeTest = new XercesNodeTest(XercesNodeTest::WILDCARD);
XercesStep* step = new XercesStep(axis, nodeTest);
stepsVector->addElement(step);
firstTokenOfLocationPath = false;
break;
}
case XercesXPath::EXPRTOKEN_NAMETEST_NAMESPACE:
{
isNamespace=true;
}
case XercesXPath::EXPRTOKEN_NAMETEST_QNAME:
{
// consume QName token
aToken = tokens.elementAt(++i);
const XMLCh* prefix = XMLUni::fgZeroLenString;
unsigned int uri = fEmptyNamespaceId;
if (scopeContext && aToken != -1) {
prefix = stringPool->getValueForId(aToken);
uri = scopeContext->getNamespaceForPrefix(prefix);
}
if (aToken != -1 && scopeContext && uri == fEmptyNamespaceId) {
ThrowXML1(XPathException, XMLExcepts::XPath_PrefixNoURI, prefix);
}
if (isNamespace) {
// build step
XercesAxis* axis = new XercesAxis(XercesAxis::CHILD);
XercesNodeTest* nodeTest = new XercesNodeTest(prefix, uri);
XercesStep* step = new XercesStep(axis, nodeTest);
stepsVector->addElement(step);
break;
}
aToken = tokens.elementAt(++i);
const XMLCh* localPart = stringPool->getValueForId(aToken);
QName aQName(prefix, localPart, uri);
// build step
XercesAxis* axis = new XercesAxis(XercesAxis::CHILD);
XercesNodeTest* nodeTest = new XercesNodeTest(&aQName);
XercesStep* step = new XercesStep(axis, nodeTest);
stepsVector->addElement(step);
firstTokenOfLocationPath = false;
break;
}
case XercesXPath::EXPRTOKEN_PERIOD:
{
// build step
XercesAxis* axis = new XercesAxis(XercesAxis::SELF);
XercesNodeTest* nodeTest = new XercesNodeTest(XercesNodeTest::NODE);
XercesStep* step = new XercesStep(axis, nodeTest);
stepsVector->addElement(step);
if (firstTokenOfLocationPath && i+1 < tokenCount) {
aToken = tokens.elementAt(i+1);
if (aToken == XercesXPath::EXPRTOKEN_OPERATOR_DOUBLE_SLASH){
if (++i == tokenCount - 1) {
ThrowXML(XPathException, XMLExcepts::XPath_ExpectedStep2);
}
if (i+1 < tokenCount) {
aToken = tokens.elementAt(i+1);
if (aToken == XercesXPath::EXPRTOKEN_OPERATOR_SLASH) {
ThrowXML(XPathException, XMLExcepts::XPath_NoForwardSlash);
}
}
// build step
axis = new XercesAxis(XercesAxis::DESCENDANT);
nodeTest = new XercesNodeTest(XercesNodeTest::NODE);
step = new XercesStep(axis, nodeTest);
stepsVector->addElement(step);
}
}
firstTokenOfLocationPath=false;
break;
}
case XercesXPath::EXPRTOKEN_OPERATOR_DOUBLE_SLASH:
{
ThrowXML(XPathException, XMLExcepts::XPath_NoDoubleForwardSlash);
}
case XercesXPath::EXPRTOKEN_OPERATOR_SLASH:
{
if (i == 0) {
ThrowXML(XPathException, XMLExcepts::XPath_NoForwardSlashAtStart);
}
// keep on truckin'
if (firstTokenOfLocationPath) {
ThrowXML(XPathException, XMLExcepts::XPath_NoSelectionOfRoot);
}
if (i == tokenCount - 1) {
ThrowXML(XPathException, XMLExcepts::XPath_ExpectedStep3);
}
firstTokenOfLocationPath=false;
break;
}
default:
firstTokenOfLocationPath=false;
}
}
int stepsSize = stepsVector->size();
if (stepsSize == 0) {
if (!fLocationPaths || fLocationPaths->size() == 0) {
ThrowXML(XPathException, XMLExcepts::XPath_EmptyExpr);
}
else {
ThrowXML(XPathException, XMLExcepts::XPath_NoUnionAtEnd);
}
}
fLocationPaths->addElement(new XercesLocationPath(stepsVector));
janSteps.orphan();
}
// ---------------------------------------------------------------------------
// XPathScanner: Constructors and Destructor
// ---------------------------------------------------------------------------
XPathScanner::XPathScanner(XMLStringPool* const stringPool)
: fAndSymbol (0)
, fOrSymbol(0)
, fModSymbol(0)
, fDivSymbol(0)
, fCommentSymbol(0)
, fTextSymbol(0)
, fPISymbol(0)
, fNodeSymbol(0)
, fAncestorSymbol(0)
, fAncestorOrSelfSymbol(0)
, fAttributeSymbol(0)
, fChildSymbol(0)
, fDescendantSymbol(0)
, fDescendantOrSelfSymbol(0)
, fFollowingSymbol(0)
, fFollowingSiblingSymbol(0)
, fNamespaceSymbol(0)
, fParentSymbol(0)
, fPrecedingSymbol(0)
, fPrecedingSiblingSymbol(0)
, fSelfSymbol(0)
, fStringPool(stringPool)
{
init();
}
// ---------------------------------------------------------------------------
// XPathScanner: Helper methods
// ---------------------------------------------------------------------------
void XPathScanner::init() {
fAndSymbol = fStringPool->addOrFind(XPathSymbols::fgSYMBOL_AND);
fOrSymbol = fStringPool->addOrFind(XPathSymbols::fgSYMBOL_OR);
fModSymbol = fStringPool->addOrFind(XPathSymbols::fgSYMBOL_MOD);
fDivSymbol = fStringPool->addOrFind(XPathSymbols::fgSYMBOL_DIV);
fCommentSymbol = fStringPool->addOrFind(XPathSymbols::fgSYMBOL_COMMENT);
fTextSymbol = fStringPool->addOrFind(XPathSymbols::fgSYMBOL_TEXT);
fPISymbol = fStringPool->addOrFind(XPathSymbols::fgSYMBOL_PI);
fNodeSymbol = fStringPool->addOrFind(XPathSymbols::fgSYMBOL_NODE);
fAncestorSymbol = fStringPool->addOrFind(XPathSymbols::fgSYMBOL_ANCESTOR);
fAncestorOrSelfSymbol = fStringPool->addOrFind(XPathSymbols::fgSYMBOL_ANCESTOR_OR_SELF);
fAttributeSymbol = fStringPool->addOrFind(XPathSymbols::fgSYMBOL_ATTRIBUTE);
fChildSymbol = fStringPool->addOrFind(XPathSymbols::fgSYMBOL_CHILD);
fDescendantSymbol = fStringPool->addOrFind(XPathSymbols::fgSYMBOL_DESCENDANT);
fDescendantOrSelfSymbol = fStringPool->addOrFind(XPathSymbols::fgSYMBOL_DESCENDANT_OR_SELF);
fFollowingSymbol = fStringPool->addOrFind(XPathSymbols::fgSYMBOL_FOLLOWING);
fFollowingSiblingSymbol = fStringPool->addOrFind(XPathSymbols::fgSYMBOL_FOLLOWING_SIBLING);
fNamespaceSymbol = fStringPool->addOrFind(XPathSymbols::fgSYMBOL_NAMESPACE);
fParentSymbol = fStringPool->addOrFind(XPathSymbols::fgSYMBOL_PARENT);
fPrecedingSymbol = fStringPool->addOrFind(XPathSymbols::fgSYMBOL_PRECEDING);
fPrecedingSiblingSymbol = fStringPool->addOrFind(XPathSymbols::fgSYMBOL_PRECEDING_SIBLING);
fSelfSymbol = fStringPool->addOrFind(XPathSymbols::fgSYMBOL_SELF);
}
// ---------------------------------------------------------------------------
// XPathScanner: Scan methods
// ---------------------------------------------------------------------------
bool XPathScanner::scanExpression(const XMLCh* const data,
int currentOffset,
const int endOffset,
ValueVectorOf<int>* tokens) {
bool starIsMultiplyOperator = false;
int nameOffset = -1;
int nameHandle = -1;
int prefixHandle = -1;
XMLCh ch;
XMLBuffer dataBuffer(128);
while (true) {
if (currentOffset == endOffset) {
break;
}
ch = data[currentOffset];
while (XMLReader::isWhitespace(ch)) {
if (++currentOffset == endOffset) {
break;
}
ch = data[currentOffset];
}
if (currentOffset == endOffset) {
break;
}
//
// [28] ExprToken ::= '(' | ')' | '[' | ']' | '.' | '..' | '@' | ',' | '::'
// | NameTest | NodeType | Operator | FunctionName
// | AxisName | Literal | Number | VariableReference
//
XMLByte chartype = (ch >= 0x80) ? CHARTYPE_NONASCII : fASCIICharMap[ch];
switch (chartype) {
case CHARTYPE_OPEN_PAREN: // '('
addToken(tokens, XercesXPath::EXPRTOKEN_OPEN_PAREN);
starIsMultiplyOperator = false;
++currentOffset;
break;
case CHARTYPE_CLOSE_PAREN: // ')'
addToken(tokens, XercesXPath::EXPRTOKEN_CLOSE_PAREN);
starIsMultiplyOperator = true;
++currentOffset;
break;
case CHARTYPE_OPEN_BRACKET: // '['
addToken(tokens, XercesXPath::EXPRTOKEN_OPEN_BRACKET);
starIsMultiplyOperator = false;
++currentOffset;
break;
case CHARTYPE_CLOSE_BRACKET: // ']'
addToken(tokens, XercesXPath::EXPRTOKEN_CLOSE_BRACKET);
starIsMultiplyOperator = true;
++currentOffset;
break;
//
// [30] Number ::= Digits ('.' Digits?)? | '.' Digits
// ^^^^^^^^^^
//
case CHARTYPE_PERIOD: // '.', '..' or '.' Digits
if (currentOffset + 1 == endOffset) {
addToken(tokens, XercesXPath::EXPRTOKEN_PERIOD);
starIsMultiplyOperator = true;
currentOffset++;
break;
}
ch = data[currentOffset + 1];
if (ch == chPeriod) { // '..'
addToken(tokens, XercesXPath::EXPRTOKEN_DOUBLE_PERIOD);
starIsMultiplyOperator = true;
currentOffset += 2;
} else if (ch >= chDigit_0 && ch <= chDigit_9) {
addToken(tokens, XercesXPath::EXPRTOKEN_NUMBER);
starIsMultiplyOperator = true;
currentOffset = scanNumber(data, endOffset, currentOffset, tokens);
} else if (ch == chForwardSlash) {
addToken(tokens, XercesXPath::EXPRTOKEN_PERIOD);
starIsMultiplyOperator = true;
currentOffset++;
} else { // '.'
ThrowXML(XPathException, XMLExcepts::XPath_InvalidChar);
}
if (currentOffset == endOffset) {
break;
}
break;
case CHARTYPE_ATSIGN: // '@'
addToken(tokens, XercesXPath::EXPRTOKEN_ATSIGN);
starIsMultiplyOperator = false;
++currentOffset;
break;
case CHARTYPE_COMMA: // ','
addToken(tokens, XercesXPath::EXPRTOKEN_COMMA);
starIsMultiplyOperator = false;
++currentOffset;
break;
case CHARTYPE_COLON: // '::'
if (++currentOffset == endOffset) {
return false; // REVISIT
}
ch = data[currentOffset];
if (ch != chColon) {
return false; // REVISIT
}
addToken(tokens, XercesXPath::EXPRTOKEN_DOUBLE_COLON);
starIsMultiplyOperator = false;
++currentOffset;
break;
case CHARTYPE_SLASH: // '/' and '//'
if (++currentOffset == endOffset) {
addToken(tokens, XercesXPath::EXPRTOKEN_OPERATOR_SLASH);
starIsMultiplyOperator = false;
break;
}
ch = data[currentOffset];
if (ch == chForwardSlash) { // '//'
addToken(tokens, XercesXPath::EXPRTOKEN_OPERATOR_DOUBLE_SLASH);
starIsMultiplyOperator = false;
++currentOffset;
} else {
addToken(tokens, XercesXPath::EXPRTOKEN_OPERATOR_SLASH);
starIsMultiplyOperator = false;
}
break;
case CHARTYPE_UNION: // '|'
addToken(tokens, XercesXPath::EXPRTOKEN_OPERATOR_UNION);
starIsMultiplyOperator = false;
++currentOffset;
break;
case CHARTYPE_PLUS: // '+'
addToken(tokens, XercesXPath::EXPRTOKEN_OPERATOR_PLUS);
starIsMultiplyOperator = false;
++currentOffset;
break;
case CHARTYPE_MINUS: // '-'
addToken(tokens, XercesXPath::EXPRTOKEN_OPERATOR_MINUS);
starIsMultiplyOperator = false;
++currentOffset;
break;
case CHARTYPE_EQUAL: // '='
addToken(tokens, XercesXPath::EXPRTOKEN_OPERATOR_EQUAL);
starIsMultiplyOperator = false;
++currentOffset;
break;
case CHARTYPE_EXCLAMATION: // '!='
if (++currentOffset == endOffset) {
return false; // REVISIT
}
ch = data[currentOffset];
if (ch != chEqual) {
return false; // REVISIT
}
addToken(tokens, XercesXPath::EXPRTOKEN_OPERATOR_NOT_EQUAL);
starIsMultiplyOperator = false;
++currentOffset;
break;
case CHARTYPE_LESS: // '<' and '<='
if (++currentOffset == endOffset) {
addToken(tokens, XercesXPath::EXPRTOKEN_OPERATOR_LESS);
starIsMultiplyOperator = false;
break;
}
ch = data[currentOffset];
if (ch == chEqual) { // '<='
addToken(tokens, XercesXPath::EXPRTOKEN_OPERATOR_LESS_EQUAL);
starIsMultiplyOperator = false;
++currentOffset;
} else {
addToken(tokens, XercesXPath::EXPRTOKEN_OPERATOR_LESS);
starIsMultiplyOperator = false;
}
break;
case CHARTYPE_GREATER: // '>' and '>='
if (++currentOffset == endOffset) {
addToken(tokens, XercesXPath::EXPRTOKEN_OPERATOR_GREATER);
starIsMultiplyOperator = false;
break;
}
ch = data[currentOffset];
if (ch == chEqual) { // '>='
addToken(tokens, XercesXPath::EXPRTOKEN_OPERATOR_GREATER_EQUAL);
starIsMultiplyOperator = false;
++currentOffset;
} else {
addToken(tokens, XercesXPath::EXPRTOKEN_OPERATOR_GREATER);
starIsMultiplyOperator = false;
}
break;
//
// [29] Literal ::= '"' [^"]* '"' | "'" [^']* "'"
//
case CHARTYPE_QUOTE: // '\"' or '\''
{
XMLCh qchar = ch;
if (++currentOffset == endOffset) {
return false; // REVISIT
}
ch = data[currentOffset];
int litOffset = currentOffset;
while (ch != qchar) {
if (++currentOffset == endOffset) {
return false; // REVISIT
}
ch = data[currentOffset];
}
addToken(tokens, XercesXPath::EXPRTOKEN_LITERAL);
starIsMultiplyOperator = true;
dataBuffer.set(data + litOffset, currentOffset - litOffset);
tokens->addElement(fStringPool->addOrFind(dataBuffer.getRawBuffer()));
++currentOffset;
break;
}
//
// [30] Number ::= Digits ('.' Digits?)? | '.' Digits
// [31] Digits ::= [0-9]+
//
case CHARTYPE_DIGIT:
addToken(tokens, XercesXPath::EXPRTOKEN_NUMBER);
starIsMultiplyOperator = true;
currentOffset = scanNumber(data, endOffset, currentOffset, tokens);
break;
//
// [36] VariableReference ::= '$' QName
//
case CHARTYPE_DOLLAR:
if (++currentOffset == endOffset) {
return false; // REVISIT
}
nameOffset = currentOffset;
currentOffset = scanNCName(data, endOffset, currentOffset);
if (currentOffset == nameOffset) {
return false; // REVISIT
}
if (currentOffset < endOffset) {
ch = data[currentOffset];
}
else {
ch = 0;
}
dataBuffer.set(data + nameOffset, currentOffset - nameOffset);
nameHandle = fStringPool->addOrFind(dataBuffer.getRawBuffer());
prefixHandle = -1;
if (ch == chColon) {
prefixHandle = nameHandle;
if (++currentOffset == endOffset) {
return false; // REVISIT
}
nameOffset = currentOffset;
currentOffset = scanNCName(data, endOffset, currentOffset);
if (currentOffset == nameOffset) {
return false; // REVISIT
}
dataBuffer.set(data + nameOffset, currentOffset - nameOffset);
nameHandle = fStringPool->addOrFind(dataBuffer.getRawBuffer());
}
addToken(tokens, XercesXPath::EXPRTOKEN_VARIABLE_REFERENCE);
starIsMultiplyOperator = true;
tokens->addElement(prefixHandle);
tokens->addElement(nameHandle);
break;
//
// [37] NameTest ::= '*' | NCName ':' '*' | QName
// [34] MultiplyOperator ::= '*'
//
case CHARTYPE_STAR: // '*'
//
// 3.7 Lexical Structure
//
// If there is a preceding token and the preceding token is not one of @, ::, (, [, , or
// an Operator, then a * must be recognized as a MultiplyOperator.
//
// Otherwise, the token must not be recognized as a MultiplyOperator.
//
if (starIsMultiplyOperator) {
addToken(tokens, XercesXPath::EXPRTOKEN_OPERATOR_MULT);
starIsMultiplyOperator = false;
} else {
addToken(tokens, XercesXPath::EXPRTOKEN_NAMETEST_ANY);
starIsMultiplyOperator = true;
}
++currentOffset;
break;
//
// NCName, QName and non-terminals
//
case CHARTYPE_NONASCII: // possibly a valid non-ascii 'Letter' (BaseChar | Ideographic)
case CHARTYPE_LETTER:
case CHARTYPE_UNDERSCORE:
//
// 3.7 Lexical Structure
//
// If there is a preceding token and the preceding token is not one of @, ::, (, [, , or
// an Operator, then an NCName must be recognized as an OperatorName.
//
// If the character following an NCName (possibly after intervening ExprWhitespace) is (,
// then the token must be recognized as a NodeType or a FunctionName.
//
// If the two characters following an NCName (possibly after intervening ExprWhitespace)
// are ::, then the token must be recognized as an AxisName.
//
// Otherwise, the token must not be recognized as an OperatorName, a NodeType, a
// FunctionName, or an AxisName.
//
// [33] OperatorName ::= 'and' | 'or' | 'mod' | 'div'
// [38] NodeType ::= 'comment' | 'text' | 'processing-instruction' | 'node'
// [35] FunctionName ::= QName - NodeType
// [6] AxisName ::= (see above)
//
// [37] NameTest ::= '*' | NCName ':' '*' | QName
// [5] NCName ::= (Letter | '_') (NCNameChar)*
// [?] NCNameChar ::= Letter | Digit | '.' | '-' | '_' (ascii subset of 'NCNameChar')
// [?] QName ::= (NCName ':')? NCName
// [?] Letter ::= [A-Za-z] (ascii subset of 'Letter')
// [?] Digit ::= [0-9] (ascii subset of 'Digit')
//
nameOffset = currentOffset;
currentOffset = scanNCName(data, endOffset, currentOffset);
if (currentOffset == nameOffset) {
return false; // REVISIT
}
if (currentOffset < endOffset) {
ch = data[currentOffset];
}
else {
ch = 0;
}
dataBuffer.set(data + nameOffset, currentOffset - nameOffset);
nameHandle = fStringPool->addOrFind(dataBuffer.getRawBuffer());
bool isNameTestNCName = false;
bool isAxisName = false;
prefixHandle = -1;
if (ch == chColon) {
if (++currentOffset == endOffset) {
return false; // REVISIT
}
ch = data[currentOffset];
if (ch == chAsterisk) {
if (++currentOffset < endOffset) {
ch = data[currentOffset];
}
isNameTestNCName = true;
} else if (ch == chColon) {
if (++currentOffset < endOffset) {
ch = data[currentOffset];
}
isAxisName = true;
} else {
prefixHandle = nameHandle;
nameOffset = currentOffset;
currentOffset = scanNCName(data, endOffset, currentOffset);
if (currentOffset == nameOffset) {
return false; // REVISIT
}
if (currentOffset < endOffset) {
ch = data[currentOffset];
}
else {
ch = 0;
}
dataBuffer.set(data + nameOffset, currentOffset - nameOffset);
nameHandle = fStringPool->addOrFind(dataBuffer.getRawBuffer());
}
}
//
// [39] ExprWhitespace ::= S
//
while (XMLReader::isWhitespace(ch)) {
if (++currentOffset == endOffset) {
break;
}
ch = data[currentOffset];
}
//
// If there is a preceding token and the preceding token is not one of @, ::, (, [, , or
// an Operator, then an NCName must be recognized as an OperatorName.
//
if (starIsMultiplyOperator) {
if (nameHandle == fAndSymbol) {
addToken(tokens, XercesXPath::EXPRTOKEN_OPERATOR_AND);
starIsMultiplyOperator = false;
} else if (nameHandle == fOrSymbol) {
addToken(tokens, XercesXPath::EXPRTOKEN_OPERATOR_OR);
starIsMultiplyOperator = false;
} else if (nameHandle == fModSymbol) {
addToken(tokens, XercesXPath::EXPRTOKEN_OPERATOR_MOD);
starIsMultiplyOperator = false;
} else if (nameHandle == fDivSymbol) {
addToken(tokens, XercesXPath::EXPRTOKEN_OPERATOR_DIV);
starIsMultiplyOperator = false;
} else {
return false; // REVISIT
}
if (isNameTestNCName) {
return false; // REVISIT - NCName:* where an OperatorName is required
} else if (isAxisName) {
return false; // REVISIT - AxisName:: where an OperatorName is required
}
break;
}
//
// If the character following an NCName (possibly after intervening ExprWhitespace) is (,
// then the token must be recognized as a NodeType or a FunctionName.
//
if (ch == chOpenParen && !isNameTestNCName && !isAxisName) {
if (nameHandle == fCommentSymbol) {
addToken(tokens, XercesXPath::EXPRTOKEN_NODETYPE_COMMENT);
} else if (nameHandle == fTextSymbol) {
addToken(tokens, XercesXPath::EXPRTOKEN_NODETYPE_TEXT);
} else if (nameHandle == fPISymbol) {
addToken(tokens, XercesXPath::EXPRTOKEN_NODETYPE_PI);
} else if (nameHandle == fNodeSymbol) {
addToken(tokens, XercesXPath::EXPRTOKEN_NODETYPE_NODE);
} else {
addToken(tokens, XercesXPath::EXPRTOKEN_FUNCTION_NAME);
tokens->addElement(prefixHandle);
tokens->addElement(nameHandle);
}
addToken(tokens, XercesXPath::EXPRTOKEN_OPEN_PAREN);
starIsMultiplyOperator = false;
++currentOffset;
break;
}
//
// If the two characters following an NCName (possibly after intervening ExprWhitespace)
// are ::, then the token must be recognized as an AxisName.
//
if (isAxisName ||
(ch == chColon && currentOffset + 1 < endOffset &&
data[currentOffset + 1] == chColon)) {
if (nameHandle == fAncestorSymbol) {
addToken(tokens, XercesXPath::EXPRTOKEN_AXISNAME_ANCESTOR);
} else if (nameHandle == fAncestorOrSelfSymbol) {
addToken(tokens, XercesXPath::EXPRTOKEN_AXISNAME_ANCESTOR_OR_SELF);
} else if (nameHandle == fAttributeSymbol) {
addToken(tokens, XercesXPath::EXPRTOKEN_AXISNAME_ATTRIBUTE);
} else if (nameHandle == fChildSymbol) {
addToken(tokens, XercesXPath::EXPRTOKEN_AXISNAME_CHILD);
} else if (nameHandle == fDescendantSymbol) {
addToken(tokens, XercesXPath::EXPRTOKEN_AXISNAME_DESCENDANT);
} else if (nameHandle == fDescendantOrSelfSymbol) {
addToken(tokens, XercesXPath::EXPRTOKEN_AXISNAME_DESCENDANT_OR_SELF);
} else if (nameHandle == fFollowingSymbol) {
addToken(tokens, XercesXPath::EXPRTOKEN_AXISNAME_FOLLOWING);
} else if (nameHandle == fFollowingSiblingSymbol) {
addToken(tokens, XercesXPath::EXPRTOKEN_AXISNAME_FOLLOWING_SIBLING);
} else if (nameHandle == fNamespaceSymbol) {
addToken(tokens, XercesXPath::EXPRTOKEN_AXISNAME_NAMESPACE);
} else if (nameHandle == fParentSymbol) {
addToken(tokens, XercesXPath::EXPRTOKEN_AXISNAME_PARENT);
} else if (nameHandle == fPrecedingSymbol) {
addToken(tokens, XercesXPath::EXPRTOKEN_AXISNAME_PRECEDING);
} else if (nameHandle == fPrecedingSiblingSymbol) {
addToken(tokens, XercesXPath::EXPRTOKEN_AXISNAME_PRECEDING_SIBLING);
} else if (nameHandle == fSelfSymbol) {
addToken(tokens, XercesXPath::EXPRTOKEN_AXISNAME_SELF);
} else {
return false; // REVISIT
}
if (isNameTestNCName) {
return false; // REVISIT - "NCName:* ::" where "AxisName ::" is required
}
addToken(tokens, XercesXPath::EXPRTOKEN_DOUBLE_COLON);
starIsMultiplyOperator = false;
if (!isAxisName) {
currentOffset += 2;
}
break;
}
//
// Otherwise, the token must not be recognized as an OperatorName, a NodeType, a
// FunctionName, or an AxisName.
//
if (isNameTestNCName) {
addToken(tokens, XercesXPath::EXPRTOKEN_NAMETEST_NAMESPACE);
tokens->addElement(nameHandle);
} else {
addToken(tokens, XercesXPath::EXPRTOKEN_NAMETEST_QNAME);
tokens->addElement(prefixHandle);
tokens->addElement(nameHandle);
}
starIsMultiplyOperator = true;
break;
}
}
return true;
}
int XPathScanner::scanNCName(const XMLCh* const data,
const int endOffset,
int currentOffset) {
XMLCh ch = data[currentOffset];
if (!XMLReader::isXMLLetter(ch) && ch != chUnderscore) {
return currentOffset;
}
while (++currentOffset < endOffset) {
ch = data[currentOffset];
if (!XMLReader::isNameChar(ch)) {
break;
}
}
return currentOffset;
}
int XPathScanner::scanNumber(const XMLCh* const data,
const int endOffset,
int currentOffset,
ValueVectorOf<int>* const tokens) {
XMLCh ch = data[currentOffset];
int whole = 0;
int part = 0;
while (ch >= chDigit_0 && ch <= chDigit_9) {
whole = (whole * 10) + (ch - chDigit_0);
if (++currentOffset == endOffset) {
break;
}
ch = data[currentOffset];
}
if (ch == chPeriod) {
if (++currentOffset < endOffset) {
int start = currentOffset;
ch = data[currentOffset];
while (ch >= chDigit_0 && ch <= chDigit_9) {
part = (part * 10) + (ch - chDigit_0);
if (++currentOffset == endOffset) {
break;
}
ch = data[currentOffset];
}
if (part != 0) {
ThrowXML(RuntimeException, XMLExcepts::XPath_FindSolution);
}
}
}
tokens->addElement(whole);
tokens->addElement(part);
return currentOffset;
}
// ---------------------------------------------------------------------------
// XPathScannerForSchema: Constructors and Destructor
// ---------------------------------------------------------------------------
XPathScannerForSchema::XPathScannerForSchema(XMLStringPool* const stringPool)
: XPathScanner(stringPool)
{
}
// ---------------------------------------------------------------------------
// XPathScannerForSchema: Helper methods
// ---------------------------------------------------------------------------
void XPathScannerForSchema::addToken(ValueVectorOf<int>* const tokens,
const int aToken) {
if (aToken == XercesXPath::EXPRTOKEN_ATSIGN ||
aToken == XercesXPath::EXPRTOKEN_AXISNAME_ATTRIBUTE ||
aToken == XercesXPath::EXPRTOKEN_AXISNAME_CHILD ||
//token == XercesXPath::EXPRTOKEN_AXISNAME_SELF ||
aToken == XercesXPath::EXPRTOKEN_DOUBLE_COLON ||
aToken == XercesXPath::EXPRTOKEN_NAMETEST_QNAME ||
//token == XercesXPath::EXPRTOKEN_NODETYPE_NODE ||
aToken == XercesXPath::EXPRTOKEN_OPERATOR_SLASH ||
aToken == XercesXPath::EXPRTOKEN_PERIOD ||
aToken == XercesXPath::EXPRTOKEN_NAMETEST_ANY ||
aToken == XercesXPath::EXPRTOKEN_NAMETEST_NAMESPACE ||
aToken == XercesXPath::EXPRTOKEN_OPERATOR_DOUBLE_SLASH ||
aToken == XercesXPath::EXPRTOKEN_OPERATOR_UNION) {
tokens->addElement(aToken);
return;
}
ThrowXML(XPathException, XMLExcepts::XPath_TokenNotSupported);
}
/**
* End of file XercesPath.cpp
*/
1.1 xml-xerces/c/src/validators/schema/identity/ValueStoreCache.hpp
Index: ValueStoreCache.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xerces" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache\@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation, and was
* originally based on software copyright (c) 2001, International
* Business Machines, Inc., http://www.ibm.com . For more information
* on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
/*
* $Id: ValueStoreCache.hpp,v 1.1 2001/11/02 14:08:40 knoaman Exp $
*/
#if !defined(VALUESTORECACHE_HPP)
#define 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., wen 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 <util/RefVectorOf.hpp>
#include <util/RefHashTableOf.hpp>
#include <util/RefStackOf.hpp>
#include <validators/schema/identity/IdentityConstraint.hpp>
#include <validators/schema/identity/IC_Field.hpp>
// ---------------------------------------------------------------------------
// Forward Declcaration
// ---------------------------------------------------------------------------
class ValueStore;
class SchemaElementDecl;
class XMLScanner;
class VALIDATORS_EXPORT ValueStoreCache
{
public:
// -----------------------------------------------------------------------
// Constructors/Destructor
// -----------------------------------------------------------------------
ValueStoreCache();
~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);
// -----------------------------------------------------------------------
// Access methods
// -----------------------------------------------------------------------
ValueStore* getValueStoreFor(const IC_Field* const field);
ValueStore* getValueStoreFor(const IdentityConstraint* const ic);
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);
private:
// -----------------------------------------------------------------------
// Unimplemented contstructors and operators
// -----------------------------------------------------------------------
ValueStoreCache(const ValueStoreCache& other);
ValueStoreCache& operator= (const ValueStoreCache& other);
// -----------------------------------------------------------------------
// Helper methods
// -----------------------------------------------------------------------
void init();
void cleanUp();
// -----------------------------------------------------------------------
// Data
// -----------------------------------------------------------------------
RefVectorOf<ValueStore>* fValueStores;
RefHashTableOf<ValueStore>* fGlobalICMap;
RefHashTableOf<ValueStore>* fIC2ValueStoreMap;
RefStackOf<RefHashTableOf<ValueStore> >* fGlobalMapStack;
XMLScanner* fScanner;
};
// ---------------------------------------------------------------------------
// ValueStoreCache: Access methods
// ---------------------------------------------------------------------------
inline void ValueStoreCache::setScanner(XMLScanner* const scanner) {
fScanner = scanner;
}
// ---------------------------------------------------------------------------
// ValueStoreCache: Access methods
// ---------------------------------------------------------------------------
inline ValueStore*
ValueStoreCache::getValueStoreFor(const IC_Field* const field) {
return fIC2ValueStoreMap->get(field->getIdentityConstraint());
}
inline ValueStore*
ValueStoreCache::getValueStoreFor(const IdentityConstraint* const ic) {
return fIC2ValueStoreMap->get(ic);
}
inline ValueStore*
ValueStoreCache::getGlobalValueStoreFor(const IdentityConstraint* const ic) {
return fGlobalICMap->get(ic);
}
// ---------------------------------------------------------------------------
// ValueStoreCache: Document handling methods
// ---------------------------------------------------------------------------
inline void ValueStoreCache::endDocument() {
}
#endif
/**
* End of file ValueStoreCache.hpp
*/
1.1 xml-xerces/c/src/validators/schema/identity/ValueStoreCache.cpp
Index: ValueStoreCache.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xerces" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache\@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation, and was
* originally based on software copyright (c) 1999, International
* Business Machines, Inc., http://www.ibm.com . For more information
* on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
/*
* $Log: ValueStoreCache.cpp,v $
* Revision 1.1 2001/11/02 14:08:40 knoaman
* Add support for identity constraints.
*
*/
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <validators/schema/identity/ValueStoreCache.hpp>
#include <validators/schema/identity/ValueStore.hpp>
#include <validators/schema/SchemaElementDecl.hpp>
#include <util/HashPtr.hpp>
// ---------------------------------------------------------------------------
// ValueStoreCache: Constructors and Destructor
// ---------------------------------------------------------------------------
ValueStoreCache::ValueStoreCache()
: fValueStores(0)
, fGlobalICMap(0)
, fIC2ValueStoreMap(0)
, fGlobalMapStack(0)
{
try {
init();
}
catch(...) {
cleanUp();
throw;
}
}
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 RefHashTableOf<ValueStore>(13, false, new HashPtr());
}
void ValueStoreCache::endElement() {
if (fGlobalMapStack->empty()) {
return; // must be an invalid doc!
}
RefHashTableOf<ValueStore>* oldMap = fGlobalMapStack->pop();
RefHashTableOfEnumerator<ValueStore> mapEnum(oldMap);
// 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 RefVectorOf<ValueStore>(8);
fGlobalICMap = new RefHashTableOf<ValueStore>(13, false, new HashPtr());
fIC2ValueStoreMap = new RefHashTableOf<ValueStore>(13, false, new HashPtr());
fGlobalMapStack = new RefStackOf<RefHashTableOf<ValueStore> >(8);
}
void ValueStoreCache::initValueStoresFor(SchemaElementDecl* const elemDecl) {
// initialize value stores for unique fields
unsigned int icCount = elemDecl->getIdentityConstraintCount();
for (unsigned int i=0; i<icCount; i++) {
IdentityConstraint* ic = elemDecl->getIdentityConstraintAt(i);
ValueStore* valueStore = fIC2ValueStoreMap->get(ic);
if (valueStore && ic->getType() != IdentityConstraint::KEYREF) {
continue;
}
valueStore = new ValueStore(ic, fScanner);
fValueStores->addElement(valueStore);
fIC2ValueStoreMap->put(ic, valueStore);
}
}
void ValueStoreCache::transplant(IdentityConstraint* const ic) {
if (ic->getType() == IdentityConstraint::KEYREF) {
return;
}
ValueStore* newVals = fIC2ValueStoreMap->get(ic);
ValueStore* currVals = fGlobalICMap->get(ic);
fIC2ValueStoreMap->removeKey(ic);
if (currVals) {
currVals->append(newVals);
} else {
fGlobalICMap->put(ic, newVals);
}
}
/**
* End of file ValueStoreCache.cpp
*/
1.1 xml-xerces/c/src/validators/schema/identity/ValueStore.hpp
Index: ValueStore.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xerces" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache\@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation, and was
* originally based on software copyright (c) 2001, International
* Business Machines, Inc., http://www.ibm.com . For more information
* on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
/*
* $Id: ValueStore.hpp,v 1.1 2001/11/02 14:08:40 knoaman Exp $
*/
#if !defined(VALUESTORE_HPP)
#define 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 <validators/schema/identity/FieldValueMap.hpp>
// ---------------------------------------------------------------------------
// Forward Declaration
// ---------------------------------------------------------------------------
class IdentityConstraint;
class XMLScanner;
class ValueStoreCache;
class VALIDATORS_EXPORT ValueStore
{
public:
// -----------------------------------------------------------------------
// Constructors/Destructor
// -----------------------------------------------------------------------
ValueStore(IdentityConstraint* const ic, XMLScanner* const scanner);
~ValueStore();
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
IdentityConstraint* getIdentityConstraint() const;
// -----------------------------------------------------------------------
// Helper methods
// -----------------------------------------------------------------------
void append(const ValueStore* const other);
void startValueScope();
void endValueScope();
void addValue(IC_Field* const field, DatatypeValidator* const dv,
const XMLCh* const value);
bool contains(const FieldValueMap* const other);
// -----------------------------------------------------------------------
// Document handling methods
// -----------------------------------------------------------------------
void endDcocumentFragment(ValueStoreCache* const valueStoreCache);
// -----------------------------------------------------------------------
// Error reporting methods
// -----------------------------------------------------------------------
void duplicateValue();
void reportNilError(IdentityConstraint* const ic);
private:
// -----------------------------------------------------------------------
// Unimplemented contstructors and operators
// -----------------------------------------------------------------------
ValueStore(const ValueStore& other);
ValueStore& operator= (const ValueStore& other);
// -----------------------------------------------------------------------
// 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);
// -----------------------------------------------------------------------
// Data
// -----------------------------------------------------------------------
bool fDoReportError;
int fValuesCount;
IdentityConstraint* fIdentityConstraint;
FieldValueMap fValues;
RefVectorOf<FieldValueMap>* fValueTuples;
ValueStore* fKeyValueStore;
XMLScanner* fScanner; // for error reporting - REVISIT
};
// ---------------------------------------------------------------------------
// ValueStore: Getter methods
// ---------------------------------------------------------------------------
inline IdentityConstraint*
ValueStore::getIdentityConstraint() const {
return fIdentityConstraint;
}
#endif
/**
* End of file ValueStore.hpp
*/
1.1 xml-xerces/c/src/validators/schema/identity/ValueStore.cpp
Index: ValueStore.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xerces" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache\@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation, and was
* originally based on software copyright (c) 1999, International
* Business Machines, Inc., http://www.ibm.com . For more information
* on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
/*
* $Log: ValueStore.cpp,v $
* Revision 1.1 2001/11/02 14:08:40 knoaman
* Add support for identity constraints.
*
*/
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <internal/XMLScanner.hpp>
#include <validators/schema/identity/ValueStore.hpp>
#include <validators/schema/identity/IC_Field.hpp>
#include <validators/schema/identity/IC_KeyRef.hpp>
#include <validators/schema/identity/ValueStoreCache.hpp>
// ---------------------------------------------------------------------------
// ValueStore: Constructors and Destructor
// ---------------------------------------------------------------------------
ValueStore::ValueStore(IdentityConstraint* const ic,
XMLScanner* const scanner)
: fDoReportError(false)
, fValuesCount(0)
, fIdentityConstraint(ic)
, fValueTuples(0)
, fKeyValueStore(0)
, fScanner(scanner)
{
fDoReportError = (scanner && scanner->getDoValidation());
}
ValueStore::~ValueStore()
{
delete fValueTuples;
}
// ---------------------------------------------------------------------------
// ValueStore: Helper methods
// ---------------------------------------------------------------------------
void ValueStore::addValue(IC_Field* const field,
DatatypeValidator* const dv,
const XMLCh* const value) {
if (!field->getMayMatch() && fDoReportError) {
fScanner->getValidator()->emitError(XMLValid::IC_FieldMultipleMatch);
}
// do we even know this field?
int index = fValues.indexOf(field);
if (index == -1) {
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 == (int) fValues.size()) {
// is this value as a group duplicated?
if (contains(&fValues)) {
duplicateValue();
}
// store values
if (!fValueTuples) {
fValueTuples = new RefVectorOf<FieldValueMap>(4);
}
fValueTuples->addElement(new FieldValueMap(fValues));
}
}
void ValueStore::append(const ValueStore* const other) {
if (!other->fValueTuples) {
return;
}
unsigned int tupleSize = other->fValueTuples->size();
for (unsigned int i=0; i<tupleSize; i++) {
FieldValueMap* valueMap = other->fValueTuples->elementAt(i);
if (!contains(valueMap)) {
fValueTuples->addElement(new FieldValueMap(*valueMap));
}
}
}
void ValueStore::startValueScope() {
fValuesCount = 0;
int count = fIdentityConstraint->getFieldCount();
for (int i = 0; i < count; i++) {
fValues.put(fIdentityConstraint->getFieldAt(i), 0, 0);
}
}
void ValueStore::endValueScope() {
if (fValuesCount == 0) {
if (fIdentityConstraint->getType() == IdentityConstraint::KEY && fDoReportError) {
fScanner->getValidator()->emitError(XMLValid::IC_AbsentKeyValue,
fIdentityConstraint->getElementName());
}
return;
}
// do we have enough values?
if ((fValuesCount != fIdentityConstraint->getFieldCount()) && fDoReportError) {
switch (fIdentityConstraint->getType()) {
case IdentityConstraint::UNIQUE:
{
fScanner->getValidator()->emitError(XMLValid::IC_UniqueNotEnoughValues,
fIdentityConstraint->getElementName());
break;
}
case IdentityConstraint::KEY:
{
fScanner->getValidator()->emitError(XMLValid::IC_KeyNotEnoughValues,
fIdentityConstraint->getElementName(), fIdentityConstraint->getIdentityConstraintName());
break;
}
case IdentityConstraint::KEYREF:
{
fScanner->getValidator()->emitError(XMLValid::IC_KeyRefNotEnoughValues,
fIdentityConstraint->getElementName(), fIdentityConstraint->getIdentityConstraintName());
break;
}
}
}
}
bool ValueStore::contains(const FieldValueMap* const other) {
if (fValueTuples) {
unsigned int otherSize = other->size();
unsigned int tupleSize = fValueTuples->size();
for (unsigned int i=0; i<tupleSize; i++) {
FieldValueMap* valueMap = fValueTuples->elementAt(i);
if (otherSize == valueMap->size()) {
bool matchFound = true;
for (unsigned int j=0; j<otherSize; j++) {
if (!isDuplicateOf(valueMap->getDatatypeValidatorAt(j), valueMap->getValueAt(j),
other->getDatatypeValidatorAt(j), other->getValueAt(j))) {
matchFound = false;
break;
}
}
if (matchFound) { // found it
return true;
}
}
}
}
return false;
}
bool ValueStore::isDuplicateOf(DatatypeValidator* const dv1, const XMLCh* const val1,
DatatypeValidator* const dv2, const XMLCh* const val2) {
// if either validator's null, fall back on string comparison
if(!dv1 || !dv2) {
return ((XMLString::compareString(val1, val2)) == 0);
}
// are the validators equal?
// As always we are obliged to compare by reference...
if (dv1 == dv2) {
return ((dv1->compare(val1, val2)) == 0);
}
// see if this.fValidator is derived from value.fValidator:
DatatypeValidator* tempVal = dv1;
for(; !tempVal || tempVal == dv2; tempVal = tempVal->getBaseValidator());
if (tempVal) { // was derived!
return ((dv2->compare(val1, val2)) == 0);
}
// see if value.fValidator is derived from this.fValidator:
for(tempVal = dv2; !tempVal || tempVal == dv1; tempVal = tempVal->getBaseValidator());
if(tempVal) { // was derived!
return ((dv1->compare(val1, val2)) == 0);
}
// if we're here it means the types weren't related. Must fall back to strings:
return ((XMLString::compareString(val1, val2)) == 0);
}
// ---------------------------------------------------------------------------
// ValueStore: Docuement handling methods
// ---------------------------------------------------------------------------
void ValueStore::endDcocumentFragment(ValueStoreCache* const valueStoreCache) {
if (fIdentityConstraint->getType() == IdentityConstraint::KEYREF) {
// verify references
// get the key store corresponding (if it exists):
fKeyValueStore = valueStoreCache->getGlobalValueStoreFor(((IC_KeyRef*) fIdentityConstraint)->getKey());
if (!fKeyValueStore) {
if (fDoReportError) {
fScanner->getValidator()->emitError(XMLValid::IC_KeyRefOutOfScope,
fIdentityConstraint->getIdentityConstraintName());
}
return;
}
unsigned int count = (fValueTuples) ? fValueTuples->size() : 0;
for (unsigned int i = 0; i < count; i++) {
FieldValueMap* valueMap = fValueTuples->elementAt(i);
if (!fKeyValueStore->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::KEY) {
fScanner->getValidator()->emitError(XMLValid::IC_KeyMatchesNillable,
ic->getElementName());
}
}
void ValueStore::duplicateValue() {
if (fDoReportError) {
switch (fIdentityConstraint->getType()) {
case IdentityConstraint::UNIQUE:
{
fScanner->getValidator()->emitError(XMLValid::IC_DuplicateUnique,
fIdentityConstraint->getElementName());
break;
}
case IdentityConstraint::KEY:
{
fScanner->getValidator()->emitError(XMLValid::IC_DuplicateKey,
fIdentityConstraint->getElementName());
break;
}
}
}
}
/**
* End of file ValueStore.cpp
*/
1.1 xml-xerces/c/src/validators/schema/identity/Makefile.in
Index: Makefile.in
===================================================================
#
# The Apache Software License, Version 1.1
#
# Copyright (c) 2001 The Apache Software Foundation. All rights
# reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
#
# 3. The end-user documentation included with the redistribution,
# if any, must include the following acknowledgment:
# "This product includes software developed by the
# Apache Software Foundation (http://www.apache.org/)."
# Alternately, this acknowledgment may appear in the software itself,
# if and wherever such third-party acknowledgments normally appear.
#
# 4. The names "Xerces" and "Apache Software Foundation" must
# not be used to endorse or promote products derived from this
# software without prior written permission. For written
# permission, please contact apache\@apache.org.
#
# 5. Products derived from this software may not be called "Apache",
# nor may "Apache" appear in their name, without prior written
# permission of the Apache Software Foundation.
#
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
# ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
# ====================================================================
#
# This software consists of voluntary contributions made by many
# individuals on behalf of the Apache Software Foundation, and was
# originally based on software copyright (c) 2001, International
# Business Machines, Inc., http://www.ibm.com . For more information
# on the Apache Software Foundation, please see
# <http://www.apache.org/>.
#
#
# $Log: Makefile.in,v $
# Revision 1.1 2001/11/02 14:08:40 knoaman
# Add support for identity constraints.
#
#
PLATFORM = @platform@
CC = @cc@
CXX = @cxx@
CXXFLAGS = @cxxflags@
CFLAGS = @cflags@
PREFIX = @prefix@
PREFIX_INCLUDE = @prefix_include@
LDFLAGS = @ldflags@
LIBS = @libs@
OSVER = @osver@
USELIBWWW = @uselibwww@
MESSAGELOADER = @messageloader@
TRANSCODER = @transcoder@
THREADS = @threads@
include ../../../Makefile.incl
MODULE = validators
SUBMODULE = schema/identity
XML_INCL := $(XML_INCL) -I$(XERCESCROOT)/src
VALIDATORS_SCHEMA_CPP_PUBHEADERS = \
FieldActivator.hpp \
FieldValueMap.hpp \
IC_Field.hpp \
IC_Key.hpp \
IC_KeyRef.hpp \
IC_Selector.hpp \
IC_Unique.hpp \
IdentityConstraint.hpp \
ValueStore.hpp \
ValueStoreCache.hpp \
XercesXPath.hpp \
XPathException.hpp \
XPathMatcher.hpp \
XPathMatcherStack.hpp \
XPathSymbols.hpp
VALIDATORS_SCHEMA_CPP_PRIVHEADERS =
VALIDATORS_SCHEMA_C_FILES =
VALIDATORS_SCHEMA_CPP_OBJECTS = \
FieldActivator.$(TO) \
FieldValueMap.$(TO) \
IC_Field.$(TO) \
IC_Key.$(TO) \
IC_KeyRef.$(TO) \
IC_Selector.$(TO) \
IC_Unique.$(TO) \
IdentityConstraint.$(TO) \
ValueStore.$(TO) \
ValueStoreCache.$(TO) \
XercesXPath.$(TO) \
XPathMatcher.$(TO) \
XPathMatcherStack.$(TO) \
XPathSymbols.$(TO)
all:: includes $(VALIDATORS_SCHEMA_CPP_OBJECTS)
includes:: pubheaders $(VALIDATORS_SCHEMA_C_FILES)
pubheaders::
-mkdir -p $(XML_INC_DIR)/$(MODULE)/$(SUBMODULE)
$(CP) $(VALIDATORS_SCHEMA_CPP_PUBHEADERS) $(VALIDATORS_SCHEMA_C_FILES) $(XML_INC_DIR)/$(MODULE)/$(SUBMODULE)
# this may generate unnecessary dependencies, but it makes life easier
depend:: includes
$(MAKE_DEPEND) $(XML_INCL) *.cpp > $(DEPFILE)
clean::
@echo "Making clean in $(MODULE)/$(SUBMODULE) ..."
$(RM2) $(addprefix $(XML_OBJ_DIR)/,$(VALIDATORS_SCHEMA_CPP_OBJECTS))
distclean:: clean
$(RM) Makefile $(DEPFILE)
@echo "Removing all $(MODULE)/$(SUBMODULE) header files ..."
$(RM2) $(addprefix $(XML_INC_DIR)/$(MODULE)/$(SUBMODULE)/,$(VALIDATORS_SCHEMA_CPP_PUBHEADERS))
install::
-mkdir -p $(PREFIX_INCLUDE)/$(MODULE)/$(SUBMODULE)
$(CP) $(VALIDATORS_SCHEMA_CPP_PUBHEADERS) $(VALIDATORS_SCHEMA_C_FILES) $(PREFIX_INCLUDE)/$(MODULE)/$(SUBMODULE)
1.1 xml-xerces/c/src/validators/schema/identity/IdentityConstraint.hpp
Index: IdentityConstraint.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xerces" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache\@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation, and was
* originally based on software copyright (c) 2001, International
* Business Machines, Inc., http://www.ibm.com . For more information
* on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
/*
* $Id: IdentityConstraint.hpp,v 1.1 2001/11/02 14:08:40 knoaman Exp $
*/
#if !defined(IDENTITYCONSTRAINT_HPP)
#define IDENTITYCONSTRAINT_HPP
/**
* The class act as a base class for schema identity constraints.
*/
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <util/RefVectorOf.hpp>
// ---------------------------------------------------------------------------
// Forward Declarations
// ---------------------------------------------------------------------------
class IC_Selector;
class IC_Field;
class VALIDATORS_EXPORT IdentityConstraint
{
public:
// -----------------------------------------------------------------------
// Constants
// -----------------------------------------------------------------------
enum {
UNIQUE = 0,
KEY = 1,
KEYREF = 2
};
// -----------------------------------------------------------------------
// Constructors/Destructor
// -----------------------------------------------------------------------
virtual ~IdentityConstraint();
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
virtual short getType() const = 0;
int getFieldCount() const;
XMLCh* getIdentityConstraintName() const;
XMLCh* getElementName() const;
IC_Selector* getSelector() const;
// -----------------------------------------------------------------------
// Setter methods
// -----------------------------------------------------------------------
void setSelector(IC_Selector* const selector);
// -----------------------------------------------------------------------
// Access methods
// -----------------------------------------------------------------------
void addField(IC_Field* const field);
const IC_Field* getFieldAt(const unsigned int index) const;
IC_Field* getFieldAt(const unsigned int index);
protected:
// -----------------------------------------------------------------------
// Constructors/Destructor
// -----------------------------------------------------------------------
IdentityConstraint(const XMLCh* const identityConstraintName,
const XMLCh* const elementName);
private:
// -----------------------------------------------------------------------
// Unimplemented contstructors 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;
};
// ---------------------------------------------------------------------------
// IdentityConstraint: Getter methods
// ---------------------------------------------------------------------------
inline int 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;
}
// ---------------------------------------------------------------------------
// IdentityConstraint: Access methods
// ---------------------------------------------------------------------------
inline void IdentityConstraint::addField(IC_Field* const field) {
if (!fFields) {
fFields = new RefVectorOf<IC_Field>(4);
}
fFields->addElement(field);
}
inline const IC_Field* IdentityConstraint::getFieldAt(const unsigned int index) const {
if (fFields) {
return (fFields->elementAt(index));
}
return 0;
}
inline IC_Field* IdentityConstraint::getFieldAt(const unsigned int index) {
if (fFields) {
return (fFields->elementAt(index));
}
return 0;
}
#endif
/**
* End of file IdentityConstraint.hpp
*/
1.1 xml-xerces/c/src/validators/schema/identity/IdentityConstraint.cpp
Index: IdentityConstraint.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xerces" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache\@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation, and was
* originally based on software copyright (c) 1999, International
* Business Machines, Inc., http://www.ibm.com . For more information
* on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
/*
* $Log: IdentityConstraint.cpp,v $
* Revision 1.1 2001/11/02 14:08:40 knoaman
* Add support for identity constraints.
*
*/
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <validators/schema/identity/IdentityConstraint.hpp>
#include <validators/schema/identity/IC_Selector.hpp>
#include <validators/schema/identity/IC_Field.hpp>
#include <util/XMLString.hpp>
// ---------------------------------------------------------------------------
// IdentityConstraint: Constructors and Destructor
// ---------------------------------------------------------------------------
IdentityConstraint::IdentityConstraint(const XMLCh* const identityConstraintName,
const XMLCh* const elemName)
: fIdentityConstraintName(XMLString::replicate(identityConstraintName))
, fElemName(0)
, fSelector(0)
, fFields(0)
{
try {
fElemName = XMLString::replicate(elemName);
}
catch(...) {
cleanUp();
throw;
}
}
IdentityConstraint::~IdentityConstraint()
{
cleanUp();
}
// ---------------------------------------------------------------------------
// IdentityConstraint: Setter methods
// ---------------------------------------------------------------------------
void IdentityConstraint::setSelector(IC_Selector* const selector) {
if (fSelector) {
delete fSelector;
}
fSelector = selector;
}
// ---------------------------------------------------------------------------
// IdentityConstraint: cleanUp methods
// ---------------------------------------------------------------------------
void IdentityConstraint::cleanUp() {
delete [] fIdentityConstraintName;
delete [] fElemName;
delete fFields;
delete fSelector;
}
/**
* End of file IdentityConstraint.cpp
*/
1.1 xml-xerces/c/src/validators/schema/identity/IC_Unique.hpp
Index: IC_Unique.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xerces" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache\@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation, and was
* originally based on software copyright (c) 2001, International
* Business Machines, Inc., http://www.ibm.com . For more information
* on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
/*
* $Id: IC_Unique.hpp,v 1.1 2001/11/02 14:08:40 knoaman Exp $
*/
#if !defined(IC_UNIQUE_HPP)
#define IC_UNIQUE_HPP
/**
* Schema unique identity constraint
*/
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <validators/schema/identity/IdentityConstraint.hpp>
class VALIDATORS_EXPORT IC_Unique: public IdentityConstraint
{
public:
// -----------------------------------------------------------------------
// Constructors/Destructor
// -----------------------------------------------------------------------
IC_Unique(const XMLCh* const identityConstraintName,
const XMLCh* const elemName);
~IC_Unique();
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
short getType() const;
private:
// -----------------------------------------------------------------------
// Unimplemented contstructors 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::UNIQUE;
}
#endif
/**
* End of file IC_Unique.hpp
*/
1.1 xml-xerces/c/src/validators/schema/identity/IC_Unique.cpp
Index: IC_Unique.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xerces" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache\@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation, and was
* originally based on software copyright (c) 1999, International
* Business Machines, Inc., http://www.ibm.com . For more information
* on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
/*
* $Log: IC_Unique.cpp,v $
* Revision 1.1 2001/11/02 14:08:40 knoaman
* Add support for identity constraints.
*
*/
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <validators/schema/identity/IC_Unique.hpp>
// ---------------------------------------------------------------------------
// IC_Unique: Constructors and Destructor
// ---------------------------------------------------------------------------
IC_Unique::IC_Unique(const XMLCh* const identityConstraintName,
const XMLCh* const elemName)
: IdentityConstraint(identityConstraintName, elemName)
{
}
IC_Unique::~IC_Unique()
{
}
/**
* End of file IC_Unique.cpp
*/
1.1 xml-xerces/c/src/validators/schema/identity/IC_Selector.hpp
Index: IC_Selector.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xerces" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache\@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation, and was
* originally based on software copyright (c) 2001, International
* Business Machines, Inc., http://www.ibm.com . For more information
* on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
/*
* $Id: IC_Selector.hpp,v 1.1 2001/11/02 14:08:40 knoaman Exp $
*/
#if !defined(IC_SELECTOR_HPP)
#define IC_SELECTOR_HPP
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <validators/schema/identity/XPathMatcher.hpp>
// ---------------------------------------------------------------------------
// Forward Declaration
// ---------------------------------------------------------------------------
class FieldActivator;
class VALIDATORS_EXPORT IC_Selector
{
public:
// -----------------------------------------------------------------------
// Constructors/Destructor
// -----------------------------------------------------------------------
IC_Selector(XercesXPath* const xpath,
IdentityConstraint* const identityConstraint);
~IC_Selector();
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
XercesXPath* getXPath() const { return fXPath; }
IdentityConstraint* getIdentityConstraint() const { return fIdentityConstraint; }
// -----------------------------------------------------------------------
// Factory methods
// -----------------------------------------------------------------------
XPathMatcher* createMatcher(FieldActivator* const fieldActivator);
private:
// -----------------------------------------------------------------------
// Unimplemented contstructors 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() {}
// -----------------------------------------------------------------------
// XMLDocumentHandler methods
// -----------------------------------------------------------------------
void startDocumentFragment();
void startElement(const XMLElementDecl& elemDecl,
const RefVectorOf<XMLAttr>& attrList,
const unsigned int attrCount);
void endElement(const XMLElementDecl& elemDecl);
private:
// -----------------------------------------------------------------------
// Constructors/Destructor
// -----------------------------------------------------------------------
SelectorMatcher(XercesXPath* const anXPath, IC_Selector* const selector,
FieldActivator* const fieldActivator);
// -----------------------------------------------------------------------
// Unimplemented contstructors and operators
// -----------------------------------------------------------------------
SelectorMatcher(const SelectorMatcher& other);
SelectorMatcher& operator= (const SelectorMatcher& other);
// -----------------------------------------------------------------------
// Friends
// -----------------------------------------------------------------------
friend class IC_Selector;
// -----------------------------------------------------------------------
// Data members
// -----------------------------------------------------------------------
int fElementDepth;
int fMatchedDepth;
IC_Selector* fSelector;
FieldActivator* fFieldActivator;
};
#endif
/**
* End of file IC_Selector.hpp
*/
1.1 xml-xerces/c/src/validators/schema/identity/IC_Selector.cpp
Index: IC_Selector.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xerces" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache\@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation, and was
* originally based on software copyright (c) 1999, International
* Business Machines, Inc., http://www.ibm.com . For more information
* on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
/*
* $Log: IC_Selector.cpp,v $
* Revision 1.1 2001/11/02 14:08:40 knoaman
* Add support for identity constraints.
*
*/
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <validators/schema/identity/IC_Selector.hpp>
#include <validators/schema/identity/XercesXPath.hpp>
#include <validators/schema/identity/IdentityConstraint.hpp>
#include <validators/schema/identity/FieldActivator.hpp>
// ---------------------------------------------------------------------------
// SelectorMatcher: Constructors and Destructor
// ---------------------------------------------------------------------------
SelectorMatcher::SelectorMatcher(XercesXPath* const xpath,
IC_Selector* const selector,
FieldActivator* const fieldActivator)
: XPathMatcher(xpath, false, selector->getIdentityConstraint())
, 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 RefVectorOf<XMLAttr>& attrList,
const unsigned int attrCount) {
XPathMatcher::startElement(elemDecl, attrList, attrCount);
fElementDepth++;
// activate the fields, if selector is matched
if (fMatchedDepth == -1 && isMatched()) {
IdentityConstraint* ic = fSelector->getIdentityConstraint();
int count = ic->getFieldCount();
fMatchedDepth = fElementDepth;
fFieldActivator->startValueScopeFor(ic);
for (int i = 0; i < count; i++) {
IC_Field* field = ic->getFieldAt(i);
XPathMatcher* matcher = fFieldActivator->activateField(field);
matcher->startElement(elemDecl, attrList, attrCount);
}
}
}
void SelectorMatcher::endElement(const XMLElementDecl& elemDecl) {
XPathMatcher::endElement(elemDecl);
if (fElementDepth-- == fMatchedDepth) {
fMatchedDepth = -1;
fFieldActivator->endValueScopeFor(fSelector->getIdentityConstraint());
}
}
// ---------------------------------------------------------------------------
// 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: Factory methods
// ---------------------------------------------------------------------------
XPathMatcher* IC_Selector::createMatcher(FieldActivator* const fieldActivator) {
return new SelectorMatcher(fXPath, this, fieldActivator);
}
/**
* End of file IC_Selector.cpp
*/
1.1 xml-xerces/c/src/validators/schema/identity/IC_KeyRef.hpp
Index: IC_KeyRef.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xerces" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache\@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation, and was
* originally based on software copyright (c) 2001, International
* Business Machines, Inc., http://www.ibm.com . For more information
* on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
/*
* $Id: IC_KeyRef.hpp,v 1.1 2001/11/02 14:08:40 knoaman Exp $
*/
#if !defined(IC_KEYREF_HPP)
#define IC_KEYREF_HPP
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <validators/schema/identity/IdentityConstraint.hpp>
class VALIDATORS_EXPORT IC_KeyRef: public IdentityConstraint
{
public:
// -----------------------------------------------------------------------
// Constructors/Destructor
// -----------------------------------------------------------------------
IC_KeyRef(const XMLCh* const identityConstraintName,
const XMLCh* const elemName,
IdentityConstraint* const icKey);
~IC_KeyRef();
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
short getType() const;
IdentityConstraint* getKey() const;
private:
// -----------------------------------------------------------------------
// Unimplemented contstructors 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::KEYREF;
}
inline IdentityConstraint* IC_KeyRef::getKey() const {
return fKey;
}
#endif
/**
* End of file IC_KeyRef.hpp
*/
1.1 xml-xerces/c/src/validators/schema/identity/IC_KeyRef.cpp
Index: IC_KeyRef.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xerces" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache\@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation, and was
* originally based on software copyright (c) 1999, International
* Business Machines, Inc., http://www.ibm.com . For more information
* on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
/*
* $Log: IC_KeyRef.cpp,v $
* Revision 1.1 2001/11/02 14:08:40 knoaman
* Add support for identity constraints.
*
*/
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <validators/schema/identity/IC_KeyRef.hpp>
// ---------------------------------------------------------------------------
// IC_KeyRef: Constructors and Destructor
// ---------------------------------------------------------------------------
IC_KeyRef::IC_KeyRef(const XMLCh* const identityConstraintName,
const XMLCh* const elemName,
IdentityConstraint* const icKey)
: IdentityConstraint(identityConstraintName, elemName)
, fKey(icKey)
{
}
IC_KeyRef::~IC_KeyRef()
{
}
/**
* End of file IC_KeyRef.cpp
*/
1.1 xml-xerces/c/src/validators/schema/identity/IC_Key.hpp
Index: IC_Key.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xerces" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache\@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation, and was
* originally based on software copyright (c) 2001, International
* Business Machines, Inc., http://www.ibm.com . For more information
* on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
/*
* $Id: IC_Key.hpp,v 1.1 2001/11/02 14:08:40 knoaman Exp $
*/
#if !defined(IC_KEY_HPP)
#define IC_KEY_HPP
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <validators/schema/identity/IdentityConstraint.hpp>
class VALIDATORS_EXPORT IC_Key: public IdentityConstraint
{
public:
// -----------------------------------------------------------------------
// Constructors/Destructor
// -----------------------------------------------------------------------
IC_Key(const XMLCh* const identityConstraintName,
const XMLCh* const elemName);
~IC_Key();
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
short getType() const;
private:
// -----------------------------------------------------------------------
// Unimplemented contstructors 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::KEY;
}
#endif
/**
* End of file IC_Key.hpp
*/
1.1 xml-xerces/c/src/validators/schema/identity/IC_Key.cpp
Index: IC_Key.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xerces" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache\@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation, and was
* originally based on software copyright (c) 1999, International
* Business Machines, Inc., http://www.ibm.com . For more information
* on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
/*
* $Log: IC_Key.cpp,v $
* Revision 1.1 2001/11/02 14:08:40 knoaman
* Add support for identity constraints.
*
*/
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <validators/schema/identity/IC_Key.hpp>
// ---------------------------------------------------------------------------
// IC_Key: Constructors and Destructor
// ---------------------------------------------------------------------------
IC_Key::IC_Key(const XMLCh* const identityConstraintName,
const XMLCh* const elemName)
: IdentityConstraint(identityConstraintName, elemName)
{
}
IC_Key::~IC_Key()
{
}
/**
* End of file IC_Key.cpp
*/
1.1 xml-xerces/c/src/validators/schema/identity/IC_Field.hpp
Index: IC_Field.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xerces" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache\@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation, and was
* originally based on software copyright (c) 2001, International
* Business Machines, Inc., http://www.ibm.com . For more information
* on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
/*
* $Id: IC_Field.hpp,v 1.1 2001/11/02 14:08:40 knoaman Exp $
*/
#if !defined(IC_FIELD_HPP)
#define IC_FIELD_HPP
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <validators/schema/identity/XPathMatcher.hpp>
// ---------------------------------------------------------------------------
// Forward Declaration
// ---------------------------------------------------------------------------
class ValueStore;
class VALIDATORS_EXPORT IC_Field
{
public:
// -----------------------------------------------------------------------
// Constructors/Destructor
// -----------------------------------------------------------------------
IC_Field(XercesXPath* const xpath,
IdentityConstraint* const identityConstraint);
~IC_Field();
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
bool getMayMatch() const { return fMayMatch; }
XercesXPath* getXPath() const { return fXPath; }
IdentityConstraint* getIdentityConstraint() const { return fIdentityConstraint; }
// -----------------------------------------------------------------------
// Setter methods
// -----------------------------------------------------------------------
void setMayMatch(const bool other) { fMayMatch = other; }
// -----------------------------------------------------------------------
// Factory methods
// -----------------------------------------------------------------------
XPathMatcher* createMatcher(ValueStore* const valueStore);
private:
// -----------------------------------------------------------------------
// Unimplemented contstructors and operators
// -----------------------------------------------------------------------
IC_Field(const IC_Field& other);
IC_Field& operator= (const IC_Field& other);
// -----------------------------------------------------------------------
// Data members
// -----------------------------------------------------------------------
bool fMayMatch;
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);
// -----------------------------------------------------------------------
// Unimplemented contstructors and operators
// -----------------------------------------------------------------------
FieldMatcher(const FieldMatcher& other);
FieldMatcher& operator= (const FieldMatcher& other);
// -----------------------------------------------------------------------
// Friends
// -----------------------------------------------------------------------
friend class IC_Field;
// -----------------------------------------------------------------------
// Data members
// -----------------------------------------------------------------------
ValueStore* fValueStore;
IC_Field* fField;
};
#endif
/**
* End of file IC_Field.hpp
*/
1.1 xml-xerces/c/src/validators/schema/identity/IC_Field.cpp
Index: IC_Field.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xerces" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache\@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation, and was
* originally based on software copyright (c) 1999, International
* Business Machines, Inc., http://www.ibm.com . For more information
* on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
/*
* $Log: IC_Field.cpp,v $
* Revision 1.1 2001/11/02 14:08:40 knoaman
* Add support for identity constraints.
*
*/
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <validators/schema/identity/IC_Field.hpp>
#include <validators/schema/identity/ValueStore.hpp>
#include <validators/schema/identity/XercesXPath.hpp>
// ---------------------------------------------------------------------------
// FieldMatcher: Constructors and Destructor
// ---------------------------------------------------------------------------
FieldMatcher::FieldMatcher(XercesXPath* const xpath, IC_Field* const aField,
ValueStore* const valueStore)
: XPathMatcher(xpath, true, 0)
, fField(aField)
, fValueStore(valueStore)
{
}
// ---------------------------------------------------------------------------
// FieldMatcher: Match methods
// ---------------------------------------------------------------------------
void FieldMatcher::matched(const XMLCh* const content,
DatatypeValidator* const dv,
const bool isNil) {
if(isNil) {
fValueStore->reportNilError(fField->getIdentityConstraint());
}
fValueStore->addValue(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).
fField->setMayMatch(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: Factory methods
// ---------------------------------------------------------------------------
XPathMatcher* IC_Field::createMatcher(ValueStore* const valueStore) {
return new FieldMatcher(fXPath, this, valueStore);
}
/**
* End of file IC_Field.cpp
*/
1.1 xml-xerces/c/src/validators/schema/identity/FieldValueMap.hpp
Index: FieldValueMap.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xerces" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache\@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation, and was
* originally based on software copyright (c) 2001, International
* Business Machines, Inc., http://www.ibm.com . For more information
* on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
/*
* $Id: FieldValueMap.hpp,v 1.1 2001/11/02 14:08:40 knoaman Exp $
*/
#if !defined(FIELDVALUEMAP_HPP)
#define 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 <util/XMLString.hpp>
#include <util/ValueVectorOf.hpp>
// ---------------------------------------------------------------------------
// Forward Declaration
// ---------------------------------------------------------------------------
class IC_Field;
class DatatypeValidator;
class VALIDATORS_EXPORT FieldValueMap
{
public:
// -----------------------------------------------------------------------
// Constructors/Destructor
// -----------------------------------------------------------------------
FieldValueMap();
FieldValueMap(const FieldValueMap& other);
~FieldValueMap();
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
DatatypeValidator* getDatatypeValidatorAt(const unsigned int index) const;
DatatypeValidator* getDatatypeValidatorFor(const IC_Field* const key) const;
XMLCh* getValueAt(const unsigned int index) const;
XMLCh* getValueFor(const IC_Field* const key) const;
IC_Field* keyAt(const unsigned int index) const;
// -----------------------------------------------------------------------
// Setter methods
// -----------------------------------------------------------------------
void put(IC_Field* const key, DatatypeValidator* const dv,
const XMLCh* const value);
// -----------------------------------------------------------------------
// Helper methods
// -----------------------------------------------------------------------
unsigned int size() const;
int indexOf(const IC_Field* const key) const;
private:
// -----------------------------------------------------------------------
// Unimplemented operators
// -----------------------------------------------------------------------
FieldValueMap& operator= (const FieldValueMap& other);
// -----------------------------------------------------------------------
// Data
// -----------------------------------------------------------------------
ValueVectorOf<IC_Field*>* fFields;
ValueVectorOf<DatatypeValidator*>* fValidators;
RefVectorOf<XMLCh>* fValues;
};
// ---------------------------------------------------------------------------
// FieldValueMap: Getter methods
// ---------------------------------------------------------------------------
inline DatatypeValidator*
FieldValueMap::getDatatypeValidatorAt(const unsigned int index) const {
if (fValidators) {
return fValidators->elementAt(index);
}
return 0;
}
inline DatatypeValidator*
FieldValueMap::getDatatypeValidatorFor(const IC_Field* const key) const {
if (fValidators) {
return fValidators->elementAt(indexOf(key));
}
return 0;
}
inline XMLCh* FieldValueMap::getValueAt(const unsigned int index) const {
if (fValues) {
return fValues->elementAt(index);
}
return 0;
}
inline XMLCh* FieldValueMap::getValueFor(const IC_Field* const key) const {
if (fValues) {
return fValues->elementAt(indexOf(key));
}
return 0;
}
inline IC_Field* FieldValueMap::keyAt(const unsigned int index) const {
if (fFields) {
return fFields->elementAt(index);
}
return 0;
}
// ---------------------------------------------------------------------------
// FieldValueMap: Helper methods
// ---------------------------------------------------------------------------
inline unsigned int 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 ValueVectorOf<IC_Field*>(4);
fValidators = new ValueVectorOf<DatatypeValidator*>(4);
fValues = new RefVectorOf<XMLCh>(4);
}
int keyIndex = indexOf(key);
if (keyIndex == -1) {
fFields->addElement(key);
fValidators->addElement(dv);
fValues->addElement(XMLString::replicate(value));
}
else {
fValidators->setElementAt(dv, keyIndex);
fValues->setElementAt(XMLString::replicate(value), keyIndex);
}
}
#endif
/**
* End of file FieldValueMap.hpp
*/
1.1 xml-xerces/c/src/validators/schema/identity/FieldValueMap.cpp
Index: FieldValueMap.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xerces" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache\@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation, and was
* originally based on software copyright (c) 1999, International
* Business Machines, Inc., http://www.ibm.com . For more information
* on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
/*
* $Log: FieldValueMap.cpp,v $
* Revision 1.1 2001/11/02 14:08:40 knoaman
* Add support for identity constraints.
*
*/
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <validators/schema/identity/FieldValueMap.hpp>
// ---------------------------------------------------------------------------
// FieldValueMap: Constructors and Destructor
// ---------------------------------------------------------------------------
FieldValueMap::FieldValueMap()
: fFields(0)
, fValidators(0)
, fValues(0)
{
}
FieldValueMap::FieldValueMap(const FieldValueMap& other)
: fFields(0)
, fValidators(0)
, fValues(0)
{
try {
if (other.fFields) {
unsigned int valuesSize = other.fValues->size();
fFields = new ValueVectorOf<IC_Field*>(*(other.fFields));
fValidators = new ValueVectorOf<DatatypeValidator*>(*(other.fValidators));
fValues = new RefVectorOf<XMLCh>(other.fFields->curCapacity());
for (unsigned int i=0; i<valuesSize; i++) {
fValues->addElement(XMLString::replicate(other.fValues->elementAt(i)));
}
}
}
catch(...) {
delete fFields;
delete fValidators;
delete fValues;
throw;
}
}
FieldValueMap::~FieldValueMap()
{
delete fFields;
delete fValidators;
delete fValues;
}
// ---------------------------------------------------------------------------
// FieldValueMap: Helper methods
// ---------------------------------------------------------------------------
int FieldValueMap::indexOf(const IC_Field* const key) const {
if (fFields) {
unsigned int fieldSize = fFields->size();
for (unsigned int i=0; i < fieldSize; i++) {
if (fFields->elementAt(i) == key) {
return i;
}
}
}
return -1;
}
/**
* End of file FieldValueMap.cpp
*/
1.1 xml-xerces/c/src/validators/schema/identity/FieldActivator.hpp
Index: FieldActivator.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xerces" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache\@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation, and was
* originally based on software copyright (c) 2001, International
* Business Machines, Inc., http://www.ibm.com . For more information
* on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
/*
* $Id: FieldActivator.hpp,v 1.1 2001/11/02 14:08:40 knoaman Exp $
*/
#if !defined(FIELDACTIVATOR_HPP)
#define FIELDACTIVATOR_HPP
/**
* This class is responsible for activating fields within a specific scope;
* the caller merely requests the fields to be activated.
*/
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <util/XercesDefs.hpp>
// ---------------------------------------------------------------------------
// Forward Declaration
// ---------------------------------------------------------------------------
class IdentityConstraint;
class XPathMatcher;
class ValueStoreCache;
class IC_Field;
class XPathMatcherStack;
class VALIDATORS_EXPORT FieldActivator
{
public:
// -----------------------------------------------------------------------
// Constructors/Destructor
// -----------------------------------------------------------------------
FieldActivator(ValueStoreCache* const valueStoreCache,
XPathMatcherStack* const matcherStack);
FieldActivator(const FieldActivator& other);
~FieldActivator();
// -----------------------------------------------------------------------
// Operator methods
// -----------------------------------------------------------------------
FieldActivator& operator =(const FieldActivator& other);
// -----------------------------------------------------------------------
// Setter methods
// -----------------------------------------------------------------------
void setValueStoreCache(ValueStoreCache* const other);
void setMatcherStack(XPathMatcherStack* const matcherStack);
// -----------------------------------------------------------------------
// 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);
/**
* Request to activate the specified field. This method returns the
* matcher for the field.
*/
XPathMatcher* activateField(IC_Field* const field);
/**
* Ends the value scope for the specified identity constraint.
*/
void endValueScopeFor(const IdentityConstraint* const ic);
private:
// -----------------------------------------------------------------------
// Data
// -----------------------------------------------------------------------
ValueStoreCache* fValueStoreCache;
XPathMatcherStack* fMatcherStack;
};
// ---------------------------------------------------------------------------
// FieldActivator: Setter methods
// ---------------------------------------------------------------------------
inline void FieldActivator::setValueStoreCache(ValueStoreCache* const other) {
fValueStoreCache = other;
}
inline void
FieldActivator::setMatcherStack(XPathMatcherStack* const matcherStack) {
fMatcherStack = matcherStack;
}
#endif
/**
* End of file FieldActivator.hpp
*/
1.1 xml-xerces/c/src/validators/schema/identity/FieldActivator.cpp
Index: FieldActivator.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xerces" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache\@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation, and was
* originally based on software copyright (c) 1999, International
* Business Machines, Inc., http://www.ibm.com . For more information
* on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
/*
* $Log: FieldActivator.cpp,v $
* Revision 1.1 2001/11/02 14:08:40 knoaman
* Add support for identity constraints.
*
*/
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <validators/schema/identity/FieldActivator.hpp>
#include <validators/schema/identity/ValueStore.hpp>
#include <validators/schema/identity/ValueStoreCache.hpp>
#include <validators/schema/identity/XPathMatcherStack.hpp>
// ---------------------------------------------------------------------------
// FieldActivator: Constructors and Destructor
// ---------------------------------------------------------------------------
FieldActivator::FieldActivator(ValueStoreCache* const valueStoreCache,
XPathMatcherStack* const matcherStack)
: fValueStoreCache(valueStoreCache)
, fMatcherStack(matcherStack)
{
}
FieldActivator::FieldActivator(const FieldActivator& other)
: fValueStoreCache(other.fValueStoreCache)
, fMatcherStack(other.fMatcherStack)
{
}
FieldActivator::~FieldActivator()
{
}
// ---------------------------------------------------------------------------
// 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) {
ValueStore* valueStore = fValueStoreCache->getValueStoreFor(field);
XPathMatcher* matcher = field->createMatcher(valueStore);
field->setMayMatch(true);
fMatcherStack->addMatcher(matcher);
matcher->startDocumentFragment();
return matcher;
}
void FieldActivator::startValueScopeFor(const IdentityConstraint* const ic) {
unsigned int fieldCount = ic->getFieldCount();
for(unsigned int i=0; i<fieldCount; i++) {
const IC_Field* field = ic->getFieldAt(i);
ValueStore* valueStore = fValueStoreCache->getValueStoreFor(field);
valueStore->startValueScope();
}
}
void FieldActivator::endValueScopeFor(const IdentityConstraint* const ic) {
ValueStore* valueStore = fValueStoreCache->getValueStoreFor(ic);
valueStore->endValueScope();
}
/**
* End of file FieldActivator.cpp
*/
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org