diff --git a/Projects/OS2/VACPP40/xerces_validators.icc b/Projects/OS2/VACPP40/xerces_validators.icc
index 1e63b8aba94f465b890253014a5040f38144826b..2596f386a4ead189442d6122980c59fc7bbf1918 100644
--- a/Projects/OS2/VACPP40/xerces_validators.icc
+++ b/Projects/OS2/VACPP40/xerces_validators.icc
@@ -21,6 +21,7 @@ group xerces_validators =
BASE_DIR "\\src\\validators\\datatype\\ENTITYDatatypeValidator.cpp",
BASE_DIR "\\src\\validators\\datatype\\QNameDatatypeValidator.cpp",
BASE_DIR "\\src\\validators\\datatype\\ListDatatypeValidator.cpp",
+ BASE_DIR "\\src\\validators\\datatype\\UnionDatatypeValidator.cpp",
BASE_DIR "\\src\\validators\\DTD\\DTDAttDef.cpp",
BASE_DIR "\\src\\validators\\DTD\\DTDAttDefList.cpp",
BASE_DIR "\\src\\validators\\DTD\\DTDElementDecl.cpp",
diff --git a/Projects/Win32/VC6/xerces-all/XercesLib/XercesLib.dsp b/Projects/Win32/VC6/xerces-all/XercesLib/XercesLib.dsp
index 202246cc13055920f0cd426509b47f234246b4a1..d76f856100f953e9be6645375f4bb2744c8dad31 100644
--- a/Projects/Win32/VC6/xerces-all/XercesLib/XercesLib.dsp
+++ b/Projects/Win32/VC6/xerces-all/XercesLib/XercesLib.dsp
@@ -1797,6 +1797,14 @@ SOURCE=..\..\..\..\..\src\validators\datatype\StringDatatypeValidator.cpp
SOURCE=..\..\..\..\..\src\validators\datatype\StringDatatypeValidator.hpp
# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\..\src\validators\datatype\UnionDatatypeValidator.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\..\src\validators\datatype\UnionDatatypeValidator.hpp
+# End Source File
# End Group
# Begin Group "DTD"
diff --git a/src/validators/datatype/DatatypeValidatorFactory.cpp b/src/validators/datatype/DatatypeValidatorFactory.cpp
index 877faf3412d2a8dfcbfb8e7f8a44565daf6941ac..ef0f3820d458ff92357c6ceb73e80f686f433900 100644
--- a/src/validators/datatype/DatatypeValidatorFactory.cpp
+++ b/src/validators/datatype/DatatypeValidatorFactory.cpp
@@ -56,6 +56,9 @@
/*
* $Log$
+ * Revision 1.16 2001/07/13 14:10:33 peiyongz
+ * UnionDTV
+ *
* Revision 1.15 2001/07/11 21:37:18 peiyongz
* ListDatatypeDTV
*
@@ -125,6 +128,7 @@
#include <validators/datatype/ENTITYDatatypeValidator.hpp>
#include <validators/datatype/QNameDatatypeValidator.hpp>
#include <validators/datatype/ListDatatypeValidator.hpp>
+#include <validators/datatype/UnionDatatypeValidator.hpp>
#include <util/PlatformUtils.hpp>
#include <util/XMLDeleterFor.hpp>
@@ -693,7 +697,7 @@ DatatypeValidatorFactory::createDatatypeValidator(const XMLCh* const typeName,
DatatypeValidator* datatypeValidator = 0;
- //datatypeValidator = new UnionDatatypeValidator(validators, finalSet);
+ datatypeValidator = new UnionDatatypeValidator(validators, finalSet);
if (datatypeValidator != 0) {
diff --git a/src/validators/datatype/Makefile.in b/src/validators/datatype/Makefile.in
index a948622d4f729aafe841c5be8342b86941284bc6..1166feacd5fa78658fe8c23ca0492605a17aee55 100644
--- a/src/validators/datatype/Makefile.in
+++ b/src/validators/datatype/Makefile.in
@@ -55,6 +55,9 @@
#
#
# $Log$
+# Revision 1.14 2001/07/13 14:10:37 peiyongz
+# UnionDTV
+#
# Revision 1.13 2001/07/11 21:37:15 peiyongz
# ListDatatypeDTV
#
@@ -133,6 +136,7 @@ VALIDATORS_DATATYPE_CPP_PUBHEADERS = \
ENTITYDatatypeValidator.hpp \
QNameDatatypeValidator.hpp \
ListDatatypeValidator.hpp \
+ UnionDatatypeValidator.hpp \
IDREFDatatypeValidator.hpp
VALIDATORS_DATATYPE_CPP_PRIVHEADERS =
@@ -152,6 +156,7 @@ VALIDATORS_DATATYPE_CPP_OBJECTS = \
ENTITYDatatypeValidator.$(TO) \
QNameDatatypeValidator.$(TO) \
ListDatatypeValidator.$(TO) \
+ UnionDatatypeValidator.$(TO) \
IDREFDatatypeValidator.$(TO)
all:: includes $(VALIDATORS_DATATYPE_CPP_OBJECTS)
diff --git a/src/validators/datatype/UnionDatatypeValidator.cpp b/src/validators/datatype/UnionDatatypeValidator.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..b99ace2e07b5448a8d7c1d9a0fe8dfbb80f22438
--- /dev/null
+++ b/src/validators/datatype/UnionDatatypeValidator.cpp
@@ -0,0 +1,353 @@
+/*
+ * 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$
+ * $Log$
+ * Revision 1.1 2001/07/13 14:10:40 peiyongz
+ * UnionDTV
+ *
+ */
+
+// ---------------------------------------------------------------------------
+// Includes
+// ---------------------------------------------------------------------------
+#include <validators/datatype/UnionDatatypeValidator.hpp>
+#include <validators/datatype/InvalidDatatypeFacetException.hpp>
+#include <validators/datatype/InvalidDatatypeValueException.hpp>
+#include <util/NumberFormatException.hpp>
+
+static const int BUF_LEN = 64;
+static XMLCh value1[BUF_LEN+1];
+static XMLCh value2[BUF_LEN+1];
+
+// ---------------------------------------------------------------------------
+// Constructors and Destructor
+// ---------------------------------------------------------------------------
+UnionDatatypeValidator::UnionDatatypeValidator(
+ RefVectorOf<DatatypeValidator>* const memberTypeValidators
+ , const int finalSet)
+:DatatypeValidator(0, 0, finalSet, DatatypeValidator::Union)
+,fEnumerationInherited(false)
+,fEnumeration(0)
+,fMemberTypeValidators(0)
+{
+ if (!memberTypeValidators)
+ ThrowXML1(InvalidDatatypeFacetException, XMLExcepts::FACET_Invalid_Len, value1);
+ //ThrowXML(InvalidDatatypeFacetException, XMLExcepts::FACET_Union_Null_memberTypeValidators);
+ //"Not Null memberTypeValidators required for UnionDatatypeValidator
+
+ // no pattern, no enumeration
+ fMemberTypeValidators = memberTypeValidators;
+}
+
+UnionDatatypeValidator::UnionDatatypeValidator(
+ DatatypeValidator* const baseValidator
+ , RefHashTableOf<KVStringPair>* const facets
+ , RefVectorOf<XMLCh>* const enums
+ , const int finalSet)
+:DatatypeValidator(baseValidator, facets, finalSet, DatatypeValidator::Union)
+,fEnumerationInherited(false)
+,fEnumeration(0)
+,fMemberTypeValidators(0)
+{
+ //
+ // baseValidator another UnionDTV from which,
+ // this UnionDTV is derived by restriction.
+ // it shall be not null
+ //
+ if (!baseValidator)
+ ThrowXML1(InvalidDatatypeFacetException, XMLExcepts::FACET_Invalid_Len, value1);
+ //ThrowXML(InvalidDatatypeFacetException, XMLExcepts::FACET_Union_Null_baseValidator);
+ //"Not Null baseValidator required for UnionDatatypeValidator
+
+ if (baseValidator->getType() != DatatypeValidator::Union)
+ ThrowXML1(InvalidDatatypeFacetException, XMLExcepts::FACET_Invalid_Len, value1);
+ //ThrowXML(InvalidDatatypeFacetException, XMLExcepts::FACET_Union_invalid_baseValidator);
+ //"Union baseValidator required for UnionDatatypeValidator
+
+ try
+ {
+ init(baseValidator, facets, enums);
+ }
+ catch (XMLException&)
+ {
+ cleanUp();
+ throw;
+ }
+}
+
+void UnionDatatypeValidator::init(DatatypeValidator* const baseValidator
+ , RefHashTableOf<KVStringPair>* const facets
+ , RefVectorOf<XMLCh>* const enums)
+{
+ if (enums)
+ setEnumeration(enums, false);
+
+ // Set Facets if any defined
+ if (facets)
+ {
+ XMLCh* key;
+ XMLCh* value;
+ RefHashTableOfEnumerator<KVStringPair> e(facets);
+
+ while (e.hasMoreElements())
+ {
+ KVStringPair pair = e.nextElement();
+ key = pair.getKey();
+ value = pair.getValue();
+
+ if (XMLString::compareString(key, SchemaSymbols::fgELT_PATTERN)==0)
+ {
+ setPattern(value);
+ if (getPattern())
+ setFacetsDefined(DatatypeValidator::FACET_PATTERN);
+ // do not construct regex until needed
+ }
+ else
+ {
+ ThrowXML(InvalidDatatypeFacetException, XMLExcepts::FACET_Invalid_Tag);
+ }
+ }//while
+
+ /***
+ Schema constraint: Part I -- self checking
+ ***/
+ // Nil
+
+ /***
+ Schema constraint: Part II base vs derived checking
+ ***/
+ // check 4.3.5.c0 must: enumeration values from the value space of base
+ if ( ((getFacetsDefined() & DatatypeValidator::FACET_ENUMERATION) != 0) &&
+ (getEnumeration() !=0))
+ {
+ int i = 0;
+ int enumLength = getEnumeration()->size();
+ try
+ {
+ for ( ; i < enumLength; i++)
+ {
+ // ask parent do a complete check
+ //
+ // enum need NOT be passed this->checkContent()
+ // since there are no other facets for Union, parent
+ // checking is good enough.
+ //
+ baseValidator->validate(getEnumeration()->elementAt(i));
+
+ }
+ }
+
+ catch ( XMLException& )
+ {
+ ThrowXML1(InvalidDatatypeFacetException
+ , XMLExcepts::FACET_enum_base
+ , getEnumeration()->elementAt(i));
+ }
+ }
+
+ }// End of Facet setting
+
+ /***
+ Inherit facets from base.facets
+
+ The reason of this inheriting (or copying values) is to ease
+ schema constraint checking, so that we need NOT trace back to our
+ very first base validator in the hierachy. Instead, we are pretty
+ sure checking against immediate base validator is enough.
+ ***/
+
+ UnionDatatypeValidator *pBaseValidator = (UnionDatatypeValidator*) baseValidator;
+
+ // inherit enumeration
+ if (((pBaseValidator->getFacetsDefined() & DatatypeValidator::FACET_ENUMERATION) !=0) &&
+ ((getFacetsDefined() & DatatypeValidator::FACET_ENUMERATION) == 0))
+ {
+ setEnumeration(pBaseValidator->getEnumeration(), true);
+ }
+
+}
+
+//
+// 1) the bottom level UnionDTV would check against
+// pattern and enumeration as well
+// 2) each UnionDTV(s) above the bottom level UnionDTV and
+// below the native UnionDTV (the top level DTV)
+// would check against pattern only.
+// 3) the natvie Union DTV (the top level DTV) would invoke
+// memberTypeValidator to validate
+//
+void UnionDatatypeValidator::checkContent(const XMLCh* const content, bool asBase)
+{
+ DatatypeValidator* bv = getBaseValidator();
+ if (bv)
+ ((UnionDatatypeValidator*)bv)->checkContent(content, true);
+ else
+ { // 3) native union type
+ // check content against each member type validator in Union
+ // report an error only in case content is not valid against all member datatypes.
+ //
+ bool memTypeValid = false;
+ for ( unsigned int i = 0; i < fMemberTypeValidators->size(); ++i )
+ {
+ if ( memTypeValid )
+ break;
+
+ try
+ {
+ fMemberTypeValidators->elementAt(i)->validate(content);
+ memTypeValid = true;
+ }
+ catch (XMLException&)
+ {
+ //absorbed
+ }
+ } // for
+
+ if ( !memTypeValid )
+ {
+ ThrowXML1(InvalidDatatypeValueException, XMLExcepts::VALUE_NotIn_Enumeration, content);
+ //( "Content '"+content+"' does not match any union types" );
+ }
+ }
+
+ // 1) and 2). we check pattern first
+ if ( (getFacetsDefined() & DatatypeValidator::FACET_PATTERN ) != 0 )
+ {
+ // lazy construction
+ if (getRegex() == 0)
+ {
+ try {
+ setRegex(new RegularExpression(getPattern(), SchemaSymbols::fgRegEx_XOption));
+ }
+ catch (XMLException &e)
+ {
+ ThrowXML1(InvalidDatatypeValueException, XMLExcepts::RethrowError, e.getMessage());
+ }
+ }
+
+ if (getRegex()->matches(content) == false)
+ {
+ ThrowXML2(InvalidDatatypeValueException
+ , XMLExcepts::VALUE_NotMatch_Pattern
+ , content
+ , getPattern());
+ }
+ }
+
+ // if this is a base validator, we only need to check pattern facet
+ // all other facet were inherited by the derived type
+ if (asBase)
+ return;
+
+ if ((getFacetsDefined() & DatatypeValidator::FACET_ENUMERATION) != 0 &&
+ (getEnumeration() != 0))
+ {
+
+ // If the content match (compare equal) any enumeration with
+ // any of the member types, it is considerd valid.
+ //
+ RefVectorOf<DatatypeValidator>* memberDTV = getMemberTypeValidators();
+ RefVectorOf<XMLCh>* tmpEnum = getEnumeration();
+ unsigned int memberTypeNumber = memberDTV->size();
+ unsigned int enumLength = tmpEnum->size();
+
+ for ( unsigned int memberIndex = 0; memberIndex < memberTypeNumber; ++memberIndex)
+ {
+ for ( unsigned int enumIndex = 0; enumIndex < enumLength; ++enumIndex)
+ {
+ try
+ {
+ if (memberDTV->elementAt(memberIndex)->compare(content, tmpEnum->elementAt(enumIndex)) == 0)
+ return;
+ }
+ catch (XMLException&)
+ {
+ //absorbed
+ }
+ } // for enumIndex
+ } // for memberIndex
+
+ ThrowXML1(InvalidDatatypeValueException, XMLExcepts::VALUE_NotIn_Enumeration, content);
+
+ } // enumeration
+
+}
+
+//
+//
+//
+int UnionDatatypeValidator::compare(const XMLCh* const lValue
+ , const XMLCh* const rValue)
+{
+ RefVectorOf<DatatypeValidator>* memberDTV = getMemberTypeValidators();
+ unsigned int memberTypeNumber = memberDTV->size();
+
+ for ( unsigned int memberIndex = 0; memberIndex < memberTypeNumber; ++memberIndex)
+ {
+ if (memberDTV->elementAt(memberIndex)->compare(lValue, rValue) ==0)
+ return 0;
+ }
+
+ //REVISIT: what does it mean for UNION1 to be <less than> or <greater than> UNION2 ?
+ // As long as -1 or +1 indicates an unequality, return either of them is ok.
+ return -1;
+}
+
+/**
+ * End of file UnionDatatypeValidator.cpp
+ */
diff --git a/src/validators/datatype/UnionDatatypeValidator.hpp b/src/validators/datatype/UnionDatatypeValidator.hpp
new file mode 100644
index 0000000000000000000000000000000000000000..28d636bbb98995602d05571ec64a084c81965c38
--- /dev/null
+++ b/src/validators/datatype/UnionDatatypeValidator.hpp
@@ -0,0 +1,267 @@
+/*
+ * 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$
+ * $Log$
+ * Revision 1.1 2001/07/13 14:10:40 peiyongz
+ * UnionDTV
+ *
+ */
+
+#if !defined(UNION_DATATYPEVALIDATOR_HPP)
+#define UNION_DATATYPEVALIDATOR_HPP
+
+#include <validators/datatype/DatatypeValidator.hpp>
+#include <validators/schema/SchemaSymbols.hpp>
+
+class VALIDATORS_EXPORT UnionDatatypeValidator : public DatatypeValidator
+{
+public:
+
+ // -----------------------------------------------------------------------
+ // Public ctor/dtor
+ // -----------------------------------------------------------------------
+ /** @name Constructor. */
+ //@{
+
+ UnionDatatypeValidator();
+
+ //
+ // constructor for native Union datatype validator
+ // <simpleType name="nativeUnion">
+ // <union memberTypes="member1 member2 ...">
+ // </simpleType>
+ //
+ UnionDatatypeValidator(RefVectorOf<DatatypeValidator>* const memberTypeValidators
+ , const int finalSet);
+
+ //
+ // constructor for derived Union datatype validator
+ // <simpleType name="derivedUnion">
+ // <restriction base="nativeUnion">
+ // <pattern value="patter_value"/>
+ // <enumeartion value="enum_value"/>
+ // </restriction>
+ // </simpleType>
+ //
+ UnionDatatypeValidator(DatatypeValidator* const baseValidator
+ , RefHashTableOf<KVStringPair>* const facets
+ , RefVectorOf<XMLCh>* const enums
+ , const int finalSet);
+
+ virtual ~UnionDatatypeValidator();
+
+ //@}
+
+ // -----------------------------------------------------------------------
+ // Getter methods
+ // -----------------------------------------------------------------------
+ /** @name Getter Functions */
+ //@{
+
+ //@}
+
+ // -----------------------------------------------------------------------
+ // Validation methods
+ // -----------------------------------------------------------------------
+ /** @name Validation Function */
+ //@{
+
+ /**
+ * validate that a string matches the boolean datatype
+ * @param content A string containing the content to be validated
+ *
+ * @exception throws InvalidDatatypeException if the content is
+ * is not valid.
+ */
+
+ void validate(const XMLCh* const content);
+
+ //@}
+
+ // -----------------------------------------------------------------------
+ // Compare methods
+ // -----------------------------------------------------------------------
+ /** @name Compare Function */
+ //@{
+
+ /**
+ * Compare two boolean data types
+ *
+ * @param content1
+ * @param content2
+ * @return
+ */
+ int compare(const XMLCh* const, const XMLCh* const);
+
+ //@}
+
+ /**
+ * Returns an instance of the base datatype validator class
+ * Used by the DatatypeValidatorFactory.
+ */
+ DatatypeValidator* newInstance(DatatypeValidator* const baseValidator
+ , RefHashTableOf<KVStringPair>* const facets
+ , RefVectorOf<XMLCh>* const enums
+ , const int finalSet);
+
+private:
+
+ void checkContent(const XMLCh* const content, bool asBase);
+
+ void init(DatatypeValidator* const baseValidator
+ , RefHashTableOf<KVStringPair>* const facets
+ , RefVectorOf<XMLCh>* const enums);
+
+ void cleanUp();
+
+ RefVectorOf<XMLCh>* getEnumeration() const;
+
+ void setEnumeration(RefVectorOf<XMLCh>*, bool);
+
+ RefVectorOf<DatatypeValidator>* getMemberTypeValidators() const;
+
+ // -----------------------------------------------------------------------
+ // Private data members
+ //
+ // fEnumeration
+ // we own it.
+ //
+ // fMemberTypeValidators
+ // we own it.
+ //
+ // -----------------------------------------------------------------------
+ bool fEnumerationInherited;
+ RefVectorOf<XMLCh>* fEnumeration;
+ RefVectorOf<DatatypeValidator>* fMemberTypeValidators;
+};
+
+// ---------------------------------------------------------------------------
+// Constructors and Destructor
+// ---------------------------------------------------------------------------
+inline UnionDatatypeValidator::UnionDatatypeValidator()
+:DatatypeValidator(0, 0, 0, DatatypeValidator::Union)
+,fEnumerationInherited(false)
+,fEnumeration(0)
+,fMemberTypeValidators(0)
+{}
+
+inline UnionDatatypeValidator::~UnionDatatypeValidator()
+{
+ cleanUp();
+}
+
+inline DatatypeValidator* UnionDatatypeValidator::newInstance(
+ DatatypeValidator* const baseValidator
+ , RefHashTableOf<KVStringPair>* const facets
+ , RefVectorOf<XMLCh>* const enums
+ , const int finalSet)
+{
+ return (DatatypeValidator*) new UnionDatatypeValidator(baseValidator, facets, enums, finalSet);
+}
+
+inline void UnionDatatypeValidator::validate( const XMLCh* const content)
+{
+ checkContent(content, false);
+}
+
+inline void UnionDatatypeValidator::cleanUp()
+{
+ //~RefVectorOf will delete all adopted elements
+ if (fEnumeration && !fEnumerationInherited)
+ delete fEnumeration;
+
+ if (fMemberTypeValidators)
+ delete fMemberTypeValidators;
+}
+
+inline RefVectorOf<XMLCh>* UnionDatatypeValidator:: getEnumeration() const
+{
+ return fEnumeration;
+}
+
+inline void UnionDatatypeValidator::setEnumeration(RefVectorOf<XMLCh>* enums
+ , bool inherited)
+{
+ if (enums)
+ {
+ if (fEnumeration && !fEnumerationInherited)
+ delete fEnumeration;
+
+ fEnumeration = enums;
+ fEnumerationInherited = inherited;
+ setFacetsDefined(DatatypeValidator::FACET_ENUMERATION);
+ }
+}
+
+//
+// get the native UnionDTV's fMemberTypeValidators
+//
+inline
+RefVectorOf<DatatypeValidator>* UnionDatatypeValidator::getMemberTypeValidators() const
+{
+ UnionDatatypeValidator* thisdv = (UnionDatatypeValidator*)this; // cast away constness
+
+ while (thisdv->getBaseValidator())
+ thisdv = (UnionDatatypeValidator*) thisdv->getBaseValidator();
+
+ return thisdv->fMemberTypeValidators;
+}
+/**
+ * End of file UnionDatatypeValidator.hpp
+ */
+#endif