diff --git a/src/validators/DTD/DTDAttDef.cpp b/src/validators/DTD/DTDAttDef.cpp deleted file mode 100644 index a6c306b70cd0065287e9a777ca9b1d889581a8f5..0000000000000000000000000000000000000000 --- a/src/validators/DTD/DTDAttDef.cpp +++ /dev/null @@ -1,129 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999-2000 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$ - * Revision 1.3 2000/03/02 19:55:39 roddey - * This checkin includes many changes done while waiting for the - * 1.1.0 code to be finished. I can't list them all here, but a list is - * available elsewhere. - * - * Revision 1.2 2000/02/09 21:42:37 abagchi - * Copyright swatswat - * - * Revision 1.1.1.1 1999/11/09 01:03:24 twl - * Initial checkin - * - * Revision 1.2 1999/11/08 20:45:39 rahul - * Swat for adding in Product name and CVS comment log variable. - * - */ - - -// --------------------------------------------------------------------------- -// Includes -// --------------------------------------------------------------------------- -#include <framework/XMLElementDecl.hpp> -#include <validators/DTD/DTDAttDef.hpp> - - -// --------------------------------------------------------------------------- -// DTDAttDef: Constructors and Destructor -// --------------------------------------------------------------------------- -DTDAttDef::DTDAttDef() : - - fElemId(XMLElementDecl::fgInvalidElemId) - , fName(0) -{ -} - -DTDAttDef::DTDAttDef(const XMLCh* const attName - , const XMLAttDef::AttTypes type - , const XMLAttDef::DefAttTypes defType) : - XMLAttDef(type, defType) - , fElemId(XMLElementDecl::fgInvalidElemId) - , fName(0) -{ - fName = XMLString::replicate(attName); -} - -DTDAttDef::DTDAttDef( const XMLCh* const attName - , const XMLCh* const attValue - , const XMLAttDef::AttTypes type - , const XMLAttDef::DefAttTypes defType - , const XMLCh* const enumValues) : - - XMLAttDef(attValue, type, defType, enumValues) - , fElemId(XMLElementDecl::fgInvalidElemId) - , fName(0) -{ - fName = XMLString::replicate(attName); -} - -DTDAttDef::~DTDAttDef() -{ - delete [] fName; -} - - -// --------------------------------------------------------------------------- -// DTDAttDef: Setter methods -// --------------------------------------------------------------------------- -void DTDAttDef::setName(const XMLCh* const newName) -{ - delete [] fName; - fName = XMLString::replicate(newName); -} diff --git a/src/validators/DTD/DTDAttDef.hpp b/src/validators/DTD/DTDAttDef.hpp deleted file mode 100644 index 0529484cf65602eea0cdd74932ef79038fd0d8fc..0000000000000000000000000000000000000000 --- a/src/validators/DTD/DTDAttDef.hpp +++ /dev/null @@ -1,177 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999-2000 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$ - * Revision 1.3 2000/02/24 20:16:48 abagchi - * Swat for removing Log from API docs - * - * Revision 1.2 2000/02/09 21:42:37 abagchi - * Copyright swat - * - * Revision 1.1.1.1 1999/11/09 01:03:26 twl - * Initial checkin - * - * Revision 1.2 1999/11/08 20:45:39 rahul - * Swat for adding in Product name and CVS comment log variable. - * - */ - -#if !defined(DTDATTDEF_HPP) -#define DTDATTDEF_HPP - -#include <util/XMLString.hpp> -#include <framework/XMLAttDef.hpp> - - -// -// This class is a derivative of the core XMLAttDef class. This class adds -// any DTD specific data members and provides DTD specific implementations -// of any underlying attribute def virtual methods. -// -// In the DTD we don't do namespaces, so the attribute names are just the -// QName literally from the DTD. This is what we return as the full name, -// which is what is used to key these in any name keyed collections. -// -class VALIDATORS_EXPORT DTDAttDef : public XMLAttDef -{ -public : - // ----------------------------------------------------------------------- - // Constructors and Destructors - // ----------------------------------------------------------------------- - DTDAttDef(); - DTDAttDef - ( - const XMLCh* const attName - , const XMLAttDef::AttTypes type = CData - , const XMLAttDef::DefAttTypes defType = Implied - ); - DTDAttDef - ( - const XMLCh* const attName - , const XMLCh* const attValue - , const XMLAttDef::AttTypes type - , const XMLAttDef::DefAttTypes defType - , const XMLCh* const enumValues = 0 - ); - ~DTDAttDef(); - - - // ----------------------------------------------------------------------- - // Implementation of the XMLAttDef interface - // ----------------------------------------------------------------------- - virtual const XMLCh* getFullName() const; - - - // ----------------------------------------------------------------------- - // Getter methods - // ----------------------------------------------------------------------- - unsigned int getElemId() const; - - - // ----------------------------------------------------------------------- - // Setter methods - // ----------------------------------------------------------------------- - void setElemId(const unsigned int newId); - void setName(const XMLCh* const newName); - - -private : - // ----------------------------------------------------------------------- - // Private data members - // - // fElemId - // This is the id of the element (the id is into the element decl - // pool) of the element this attribute def said it belonged to. - // This is used later to link back to the element, mostly for - // validation purposes. - // - // fName - // This is the name of the attribute. Since we don't do namespaces - // in the DTD, its just the fully qualified name. - // ----------------------------------------------------------------------- - unsigned int fElemId; - XMLCh* fName; -}; - - -// --------------------------------------------------------------------------- -// DTDAttDef: Implementation of the XMLAttDef interface -// --------------------------------------------------------------------------- -inline const XMLCh* DTDAttDef::getFullName() const -{ - return fName; -} - - -// --------------------------------------------------------------------------- -// DTDAttDef: Getter methods -// --------------------------------------------------------------------------- -inline unsigned int DTDAttDef::getElemId() const -{ - return fElemId; -} - - -// --------------------------------------------------------------------------- -// DTDAttDef: Setter methods -// --------------------------------------------------------------------------- -inline void DTDAttDef::setElemId(const unsigned int newId) -{ - fElemId = newId; -} - -#endif diff --git a/src/validators/DTD/DTDAttDefList.cpp b/src/validators/DTD/DTDAttDefList.cpp deleted file mode 100644 index 6d9a9d20d2aa9573755e373ad6da60aa10895ef8..0000000000000000000000000000000000000000 --- a/src/validators/DTD/DTDAttDefList.cpp +++ /dev/null @@ -1,157 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999-2000 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$ - * Revision 1.3 2000/03/02 19:55:39 roddey - * This checkin includes many changes done while waiting for the - * 1.1.0 code to be finished. I can't list them all here, but a list is - * available elsewhere. - * - * Revision 1.2 2000/02/09 21:42:37 abagchi - * Copyright swatswat - * - * Revision 1.1.1.1 1999/11/09 01:03:27 twl - * Initial checkin - * - * Revision 1.2 1999/11/08 20:45:39 rahul - * Swat for adding in Product name and CVS comment log variable. - * - */ - - -// --------------------------------------------------------------------------- -// Includes -// --------------------------------------------------------------------------- -#include <validators/DTD/DTDAttDefList.hpp> - - -// --------------------------------------------------------------------------- -// DTDAttDefList: Constructors and Destructor -// --------------------------------------------------------------------------- -DTDAttDefList::DTDAttDefList(RefHashTableOf<DTDAttDef>* const listToUse) : - - fEnum(0) - , fList(listToUse) -{ - fEnum = new RefHashTableOfEnumerator<DTDAttDef>(listToUse); -} - -DTDAttDefList::~DTDAttDefList() -{ - delete fEnum; -} - - -// --------------------------------------------------------------------------- -// DTDAttDefList: Implementation of the virtual interface -// --------------------------------------------------------------------------- -bool DTDAttDefList::hasMoreElements() const -{ - return fEnum->hasMoreElements(); -} - - -bool DTDAttDefList::isEmpty() const -{ - return fList->isEmpty(); -} - - -XMLAttDef* DTDAttDefList::findAttDef(const unsigned long uriID - , const XMLCh* const attName) -{ - // We don't use the URI, so we just look up the name - return fList->get(attName); -} - - -const XMLAttDef* -DTDAttDefList::findAttDef( const unsigned long uriID - , const XMLCh* const attName) const -{ - // We don't use the URI, so we just look up the name - return fList->get(attName); -} - - -XMLAttDef* DTDAttDefList::findAttDef( const XMLCh* const attURI - , const XMLCh* const attName) -{ - // We don't use the URI, so we just look up the name - return fList->get(attName); -} - - -const XMLAttDef* -DTDAttDefList::findAttDef( const XMLCh* const attURI - , const XMLCh* const attName) const -{ - // We don't use the URI, so we just look up the name - return fList->get(attName); -} - - -XMLAttDef& DTDAttDefList::nextElement() -{ - return fEnum->nextElement(); -} - - -void DTDAttDefList::Reset() -{ - fEnum->Reset(); -} diff --git a/src/validators/DTD/DTDAttDefList.hpp b/src/validators/DTD/DTDAttDefList.hpp deleted file mode 100644 index eed77d641e479e877d719a9a1f61bc565c0cce78..0000000000000000000000000000000000000000 --- a/src/validators/DTD/DTDAttDefList.hpp +++ /dev/null @@ -1,157 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999-2000 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$ - * Revision 1.3 2000/02/24 20:16:48 abagchi - * Swat for removing Log from API docs - * - * Revision 1.2 2000/02/09 21:42:37 abagchi - * Copyright swat - * - * Revision 1.1.1.1 1999/11/09 01:03:28 twl - * Initial checkin - * - * Revision 1.2 1999/11/08 20:45:39 rahul - * Swat for adding in Product name and CVS comment log variable. - * - */ - - -#if !defined(DTDATTDEFLIST_HPP) -#define DTDATTDEFLIST_HPP - -#include <util/RefHashTableOf.hpp> -#include <validators/DTD/DTDElementDecl.hpp> - - -// -// This is a derivative of the framework abstract class which defines the -// interface to a list of attribute defs that belong to a particular -// element. The scanner needs to be able to get a list of the attributes -// that an element supports, for use during the validation process and for -// fixed/default attribute processing. -// -// Since each validator can store attributes differently, this abstract -// interface allows each validator to provide an implementation of this -// data strucure that works best for it. -// -// For us, we just wrap the RefHashTableOf collection that the DTDElementDecl -// class uses to store the attributes that belong to it. -// -// This clss does not adopt the hash table, it just references it. The -// hash table is owned by the element decl it is a member of. -// -class DTDAttDefList : public XMLAttDefList -{ -public : - // ----------------------------------------------------------------------- - // Constructors and Destructor - // ----------------------------------------------------------------------- - DTDAttDefList - ( - RefHashTableOf<DTDAttDef>* const listToUse - ); - - ~DTDAttDefList(); - - - // ----------------------------------------------------------------------- - // Implementation of the virtual interface - // ----------------------------------------------------------------------- - virtual bool hasMoreElements() const; - virtual bool isEmpty() const; - virtual XMLAttDef* findAttDef - ( - const unsigned long uriID - , const XMLCh* const attName - ); - virtual const XMLAttDef* findAttDef - ( - const unsigned long uriID - , const XMLCh* const attName - ) const; - virtual XMLAttDef* findAttDef - ( - const XMLCh* const attURI - , const XMLCh* const attName - ); - virtual const XMLAttDef* findAttDef - ( - const XMLCh* const attURI - , const XMLCh* const attName - ) const; - virtual XMLAttDef& nextElement(); - virtual void Reset(); - - -private : - // ----------------------------------------------------------------------- - // Private data members - // - // fEnum - // This is an enerator for the list that we use to do the enumerator - // type methods of this class. - // - // fList - // The list of DTDAttDef objects that represent the attributes that - // a particular element supports. - // ----------------------------------------------------------------------- - RefHashTableOfEnumerator<DTDAttDef>* fEnum; - RefHashTableOf<DTDAttDef>* fList; -}; - -#endif diff --git a/src/validators/DTD/DTDElementDecl.cpp b/src/validators/DTD/DTDElementDecl.cpp deleted file mode 100644 index 76aebd4020182eb06774c775fa68ab6fbf350cbf..0000000000000000000000000000000000000000 --- a/src/validators/DTD/DTDElementDecl.cpp +++ /dev/null @@ -1,438 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999-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/>. - */ - -/* - * $Id$ - */ - - -// --------------------------------------------------------------------------- -// Includes -// --------------------------------------------------------------------------- -#include <util/XMLString.hpp> -#include <util/XMLUniDefs.hpp> -#include <util/XMLUni.hpp> -#include <framework/XMLBuffer.hpp> -#include <validators/common/DFAContentModel.hpp> -#include <validators/common/ContentSpecNode.hpp> -#include <validators/common/MixedContentModel.hpp> -#include <validators/common/SimpleContentModel.hpp> -#include <validators/DTD/DTDAttDefList.hpp> -#include <validators/DTD/DTDElementDecl.hpp> - - -// --------------------------------------------------------------------------- -// DTDElementDecl: Constructors and Destructor -// --------------------------------------------------------------------------- -DTDElementDecl::DTDElementDecl() : - - fAttDefs(0) - , fAttList(0) - , fContentSpec(0) - , fModelType(Any) - , fContentModel(0) - , fFormattedModel(0) -{ -} - -DTDElementDecl::DTDElementDecl( const XMLCh* const elemRawName - , const unsigned int uriId - , const DTDElementDecl::ModelTypes type) : - fAttDefs(0) - , fAttList(0) - , fContentSpec(0) - , fModelType(type) - , fContentModel(0) - , fFormattedModel(0) -{ - setElementName(elemRawName, uriId); -} - -DTDElementDecl::DTDElementDecl( QName* const elementName - , const DTDElementDecl::ModelTypes type) : - fAttDefs(0) - , fAttList(0) - , fContentSpec(0) - , fModelType(type) - , fContentModel(0) - , fFormattedModel(0) -{ - setElementName(elementName); -} - -DTDElementDecl::~DTDElementDecl() -{ - delete fAttDefs; - delete fAttList; - delete fContentSpec; - delete fContentModel; - delete [] fFormattedModel; -} - - - -// --------------------------------------------------------------------------- -// The virtual element decl interface -// --------------------------------------------------------------------------- -XMLAttDef* DTDElementDecl::findAttr(const XMLCh* const qName - , const unsigned int uriId - , const XMLCh* const baseName - , const XMLCh* const prefix - , const LookupOpts options - , bool& wasAdded) const -{ - DTDAttDef* retVal = 0; - - // If no att list faulted in yet, then it cannot exist - if (fAttDefs) - retVal = fAttDefs->get(qName); - - // Fault it in if not found and ask to add it - if (!retVal && (options == XMLElementDecl::AddIfNotFound)) - { - // Fault in the list itself if not already - if (!fAttDefs) - faultInAttDefList(); - - // And add a default attribute for this name - retVal = new DTDAttDef(qName); - retVal->setElemId(getId()); - fAttDefs->put((void*)retVal->getFullName(), retVal); - - wasAdded = true; - } - else - { - wasAdded = false; - } - return retVal; -} - - -XMLAttDefList& DTDElementDecl::getAttDefList() const -{ - if (!fAttList) - { - // If the att def list is not made yet, then fault it in too - if (!fAttDefs) - faultInAttDefList(); - - ((DTDElementDecl*)this)->fAttList = new DTDAttDefList(fAttDefs); - } - - // Reset it before we return it - fAttList->Reset(); - return *fAttList; -} - - -XMLElementDecl::CharDataOpts DTDElementDecl::getCharDataOpts() const -{ - XMLElementDecl::CharDataOpts retVal; - switch(fModelType) - { - case Children : - retVal = XMLElementDecl::SpacesOk; - break; - - case Empty : - retVal = XMLElementDecl::NoCharData; - break; - - default : - retVal = XMLElementDecl::AllCharData; - break; - } - return retVal; -} - - -bool DTDElementDecl::hasAttDefs() const -{ - // If the collection hasn't been faulted in, then no att defs - if (!fAttDefs) - return false; - - return !fAttDefs->isEmpty(); -} - - -bool DTDElementDecl::resetDefs() -{ - // If the collection hasn't been faulted in, then no att defs - if (!fAttDefs) - return false; - - // - // Ok, run through them and clear the 'provided' flag on each of them. - // This lets the scanner use them to track which has been provided and - // which have not. - // - RefHashTableOfEnumerator<DTDAttDef> enumDefs(fAttDefs); - while (enumDefs.hasMoreElements()) - enumDefs.nextElement().setProvided(false); - return true; -} - -void -DTDElementDecl::setContentSpec(ContentSpecNode* toAdopt) -{ - delete fContentSpec; - fContentSpec = toAdopt; -} - -const XMLCh* -DTDElementDecl::getFormattedContentModel() const -{ - // - // If its not already built, then call the protected virtual method - // to allow the derived class to build it (since only it knows.) - // Otherwise, just return the previously formatted methods. - // - // Since we are faulting this in, within a const getter, we have to - // cast off the const-ness. - // - if (!fFormattedModel) - ((DTDElementDecl*)this)->fFormattedModel = formatContentModel(); - - return fFormattedModel; -} - - -// --------------------------------------------------------------------------- -// DTDElementDecl: Getter methods -// --------------------------------------------------------------------------- -const DTDAttDef* DTDElementDecl::getAttDef(const XMLCh* const attName) const -{ - // If no list, then return a null - if (!fAttDefs) - return 0; - - return fAttDefs->get(attName); -} - - -DTDAttDef* DTDElementDecl::getAttDef(const XMLCh* const attName) -{ - // If no list, then return a null - if (!fAttDefs) - return 0; - - return fAttDefs->get(attName); -} - - -// --------------------------------------------------------------------------- -// DTDElementDecl: Implementation of the protected virtual interface -// --------------------------------------------------------------------------- -void DTDElementDecl::addAttDef(DTDAttDef* const toAdd) -{ - // Fault in the att list if required - if (!fAttDefs) - faultInAttDefList(); - - // Tell this guy the element id of its parent (us) - toAdd->setElemId(getId()); - - fAttDefs->put((void*)(toAdd->getFullName()), toAdd); -} - - -// --------------------------------------------------------------------------- -// DTDElementDecl: Private helper methods -// --------------------------------------------------------------------------- -XMLCh* -DTDElementDecl::formatContentModel() const -{ - XMLCh* newValue = 0; - if (fModelType == Any) - { - newValue = XMLString::replicate(XMLUni::fgAnyString); - } - else if (fModelType == Empty) - { - newValue = XMLString::replicate(XMLUni::fgEmptyString); - } - else - { - // - // Use a temp XML buffer to format into. Content models could be - // pretty long, but very few will be longer than one K. The buffer - // will expand to handle the more pathological ones. - // - XMLBuffer bufFmt; - getContentSpec()->formatSpec(bufFmt); - newValue = XMLString::replicate(bufFmt.getRawBuffer()); - } - return newValue; -} - -XMLContentModel* DTDElementDecl::makeContentModel() -{ - XMLContentModel* cmRet = 0; - if (fModelType == Mixed_Simple) - { - // - // Just create a mixel content model object. This type of - // content model is optimized for mixed content validation. - // - cmRet = new MixedContentModel(true, this->getContentSpec()); - } - else if (fModelType == Children) - { - // - // This method will create an optimal model for the complexity - // of the element's defined model. If its simple, it will create - // a SimpleContentModel object. If its a simple list, it will - // create a SimpleListContentModel object. If its complex, it - // will create a DFAContentModel object. - // - cmRet = createChildModel(); - } - else - { - ThrowXML(RuntimeException, XMLExcepts::CM_MustBeMixedOrChildren); - } - return cmRet; -} - - -XMLContentModel* DTDElementDecl::createChildModel() -{ - // Get the content spec node of the element - ContentSpecNode* specNode = getContentSpec(); - - if(!specNode) - ThrowXML(RuntimeException, XMLExcepts::CM_UnknownCMSpecType); - - // - // Do a sanity check that the node does not have a PCDATA id. Since, - // if it was, it should have already gotten taken by the Mixed model. - // - if (specNode->getElement()) { - if (specNode->getElement()->getURI() == XMLElementDecl::fgPCDataElemId) - ThrowXML(RuntimeException, XMLExcepts::CM_NoPCDATAHere); - } - - // - // According to the type of node, we will create the correct type of - // content model. - // - if (specNode->getType() == ContentSpecNode::Leaf) - { - // Create a simple content model - return new SimpleContentModel - ( - true - , specNode->getElement() - , 0 - , ContentSpecNode::Leaf - ); - } - else if ((specNode->getType() == ContentSpecNode::Choice) - || (specNode->getType() == ContentSpecNode::Sequence)) - { - // - // Lets see if both of the children are leafs. If so, then it has to - // be a simple content model - // - if ((specNode->getFirst()->getType() == ContentSpecNode::Leaf) - && (specNode->getSecond()->getType() == ContentSpecNode::Leaf)) - { - return new SimpleContentModel - ( - true - , specNode->getFirst()->getElement() - , specNode->getSecond()->getElement() - , specNode->getType() - ); - } - } - else if ((specNode->getType() == ContentSpecNode::OneOrMore) - || (specNode->getType() == ContentSpecNode::ZeroOrMore) - || (specNode->getType() == ContentSpecNode::ZeroOrOne)) - { - // - // Its a repetition, so see if its one child is a leaf. If so its a - // repetition of a single element, so we can do a simple content - // model for that. - // - if (specNode->getFirst()->getType() == ContentSpecNode::Leaf) - { - return new SimpleContentModel - ( - true - , specNode->getFirst()->getElement() - , 0 - , specNode->getType() - ); - } - } - else - { - ThrowXML(RuntimeException, XMLExcepts::CM_UnknownCMSpecType); - } - - // Its not any simple type of content, so create a DFA based content model - return new DFAContentModel(true, this->getContentSpec()); -} - - -void DTDElementDecl::faultInAttDefList() const -{ - // Use a hash modulus of 29 and tell it owns its elements - ((DTDElementDecl*)this)->fAttDefs = new RefHashTableOf<DTDAttDef>(29, true); -} diff --git a/src/validators/DTD/DTDElementDecl.hpp b/src/validators/DTD/DTDElementDecl.hpp deleted file mode 100644 index cd8d577df3691c5b41d2db2de559cd96d2441781..0000000000000000000000000000000000000000 --- a/src/validators/DTD/DTDElementDecl.hpp +++ /dev/null @@ -1,315 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999-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$ - * Revision 1.12 2001/09/05 20:49:10 knoaman - * Fix for complexTypes with mixed content model. - * - * Revision 1.11 2001/08/21 16:06:11 tng - * Schema: Unique Particle Attribution Constraint Checking. - * - * Revision 1.10 2001/05/11 13:27:08 tng - * Copyright update. - * - * Revision 1.9 2001/04/19 18:17:20 tng - * Schema: SchemaValidator update, and use QName in Content Model - * - * Revision 1.8 2001/03/21 21:56:19 tng - * Schema: Add Schema Grammar, Schema Validator, and split the DTDValidator into DTDValidator, DTDScanner, and DTDGrammar. - * - * Revision 1.7 2001/03/21 19:29:43 tng - * Schema: Content Model Updates, by Pei Yong Zhang. - * - * Revision 1.6 2001/02/26 19:29:21 tng - * Schema: add virtual method getURI(), getContentSpec and setContenSpec in XMLElementDecl, and DTDElementDecl. - * - * Revision 1.5 2001/02/26 19:22:02 tng - * Schema: add parameter prefix in findElem and findAttr. - * - * Revision 1.4 2000/02/24 20:16:49 abagchi - * Swat for removing Log from API docs - * - * Revision 1.3 2000/02/09 21:42:37 abagchi - * Copyright swat - * - * Revision 1.2 1999/11/23 01:51:04 rahulj - * Cannot use class qualifier in class defn. CC under HPUX is happy. - * - * Revision 1.1.1.1 1999/11/09 01:03:32 twl - * Initial checkin - * - * Revision 1.3 1999/11/08 20:45:40 rahul - * Swat for adding in Product name and CVS comment log variable. - * - */ - - -#if !defined(DTDELEMENTDECL_HPP) -#define DTDELEMENTDECL_HPP - -#include <util/RefHashTableOf.hpp> -#include <util/QName.hpp> -#include <framework/XMLElementDecl.hpp> -#include <framework/XMLContentModel.hpp> -#include <validators/DTD/DTDAttDef.hpp> - -class ContentSpecNode; -class DTDAttDefList; - - -// -// This class is a derivative of the basic element decl. This one implements -// the virtuals so that they work for a DTD. THe big difference is that -// they don't live in any URL in the DTD. The names are just stored as full -// QNames, so they are not split out and element decls don't live within -// URL namespaces or anything like that. -// - -class VALIDATORS_EXPORT DTDElementDecl : public XMLElementDecl -{ -public : - // ----------------------------------------------------------------------- - // Class specific types - // - // ModelTypes - // Indicates the type of content model that an element has. This - // indicates how the content model is represented and validated. - // ----------------------------------------------------------------------- - enum ModelTypes - { - Empty - , Any - , Mixed_Simple - , Children - - , ModelTypes_Count - }; - - - // ----------------------------------------------------------------------- - // Constructors and Destructor - // ----------------------------------------------------------------------- - DTDElementDecl(); - - DTDElementDecl - ( - const XMLCh* const elemRawName - , const unsigned int uriId - , const ModelTypes modelType = Any - ); - - DTDElementDecl - ( - QName* const elementName - , const ModelTypes modelType = Any - ); - - ~DTDElementDecl(); - - - // ----------------------------------------------------------------------- - // The virtual element decl interface - // ----------------------------------------------------------------------- - virtual XMLAttDef* findAttr - ( - const XMLCh* const qName - , const unsigned int uriId - , const XMLCh* const baseName - , const XMLCh* const prefix - , const LookupOpts options - , bool& wasAdded - ) const; - virtual XMLAttDefList& getAttDefList() const; - virtual CharDataOpts getCharDataOpts() const; - virtual bool hasAttDefs() const; - virtual bool resetDefs(); - virtual const ContentSpecNode* getContentSpec() const; - virtual ContentSpecNode* getContentSpec(); - virtual void setContentSpec(ContentSpecNode* toAdopt); - virtual XMLContentModel* getContentModel(); - virtual void setContentModel(XMLContentModel* const newModelToAdopt); - virtual const XMLCh* getFormattedContentModel () const; - - // ----------------------------------------------------------------------- - // Support keyed collections - // - // This method allows objects of this type be placed into one of the - // standard keyed collections. This method will return the full name of - // the element, which will vary depending upon the type of the grammar. - // ----------------------------------------------------------------------- - const XMLCh* getKey() const; - - // ----------------------------------------------------------------------- - // Getter methods - // ----------------------------------------------------------------------- - const DTDAttDef* getAttDef(const XMLCh* const attName) const; - DTDAttDef* getAttDef(const XMLCh* const attName); - ModelTypes getModelType() const; - - - // ----------------------------------------------------------------------- - // Setter methods - // ----------------------------------------------------------------------- - void addAttDef(DTDAttDef* const toAdd); - void setModelType(const DTDElementDecl::ModelTypes toSet); - - -private : - // ----------------------------------------------------------------------- - // Private helper methods - // ----------------------------------------------------------------------- - void faultInAttDefList() const; - XMLContentModel* createChildModel() ; - XMLContentModel* makeContentModel() ; - XMLCh* formatContentModel () const ; - - - // ----------------------------------------------------------------------- - // Private data members - // - // fAttDefs - // The list of attributes that are defined for this element. Each - // element is its own little 'namespace' for attributes, so each - // element maintains its own list of owned attribute defs. It is - // faulted in when an attribute is actually added. - // - // fAttList - // We have to return a view of our att defs via the abstract view - // that the scanner understands. It may or may not ever be asked - // for so we fault it in as needed. - // - // fContentSpec - // This is the content spec for the node. It contains the original - // content spec that was read from the DTD, as a tree of nodes. This - // one is always set up, and is used to build the fContentModel - // version if we are validating. - // - // fModelType - // The content model type of this element. This tells us what kind - // of content model to create. - // - // fContentModel - // The content model object for this element. It is stored here via - // its abstract interface. - // - // fFormattedModel - // This is a faulted in member. When the outside world asks for - // our content model as a string, we format it and fault it into - // this field (to avoid doing the formatted over and over.) - // ----------------------------------------------------------------------- - RefHashTableOf<DTDAttDef>* fAttDefs; - DTDAttDefList* fAttList; - ContentSpecNode* fContentSpec; - ModelTypes fModelType; - XMLContentModel* fContentModel; - XMLCh* fFormattedModel; -}; - -// --------------------------------------------------------------------------- -// DTDElementDecl: XMLElementDecl virtual interface implementation -// --------------------------------------------------------------------------- -inline ContentSpecNode* DTDElementDecl::getContentSpec() -{ - return fContentSpec; -} - -inline const ContentSpecNode* DTDElementDecl::getContentSpec() const -{ - return fContentSpec; -} - -inline XMLContentModel* DTDElementDecl::getContentModel() -{ - if (!fContentModel) - fContentModel = makeContentModel(); - return fContentModel; -} - -inline void -DTDElementDecl::setContentModel(XMLContentModel* const newModelToAdopt) -{ - delete fContentModel; - fContentModel = newModelToAdopt; -} - -// --------------------------------------------------------------------------- -// DTDElementDecl: Miscellaneous methods -// --------------------------------------------------------------------------- -inline const XMLCh* DTDElementDecl::getKey() const -{ - return getFullName(); -} - -// --------------------------------------------------------------------------- -// DTDElementDecl: Getter methods -// --------------------------------------------------------------------------- -inline DTDElementDecl::ModelTypes DTDElementDecl::getModelType() const -{ - return fModelType; -} - - -// --------------------------------------------------------------------------- -// DTDElementDecl: Setter methods -// --------------------------------------------------------------------------- -inline void -DTDElementDecl::setModelType(const DTDElementDecl::ModelTypes toSet) -{ - fModelType = toSet; -} - -#endif diff --git a/src/validators/DTD/DTDEntityDecl.hpp b/src/validators/DTD/DTDEntityDecl.hpp deleted file mode 100644 index 1e471f4f4f6ce80f0977758a6956f5ab4a86f859..0000000000000000000000000000000000000000 --- a/src/validators/DTD/DTDEntityDecl.hpp +++ /dev/null @@ -1,248 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999-2000 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$ - * Revision 1.4 2000/02/24 20:16:49 abagchi - * Swat for removing Log from API docs - * - * Revision 1.3 2000/02/09 21:42:37 abagchi - * Copyright swat - * - * Revision 1.2 2000/01/20 01:57:07 rahulj - * Reported by marc@ist.de - * Removed extra 'const' qualifiers. - * - * Revision 1.1.1.1 1999/11/09 01:03:34 twl - * Initial checkin - * - * Revision 1.2 1999/11/08 20:45:40 rahul - * Swat for adding in Product name and CVS comment log variable. - * - */ - - -#if !defined(DTDENTITYDECL_HPP) -#define DTDENTITYDECL_HPP - -#include <framework/XMLEntityDecl.hpp> - - -// -// This is a derivative of the abstract version of an entity decl in the -// framework directory. We just need to provide implementation of a couple -// of methods. -// -class VALIDATORS_EXPORT DTDEntityDecl : public XMLEntityDecl -{ -public : - // ----------------------------------------------------------------------- - // Constructors and Destructor - // ----------------------------------------------------------------------- - DTDEntityDecl(); - DTDEntityDecl - ( - const XMLCh* const entName - , const bool fromIntSubset = false - ); - DTDEntityDecl - ( - const XMLCh* const entName - , const XMLCh* const value - , const bool fromIntSubset = false - ); - DTDEntityDecl - ( - const XMLCh* const entName - , const XMLCh value - , const bool fromIntSubset = false - , const bool specialChar = false - ); - ~DTDEntityDecl(); - - - // ----------------------------------------------------------------------- - // Implementation of the virtual XMLEntityDecl interface - // ----------------------------------------------------------------------- - virtual bool getDeclaredInIntSubset() const; - virtual bool getIsParameter() const; - virtual bool getIsSpecialChar() const; - - - // ----------------------------------------------------------------------- - // Setter methods - // ----------------------------------------------------------------------- - void setDeclaredInIntSubset(const bool newValue); - void setIsParameter(const bool newValue); - void setIsSpecialChar(const bool newValue); - - -private : - // ----------------------------------------------------------------------- - // Unimplemented constructors and operators - // ----------------------------------------------------------------------- - DTDEntityDecl(const DTDEntityDecl&); - void operator=(DTDEntityDecl&); - - - // ----------------------------------------------------------------------- - // Private data members - // - // fDeclaredInIntSubset - // Indicates whether the entity was declared in the internal subset - // or not. If not, it cannot be referred to from a standalone - // document. - // - // fIsParameter - // Indicates whether this is a parameter entity or a general entity. - // - // fIsSpecialChar - // This indicates that its one of the special character entities, - // e.g. lt or gt or amp. We need to know this because there are - // places where only a numeric char ref or special char ref is valid - // and all others are ignored or illegal. - // ----------------------------------------------------------------------- - bool fDeclaredInIntSubset; - bool fIsParameter; - bool fIsSpecialChar; -}; - - -// --------------------------------------------------------------------------- -// DTDEntityDecl: Constructors and Destructor -// --------------------------------------------------------------------------- -inline DTDEntityDecl::DTDEntityDecl() : - - fDeclaredInIntSubset(false) - , fIsParameter(false) - , fIsSpecialChar(false) -{ -} - -inline DTDEntityDecl::DTDEntityDecl(const XMLCh* const entName - , const bool fromIntSubset) : - - XMLEntityDecl(entName) - , fDeclaredInIntSubset(fromIntSubset) - , fIsParameter(false) - , fIsSpecialChar(false) -{ -} - -inline DTDEntityDecl::DTDEntityDecl(const XMLCh* const entName - , const XMLCh* const value - , const bool fromIntSubset) : - XMLEntityDecl(entName, value) - , fDeclaredInIntSubset(fromIntSubset) - , fIsParameter(false) - , fIsSpecialChar(false) -{ -} - -inline DTDEntityDecl::DTDEntityDecl(const XMLCh* const entName - , const XMLCh value - , const bool fromIntSubset - , const bool specialChar) : - XMLEntityDecl(entName, value) - , fDeclaredInIntSubset(fromIntSubset) - , fIsParameter(false) - , fIsSpecialChar(specialChar) -{ -} - -inline DTDEntityDecl::~DTDEntityDecl() -{ -} - - -// --------------------------------------------------------------------------- -// DTDEntityDecl: Getter methods -// --------------------------------------------------------------------------- -inline bool DTDEntityDecl::getDeclaredInIntSubset() const -{ - return fDeclaredInIntSubset; -} - -inline bool DTDEntityDecl::getIsParameter() const -{ - return fIsParameter; -} - -inline bool DTDEntityDecl::getIsSpecialChar() const -{ - return fIsSpecialChar; -} - - -// --------------------------------------------------------------------------- -// DTDEntityDecl: Setter methods -// --------------------------------------------------------------------------- -inline void DTDEntityDecl::setDeclaredInIntSubset(const bool newValue) -{ - fDeclaredInIntSubset = newValue; -} - -inline void DTDEntityDecl::setIsParameter(const bool newValue) -{ - fIsParameter = newValue; -} - -inline void DTDEntityDecl::setIsSpecialChar(const bool newValue) -{ - fIsSpecialChar = newValue; -} - -#endif diff --git a/src/validators/DTD/DTDGrammar.cpp b/src/validators/DTD/DTDGrammar.cpp deleted file mode 100644 index 70e62d67e83c9f9481fd66ee23de43852e4a9147..0000000000000000000000000000000000000000 --- a/src/validators/DTD/DTDGrammar.cpp +++ /dev/null @@ -1,158 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999-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$ - * Revision 1.4 2001/09/14 14:50:22 tng - * Schema: Fix some wildcard bugs, and some retrieving qualified/unqualified element decl problems. - * - * Revision 1.3 2001/05/11 13:27:08 tng - * Copyright update. - * - * Revision 1.2 2001/04/19 18:17:20 tng - * Schema: SchemaValidator update, and use QName in Content Model - * - * Revision 1.1 2001/03/21 21:56:20 tng - * Schema: Add Schema Grammar, Schema Validator, and split the DTDValidator into DTDValidator, DTDScanner, and DTDGrammar. - * - */ - - -// --------------------------------------------------------------------------- -// Includes -// --------------------------------------------------------------------------- -#include <util/XMLUniDefs.hpp> -#include <util/XMLUni.hpp> -#include <validators/DTD/DTDGrammar.hpp> - -//--------------------------------------------------------------------------- -// DTDGrammar: Constructors and Destructor -// --------------------------------------------------------------------------- -DTDGrammar::DTDGrammar() : - fElemDeclPool(0) - , fNotationDeclPool(0) -{ - // - // Init all the pool members. - // - // <TBD> Investigate what the optimum values would be for the various - // pools. - // - fElemDeclPool = new NameIdPool<DTDElementDecl>(109); - fNotationDeclPool = new NameIdPool<XMLNotationDecl>(109); - - // - // Call our own reset method. This lets us have the pool setup stuff - // done in just one place (because this stame setup stuff has to be - // done every time we are reset.) - // - reset(); -} - -DTDGrammar::~DTDGrammar() -{ - delete fElemDeclPool; - delete fNotationDeclPool; -} - -// ----------------------------------------------------------------------- -// Virtual methods -// ----------------------------------------------------------------------- -XMLElementDecl* DTDGrammar::findOrAddElemDecl (const unsigned int uriId - , const XMLCh* const baseName - , const XMLCh* const prefixName - , const XMLCh* const qName - , unsigned int scope - , bool& wasAdded ) -{ - // See it it exists - DTDElementDecl* retVal = fElemDeclPool->getByKey(qName); - - // if not, then add this in - if (!retVal) - { - retVal = new DTDElementDecl(qName, uriId, DTDElementDecl::Any); - const unsigned int elemId = fElemDeclPool->put(retVal); - retVal->setId(elemId); - wasAdded = true; - } - else - { - wasAdded = false; - } - return retVal; -} - -XMLElementDecl* DTDGrammar::putElemDecl (const unsigned int uriId - , const XMLCh* const baseName - , const XMLCh* const prefixName - , const XMLCh* const qName - , unsigned int scope) -{ - DTDElementDecl* retVal = new DTDElementDecl(qName, uriId, DTDElementDecl::Any); - const unsigned int elemId = fElemDeclPool->put(retVal); - retVal->setId(elemId); - return retVal; -} - -void DTDGrammar::reset() -{ - // - // We need to reset all of the pools. - // - fElemDeclPool->removeAll(); - fNotationDeclPool->removeAll(); -} diff --git a/src/validators/DTD/DTDGrammar.hpp b/src/validators/DTD/DTDGrammar.hpp deleted file mode 100644 index 2de6fd87b8697561244da57fe36b3589658aa111..0000000000000000000000000000000000000000 --- a/src/validators/DTD/DTDGrammar.hpp +++ /dev/null @@ -1,331 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999-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$ - * Revision 1.5 2001/09/14 14:50:22 tng - * Schema: Fix some wildcard bugs, and some retrieving qualified/unqualified element decl problems. - * - * Revision 1.4 2001/05/28 20:56:17 tng - * Schema: Move getTargetNamespace as virtual function in base class Grammar - * - * Revision 1.3 2001/05/11 13:27:09 tng - * Copyright update. - * - * Revision 1.2 2001/04/19 18:17:21 tng - * Schema: SchemaValidator update, and use QName in Content Model - * - * Revision 1.1 2001/03/21 21:56:20 tng - * Schema: Add Schema Grammar, Schema Validator, and split the DTDValidator into DTDValidator, DTDScanner, and DTDGrammar. - * - */ - - - -#if !defined(DTDGRAMMAR_HPP) -#define DTDGRAMMAR_HPP - -#include <util/RefHashTableOf.hpp> -#include <util/NameIdPool.hpp> -#include <util/StringPool.hpp> -#include <validators/common/Grammar.hpp> -#include <validators/DTD/DTDElementDecl.hpp> - -// -// This class stores the DTD information -// NOTE: DTDs are not namespace aware, so we just use regular NameIdPool -// data structures to store element and attribute decls. They are all set -// to be in the global namespace and the full QName is used as the base name -// of the decl. This means that all the URI parameters below are expected -// to be null pointers (and anything else will cause an exception.) -// - -class VALIDATORS_EXPORT DTDGrammar : public Grammar -{ -public: - // ----------------------------------------------------------------------- - // Constructors and Destructor - // ----------------------------------------------------------------------- - DTDGrammar(); - virtual ~DTDGrammar(); - - - // ----------------------------------------------------------------------- - // Implementation of Virtual Interface - // ----------------------------------------------------------------------- - virtual Grammar::GrammarType getGrammarType(); - virtual const XMLCh* getTargetNamespace() const; - - virtual XMLElementDecl* findOrAddElemDecl - ( - const unsigned int uriId - , const XMLCh* const baseName - , const XMLCh* const prefixName - , const XMLCh* const qName - , unsigned int scope - , bool& wasAdded - ) ; - - virtual unsigned int getElemId - ( - const unsigned int uriId - , const XMLCh* const baseName - , const XMLCh* const qName - , unsigned int scope - ) const ; - - virtual const XMLElementDecl* getElemDecl - ( - const unsigned int uriId - , const XMLCh* const baseName - , const XMLCh* const qName - , unsigned int scope - ) const ; - - virtual XMLElementDecl* getElemDecl - ( - const unsigned int uriId - , const XMLCh* const baseName - , const XMLCh* const qName - , unsigned int scope - ); - - virtual const XMLElementDecl* getElemDecl - ( - const unsigned int elemId - ) const; - - virtual XMLElementDecl* getElemDecl - ( - const unsigned int elemId - ); - - virtual const XMLNotationDecl* getNotationDecl - ( - const XMLCh* const notName - ) const; - - virtual XMLNotationDecl* getNotationDecl - ( - const XMLCh* const notName - ); - - virtual XMLElementDecl* putElemDecl - ( - const unsigned int uriId - , const XMLCh* const baseName - , const XMLCh* const prefixName - , const XMLCh* const qName - , unsigned int scope - ); - - virtual unsigned int putElemDecl - ( - XMLElementDecl* const elemDecl - ) const; - - virtual unsigned int putNotationDecl - ( - XMLNotationDecl* const notationDecl - ) const; - - virtual void reset(); - - // ----------------------------------------------------------------------- - // Getter methods - // ----------------------------------------------------------------------- - unsigned int getRootElemId(); - NameIdPoolEnumerator<DTDElementDecl> getElemEnumerator() const; - NameIdPoolEnumerator<XMLNotationDecl> getNotationEnumerator() const; - - // ----------------------------------------------------------------------- - // Setter methods - // ----------------------------------------------------------------------- - void setRootElemId(unsigned int rootElemId); - -private: - - // ----------------------------------------------------------------------- - // Private data members - // - // fElemDeclPool - // This is the element decl pool. It contains all of the elements - // declared in the DTD (and their associated attributes.) When in - // non-validating mode, its just populated as new elements are seen - // and they are given default characteristics. - // - // fNotationDeclPool - // This is a pool of NotationDecl objects, which contains all of the - // notations declared in the DTD subsets. - // - // fRootElemId - // The id of the root element that we found in the DOCTYPE statement. - // Its initialized to ContentModel::fgInvalidElemId, so that its - // invalid unless we have a DOCTYPE. - // ----------------------------------------------------------------------- - NameIdPool<DTDElementDecl>* fElemDeclPool; - NameIdPool<XMLNotationDecl>* fNotationDeclPool; - unsigned int fRootElemId; -}; - - -// --------------------------------------------------------------------------- -// DTDGrammar: Getter methods -// --------------------------------------------------------------------------- -inline unsigned int DTDGrammar::getRootElemId() -{ - return fRootElemId; -} - -// --------------------------------------------------------------------------- -// DTDGrammar: Getter methods -// --------------------------------------------------------------------------- -inline NameIdPoolEnumerator<DTDElementDecl> -DTDGrammar::getElemEnumerator() const -{ - return NameIdPoolEnumerator<DTDElementDecl>(fElemDeclPool); -} - -inline NameIdPoolEnumerator<XMLNotationDecl> -DTDGrammar::getNotationEnumerator() const -{ - return NameIdPoolEnumerator<XMLNotationDecl>(fNotationDeclPool); -} - -// ----------------------------------------------------------------------- -// Setter methods -// ----------------------------------------------------------------------- -inline void DTDGrammar::setRootElemId(unsigned int rootElemId) { - fRootElemId = rootElemId; -} - -// --------------------------------------------------------------------------- -// DTDGrammar: Virtual methods -// --------------------------------------------------------------------------- -inline Grammar::GrammarType DTDGrammar::getGrammarType() { - return Grammar::DTDGrammarType; -} - -inline const XMLCh* DTDGrammar::getTargetNamespace() const { - return XMLUni::fgZeroLenString; -} - -// Element Decl -inline unsigned int DTDGrammar::getElemId (const unsigned int uriId - , const XMLCh* const baseName - , const XMLCh* const qName - , unsigned int scope ) const -{ - // - // In this case, we don't return zero to mean 'not found', so we have to - // map it to the official not found value if we don't find it. - // - const DTDElementDecl* decl = fElemDeclPool->getByKey(qName); - if (!decl) - return XMLElementDecl::fgInvalidElemId; - return decl->getId(); -} - -inline const XMLElementDecl* DTDGrammar::getElemDecl( const unsigned int uriId - , const XMLCh* const baseName - , const XMLCh* const qName - , unsigned int scope ) const -{ - return fElemDeclPool->getByKey(qName); -} - -inline XMLElementDecl* DTDGrammar::getElemDecl (const unsigned int uriId - , const XMLCh* const baseName - , const XMLCh* const qName - , unsigned int scope ) -{ - return fElemDeclPool->getByKey(qName); -} - -inline const XMLElementDecl* DTDGrammar::getElemDecl(const unsigned int elemId) const -{ - // Look up this element decl by id - return fElemDeclPool->getById(elemId); -} - -inline XMLElementDecl* DTDGrammar::getElemDecl(const unsigned int elemId) -{ - // Look up this element decl by id - return fElemDeclPool->getById(elemId); -} - -inline unsigned int DTDGrammar::putElemDecl (XMLElementDecl* const elemDecl) const -{ - return fElemDeclPool->put((DTDElementDecl*) elemDecl); -} - -// Notation Decl -inline const XMLNotationDecl* DTDGrammar::getNotationDecl(const XMLCh* const notName) const -{ - return fNotationDeclPool->getByKey(notName); -} - -inline XMLNotationDecl* DTDGrammar::getNotationDecl(const XMLCh* const notName) -{ - return fNotationDeclPool->getByKey(notName); -} - -inline unsigned int DTDGrammar::putNotationDecl(XMLNotationDecl* const notationDecl) const -{ - return fNotationDeclPool->put(notationDecl); -} - -#endif diff --git a/src/validators/DTD/DTDScanner.cpp b/src/validators/DTD/DTDScanner.cpp deleted file mode 100644 index 6cd7472b292d327a17abc8bbfc1fd31ebdd5816b..0000000000000000000000000000000000000000 --- a/src/validators/DTD/DTDScanner.cpp +++ /dev/null @@ -1,3952 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999-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$ - * Revision 1.25 2002/01/24 16:30:50 tng - * [Bug 3111] Problem with LexicalHandler::startDTD() and LexicalHandler::endDTD() . - * - * Revision 1.24 2001/12/17 15:39:14 knoaman - * Fix for surrogate pair support. - * - * Revision 1.23 2001/12/14 20:21:37 knoaman - * Add surrogate support to comments and processing instrunctions. - * - * Revision 1.22 2001/12/06 17:51:18 tng - * Performance Enhancement. The ContentSpecNode constructor always copied the QName - * that was passed to it. Added a second constructor that allows the QName to be just assigned, not copied. - * That was because there are some cases in which a temporary QName was constructed, passed to ContentSpecNode, and then deleted. - * There were examples of that in TraverseSchema and DTDScanner. - * By Henry Zongaro. - * - * Revision 1.21 2001/11/13 13:27:28 tng - * Move root element check to XMLScanner. - * - * Revision 1.20 2001/09/05 20:49:10 knoaman - * Fix for complexTypes with mixed content model. - * - * Revision 1.19 2001/08/02 16:54:39 tng - * Reset some Scanner flags in scanReset(). - * - * Revision 1.18 2001/07/13 16:57:11 tng - * ScanId fix. - * - * Revision 1.17 2001/07/12 20:10:18 tng - * Partial Markup in Parameter Entity is validity constraint and thus should be just error, not fatal error. - * - * Revision 1.16 2001/07/10 21:09:39 tng - * Give proper error messsage when scanning external id. - * - * Revision 1.15 2001/07/10 20:56:17 tng - * Should check the first char of PI Target Name. - * - * Revision 1.14 2001/07/09 13:42:20 tng - * Partial Markup in Parameter Entity is validity constraint and thus should be just error, not fatal error. - * - * Revision 1.13 2001/07/05 14:05:29 tng - * Encoding String must present for external entity text decl. - * - * Revision 1.12 2001/07/05 13:12:19 tng - * Standalone checking is validity constraint and thus should be just error, not fatal error: - * - * Revision 1.11 2001/06/25 14:39:54 knoaman - * Fix bug #965 - submitted by Matt Lovett - * - * Revision 1.10 2001/06/22 12:42:33 tng - * [Bug 2257] 1.5 thinks a <?xml-stylesheet ...> tag is a <?xml ...> tag - * - * Revision 1.9 2001/06/21 14:25:53 knoaman - * Fix for bug 1946 - * - * Revision 1.8 2001/06/04 13:25:50 tng - * the start tag "<?xml" could be followed by (#x20 | #x9 | #xD | #xA)+. Fixed by Pei Yong Zhang. - * - * Revision 1.7 2001/05/28 20:54:06 tng - * Schema: allocate a fDTDValidator, fSchemaValidator explicitly to avoid wrong cast - * - * Revision 1.6 2001/05/11 13:27:09 tng - * Copyright update. - * - * Revision 1.5 2001/05/03 20:34:36 tng - * Schema: SchemaValidator update - * - * Revision 1.4 2001/04/23 18:54:35 tng - * Reuse grammar should allow users to use any stored element decl as root. Fixed by Erik Rydgren. - * - * Revision 1.3 2001/04/19 18:17:21 tng - * Schema: SchemaValidator update, and use QName in Content Model - * - * Revision 1.2 2001/03/30 16:35:17 tng - * Schema: Whitespace normalization. - * - * Revision 1.1 2001/03/21 21:56:20 tng - * Schema: Add Schema Grammar, Schema Validator, and split the DTDValidator into DTDValidator, DTDScanner, and DTDGrammar. - * - */ - - -// --------------------------------------------------------------------------- -// Includes -// --------------------------------------------------------------------------- -#include <util/BinMemInputStream.hpp> -#include <util/FlagJanitor.hpp> -#include <util/Janitor.hpp> -#include <util/XMLUniDefs.hpp> -#include <util/UnexpectedEOFException.hpp> -#include <sax/InputSource.hpp> -#include <framework/XMLDocumentHandler.hpp> -#include <framework/XMLEntityHandler.hpp> -#include <internal/EndOfEntityException.hpp> -#include <internal/XMLScanner.hpp> -#include <validators/common/ContentSpecNode.hpp> -#include <validators/common/MixedContentModel.hpp> -#include <validators/DTD/DTDEntityDecl.hpp> -#include <validators/DTD/DocTypeHandler.hpp> -#include <validators/DTD/DTDScanner.hpp> - -// --------------------------------------------------------------------------- -// Local methods -// --------------------------------------------------------------------------- -// -// This method automates the grunt work of looking at a char and see if its -// a repetition suffix. If so, it creates a new correct rep node and wraps -// the pass node in it. Otherwise, it returns the previous node. -// -static ContentSpecNode* -makeRepNode(const XMLCh testCh, ContentSpecNode* const prevNode) -{ - if (testCh == chQuestion) - { - return new ContentSpecNode - ( - ContentSpecNode::ZeroOrOne - , prevNode - , 0 - ); - } - else if (testCh == chPlus) - { - return new ContentSpecNode - ( - ContentSpecNode::OneOrMore - , prevNode - , 0 - ); - } - else if (testCh == chAsterisk) - { - return new ContentSpecNode - ( - ContentSpecNode::ZeroOrMore - , prevNode - , 0 - ); - } - - // Just return the incoming node - return prevNode; -} - -// --------------------------------------------------------------------------- -// DTDValidator: Constructors and Destructor -// --------------------------------------------------------------------------- -DTDScanner::DTDScanner(DTDGrammar* dtdGrammar, NameIdPool<DTDEntityDecl>* entityDeclPool, DocTypeHandler* const docTypeHandler) : - fDocTypeHandler(docTypeHandler) - , fDumAttDef(0) - , fDumElemDecl(0) - , fDumEntityDecl(0) - , fInternalSubset(false) - , fNextAttrId(1) - , fDTDGrammar(dtdGrammar) - , fPEntityDeclPool(0) - , fEntityDeclPool(entityDeclPool) - , fDocTypeReaderId(0) -{ - fPEntityDeclPool = new NameIdPool<DTDEntityDecl>(109); -} - -DTDScanner::~DTDScanner() -{ - delete fDumAttDef; - delete fDumElemDecl; - delete fDumEntityDecl; - delete fPEntityDeclPool; -} - -// --------------------------------------------------------------------------- -// DTDScanner: Private scanning methods -// --------------------------------------------------------------------------- -bool DTDScanner::checkForPERef(const bool spaceRequired - , const bool inLiteral - , const bool inMarkup - , const bool throwAtEndExt) -{ - bool gotSpace = false; - - // - // See if we have any spaces up front. If so, then skip them and set - // the gotSpaces flag. - // - if (fReaderMgr->skippedSpace()) - { - fReaderMgr->skipPastSpaces(); - gotSpace = true; - } - - // If the next char is a percent, then expand the PERef - if (!fReaderMgr->skippedChar(chPercent)) - return gotSpace; - - while (true) - { - if (!expandPERef(false, inLiteral, inMarkup, throwAtEndExt)) - fScanner->emitError(XMLErrs::ExpectedEntityRefName); - // And skip any more spaces in the expanded value - if (fReaderMgr->skippedSpace()) - { - fReaderMgr->skipPastSpaces(); - gotSpace = true; - } - if (!fReaderMgr->skippedChar(chPercent)) - break; - } - return gotSpace; -} - - -bool DTDScanner::expandPERef( const bool scanExternal - , const bool inLiteral - , const bool inMarkup - , const bool throwEndOfExt) -{ - fScanner->setHasNoDTD(false); - XMLBufBid bbName(fBufMgr); - - // - // If we are in the internal subset and in markup, then this is - // an error but we go ahead and do it anyway. - // - if (fInternalSubset && inMarkup) - fScanner->emitError(XMLErrs::PERefInMarkupInIntSubset); - - if (!fReaderMgr->getName(bbName.getBuffer())) - { - fScanner->emitError(XMLErrs::ExpectedPEName); - - // Skip the semicolon if that's what we ended up on - fReaderMgr->skippedChar(chSemiColon); - return false; - } - - // If no terminating semicolon, emit an error but try to keep going - if (!fReaderMgr->skippedChar(chSemiColon)) - fScanner->emitError(XMLErrs::UnterminatedEntityRef, bbName.getRawBuffer()); - - // - // Look it up in the PE decl pool and see if it exists. If not, just - // emit an error and continue. - // - XMLEntityDecl* decl = fPEntityDeclPool->getByKey(bbName.getRawBuffer()); - if (!decl) - { - // XML 1.0 Section 4.1 - if (fScanner->getStandalone()) { - // no need to check fScanner->fHasNoDTD which is for sure false - // since we are in expandPERef already - fScanner->emitError(XMLErrs::EntityNotFound, bbName.getRawBuffer()); - } - else { - if (fScanner->getDoValidation()) - fScanner->getValidator()->emitError(XMLValid::VC_EntityNotFound, bbName.getRawBuffer()); - } - - return false; - } - - // - // If we are a standalone document, then it has to have been declared - // in the internal subset. Keep going though. - // - if (fScanner->getDoValidation() && fScanner->getStandalone() && !decl->getDeclaredInIntSubset()) - fScanner->getValidator()->emitError(XMLValid::IllegalRefInStandalone, bbName.getRawBuffer()); - - // - // Okee dokee, we found it. So create either a memory stream with - // the entity value contents, or a file stream if its an external - // entity. - // - if (decl->isExternal()) - { - // And now create a reader to read this entity - InputSource* srcUsed; - XMLReader* reader = fReaderMgr->createReader - ( - decl->getSystemId() - , decl->getPublicId() - , false - , inLiteral ? XMLReader::RefFrom_Literal : XMLReader::RefFrom_NonLiteral - , XMLReader::Type_PE - , XMLReader::Source_External - , srcUsed - ); - - // Put a janitor on the source so its cleaned up on exit - Janitor<InputSource> janSrc(srcUsed); - - // If the creation failed then throw an exception - if (!reader) - ThrowXML1(RuntimeException, XMLExcepts::Gen_CouldNotOpenExtEntity, srcUsed->getSystemId()); - - // Set the 'throw at end' flag, to the one we were given - reader->setThrowAtEnd(throwEndOfExt); - - // - // Push the reader. If its a recursive expansion, then emit an error - // and return an failure. - // - if (!fReaderMgr->pushReader(reader, decl)) - { - fScanner->emitError(XMLErrs::RecursiveEntity, decl->getName()); - return false; - } - - // - // If the caller wants us to scan the external entity, then lets - // do that now. - // - if (scanExternal) - { - XMLEntityHandler* entHandler = fScanner->getEntityHandler(); - - // If we have an entity handler, tell it we are starting this entity - if (entHandler) - entHandler->startInputSource(*srcUsed); - - // - // Scan the external entity now. The parameter tells it that - // it is not in an include section. Get the current reader - // level so we can catch partial markup errors and be sure - // to get back to here if we get an exception out of the - // ext subset scan. - // - const unsigned int readerNum = fReaderMgr->getCurrentReaderNum(); - try - { - scanExtSubsetDecl(false); - } - - catch(...) - { - // Pop the reader back to the original level - fReaderMgr->cleanStackBackTo(readerNum); - - // End the input source, even though its not happy - if (entHandler) - entHandler->endInputSource(*srcUsed); - throw; - } - - // If we have an entity handler, tell it we are ending this entity - if (entHandler) - entHandler->endInputSource(*srcUsed); - } - } - else - { - // Create a reader over a memory stream over the entity value - XMLReader* valueReader = fReaderMgr->createIntEntReader - ( - decl->getName() - , inLiteral ? XMLReader::RefFrom_Literal : XMLReader::RefFrom_NonLiteral - , XMLReader::Type_PE - , decl->getValue() - , decl->getValueLen() - , false - ); - - // - // Trt to push the entity reader onto the reader manager stack, - // where it will become the subsequent input. If it fails, that - // means the entity is recursive, so issue an error. The reader - // will have just been discarded, but we just keep going. - // - if (!fReaderMgr->pushReader(valueReader, decl)) - fScanner->emitError(XMLErrs::RecursiveEntity, decl->getName()); - } - - return true; -} - - -bool DTDScanner::getQuotedString(XMLBuffer& toFill) -{ - // Reset the target buffer - toFill.reset(); - - // Get the next char which must be a single or double quote - XMLCh quoteCh; - if (!fReaderMgr->skipIfQuote(quoteCh)) - return false; - - while (true) - { - // Get another char - const XMLCh nextCh = fReaderMgr->getNextChar(); - - // See if it matches the starting quote char - if (nextCh == quoteCh) - break; - - // - // We should never get either an end of file null char here. If we - // do, just fail. It will be handled more gracefully in the higher - // level code that called us. - // - if (!nextCh) - return false; - - // Else add it to the buffer - toFill.append(nextCh); - } - return true; -} - - -XMLAttDef* -DTDScanner::scanAttDef(DTDElementDecl& parentElem, XMLBuffer& bufToUse) -{ - // Check for PE ref or optional whitespace - checkForPERef(false, false, true); - - // Get the name of the attribute - if (!fReaderMgr->getName(bufToUse)) - { - fScanner->emitError(XMLErrs::ExpectedAttrName); - return 0; - } - - // - // Look up this attribute in the parent element's attribute list. If - // it already exists, then use the dummy. - // - DTDAttDef* decl = parentElem.getAttDef(bufToUse.getRawBuffer()); - if (decl) - { - // It already exists, so put out a warning - fScanner->emitError - ( - XMLErrs::AttListAlreadyExists - , bufToUse.getRawBuffer() - , parentElem.getFullName() - ); - - // Use the dummy decl to parse into and set its name to the name we got - if (!fDumAttDef) - { - fDumAttDef = new DTDAttDef; - fDumAttDef->setId(fNextAttrId++); - } - fDumAttDef->setName(bufToUse.getRawBuffer()); - decl = fDumAttDef; - } - else - { - // - // It does not already exist so create a new one, give it the next - // available unique id, and add it - // - decl = new DTDAttDef(bufToUse.getRawBuffer()); - decl->setId(fNextAttrId++); - decl->setExternalAttDeclaration(isReadingExternalEntity()); - parentElem.addAttDef(decl); - } - - // Set a flag to indicate whether we are doing a dummy parse - const bool isIgnored = (decl == fDumAttDef); - - // Space is required here, so check for PE ref, and require space - if (!checkForPERef(true, false, true)) - fScanner->emitError(XMLErrs::ExpectedWhitespace); - - // - // Next has to be one of the attribute type strings. This tells us what - // is to follow. - // - if (fReaderMgr->skippedString(XMLUni::fgCDATAString)) - { - decl->setType(XMLAttDef::CData); - } - else if (fReaderMgr->skippedString(XMLUni::fgIDString)) - { - if (!fReaderMgr->skippedString(XMLUni::fgRefString)) - decl->setType(XMLAttDef::ID); - else if (!fReaderMgr->skippedChar(chLatin_S)) - decl->setType(XMLAttDef::IDRef); - else - decl->setType(XMLAttDef::IDRefs); - } - else if (fReaderMgr->skippedString(XMLUni::fgEntitString)) - { - if (fReaderMgr->skippedChar(chLatin_Y)) - { - decl->setType(XMLAttDef::Entity); - } - else if (fReaderMgr->skippedString(XMLUni::fgIESString)) - { - decl->setType(XMLAttDef::Entities); - } - else - { - fScanner->emitError - ( - XMLErrs::ExpectedAttributeType - , decl->getFullName() - , parentElem.getFullName() - ); - return 0; - } - } - else if (fReaderMgr->skippedString(XMLUni::fgNmTokenString)) - { - if (fReaderMgr->skippedChar(chLatin_S)) - decl->setType(XMLAttDef::NmTokens); - else - decl->setType(XMLAttDef::NmToken); - } - else if (fReaderMgr->skippedString(XMLUni::fgNotationString)) - { - // Check for PE ref and require space - if (!checkForPERef(true, false, true)) - fScanner->emitError(XMLErrs::ExpectedWhitespace); - - decl->setType(XMLAttDef::Notation); - if (!scanEnumeration(*decl, bufToUse, true)) - return 0; - - // Set the value as the enumeration for this decl - decl->setEnumeration(bufToUse.getRawBuffer()); - } - else if (fReaderMgr->skippedChar(chOpenParen)) - { - decl->setType(XMLAttDef::Enumeration); - if (!scanEnumeration(*decl, bufToUse, false)) - return 0; - - // Set the value as the enumeration for this decl - decl->setEnumeration(bufToUse.getRawBuffer()); - } - else - { - fScanner->emitError - ( - XMLErrs::ExpectedAttributeType - , decl->getFullName() - , parentElem.getFullName() - ); - return 0; - } - - // Space is required here, so check for PE ref, and require space - if (!checkForPERef(true, false, true)) - fScanner->emitError(XMLErrs::ExpectedWhitespace); - - // And then scan for the optional default value declaration - scanDefaultDecl(*decl); - - // If validating, then do a couple of validation constraints - if (fScanner->getDoValidation()) - { - if (decl->getType() == XMLAttDef::ID) - { - if ((decl->getDefaultType() != XMLAttDef::Implied) - && (decl->getDefaultType() != XMLAttDef::Required)) - { - fScanner->getValidator()->emitError(XMLValid::BadIDAttrDefType, decl->getFullName()); - } - } - - // if attdef is xml:space, check correct enumeration (default|preserve) - const XMLCh fgXMLSpace[] = { chLatin_x, chLatin_m, chLatin_l, chColon, chLatin_s, chLatin_p, chLatin_a, chLatin_c, chLatin_e, chNull }; - - if (!XMLString::compareString(decl->getFullName(),fgXMLSpace)) { - const XMLCh fgPreserve[] = { chLatin_p, chLatin_r, chLatin_e, chLatin_s, chLatin_e, chLatin_r, chLatin_v, chLatin_e, chNull }; - const XMLCh fgDefault[] = { chLatin_d, chLatin_e, chLatin_f, chLatin_a, chLatin_u, chLatin_l, chLatin_t, chNull }; - bool ok = false; - if (decl->getType() == XMLAttDef::Enumeration) { - RefVectorOf<XMLCh>* enumVector = XMLString::tokenizeString(decl->getEnumeration()); - int size = enumVector->size(); - ok = (size == 1 && - (!XMLString::compareString(enumVector->elementAt(0), fgDefault) || - !XMLString::compareString(enumVector->elementAt(0), fgPreserve))) || - (size == 2 && - (!XMLString::compareString(enumVector->elementAt(0), fgDefault) && - !XMLString::compareString(enumVector->elementAt(1), fgPreserve))) || - (size == 2 && - (!XMLString::compareString(enumVector->elementAt(1), fgDefault) && - !XMLString::compareString(enumVector->elementAt(0), fgPreserve))); - delete enumVector; - } - if (!ok) - fScanner->getValidator()->emitError(XMLValid::IllegalXMLSpace); - } - } - - // If we have a doc type handler, tell it about this attdef. - if (fDocTypeHandler) - fDocTypeHandler->attDef(parentElem, *decl, isIgnored); - return decl; -} - - -void DTDScanner::scanAttListDecl() -{ - // Space is required here, so check for a PE ref - if (!checkForPERef(true, false, true)) - { - fScanner->emitError(XMLErrs::ExpectedWhitespace); - fReaderMgr->skipPastChar(chCloseAngle); - return; - } - - // - // Next should be the name of the element it belongs to, so get a buffer - // and get the name into it. - // - XMLBufBid bbName(fBufMgr); - if (!fReaderMgr->getName(bbName.getBuffer())) - { - fScanner->emitError(XMLErrs::ExpectedElementName); - fReaderMgr->skipPastChar(chCloseAngle); - return; - } - - // - // Find this element's declaration. If it has not been declared yet, - // we will force one into the list, but not mark it as declared. - // - DTDElementDecl* elemDecl = (DTDElementDecl*) fDTDGrammar->getElemDecl(fEmptyNamespaceId, 0, bbName.getRawBuffer(), Grammar::TOP_LEVEL_SCOPE); - if (!elemDecl) - { - // - // Lets fault in a declaration and add it to the pool. We mark - // it having been created because of an attlist. Later, if its - // declared, this will be updated. - // - elemDecl = new DTDElementDecl(bbName.getRawBuffer(), fEmptyNamespaceId); - elemDecl->setCreateReason(XMLElementDecl::AttList); - elemDecl->setExternalElemDeclaration(isReadingExternalEntity()); - fDTDGrammar->putElemDecl((XMLElementDecl*) elemDecl); - } - - // If we have a doc type handler, tell it the att list is starting - if (fDocTypeHandler) - fDocTypeHandler->startAttList(*elemDecl); - - // - // Now we loop until we are done with all of the attributes in this - // list. We need a buffer to use for local processing. - // - XMLBufBid bbTmp(fBufMgr); - XMLBuffer& tmpBuf = bbTmp.getBuffer(); - bool seenAnId = false; - while (true) - { - // Get the next char out and see what it tells us to do - const XMLCh nextCh = fReaderMgr->peekNextChar(); - - // Watch for EOF - if (!nextCh) - ThrowXML(UnexpectedEOFException, XMLExcepts::Gen_UnexpectedEOF); - - if (nextCh == chCloseAngle) - { - // We are done with this attribute list - fReaderMgr->getNextChar(); - break; - } - else if (XMLReader::isWhitespace(nextCh)) - { - // - // If advanced callbacks are enabled and we have a doc - // type handler, then gather up the white space and call - // back on the doctype handler. Otherwise, just skip - // whitespace. - // - if (fDocTypeHandler) - { - fReaderMgr->getSpaces(tmpBuf); - fDocTypeHandler->doctypeWhitespace - ( - tmpBuf.getRawBuffer() - , tmpBuf.getLen() - ); - } - else - { - fReaderMgr->skipPastSpaces(); - } - } - else if (nextCh == chPercent) - { - // Eat the percent and expand the ref - fReaderMgr->getNextChar(); - expandPERef(false, false, true); - } - else - { - // - // It must be an attribute name, so scan it. We let - // it use our local buffer for its name scanning. - // - XMLAttDef* attDef = scanAttDef(*elemDecl, tmpBuf); - - if (!attDef) - { - fReaderMgr->skipPastChar(chCloseAngle); - break; - } - - // - // If we are validating and its an ID type, then we have to - // make sure that we have not seen an id attribute yet. Set - // the flag to say that we've seen one now also. - // - if (fScanner->getDoValidation()) - { - if (attDef->getType() == XMLAttDef::ID) - { - if (seenAnId) - fScanner->getValidator()->emitError(XMLValid::MultipleIdAttrs, elemDecl->getFullName()); - seenAnId = true; - } - } - } - } - - // If we have a doc type handler, tell it the att list is ending - if (fDocTypeHandler) - fDocTypeHandler->endAttList(*elemDecl); -} - - -// -// This method is called to scan the value of an attribute in content. This -// involves some normalization and replacement of general entity and -// character references. -// -// End of entity's must be dealt with here. During DTD scan, they can come -// from external entities. During content, they can come from any entity. -// We just eat the end of entity and continue with our scan until we come -// to the closing quote. If an unterminated value causes us to go through -// subsequent entities, that will cause errors back in the calling code, -// but there's little we can do about it here. -// -bool DTDScanner::scanAttValue(const XMLCh* const attrName - , XMLBuffer& toFill - , const XMLAttDef::AttTypes type) -{ - enum States - { - InWhitespace - , InContent - }; - - // Reset the target buffer - toFill.reset(); - - // Get the next char which must be a single or double quote - XMLCh quoteCh; - if (!fReaderMgr->skipIfQuote(quoteCh)) - return false; - - // - // We have to get the current reader because we have to ignore closing - // quotes until we hit the same reader again. - // - const unsigned int curReader = fReaderMgr->getCurrentReaderNum(); - - // - // Loop until we get the attribute value. Note that we use a double - // loop here to avoid the setup/teardown overhead of the exception - // handler on every round. - // - XMLCh nextCh; - XMLCh secondCh = 0; - States curState = InContent; - bool firstNonWS = false; - bool gotLeadingSurrogate = false; - bool escaped; - while (true) - { - try - { - while(true) - { - // Get another char. Use second char from prevous is its there - if (secondCh) - { - nextCh = secondCh; - secondCh = 0; - } - else - { - nextCh = fReaderMgr->getNextChar(); - } - - if (!nextCh) - ThrowXML(UnexpectedEOFException, XMLExcepts::Gen_UnexpectedEOF); - - // Check for our ending quote in the same entity - if (nextCh == quoteCh) - { - if (curReader == fReaderMgr->getCurrentReaderNum()) - return true; - - // Watch for spillover into a previous entity - if (curReader > fReaderMgr->getCurrentReaderNum()) - { - fScanner->emitError(XMLErrs::PartialMarkupInEntity); - return false; - } - } - - // - // Check for an entity ref now, before we let it affect our - // whitespace normalization logic below. We ignore the empty flag - // in this one. - // - escaped = false; - if (nextCh == chAmpersand) - { - if (scanEntityRef(nextCh, secondCh, escaped) != EntityExp_Returned) - { - gotLeadingSurrogate = false; - continue; - } - } - - // Check for correct surrogate pairs - if ((nextCh >= 0xD800) && (nextCh <= 0xDBFF)) - { - if (gotLeadingSurrogate) - fScanner->emitError(XMLErrs::Expected2ndSurrogateChar); - else - gotLeadingSurrogate = true; - } - else - { - if (gotLeadingSurrogate) - { - if ((nextCh < 0xDC00) || (nextCh > 0xDFFF)) - fScanner->emitError(XMLErrs::Expected2ndSurrogateChar); - } - // Its got to at least be a valid XML character - else if (!XMLReader::isXMLChar(nextCh)) { - - XMLCh tmpBuf[9]; - XMLString::binToText - ( - nextCh - , tmpBuf - , 8 - , 16 - ); - fScanner->emitError - ( - XMLErrs::InvalidCharacter - , attrName - , tmpBuf - ); - } - - gotLeadingSurrogate = false; - } - - // - // If its not escaped, then make sure its not a < character, which - // is not allowed in attribute values. - // - if (!escaped && (nextCh == chOpenAngle)) - fScanner->emitError(XMLErrs::BracketInAttrValue, attrName); - - // - // If the attribute is a CDATA type we do simple replacement of - // tabs and new lines with spaces, if the character is not escaped - // by way of a char ref. - // - // Otherwise, we do the standard non-CDATA normalization of - // compressing whitespace to single spaces and getting rid of - // leading and trailing whitespace. - // - if (type == XMLAttDef::CData) - { - if (!escaped) - { - if ((nextCh == 0x09) || (nextCh == 0x0A) || (nextCh == 0x0D)) - nextCh = chSpace; - } - } - else - { - if (curState == InWhitespace) - { - if (!XMLReader::isWhitespace(nextCh)) - { - if (firstNonWS) - toFill.append(chSpace); - curState = InContent; - firstNonWS = true; - } - else - { - continue; - } - } - else if (curState == InContent) - { - if (XMLReader::isWhitespace(nextCh)) - { - curState = InWhitespace; - continue; - } - firstNonWS = true; - } - } - - // Else add it to the buffer - toFill.append(nextCh); - } - } - - catch(const EndOfEntityException&) - { - // Just eat it and continue. - gotLeadingSurrogate = false; - escaped = false; - } - } - return true; -} - - -bool DTDScanner::scanCharRef(XMLCh& first, XMLCh& second) -{ - bool gotOne = false; - unsigned int value = 0; - - // - // Set the radix. Its supposed to be a lower case x if hex. But, in - // order to recover well, we check for an upper and put out an error - // for that. - // - unsigned int radix = 10; - - if (fReaderMgr->skippedChar(chLatin_x)) - { - radix = 16; - } - else if (fReaderMgr->skippedChar(chLatin_X)) - { - fScanner->emitError(XMLErrs::HexRadixMustBeLowerCase); - radix = 16; - } - - while (true) - { - const XMLCh nextCh = fReaderMgr->peekNextChar(); - - // Watch for EOF - if (!nextCh) - ThrowXML(UnexpectedEOFException, XMLExcepts::Gen_UnexpectedEOF); - - // Break out on the terminating semicolon - if (nextCh == chSemiColon) - { - fReaderMgr->getNextChar(); - break; - } - - // - // Convert this char to a binary value, or bail out if its not - // one. - // - unsigned int nextVal; - if ((nextCh >= chDigit_0) && (nextCh <= chDigit_9)) - nextVal = (unsigned int)(nextCh - chDigit_0); - else if ((nextCh >= chLatin_A) && (nextCh <= chLatin_F)) - nextVal= (unsigned int)(10 + (nextCh - chLatin_A)); - else if ((nextCh >= chLatin_a) && (nextCh <= chLatin_f)) - nextVal = (unsigned int)(10 + (nextCh - chLatin_a)); - else - { - // - // If we got at least a sigit, then do an unterminated ref - // error. Else, do an expected a numerical ref thing. - // - if (gotOne) - fScanner->emitError(XMLErrs::UnterminatedCharRef); - else - fScanner->emitError(XMLErrs::ExpectedNumericalCharRef); - - return false; - } - - // - // Make sure its valid for the radix. If not, then just eat the - // digit and go on after issueing an error. Else, update the - // running value with this new digit. - // - if (nextVal >= radix) - { - XMLCh tmpStr[2]; - tmpStr[0] = nextCh; - tmpStr[1] = chNull; - fScanner->emitError(XMLErrs::BadDigitForRadix, tmpStr); - } - else - { - value = (value * radix) + nextVal; - } - - // Indicate that we got at least one good digit - gotOne = true; - - // Eat the char we just processed - fReaderMgr->getNextChar(); - } - - // Return the char (or chars) - if (value >= 0x10000) - { - value -= 0x10000; - first = XMLCh((value >> 10) + 0xD800); - second = XMLCh((value & 0x3FF) + 0xDC00); - } - else - { - first = XMLCh(value); - second = 0; - } - return true; -} - - -ContentSpecNode* -DTDScanner::scanChildren(const DTDElementDecl& elemDecl, XMLBuffer& bufToUse) -{ - // Check for a PE ref here, but don't require spaces - checkForPERef(false, false, true); - - // We have to check entity nesting here - unsigned int curReader; - - // - // We know that the caller just saw an opening parenthesis, so we need - // to parse until we hit the end of it, recursing for other nested - // parentheses we see. - // - // We have to check for one up front, since it could be something like - // (((a)*)) etc... - // - ContentSpecNode* curNode = 0; - if (fReaderMgr->skippedChar(chOpenParen)) - { - curReader = fReaderMgr->getCurrentReaderNum(); - - // Lets call ourself and get back the resulting node - curNode = scanChildren(elemDecl, bufToUse); - - // If that failed, no need to go further, return failure - if (!curNode) - return 0; - - if (curReader != fReaderMgr->getCurrentReaderNum() && fScanner->getDoValidation()) - fScanner->getValidator()->emitError(XMLValid::PartialMarkupInPE); - } - else - { - // Not a nested paren, so it must be a leaf node - if (!fReaderMgr->getName(bufToUse)) - { - fScanner->emitError(XMLErrs::ExpectedElementName); - return 0; - } - - // - // Create a leaf node for it. If we can find the element id for - // this element, then use it. Else, we have to fault in an element - // decl, marked as created because of being in a content model. - // - XMLElementDecl* decl = fDTDGrammar->getElemDecl(fEmptyNamespaceId, 0, bufToUse.getRawBuffer(), Grammar::TOP_LEVEL_SCOPE); - if (!decl) - { - decl = new DTDElementDecl(bufToUse.getRawBuffer(), fEmptyNamespaceId); - decl->setCreateReason(XMLElementDecl::InContentModel); - decl->setExternalElemDeclaration(isReadingExternalEntity()); - fDTDGrammar->putElemDecl(decl); - } - curNode = new ContentSpecNode(decl->getElementName()); - - // Check for a PE ref here, but don't require spaces - const bool gotSpaces = checkForPERef(false, false, true); - - // Check for a repetition character after the leaf - const XMLCh repCh = fReaderMgr->peekNextChar(); - ContentSpecNode* tmpNode = makeRepNode(repCh, curNode); - if (tmpNode != curNode) - { - if (gotSpaces) - fScanner->emitError(XMLErrs::UnexpectedWhitespace); - fReaderMgr->getNextChar(); - curNode = tmpNode; - } - } - - // Check for a PE ref here, but don't require spaces - checkForPERef(false, false, true); - - // - // Ok, the next character tells us what kind of content this particular - // model this particular parentesized section is. Its either a choice if - // we see ',', a sequence if we see '|', or a single leaf node if we see - // a closing paren. - // - const XMLCh opCh = fReaderMgr->peekNextChar(); - - if ((opCh != chComma) - && (opCh != chPipe) - && (opCh != chCloseParen)) - { - // Not a legal char, so delete our node and return failure - fScanner->emitError(XMLErrs::ExpectedSeqChoiceLeaf); - delete curNode; - return 0; - } - - // - // Create the head node of the correct type. We need this to remember - // the top of the local tree. If it was a single subexpr, then just - // set the head node to the current node. For the others, we'll build - // the tree off the second child as we move across. - // - ContentSpecNode* headNode = 0; - ContentSpecNode::NodeTypes curType; - if (opCh == chComma) - { - curType = ContentSpecNode::Sequence; - headNode = new ContentSpecNode(curType, curNode, 0); - curNode = headNode; - } - else if (opCh == chPipe) - { - curType = ContentSpecNode::Choice; - headNode = new ContentSpecNode(curType, curNode, 0); - curNode = headNode; - } - else - { - headNode = curNode; - fReaderMgr->getNextChar(); - } - - // - // If it was a sequence or choice, we just loop until we get to the - // end of our section, adding each new leaf or sub expression to the - // right child of the current node, and making that new node the current - // node. - // - if ((opCh == chComma) || (opCh == chPipe)) - { - ContentSpecNode* lastNode = 0; - while (true) - { - // - // The next thing must either be another | or , character followed - // by another leaf or subexpression, or a closing parenthesis, or a - // PE ref. - // - if (fReaderMgr->lookingAtChar(chPercent)) - { - checkForPERef(false, false, true); - } - else if (fReaderMgr->skippedSpace()) - { - // Just skip whitespace - fReaderMgr->skipPastSpaces(); - } - else if (fReaderMgr->skippedChar(chCloseParen)) - { - // - // We've hit the end of this section, so break out. But, we - // need to see if we left a partial sequence of choice node - // without a second node. If so, we have to undo that and - // put its left child into the right node of the previous - // node. - // - if ((curNode->getType() == ContentSpecNode::Choice) - || (curNode->getType() == ContentSpecNode::Sequence)) - { - if (!curNode->getSecond()) - { - ContentSpecNode* saveFirst = curNode->orphanFirst(); - lastNode->setSecond(saveFirst); - curNode = lastNode; - } - } - break; - } - else if (fReaderMgr->skippedChar(opCh)) - { - // Check for a PE ref here, but don't require spaces - checkForPERef(false, false, true); - - if (fReaderMgr->skippedChar(chOpenParen)) - { - curReader = fReaderMgr->getCurrentReaderNum(); - - // Recurse to handle this new guy - ContentSpecNode* subNode = scanChildren(elemDecl, bufToUse); - - // If it failed, we are done, clean up here and return failure - if (!subNode) - { - delete headNode; - return 0; - } - - if (curReader != fReaderMgr->getCurrentReaderNum() && fScanner->getDoValidation()) - fScanner->getValidator()->emitError(XMLValid::PartialMarkupInPE); - - // Else patch it in and make it the new current - ContentSpecNode* newCur = new ContentSpecNode - ( - curType - , subNode - , 0 - ); - curNode->setSecond(newCur); - lastNode = curNode; - curNode = newCur; - } - else - { - // - // Got to be a leaf node, so get a name. If we cannot get - // one, then clean up and get outa here. - // - if (!fReaderMgr->getName(bufToUse)) - { - delete headNode; - fScanner->emitError(XMLErrs::ExpectedElementName); - return 0; - } - - // - // Create a leaf node for it. If we can find the element - // id for this element, then use it. Else, we have to - // fault in an element decl, marked as created because - // of being in a content model. - // - XMLElementDecl* decl = fDTDGrammar->getElemDecl(fEmptyNamespaceId, 0, bufToUse.getRawBuffer(), Grammar::TOP_LEVEL_SCOPE); - if (!decl) - { - decl = new DTDElementDecl(bufToUse.getRawBuffer(), fEmptyNamespaceId); - decl->setCreateReason(XMLElementDecl::InContentModel); - decl->setExternalElemDeclaration(isReadingExternalEntity()); - fDTDGrammar->putElemDecl(decl); - } - - ContentSpecNode* tmpLeaf = new ContentSpecNode(decl->getElementName()); - - // Check for a repetition character after the leaf - const XMLCh repCh = fReaderMgr->peekNextChar(); - ContentSpecNode* tmpLeaf2 = makeRepNode(repCh, tmpLeaf); - if (tmpLeaf != tmpLeaf2) - fReaderMgr->getNextChar(); - - // - // Create a new sequence or choice node, with the leaf - // (or rep surrounding it) we just got as its first node. - // Make the new node the second node of the current node, - // and then make it the current node. - // - ContentSpecNode* newCur = new ContentSpecNode - ( - curType - , tmpLeaf2 - , 0 - ); - curNode->setSecond(newCur); - lastNode = curNode; - curNode = newCur; - } - } - else - { - // Cannot be valid - if (opCh == chComma) - { - fScanner->emitError(XMLErrs::ExpectedChoiceOrCloseParen); - } - else - { - fScanner->emitError - ( - XMLErrs::ExpectedSeqOrCloseParen - , elemDecl.getFullName() - ); - } - delete headNode; - return 0; - } - } - } - - // - // We saw the terminating parenthesis so lets check for any repetition - // character, and create a node for that, making the head node the child - // of it. - // - XMLCh repCh = fReaderMgr->peekNextChar(); - ContentSpecNode* retNode = makeRepNode(repCh, headNode); - if (retNode != headNode) - fReaderMgr->getNextChar(); - - return retNode; -} - - -// -// We get here after the '<!--' part of the comment. We scan past the -// terminating '-->' It will calls the appropriate handler with the comment -// text, if one is provided. A comment can be in either the document or -// the DTD, so the fInDocument flag is used to know which handler to send -// it to. -// -void DTDScanner::scanComment() -{ - enum States - { - InText - , OneDash - , TwoDashes - }; - - // Get a buffer for this - XMLBufBid bbComment(fBufMgr); - - // - // Get the comment text into a temp buffer. Be sure to use temp buffer - // two here, since its to be used for stuff that is potentially longer - // than just a name. - // - bool gotLeadingSurrogate = false; - States curState = InText; - while (true) - { - // Get the next character - const XMLCh nextCh = fReaderMgr->getNextChar(); - - // Watch for an end of file - if (!nextCh) - { - fScanner->emitError(XMLErrs::UnterminatedComment); - ThrowXML(UnexpectedEOFException, XMLExcepts::Gen_UnexpectedEOF); - } - - // Check for correct surrogate pairs - if ((nextCh >= 0xD800) && (nextCh <= 0xDBFF)) - { - if (gotLeadingSurrogate) - fScanner->emitError(XMLErrs::Expected2ndSurrogateChar); - else - gotLeadingSurrogate = true; - } - else - { - if (gotLeadingSurrogate) - { - if ((nextCh < 0xDC00) || (nextCh > 0xDFFF)) - fScanner->emitError(XMLErrs::Expected2ndSurrogateChar); - } - // Its got to at least be a valid XML character - else if (!XMLReader::isXMLChar(nextCh)) { - - XMLCh tmpBuf[9]; - XMLString::binToText - ( - nextCh - , tmpBuf - , 8 - , 16 - ); - fScanner->emitError(XMLErrs::InvalidCharacter, tmpBuf); - } - - gotLeadingSurrogate = false; - } - - if (curState == InText) - { - // If its a dash, go to OneDash state. Otherwise take as text - if (nextCh == chDash) - curState = OneDash; - else - bbComment.append(nextCh); - } - else if (curState == OneDash) - { - // - // If its another dash, then we change to the two dashes states. - // Otherwise, we have to put in the deficit dash and the new - // character and go back to InText. - // - if (nextCh == chDash) - { - curState = TwoDashes; - } - else - { - bbComment.append(chDash); - bbComment.append(nextCh); - curState = InText; - } - } - else if (curState == TwoDashes) - { - // The next character must be the closing bracket - if (nextCh != chCloseAngle) - { - fScanner->emitError(XMLErrs::IllegalSequenceInComment); - fReaderMgr->skipPastChar(chCloseAngle); - return; - } - break; - } - } - - // If there is a doc type handler, then pass on the comment stuff - if (fDocTypeHandler) - fDocTypeHandler->doctypeComment(bbComment.getRawBuffer()); -} - - -bool DTDScanner::scanContentSpec(DTDElementDecl& toFill) -{ - // - // Check for for a couple of the predefined content type strings. If - // its not one of these, its got to be a parenthesized reg ex type - // expression. - // - if (fReaderMgr->skippedString(XMLUni::fgEmptyString)) - { - toFill.setModelType(DTDElementDecl::Empty); - return true; - } - - if (fReaderMgr->skippedString(XMLUni::fgAnyString)) - { - toFill.setModelType(DTDElementDecl::Any); - return true; - } - - // Its got to be a parenthesized regular expression - if (!fReaderMgr->skippedChar(chOpenParen)) - { - fScanner->emitError - ( - XMLErrs::ExpectedContentSpecExpr - , toFill.getFullName() - ); - return false; - } - - // Get the current reader id, so we can test for partial markup - const unsigned int curReader = fReaderMgr->getCurrentReaderNum(); - - // We could have a PE ref here, but don't require space - checkForPERef(false, false, true); - - // - // Now we look for a PCDATA string. If its PCDATA, then it must be a - // MIXED model. Otherwise, it must be a regular list of children in - // a regular expression perhaps. - // - bool status; - if (fReaderMgr->skippedString(XMLUni::fgPCDATAString)) - { - // Set the model to mixed - toFill.setModelType(DTDElementDecl::Mixed_Simple); - status = scanMixed(toFill); - - // - // If we are validating we have to check that there are no multiple - // uses of any child elements. - // - if (fScanner->getDoValidation()) - { - if (((const MixedContentModel*)toFill.getContentModel())->hasDups()) - fScanner->getValidator()->emitError(XMLValid::RepElemInMixed); - } - } - else - { - // - // We have to do a recursive scan of the content model. Create a - // buffer for it to use, for efficiency. It returns the top ofthe - // content spec node tree, which we set if successful. - // - toFill.setModelType(DTDElementDecl::Children); - XMLBufBid bbTmp(fBufMgr); - ContentSpecNode* resNode = scanChildren(toFill, bbTmp.getBuffer()); - status = (resNode != 0); - if (status) - toFill.setContentSpec(resNode); - } - - // Make sure we are on the same reader as where we started - if (curReader != fReaderMgr->getCurrentReaderNum() && fScanner->getDoValidation()) - fScanner->getValidator()->emitError(XMLValid::PartialMarkupInPE); - - return status; -} - - -void DTDScanner::scanDefaultDecl(DTDAttDef& toFill) -{ - if (fReaderMgr->skippedString(XMLUni::fgRequiredString)) - { - toFill.setDefaultType(XMLAttDef::Required); - return; - } - - if (fReaderMgr->skippedString(XMLUni::fgImpliedString)) - { - toFill.setDefaultType(XMLAttDef::Implied); - return; - } - - if (fReaderMgr->skippedString(XMLUni::fgFixedString)) - { - // - // There must be space before the fixed value. If there is not, then - // emit an error but keep going. - // - if (!fReaderMgr->skippedSpace()) - fScanner->emitError(XMLErrs::ExpectedWhitespace); - else - fReaderMgr->skipPastSpaces(); - toFill.setDefaultType(XMLAttDef::Fixed); - } - else - { - toFill.setDefaultType(XMLAttDef::Default); - } - - // - // If we got here, its fixed or default, so we need to get a value. - // If we don't, then emit an error but just set the default value to - // an empty string and try to keep going. - // - XMLBufBid bbValue(fBufMgr); - if (!scanAttValue(toFill.getFullName(), bbValue.getBuffer(), toFill.getType())) - fScanner->emitError(XMLErrs::ExpectedDefAttrDecl); - - toFill.setValue(bbValue.getRawBuffer()); -} - - -// -// This method handles the high level logic of scanning the DOCType -// declaration. This kicks off both the scanning of the internal subset and -// the scanning of the external subset, if any. -// -// When we get here the '<!DOCTYPE' part has already been scanned, which is -// what told us that we had a doc type decl to parse. -// - -void DTDScanner::scanDocTypeDecl(const bool reuseGrammar) -{ - if (fDocTypeHandler) - fDocTypeHandler->resetDocType(); - - // There must be some space after DOCTYPE - if (!fReaderMgr->skipPastSpaces()) - { - fScanner->emitError(XMLErrs::ExpectedWhitespace); - - // Just skip the Doctype declaration and return - fReaderMgr->skipPastChar(chCloseAngle); - return; - } - - // Get a buffer for the root element - XMLBufBid bbRootName(fBufMgr); - - // - // Get a name from the input, which should be the name of the root - // element of the upcoming content. - // - fReaderMgr->getName(bbRootName.getBuffer()); - if (bbRootName.isEmpty()) - { - fScanner->emitError(XMLErrs::NoRootElemInDOCTYPE); - fReaderMgr->skipPastChar(chCloseAngle); - return; - } - - // - // Store the root element name for later check - // - fScanner->setRootElemName(bbRootName.getRawBuffer()); - - // - // This element obviously is not going to exist in the element decl - // pool yet, but we need to call docTypeDecl. So force it into - // the element decl pool, marked as being there because it was in - // the DOCTYPE. Later, when its declared, the status will be updated. - // - // Only do this if we are not reusing the validator! If we are reusing, - // then look it up instead. It has to exist! - // - DTDElementDecl* rootDecl; - Janitor<DTDElementDecl> janSrc(0); - - if (reuseGrammar) - { - Grammar* fGrammar = fDTDGrammar; - if (fGrammar->getGrammarType() == Grammar::DTDGrammarType) { - rootDecl = (DTDElementDecl*) fDTDGrammar->getElemDecl(fEmptyNamespaceId, 0, bbRootName.getRawBuffer(), Grammar::TOP_LEVEL_SCOPE); - if (rootDecl) - fDTDGrammar->setRootElemId(rootDecl->getId()); - else { - rootDecl = new DTDElementDecl(bbRootName.getRawBuffer(), fEmptyNamespaceId); - rootDecl->setCreateReason(DTDElementDecl::AsRootElem); - rootDecl->setExternalElemDeclaration(isReadingExternalEntity()); - fDTDGrammar->setRootElemId(fDTDGrammar->putElemDecl(rootDecl)); - } - } - else { - rootDecl = new DTDElementDecl(bbRootName.getRawBuffer(), fEmptyNamespaceId); - rootDecl->setCreateReason(DTDElementDecl::AsRootElem); - rootDecl->setExternalElemDeclaration(isReadingExternalEntity()); - janSrc.reset(rootDecl); - } - } - else - { - rootDecl = new DTDElementDecl(bbRootName.getRawBuffer(), fEmptyNamespaceId); - rootDecl->setCreateReason(DTDElementDecl::AsRootElem); - rootDecl->setExternalElemDeclaration(isReadingExternalEntity()); - fDTDGrammar->setRootElemId(fDTDGrammar->putElemDecl(rootDecl)); - } - - // Skip any spaces after the name - fReaderMgr->skipPastSpaces(); - - // - // And now if we are looking at a >, then we are done. It is not - // required to have an internal or external subset, though why you - // would not escapes me. - // - if (fReaderMgr->skippedChar(chCloseAngle)) { - // - // If we have a doc type handler and advanced callbacks are enabled, - // call the doctype event. - // - if (fDocTypeHandler) - fDocTypeHandler->doctypeDecl(*rootDecl, 0, 0, false); - return; - } - - // either internal/external subset - if(!reuseGrammar) { - if (fScanner->getValidationScheme() == XMLScanner::Val_Auto) - fScanner->setDoValidation(true, false); - } - - - bool hasIntSubset = false; - bool hasExtSubset = false; - XMLCh* sysId = 0; - XMLCh* pubId = 0; - - // - // If the next character is '[' then we have no external subset cause - // there is no system id, just the opening character of the internal - // subset. Else, has to be an id. - // - // Just look at the next char, don't eat it. - if (fReaderMgr->peekNextChar() == chOpenSquare) - { - hasIntSubset = true; - } - else - { - // Indicate we have an external subset - hasExtSubset = true; - fScanner->setHasNoDTD(false); - - // Get buffers for the ids - XMLBufBid bbPubId(fBufMgr); - XMLBufBid bbSysId(fBufMgr); - - // Get the external subset id - if (!scanId(bbPubId.getBuffer(), bbSysId.getBuffer(), IDType_External)) - { - fReaderMgr->skipPastChar(chCloseAngle); - return; - } - - // Get copies of the ids we got - pubId = XMLString::replicate(bbPubId.getRawBuffer()); - sysId = XMLString::replicate(bbSysId.getRawBuffer()); - - // Skip spaces and check again for the opening of an internal subset - fReaderMgr->skipPastSpaces(); - - // Just look at the next char, don't eat it. - if (fReaderMgr->peekNextChar() == chOpenSquare) { - hasIntSubset = true; - } - } - - // Insure that the ids get cleaned up, if they got allocated - ArrayJanitor<XMLCh> janSysId(sysId); - ArrayJanitor<XMLCh> janPubId(pubId); - - // - // If we have a doc type handler and advanced callbacks are enabled, - // call the doctype event. - // - if (fDocTypeHandler) - fDocTypeHandler->doctypeDecl(*rootDecl, pubId, sysId, hasIntSubset); - - // - // Ok, if we had an internal subset, we are just past the [ character - // and need to parse that first. - // - if (hasIntSubset) - { - // Eat the opening square bracket - fReaderMgr->getNextChar(); - - // We can't have any internal subset if we are reusing the validator - if (reuseGrammar) - ThrowXML(RuntimeException, XMLExcepts::Val_CantHaveIntSS); - - // Indicate we are in the internal subset now - FlagJanitor<bool> janContentFlag(&fInternalSubset, true); - - // - // And try to scan the internal subset. If we fail, try to recover - // by skipping forward tot he close angle and returning. - // - if (!scanInternalSubset()) - { - fReaderMgr->skipPastChar(chCloseAngle); - return; - } - - // - // Do a sanity check that some expanded PE did not propogate out of - // the doctype. This could happen if it was terminated early by bad - // syntax. - // - if (fReaderMgr->getReaderDepth() > 1) - { - fScanner->emitError(XMLErrs::PEPropogated); - - // Ask the reader manager to pop back down to the main level - fReaderMgr->cleanStackBackTo(1); - } - - fReaderMgr->skipPastSpaces(); - } - - // And that should leave us at the closing > of the DOCTYPE line - if (!fReaderMgr->skippedChar(chCloseAngle)) - { - // - // Do a special check for the common scenario of an extra ] char at - // the end. This is easy to recover from. - // - if (fReaderMgr->skippedChar(chCloseSquare) - && fReaderMgr->skippedChar(chCloseAngle)) - { - fScanner->emitError(XMLErrs::ExtraCloseSquare); - } - else - { - fScanner->emitError(XMLErrs::UnterminatedDOCTYPE); - fReaderMgr->skipPastChar(chCloseAngle); - } - } - - // - // If we had an external subset, then we need to deal with that one - // next. If we are reusing the validator, then don't scan it. - // - if (hasExtSubset && !reuseGrammar) - { - // Indicate we are in the external subset now - FlagJanitor<bool> janContentFlag(&fInternalSubset, false); - - // And now create a reader to read this entity - InputSource* srcUsed; - XMLReader* reader = fReaderMgr->createReader - ( - sysId - , pubId - , false - , XMLReader::RefFrom_NonLiteral - , XMLReader::Type_General - , XMLReader::Source_External - , srcUsed - ); - - // Put a janitor on the input source - Janitor<InputSource> janSrc(srcUsed); - - // - // If it failed then throw an exception - // - if (!reader) - ThrowXML1(RuntimeException, XMLExcepts::Gen_CouldNotOpenDTD, srcUsed->getSystemId()); - - // - // In order to make the processing work consistently, we have to - // make this look like an external entity. So create an entity - // decl and fill it in and push it with the reader, as happens - // with an external entity. Put a janitor on it to insure it gets - // cleaned up. The reader manager does not adopt them. - // - const XMLCh gDTDStr[] = { chLatin_D, chLatin_T, chLatin_D , chNull }; - DTDEntityDecl* declDTD = new DTDEntityDecl(gDTDStr); - declDTD->setSystemId(sysId); - Janitor<DTDEntityDecl> janDecl(declDTD); - - // Mark this one as a throw at end - reader->setThrowAtEnd(true); - - // And push it onto the stack, with its pseudo name - fReaderMgr->pushReader(reader, declDTD); - - // Tell it its not in an include section - scanExtSubsetDecl(false); - } -} - - -// -// This is called after seeing '<!ELEMENT' which indicates that an element -// markup is starting. This guy scans the rest of it and adds it to the -// element decl pool if it has not already been declared. -// -void DTDScanner::scanElementDecl() -{ - // - // Space is legal (required actually) here so check for a PE ref. If - // we don't get our whitespace, then issue and error, but try to keep - // going. - // - if (!checkForPERef(true, false, true)) - fScanner->emitError(XMLErrs::ExpectedWhitespace); - - // Get a buffer for the element name and scan in the name - XMLBufBid bbName(fBufMgr); - if (!fReaderMgr->getName(bbName.getBuffer())) - { - fScanner->emitError(XMLErrs::ExpectedElementName); - fReaderMgr->skipPastChar(chCloseAngle); - return; - } - - // Look this guy up in the element decl pool - DTDElementDecl* decl = (DTDElementDecl*) fDTDGrammar->getElemDecl(fEmptyNamespaceId, 0, bbName.getRawBuffer(), Grammar::TOP_LEVEL_SCOPE); - - // - // If it does not exist, then we need to create it. If it does and - // its marked as declared, then that's an error, but we still need to - // scan over the content model so use the dummy declaration that the - // parsing code can fill in. - // - if (decl) - { - if (decl->isDeclared()) - { - if (fScanner->getDoValidation()) - fScanner->getValidator()->emitError(XMLValid::ElementAlreadyExists, bbName.getRawBuffer()); - - if (!fDumElemDecl) - fDumElemDecl = new DTDElementDecl(bbName.getRawBuffer(), fEmptyNamespaceId); - else - fDumElemDecl->setElementName(bbName.getRawBuffer(),fEmptyNamespaceId); - } - } - else - { - // - // Create the new empty declaration to fill in and put it into - // the decl pool. - // - decl = new DTDElementDecl(bbName.getRawBuffer(), fEmptyNamespaceId); - fDTDGrammar->putElemDecl(decl); - } - - // Set a flag for whether we will ignore this one - const bool isIgnored = (decl == fDumElemDecl); - - // Mark this one if being externally declared - decl->setExternalElemDeclaration(isReadingExternalEntity()); - - // Mark this one as being declared - decl->setCreateReason(XMLElementDecl::Declared); - - // Another check for a PE ref, with at least required whitespace - if (!checkForPERef(true, false, true)) - fScanner->emitError(XMLErrs::ExpectedWhitespace); - - // And now scan the content model for this guy. - if (!scanContentSpec(*decl)) - { - fReaderMgr->skipPastChar(chCloseAngle); - return; - } - - // Another check for a PE ref, but we don't require whitespace here - checkForPERef(false, false, true); - - // And we should have the ending angle bracket - if (!fReaderMgr->skippedChar(chCloseAngle)) - { - fScanner->emitError(XMLErrs::UnterminatedElementDecl, bbName.getRawBuffer()); - fReaderMgr->skipPastChar(chCloseAngle); - } - - // - // If we have a DTD handler tell it about the new element decl. We - // tell it if its one that can be ignored, cause its an override of a - // previously existing decl. If it is being ignored, only call back - // if advanced callbacks are enabled. - // - if (fDocTypeHandler) - fDocTypeHandler->elementDecl(*decl, isIgnored); -} - - -// -// This method will process a general or parameter entity reference. The -// entity name and entity text will be stored in the entity pool. The value -// of the entity will be scanned for any other parameter entity or char -// references which will be expanded. So the stored value can only have -// general entity references when done. -// -void DTDScanner::scanEntityDecl() -{ - // - // Space is required here, but we cannot check for a PE Ref since - // there could be a legal (no-ref) percent sign here. Since any - // entity that ended here would be illegal, we just skip spaces - // and then check for a percent. - // - if (!fReaderMgr->lookingAtSpace()) - fScanner->emitError(XMLErrs::ExpectedWhitespace); - else - fReaderMgr->skipPastSpaces(); - const bool isPEDecl = fReaderMgr->skippedChar(chPercent); - - // - // If a PE decl, then eat the percent and check for spaces or a - // PE ref on the other side of it. At least spaces are required. - // - if (isPEDecl) - { - if (!checkForPERef(true, false, true)) - fScanner->emitError(XMLErrs::ExpectedWhitespace); - } - - // - // Now lets get a name, which should be the name of the entity. We - // have to get a buffer for this. - // - XMLBufBid bbName(fBufMgr); - if (!fReaderMgr->getName(bbName.getBuffer())) - { - fScanner->emitError(XMLErrs::ExpectedPEName); - fReaderMgr->skipPastChar(chCloseAngle); - return; - } - - // If namespaces are enabled, then no colons allowed - if (fScanner->getDoNamespaces()) - { - if (XMLString::indexOf(bbName.getRawBuffer(), chColon) != -1) - fScanner->emitError(XMLErrs::ColonNotLegalWithNS); - } - - // - // See if this entity already exists. If so, then the existing one - // takes precendence. So we use the local dummy decl to parse into - // and just ignore the results. - // - DTDEntityDecl* entityDecl; - if (isPEDecl) - entityDecl = fPEntityDeclPool->getByKey(bbName.getRawBuffer()); - else - entityDecl = fEntityDeclPool->getByKey(bbName.getRawBuffer()); - - if (entityDecl) - { - if (!fDumEntityDecl) - fDumEntityDecl = new DTDEntityDecl; - fDumEntityDecl->setName(bbName.getRawBuffer()); - entityDecl = fDumEntityDecl; - } - else - { - // Its not in existence already, then create an entity decl for it - entityDecl = new DTDEntityDecl(bbName.getRawBuffer()); - - // - // Set the declaration location. The parameter indicates whether its - // declared in the content/internal subset, so we know whether or not - // its in the external subset. - // - entityDecl->setDeclaredInIntSubset(fInternalSubset); - - // Add it to the appropriate entity decl pool - if (isPEDecl) - fPEntityDeclPool->put(entityDecl); - else - fEntityDeclPool->put(entityDecl); - } - - // Set a flag that indicates whether we are ignoring this one - const bool isIgnored = (entityDecl == fDumEntityDecl); - - // Set the PE flag on it - entityDecl->setIsParameter(isPEDecl); - - // - // Space is legal (required actually) here so check for a PE ref. If - // we don't get our whitespace, then issue an error, but try to keep - // going. - // - if (!checkForPERef(true, false, true)) - fScanner->emitError(XMLErrs::ExpectedWhitespace); - - // save the hasNoDTD status for Entity Constraint Checking - bool hasNoDTD = fScanner->getHasNoDTD(); - if (hasNoDTD && isPEDecl) - fScanner->setHasNoDTD(false); - - // According to the type call the value scanning method - if (!scanEntityDef(*entityDecl, isPEDecl)) - { - fReaderMgr->skipPastChar(chCloseAngle); - fScanner->setHasNoDTD(true); - fScanner->emitError(XMLErrs::ExpectedEntityValue); - return; - } - if (hasNoDTD) - fScanner->setHasNoDTD(true); - - // Space is legal (but not required) here so check for a PE ref - checkForPERef(false, false, true); - - // And then we have to have the closing angle bracket - if (!fReaderMgr->skippedChar(chCloseAngle)) - { - fScanner->emitError(XMLErrs::UnterminatedEntityDecl, entityDecl->getName()); - fReaderMgr->skipPastChar(chCloseAngle); - } - - // - // If we have a doc type handler, then call it. But only call it for - // ignored elements if advanced callbacks are enabled. - // - if (fDocTypeHandler) - fDocTypeHandler->entityDecl(*entityDecl, isPEDecl, isIgnored); -} - - -// -// This method will scan a general/character entity ref. It will either -// expand a char ref and return the value directly, or it will expand -// a general entity and a reader for it onto the reader stack. -// -// The return value indicates whether the value was returned directly or -// pushed as a reader or it failed. -// -// The escaped flag tells the caller whether the returnd parameter resulted -// from a character reference, which escapes the character in some cases. It -// only makes any difference if the return indicates the value was returned -// directly. -// -// NOTE: This is only called when scanning attribute values, so we always -// expand general entities. -// -DTDScanner::EntityExpRes -DTDScanner::scanEntityRef(XMLCh& firstCh, XMLCh& secondCh, bool& escaped) -{ - // Assume no escape and no second char - escaped = false; - secondCh = 0; - - // We have to insure its all done in a single entity - const unsigned int curReader = fReaderMgr->getCurrentReaderNum(); - - // - // If the next char is a pound, then its a character reference and we - // need to expand it always. - // - if (fReaderMgr->skippedChar(chPound)) - { - // - // Its a character reference, so scan it and get back the numeric - // value it represents. If it fails, just return immediately. - // - if (!scanCharRef(firstCh, secondCh)) - return EntityExp_Failed; - - if (curReader != fReaderMgr->getCurrentReaderNum()) - fScanner->emitError(XMLErrs::PartialMarkupInEntity); - - // Its now escaped since it was a char ref - escaped = true; - return EntityExp_Returned; - } - - // Get the name of the general entity - XMLBufBid bbName(fBufMgr); - if (!fReaderMgr->getName(bbName.getBuffer())) - { - fScanner->emitError(XMLErrs::ExpectedEntityRefName); - return EntityExp_Failed; - } - - // - // Next char must be a semi-colon. But if its not, just emit - // an error and try to continue. - // - if (!fReaderMgr->skippedChar(chSemiColon)) - fScanner->emitError(XMLErrs::UnterminatedEntityRef, bbName.getRawBuffer()); - - // Make sure it was all in one entity reader - if (curReader != fReaderMgr->getCurrentReaderNum()) - fScanner->emitError(XMLErrs::PartialMarkupInEntity); - - // Look it up the name the general entity pool - XMLEntityDecl* decl = fEntityDeclPool->getByKey(bbName.getRawBuffer()); - - // If it does not exist, then obviously an error - if (!decl) - { - // XML 1.0 Section 4.1 - if (fScanner->getStandalone() || fScanner->getHasNoDTD()) { - fScanner->emitError(XMLErrs::EntityNotFound, bbName.getRawBuffer()); - } - else { - if (fScanner->getDoValidation()) - fScanner->getValidator()->emitError(XMLValid::VC_EntityNotFound, bbName.getRawBuffer()); - } - - return EntityExp_Failed; - } - - - // - // If we are a standalone document, then it has to have been declared - // in the internal subset. Keep going though. - // - if (fScanner->getDoValidation() && fScanner->getStandalone() && !decl->getDeclaredInIntSubset()) - fScanner->getValidator()->emitError(XMLValid::IllegalRefInStandalone, bbName.getRawBuffer()); - - // - // If its a special char reference, then its escaped and we can return - // it directly. - // - if (decl->getIsSpecialChar()) - { - firstCh = decl->getValue()[0]; - escaped = true; - return EntityExp_Returned; - } - - if (decl->isExternal()) - { - // If its unparsed, then its not valid here - // XML 1.0 Section 4.4.4 the appearance of a reference to an unparsed entity is forbidden. - if (decl->isUnparsed()) - { - fScanner->emitError(XMLErrs::NoUnparsedEntityRefs, bbName.getRawBuffer()); - return EntityExp_Failed; - } - - // We are in an attribute value, so not valid. - // XML 1.0 Section 4.4.4 a reference to an external entity in an attribute value is forbidden. - fScanner->emitError(XMLErrs::NoExtRefsInAttValue); - - // And now create a reader to read this entity - InputSource* srcUsed; - XMLReader* reader = fReaderMgr->createReader - ( - decl->getSystemId() - , decl->getPublicId() - , false - , XMLReader::RefFrom_NonLiteral - , XMLReader::Type_General - , XMLReader::Source_External - , srcUsed - ); - - // Put a janitor on the source so it gets cleaned up on exit - Janitor<InputSource> janSrc(srcUsed); - - // - // If the creation failed then throw an exception - // - if (!reader) - ThrowXML1(RuntimeException, XMLExcepts::Gen_CouldNotOpenExtEntity, srcUsed->getSystemId()); - - // - // Push the reader. If its a recursive expansion, then emit an error - // and return an failure. - // - if (!fReaderMgr->pushReader(reader, decl)) - { - fScanner->emitError(XMLErrs::RecursiveEntity, decl->getName()); - return EntityExp_Failed; - } - - // If it starts with the XML string, then parse a text decl - if (fScanner->checkXMLDecl(true)) - scanTextDecl(); - } - else - { - // - // Create a reader over a memory stream over the entity value - // We force it to assume UTF-16 by passing in an encoding - // string. This way it won't both trying to predecode the - // first line, looking for an XML/TextDecl. - // - XMLReader* valueReader = fReaderMgr->createIntEntReader - ( - decl->getName() - , XMLReader::RefFrom_NonLiteral - , XMLReader::Type_General - , decl->getValue() - , decl->getValueLen() - , false - ); - - // - // Trt to push the entity reader onto the reader manager stack, - // where it will become the subsequent input. If it fails, that - // means the entity is recursive, so issue an error. The reader - // will have just been discarded, but we just keep going. - // - if (!fReaderMgr->pushReader(valueReader, decl)) - fScanner->emitError(XMLErrs::RecursiveEntity, decl->getName()); - } - - return EntityExp_Pushed; -} - - -// -// This method will scan a quoted literal of an entity value. It has to -// deal with replacement of PE references; however, since this is a DTD -// scanner, all such entity literals are in entity decls and therefore -// general entities are not expanded. -// -bool DTDScanner::scanEntityLiteral(XMLBuffer& toFill, const bool isPE) -{ - toFill.reset(); - - // Get the next char which must be a single or double quote - XMLCh quoteCh; - if (!fReaderMgr->skipIfQuote(quoteCh)) - return false; - - // Get a buffer for pulling in entity names when we see GE refs - XMLBufBid bbName(fBufMgr); - XMLBuffer& nameBuf = bbName.getBuffer(); - - // Remember the current reader - const unsigned int orgReader = fReaderMgr->getCurrentReaderNum(); - - // - // Loop until we see the ending quote character, handling any references - // in the process. - // - XMLCh nextCh; - XMLCh secondCh = 0; - bool gotLeadingSurrogate = false; - while (true) - { - // Get the second char if we have one, else get another - if (secondCh) - { - nextCh = secondCh; - secondCh = 0; - } - else - { - nextCh = fReaderMgr->getNextChar(); - } - - // - // Watch specifically for EOF and issue a more meaningful error - // if that occurs (since an unterminated quoted char can cause - // this easily.) - // - if (!nextCh) - { - fScanner->emitError(XMLErrs::UnterminatedEntityLiteral); - ThrowXML(UnexpectedEOFException, XMLExcepts::Gen_UnexpectedEOF); - } - - // - // Break out on our terminating quote char when we are back in the - // same reader. Otherwise, we might trigger on a nested quote char - // in an expanded entity. - // - if ((nextCh == quoteCh) - && (fReaderMgr->getCurrentReaderNum() == orgReader)) - { - break; - } - - if (nextCh == chPercent) - { - // - // Put the PE's value on the reader stack and then jump back - // to the top to start processing it. The parameter indicates - // that it should not scan the reference's content as an external - // subset. - // - expandPERef(false, true, true); - continue; - } - - // - // Ok, now that all the other special stuff is checked, we can - // look for a general entity. In here, we cannot have a naked & - // and will only expand numerical char refs or the intrinsic char - // refs. Others will be left alone. - // - if (nextCh == chAmpersand) - { - // - // Here, we only expand numeric char refs, but not any general - // entities. However, the stupid XML spec requires that we check - // and make sure it does refer to a general entity if its not - // a char ref (i.e. no naked '&' chars.) - // - if (fReaderMgr->skippedChar(chPound)) - { - // If it failed, then just jump back to the top and try to pick up - if (!scanCharRef(nextCh, secondCh)) - { - gotLeadingSurrogate = false; - continue; - } - } - else - { - if (!fReaderMgr->getName(nameBuf)) - { - fScanner->emitError(XMLErrs::ExpectedEntityRefName); - } - else - { - // - // Since we are not expanding any of this, we have to - // put the amp and name into the target buffer as data. - // - toFill.append(chAmpersand); - toFill.append(nameBuf.getRawBuffer()); - - // Make sure we skipped a trailing semicolon - if (!fReaderMgr->skippedChar(chSemiColon)) - { - fScanner->emitError - ( - XMLErrs::UnterminatedEntityRef - , nameBuf.getRawBuffer() - ); - } - - // And make the new character the semicolon - nextCh = chSemiColon; - } - - // Either way here we reset the surrogate flag - gotLeadingSurrogate = false; - } - } - - if ((nextCh >= 0xD800) && (nextCh <= 0xDBFF)) - { - if (gotLeadingSurrogate) - fScanner->emitError(XMLErrs::Expected2ndSurrogateChar); - else - gotLeadingSurrogate = true; - } - else - { - if (gotLeadingSurrogate) - { - if ((nextCh < 0xDC00) || (nextCh > 0xDFFF)) - fScanner->emitError(XMLErrs::Expected2ndSurrogateChar); - } - else if (!XMLReader::isXMLChar(nextCh)) - { - XMLCh tmpBuf[9]; - XMLString::binToText - ( - nextCh - , tmpBuf - , 8 - , 16 - ); - fScanner->emitError(XMLErrs::InvalidCharacter, tmpBuf); - fReaderMgr->skipPastChar(quoteCh); - return false; - } - gotLeadingSurrogate = false; - } - - // Looks ok, so add it to the literal - toFill.append(nextCh); - } - - // - // If we got here and did not get back to the original reader level, - // then we propogated some entity out of the literal, so issue an - // error, but don't fail. - // - if (fReaderMgr->getCurrentReaderNum() != orgReader && fScanner->getDoValidation()) - fScanner->getValidator()->emitError(XMLValid::PartialMarkupInPE); - - return true; -} - - -// -// This method is called after the entity name has been scanned, and any -// PE referenced following the name is handled. The passed decl will be -// filled in with the info scanned. -// -bool DTDScanner::scanEntityDef(DTDEntityDecl& decl, const bool isPEDecl) -{ - // Its got to be an entity literal - if (fReaderMgr->lookingAtChar(chSingleQuote) - || fReaderMgr->lookingAtChar(chDoubleQuote)) - { - // Get a buffer for the literal - XMLBufBid bbValue(fBufMgr); - - if (!scanEntityLiteral(bbValue.getBuffer(), isPEDecl)) - return false; - - // Set it on the entity decl - decl.setValue(bbValue.getRawBuffer()); - return true; - } - - // - // Its got to be an external entity, so there must be an external id. - // Get buffers for them and scan an external id into them. - // - XMLBufBid bbPubId(fBufMgr); - XMLBufBid bbSysId(fBufMgr); - if (!scanId(bbPubId.getBuffer(), bbSysId.getBuffer(), IDType_External)) - return false; - - // Fill in the id fields of the decl with the info we got - decl.setPublicId(bbPubId.getRawBuffer()); - decl.setSystemId(bbSysId.getRawBuffer()); - - // If its a PE decl, we are done - bool gotSpaces = checkForPERef(false, false, true); - if (isPEDecl) - { - // - // Check for a common error here. NDATA is not allowed for PEs - // so check for the NDATA string. If found give a nice meaningful - // error and continue parsing to eat the NDATA text. - // - if (gotSpaces) - { - if (fReaderMgr->skippedString(XMLUni::fgNDATAString)) - fScanner->emitError(XMLErrs::NDATANotValidForPE); - } - else - { - return true; - } - } - - // If looking at close angle now, we are done - if (fReaderMgr->lookingAtChar(chCloseAngle)) - return true; - - // Else we had to have seem the whitespace - if (!gotSpaces) - fScanner->emitError(XMLErrs::ExpectedWhitespace); - - // We now have to see a notation data string - if (!fReaderMgr->skippedString(XMLUni::fgNDATAString)) - fScanner->emitError(XMLErrs::ExpectedNDATA); - - // Space is required here, but try to go on if not - if (!checkForPERef(false, false, true)) - fScanner->emitError(XMLErrs::ExpectedWhitespace); - - // Get a name - XMLBufBid bbName(fBufMgr); - if (!fReaderMgr->getName(bbName.getBuffer())) - { - fScanner->emitError(XMLErrs::ExpectedNotationName); - return false; - } - - // Set the decl's notation name - decl.setNotationName(bbName.getRawBuffer()); - - return true; -} - - -// -// This method is called after an attribute decl name or a notation decl has -// been scanned and then an opening parenthesis was see, indicating the list -// of values. It scans the enumeration values and creates a single string -// which has a single space between each value. -// -// The terminating close paren ends this scan. -// -bool DTDScanner::scanEnumeration( const DTDAttDef& attDef - , XMLBuffer& toFill - , const bool notation) -{ - // Reset the passed buffer - toFill.reset(); - - // Check for PE ref but don't require space - checkForPERef(false, false, true); - - // If this is a notation, we need an opening paren - if (notation) - { - if (!fReaderMgr->skippedChar(chOpenParen)) - fScanner->emitError(XMLErrs::ExpectedOpenParen); - } - - // We need a local buffer to use as well - XMLBufBid bbTmp(fBufMgr); - - while (true) - { - // Space is allowed here for either type so check for PE ref - checkForPERef(false, false, true); - - // And then get either a name or a name token - bool success; - if (notation) - success = fReaderMgr->getName(bbTmp.getBuffer()); - else - success = fReaderMgr->getNameToken(bbTmp.getBuffer()); - - if (!success) - { - fScanner->emitError - ( - XMLErrs::ExpectedEnumValue - , attDef.getFullName() - ); - return false; - } - - // Append this value to the target value - toFill.append(bbTmp.getRawBuffer(), bbTmp.getLen()); - - // Space is allowed here for either type so check for PE ref - checkForPERef(false, false, true); - - // Check for the terminating paren - if (fReaderMgr->skippedChar(chCloseParen)) - break; - - // And append a space separator - toFill.append(chSpace); - - // Check for the pipe character separator - if (!fReaderMgr->skippedChar(chPipe)) - { - fScanner->emitError(XMLErrs::ExpectedEnumSepOrParen); - return false; - } - } - return true; -} - - -bool DTDScanner::scanEq() -{ - fReaderMgr->skipPastSpaces(); - if (fReaderMgr->skippedChar(chEqual)) - { - fReaderMgr->skipPastSpaces(); - return true; - } - return false; -} - - -// -// This method is called when an external entity reference is seen in the -// DTD or an external DTD subset is encountered, and their contents pushed -// onto the reader stack. This method will scan that contents. -// -void DTDScanner::scanExtSubsetDecl(const bool inIncludeSect) -{ - bool bAcceptDecl = !inIncludeSect; - - // Get a buffer for whitespace - XMLBufBid bbSpace(fBufMgr); - - // - // If we have a doc type handler and we are not being called recursively - // to handle an include section, tell it the ext subset starts - // - if (fDocTypeHandler && !inIncludeSect) - fDocTypeHandler->startExtSubset(); - - // - // We have to play a trick here if the current entity we are parsing - // is a PE. Because the spooling code will put out a whitespace before - // and after an expanded PE if its being scanned outside the context of - // a literal entity, this will confuse this external subset code. - // - // So, we see if that is what is happening and, if so, eat the single - // space, a check for the <?xml string. If we find it, we parse that - // markup right now and put the space back. - // - if (fReaderMgr->isScanningPERefOutOfLiteral()) - { - if (fReaderMgr->skippedSpace()) - { - if (fScanner->checkXMLDecl(true)) - { - scanTextDecl(); - bAcceptDecl = false; - - // <TBD> Figure out how to do this - // fReaderMgr->unGet(chSpace); - } - } - } - - // Get the current reader number - const unsigned int orgReader = fReaderMgr->getCurrentReaderNum(); - - // - // Loop until we hit the end of the external subset entity. Note that - // we use a double loop here in order to avoid the overhead of doing - // the exception setup/teardown work on every loop. - // - bool inMarkup = false; - bool inCharData = false; - while (true) - { - try - { - while (true) - { - const XMLCh nextCh = fReaderMgr->peekNextChar(); - - if (nextCh == chOpenAngle) - { - // Get the reader we started this on - const unsigned int orgReader = fReaderMgr->getCurrentReaderNum(); - - // - // Now scan the markup. Set the flag so that we will know that - // we were in markup if an end of entity exception occurs. - // - fReaderMgr->getNextChar(); - inMarkup = true; - scanMarkupDecl(bAcceptDecl); - inMarkup = false; - - // - // And see if we got back to the same level. If not, then its - // a partial markup error. - // - if (fReaderMgr->getCurrentReaderNum() != orgReader && fScanner->getDoValidation()) - fScanner->getValidator()->emitError(XMLValid::PartialMarkupInPE); - - } - else if (XMLReader::isWhitespace(nextCh)) - { - // - // If we have a doc type handler, and advanced callbacks are - // enabled, then gather up whitespace and call back. Otherwise - // just skip whitespaces. - // - if (fDocTypeHandler) - { - inCharData = true; - fReaderMgr->getSpaces(bbSpace.getBuffer()); - inCharData = false; - - fDocTypeHandler->doctypeWhitespace - ( - bbSpace.getRawBuffer() - , bbSpace.getLen() - ); - } - else - { - // - // If we hit an end of entity in the middle of white - // space, that's fine. We'll just come back in here - // again on the next round and skip some more. - // - fReaderMgr->skipPastSpaces(); - } - } - else if (nextCh == chPercent) - { - // - // Expand (and scan if external) the reference value. Tell - // it to throw an end of entity exception at the end of the - // entity. - // - fReaderMgr->getNextChar(); - expandPERef(true, false, false, true); - } - else if (inIncludeSect && (nextCh == chCloseSquare)) - { - // - // Its the end of a conditional include section. So scan it and - // decrement the include depth counter. - // - fReaderMgr->getNextChar(); - if (!fReaderMgr->skippedChar(chCloseSquare)) - { - fScanner->emitError(XMLErrs::ExpectedEndOfConditional); - fReaderMgr->skipPastChar(chCloseAngle); - } - else if (!fReaderMgr->skippedChar(chCloseAngle)) - { - fScanner->emitError(XMLErrs::ExpectedEndOfConditional); - fReaderMgr->skipPastChar(chCloseAngle); - } - return; - } - else - { - fReaderMgr->getNextChar(); - if (!XMLReader::isXMLChar(nextCh)) - { - XMLCh tmpBuf[9]; - XMLString::binToText - ( - nextCh - , tmpBuf - , 8 - , 16 - ); - fScanner->emitError(XMLErrs::InvalidCharacter, tmpBuf); - } - else - { - fScanner->emitError(XMLErrs::InvalidDocumentStructure); - } - - // Try to get realigned - static const XMLCh toSkip[] = - { - chPercent, chCloseSquare, chOpenAngle, chNull - }; - fReaderMgr->skipUntilInOrWS(toSkip); - } - bAcceptDecl = false; - } - } - - catch(const EndOfEntityException& toCatch) - { - // - // If the external entity ended while we were in markup, then that's - // a partial markup error. - // - if (inMarkup) - { - fScanner->emitError(XMLErrs::PartialMarkupInEntity); - inMarkup = false; - } - - // If we were in char data, then send what we got - if (inCharData) - { - // Send what we got, then rethrow - if (fDocTypeHandler) - { - fDocTypeHandler->doctypeWhitespace - ( - bbSpace.getRawBuffer() - , bbSpace.getLen() - ); - } - inCharData = false; - } - - // - // If the entity that just ended was the entity that we started - // on, then this is the end of the external subset. - // - if (orgReader == toCatch.getReaderNum()) - break; - } - } - - // If we have a doc type handler, tell it the ext subset ends - if (fDocTypeHandler) - fDocTypeHandler->endExtSubset(); -} - - -// -// This method will scan for an id, either public or external. -// -// -// [75] ExternalID ::= 'SYSTEM' S SystemLiteral -// | 'PUBLIC' S PubidLiteral S SystemLiteral -// [83] PublicID ::= 'PUBLIC' S PubidLiteral -// -bool DTDScanner::scanId( XMLBuffer& pubIdToFill - , XMLBuffer& sysIdToFill - , const IDTypes whatKind) -{ - // Clean out both return buffers - pubIdToFill.reset(); - sysIdToFill.reset(); - - // - // Check first for the system id first. If we find it, and system id - // is one of the legal values, then lets try to scan it. - // - // 'SYSTEM' S SystemLiteral - if (fReaderMgr->skippedString(XMLUni::fgSysIDString)) - { - // If they were looking for a public id, then we failed - if (whatKind == IDType_Public) - { - fScanner->emitError(XMLErrs::ExpectedPublicId); - return false; - } - - // We must skip spaces - if (!fReaderMgr->skipPastSpaces()) - { - fScanner->emitError(XMLErrs::ExpectedWhitespace); - return false; - } - - // Get the system literal value - return scanSystemLiteral(sysIdToFill); - } - - // Now scan for public id - // 'PUBLIC' S PubidLiteral S SystemLiteral - // or - // 'PUBLIC' S PubidLiteral - - // If we don't have any public id string => Error - if (!fReaderMgr->skippedString(XMLUni::fgPubIDString)) { - fScanner->emitError(XMLErrs::ExpectedSystemOrPublicId); - return false; - } - - // - // So following this we must have whitespace, a public literal, whitespace, - // and a system literal. - // - if (!fReaderMgr->skipPastSpaces()) - { - fScanner->emitError(XMLErrs::ExpectedWhitespace); - - // - // Just in case, if they just forgot the whitespace but the next char - // is a single or double quote, then keep going. - // - const XMLCh chPeek = fReaderMgr->peekNextChar(); - if ((chPeek != chDoubleQuote) && (chPeek != chSingleQuote)) - return false; - } - - if (!scanPublicLiteral(pubIdToFill)) - return false; - - // If they wanted a public id, then this is all - if (whatKind == IDType_Public) - return true; - - // check if there is any space follows - bool hasSpace = fReaderMgr->skipPastSpaces(); - - // - // In order to recover best here we need to see if - // the next thing is a quote or not - // - const XMLCh chPeek = fReaderMgr->peekNextChar(); - const bool bIsQuote = ((chPeek == chDoubleQuote) - || (chPeek == chSingleQuote)); - - if (!hasSpace) - { - if (whatKind == IDType_External) - { - // - // If its an external Id, then we need to see the system id. - // So, emit the error. But, if the next char is a quote, don't - // give up since its probably going to work. The user just - // missed the separating space. Otherwise, fail. - // - fScanner->emitError(XMLErrs::ExpectedWhitespace); - if (!bIsQuote) - return false; - } - else - { - // - // We can legally return here. But, if the next char is a quote, - // then that's probably not what was desired, since its probably - // just that space was forgotten and there really is a system - // id to follow. - // - // So treat it like missing whitespace if so and keep going. - // Else, just return success. - // - if (bIsQuote) - fScanner->emitError(XMLErrs::ExpectedWhitespace); - else - return true; - } - } - - if (bIsQuote) { - // there is a quote coming, scan the system literal - if (!scanSystemLiteral(sysIdToFill)) - return false; - } - else { - // no quote, if expecting exteral id, this is an error - if (whatKind == IDType_External) - fScanner->emitError(XMLErrs::ExpectedQuotedString); - } - - return true; -} - - -// -// This method will scan the contents of an ignored section. It assumes that -// we already are in the body, i.e. we've seen <![IGNORE[ at this point. So -// we have to just scan until we see a matching ]]> closing markup. -// -void DTDScanner::scanIgnoredSection() -{ - // - // Depth starts at one because we are already in one section and want - // to parse until we hit its end. - // - unsigned long depth = 1; - while (true) - { - const XMLCh nextCh = fReaderMgr->getNextChar(); - - if (!nextCh) - ThrowXML(UnexpectedEOFException, XMLExcepts::Gen_UnexpectedEOF); - - if (nextCh == chOpenAngle) - { - if (fReaderMgr->skippedChar(chBang) - && fReaderMgr->skippedChar(chOpenSquare)) - { - depth++; - } - } - else if (nextCh == chCloseSquare) - { - if (fReaderMgr->skippedChar(chCloseSquare)) - { - while (fReaderMgr->skippedChar(chCloseSquare)) - { - // Do nothing, just skip them - } - - if (fReaderMgr->skippedChar(chCloseAngle)) - { - depth--; - if (!depth) - break; - } - } - } - else if (!XMLReader::isXMLChar(nextCh)) - { - XMLCh tmpBuf[9]; - XMLString::binToText - ( - nextCh - , tmpBuf - , 8 - , 16 - ); - fScanner->emitError(XMLErrs::InvalidCharacter, tmpBuf); - } - } -} - - -// -// This method scans the entire internal subset. All we can have here is -// decl markup, and PE references. The expanded PE references must contain -// whole markup, so we don't have to worry about their content at this -// level. We just scan them, expand them, push them, and parse their content -// right there, via the expandERef() method. -// -bool DTDScanner::scanInternalSubset() -{ - // If we have a doc type handler, tell it the internal subset starts - if (fDocTypeHandler) - fDocTypeHandler->startIntSubset(); - - // Get a buffer for whitespace - XMLBufBid bbSpace(fBufMgr); - - bool noErrors = true; - while (true) - { - const XMLCh nextCh = fReaderMgr->peekNextChar(); - - // - // If we get an end of file marker, just unget it and return a - // failure status. The caller will then see the end of file and - // faill out correctly. - // - if (!nextCh) - return false; - - // Watch for the end of internal subset marker - if (nextCh == chCloseSquare) - { - fReaderMgr->getNextChar(); - break; - } - - if (nextCh == chPercent) - { - // - // Expand (and scan if external) the reference value. Tell - // it to set the reader to cause an end of entity exception - // when this reader dies, which is what the scanExtSubset - // method wants (who is called to scan this.) - // - fReaderMgr->getNextChar(); - expandPERef(true, false, false, true); - } - else if (nextCh == chOpenAngle) - { - // Remember this reader before we start the scan - const unsigned int orgReader = fReaderMgr->getCurrentReaderNum(); - - // And scan this markup - fReaderMgr->getNextChar(); - scanMarkupDecl(false); - - // If we did not get back to entry level, then partial markup - if (fReaderMgr->getCurrentReaderNum() != orgReader && fScanner->getDoValidation()) - fScanner->getValidator()->emitError(XMLValid::PartialMarkupInPE); - } - else if (XMLReader::isWhitespace(nextCh)) - { - // - // IF we are doing advanced callbacks and have a doc type - // handler, then get the whitespace and call the doc type - // handler with it. Otherwise, just skip whitespace. - // - if (fDocTypeHandler) - { - fReaderMgr->getSpaces(bbSpace.getBuffer()); - fDocTypeHandler->doctypeWhitespace - ( - bbSpace.getRawBuffer() - , bbSpace.getLen() - ); - } - else - { - fReaderMgr->skipPastSpaces(); - } - } - else - { - // Not valid, so emit an error - XMLCh tmpBuf[9]; - XMLString::binToText - ( - fReaderMgr->getNextChar() - , tmpBuf - , 8 - , 16 - ); - fScanner->emitError - ( - XMLErrs::InvalidCharacterInIntSubset - , tmpBuf - ); - - // - // If an '>', then probably an abnormally terminated - // internal subset so just return. - // - if (nextCh == chCloseAngle) - { - noErrors = false; - break; - } - - // - // Otherwise, try to sync back up by scanning forward for - // a reasonable start character. - // - static const XMLCh toSkip[] = - { - chPercent, chCloseSquare, chOpenAngle, chNull - }; - fReaderMgr->skipUntilInOrWS(toSkip); - } - } - - // If we have a doc type handler, tell it the internal subset ends - if (fDocTypeHandler) - fDocTypeHandler->endIntSubset(); - - return noErrors; -} - - -// -// This method is called once we see a < in the input of an int/ext subset, -// which indicates the start of some sort of markup. -// -void DTDScanner::scanMarkupDecl(const bool parseTextDecl) -{ - // - // We only have two valid first characters here. One is a ! which opens - // some markup decl. The other is a ?, which could begin either a PI - // or a text decl. If parseTextDecl is false, we cannot accept a text - // decl. - // - const XMLCh nextCh = fReaderMgr->getNextChar(); - - if (nextCh == chBang) - { - if (fReaderMgr->skippedChar(chDash)) - { - if (fReaderMgr->skippedChar(chDash)) - { - scanComment(); - } - else - { - fScanner->emitError(XMLErrs::CommentsMustStartWith); - fReaderMgr->skipPastChar(chCloseAngle); - } - } - else if (fReaderMgr->skippedChar(chOpenSquare)) - { - // - // Its a conditional section. This is only valid in the external - // subset, so issue an error if we aren't there. - // - if (fInternalSubset) - { - fScanner->emitError(XMLErrs::ConditionalSectInIntSubset); - fReaderMgr->skipPastChar(chCloseAngle); - return; - } - - // A PE ref can happen here, but space is not required - checkForPERef(false, false, true); - - if (fReaderMgr->skippedString(XMLUni::fgIncludeString)) - { - checkForPERef(false, false, true); - - // Check for the following open square bracket - if (!fReaderMgr->skippedChar(chOpenSquare)) - fScanner->emitError(XMLErrs::ExpectedINCLUDEBracket); - - checkForPERef(false, false, true); - - // - // Recurse back to the ext subset call again, telling it its - // in an include section. - // - scanExtSubsetDecl(true); - } - else if (fReaderMgr->skippedString(XMLUni::fgIgnoreString)) - { - checkForPERef(false, false, true); - - // Check for the following open square bracket - if (!fReaderMgr->skippedChar(chOpenSquare)) - fScanner->emitError(XMLErrs::ExpectedINCLUDEBracket); - - // And scan over the ignored part - scanIgnoredSection(); - } - else - { - fScanner->emitError(XMLErrs::ExpectedIncOrIgn); - fReaderMgr->skipPastChar(chCloseAngle); - } - } - else if (fReaderMgr->skippedString(XMLUni::fgAttListString)) - { - scanAttListDecl(); - } - else if (fReaderMgr->skippedString(XMLUni::fgElemString)) - { - scanElementDecl(); - } - else if (fReaderMgr->skippedString(XMLUni::fgEntityString)) - { - scanEntityDecl(); - } - else if (fReaderMgr->skippedString(XMLUni::fgNotationString)) - { - scanNotationDecl(); - } - else - { - fScanner->emitError(XMLErrs::ExpectedMarkupDecl); - fReaderMgr->skipPastChar(chCloseAngle); - } - } - else if (nextCh == chQuestion) - { - // It could be a PI or the XML declaration. Check for Decl - if (fScanner->checkXMLDecl(false)) - { - // If we are not accepting text decls, its an error - if (parseTextDecl) - { - scanTextDecl(); - } - else - { - // Emit the error and skip past this markup - fScanner->emitError(XMLErrs::TextDeclNotLegalHere); - fReaderMgr->skipPastChar(chCloseAngle); - } - } - else - { - // It has to be a PI - scanPI(); - } - } - else - { - // Can't be valid so emit error and try to skip past end of this decl - fScanner->emitError(XMLErrs::ExpectedMarkupDecl); - fReaderMgr->skipPastChar(chCloseAngle); - } -} - - -// -// This method is called for a mixed model element's content mode. We've -// already scanned past the '(PCDATA' part by the time we get here. So -// everything else is element names separated by | characters until we -// hit the end. The passed element decl's content model is filled in with -// the information found. -// -bool DTDScanner::scanMixed(DTDElementDecl& toFill) -{ - // - // The terminating star is only required if there is something more - // than (PCDATA). - // - bool starRequired = false; - - // Get a buffer to be used below to get element names - XMLBufBid bbName(fBufMgr); - XMLBuffer& nameBuf = bbName.getBuffer(); - - // - // Create an initial content spec node. Its just a leaf node with a - // PCDATA element id. This current node pointer will be pushed down the - // tree as we go. - // - ContentSpecNode* curNode = - new ContentSpecNode(new QName(XMLUni::fgZeroLenString, - XMLUni::fgZeroLenString, - XMLElementDecl::fgPCDataElemId), - false); - - // - // Set the initial leaf as the temporary head. If we hit the first choice - // node, it will be set up here. When done, this is the node that's set - // as the content spec for the element. - // - ContentSpecNode* headNode = curNode; - - // Remember the original node so we can sense the first choice node - ContentSpecNode* orgNode = curNode; - - // - // We just loop around, getting the | character at the top and then - // looking for the next element name. We keep up with the last node - // and add each new one to its right node. - // - while (true) - { - // - // First of all we check for some grunt work details of skipping - // whitespace, expand PE refs, and catching invalid reps. - // - if (fReaderMgr->lookingAtChar(chPercent)) - { - // Expand it and continue - checkForPERef(false, false, true); - } - else if (fReaderMgr->skippedChar(chAsterisk)) - { - // - // Tell them they can't have reps in mixed model, but eat - // it and keep going if we are allowed to. - // - fScanner->emitError(XMLErrs::NoRepInMixed); - } - else if (fReaderMgr->skippedSpace()) - { - // Spaces are ok at this point, just eat them and continue - fReaderMgr->skipPastSpaces(); - } - else - { - if (!fReaderMgr->skippedChar(chPipe)) - { - // Has to be the closing paren now. - if (!fReaderMgr->skippedChar(chCloseParen)) - { - fScanner->emitError(XMLErrs::UnterminatedContentModel); - delete headNode; - return false; - } - - if (!fReaderMgr->skippedChar(chAsterisk) && starRequired) - fScanner->emitError(XMLErrs::ExpectedAsterisk); - - // - // Create a zero or more node and make the original head - // node its first child. - // - headNode = new ContentSpecNode - ( - ContentSpecNode::ZeroOrMore - , headNode - , 0 - ); - - // Store the head node as the content spec of the element. - toFill.setContentSpec(headNode); - break; - } - - // Its more than just a PCDATA, so an ending star will be required now - starRequired = true; - - // Space is legal here so check for a PE ref, but don't require space - checkForPERef(false, false, true); - - // Get a name token - if (!fReaderMgr->getName(nameBuf)) - { - fScanner->emitError(XMLErrs::ExpectedElementName); - delete headNode; - return false; - } - - // - // Create a leaf node for it. If we can find the element id for - // this element, then use it. Else, we have to fault in an element - // decl, marked as created because of being in a content model. - // - XMLElementDecl* decl = fDTDGrammar->getElemDecl(fEmptyNamespaceId, 0, nameBuf.getRawBuffer(), Grammar::TOP_LEVEL_SCOPE); - if (!decl) - { - decl = new DTDElementDecl(nameBuf.getRawBuffer(), fEmptyNamespaceId); - decl->setCreateReason(XMLElementDecl::InContentModel); - decl->setExternalElemDeclaration(isReadingExternalEntity()); - fDTDGrammar->putElemDecl(decl); - } - - // - // If the current node is the original node, this is the first choice - // node, so create an initial choice node with the current node and - // the new element id. Store this as the head node. - // - // Otherwise, we have to steal the right node of the previous choice - // and weave in another choice node there, which has the old choice - // as its left and the new leaf as its right. - // - if (curNode == orgNode) - { - curNode = new ContentSpecNode - ( - ContentSpecNode::Choice - , curNode - , new ContentSpecNode(decl->getElementName()) - ); - - // Remember the top node - headNode = curNode; - } - else - { - ContentSpecNode* oldRight = curNode->orphanSecond(); - curNode->setSecond - ( - new ContentSpecNode - ( - ContentSpecNode::Choice - , oldRight - , new ContentSpecNode(decl->getElementName()) - ) - ); - - // Make the new right node the current node - curNode = curNode->getSecond(); - } - } - } - - return true; -} - - -// -// This method is called when we see a '<!NOTATION' string while scanning -// markup decl. It parses out the notation and its id and stores a new -// notation decl object in the notation decl pool. -// -void DTDScanner::scanNotationDecl() -{ - // Space is required here so check for a PE ref, and require space - if (!checkForPERef(true, false, true)) - { - fScanner->emitError(XMLErrs::ExpectedWhitespace); - fReaderMgr->skipPastChar(chCloseAngle); - return; - } - - // - // And now we get a name, which is the name of the notation. Get a - // buffer for the name. - // - XMLBufBid bbName(fBufMgr); - if (!fReaderMgr->getName(bbName.getBuffer())) - { - fScanner->emitError(XMLErrs::ExpectedNotationName); - fReaderMgr->skipPastChar(chCloseAngle); - return; - } - - // If namespaces are enabled, then no colons allowed - if (fScanner->getDoNamespaces()) - { - if (XMLString::indexOf(bbName.getRawBuffer(), chColon) != -1) - fScanner->emitError(XMLErrs::ColonNotLegalWithNS); - } - - // Space is required here so check for a PE ref, and require space - if (!checkForPERef(true, false, true)) - { - fScanner->emitError(XMLErrs::ExpectedWhitespace); - fReaderMgr->skipPastChar(chCloseAngle); - return; - } - - // - // And scan an external or public id. We need buffers to use for both - // of these. - // - XMLBufBid bbPubId(fBufMgr); - XMLBufBid bbSysId(fBufMgr); - if (!scanId(bbPubId.getBuffer(), bbSysId.getBuffer(), IDType_Either)) - { - fReaderMgr->skipPastChar(chCloseAngle); - return; - } - - // We can have an optional space or PE ref here - checkForPERef(false, false, true); - - // - // See if it already exists. If so, add it to the notatino decl pool. - // Otherwise, if advanced callbacks are on, create a temp one and - // call out for that one. - // - XMLNotationDecl* decl = fDTDGrammar->getNotationDecl(bbName.getRawBuffer()); - bool isIgnoring = (decl != 0); - if (isIgnoring) - { - fScanner->emitError(XMLErrs::NotationAlreadyExists, bbName.getRawBuffer()); - } - else - { - // Fill in a new notation declaration and add it to the pool - decl = new XMLNotationDecl - ( - bbName.getRawBuffer() - , bbPubId.getRawBuffer() - , bbSysId.getRawBuffer() - ); - fDTDGrammar->putNotationDecl(decl); - } - - // - // If we have a document type handler, then tell it about this. If we - // are ignoring it, only call out if advanced callbacks are enabled. - // - if (fDocTypeHandler) - { - fDocTypeHandler->notationDecl - ( - *decl - , isIgnoring - ); - } - - // And one more optional space or PE ref - checkForPERef(false, false, true); - - // And skip the terminating bracket - if (!fReaderMgr->skippedChar(chCloseAngle)) - fScanner->emitError(XMLErrs::UnterminatedNotationDecl); -} - - -// -// Scans a PI and calls the appropriate callbacks. A PI can happen in either -// the document or the DTD, so it calls the appropriate handler according -// to the fInDocument flag. -// -// At entry we have just scanned the <? part, and need to now start on the -// PI target name. -// -void DTDScanner::scanPI() -{ - const XMLCh* namePtr = 0; - const XMLCh* targetPtr = 0; - - // - // If there are any spaces here, then warn about it. If we aren't in - // 'first error' mode, then we'll come back and can easily pick up - // again by just skipping them. - // - if (fReaderMgr->lookingAtSpace()) - { - fScanner->emitError(XMLErrs::PINameExpected); - fReaderMgr->skipPastSpaces(); - } - - // Get a buffer for the PI name and scan it in - XMLBufBid bbName(fBufMgr); - if (!fReaderMgr->getName(bbName.getBuffer())) - { - fScanner->emitError(XMLErrs::PINameExpected); - fReaderMgr->skipPastChar(chCloseAngle); - return; - } - - // Point the name pointer at the raw data - namePtr = bbName.getRawBuffer(); - - // See if it issome form of 'xml' and emit a warning - if (!XMLString::compareIString(namePtr, XMLUni::fgXMLString)) - fScanner->emitError(XMLErrs::NoPIStartsWithXML); - - // If namespaces are enabled, then no colons allowed - if (fScanner->getDoNamespaces()) - { - if (XMLString::indexOf(namePtr, chColon) != -1) - fScanner->emitError(XMLErrs::ColonNotLegalWithNS); - } - - // - // If we don't hit a space next, then the PI has no target. If we do - // then get out the target. Get a buffer for it as well - // - XMLBufBid bbTarget(fBufMgr); - if (fReaderMgr->skippedSpace()) - { - // Skip any leading spaces - fReaderMgr->skipPastSpaces(); - - bool gotLeadingSurrogate = false; - - // It does have a target, so lets move on to deal with that. - while (1) - { - const XMLCh nextCh = fReaderMgr->getNextChar(); - - // Watch for an end of file, which is always bad here - if (!nextCh) - { - fScanner->emitError(XMLErrs::UnterminatedPI); - ThrowXML(UnexpectedEOFException, XMLExcepts::Gen_UnexpectedEOF); - } - - // Watch for potential terminating character - if (nextCh == chQuestion) - { - // It must be followed by '>' to be a termination of the target - if (fReaderMgr->skippedChar(chCloseAngle)) - break; - } - - // Check for correct surrogate pairs - if ((nextCh >= 0xD800) && (nextCh <= 0xDBFF)) - { - if (gotLeadingSurrogate) - fScanner->emitError(XMLErrs::Expected2ndSurrogateChar); - else - gotLeadingSurrogate = true; - } - else - { - if (gotLeadingSurrogate) - { - if ((nextCh < 0xDC00) || (nextCh > 0xDFFF)) - fScanner->emitError(XMLErrs::Expected2ndSurrogateChar); - } - // Its got to at least be a valid XML character - else if (!XMLReader::isXMLChar(nextCh)) { - - XMLCh tmpBuf[9]; - XMLString::binToText - ( - nextCh - , tmpBuf - , 8 - , 16 - ); - fScanner->emitError(XMLErrs::InvalidCharacter, tmpBuf); - } - - gotLeadingSurrogate = false; - } - bbTarget.append(nextCh); - } - } - else - { - // No target, but make sure its terminated ok - if (!fReaderMgr->skippedChar(chQuestion)) - { - fScanner->emitError(XMLErrs::UnterminatedPI); - fReaderMgr->skipPastChar(chCloseAngle); - return; - } - - if (!fReaderMgr->skippedChar(chCloseAngle)) - { - fScanner->emitError(XMLErrs::UnterminatedPI); - fReaderMgr->skipPastChar(chCloseAngle); - return; - } - } - - // Point the target pointer at the raw data - targetPtr = bbTarget.getRawBuffer(); - - // - // If we have a handler, then call it. - // - if (fDocTypeHandler) - { - fDocTypeHandler->doctypePI - ( - namePtr - , targetPtr - ); - } -} - - -// -// This method scans a public literal. It must be quoted and all of its -// characters must be valid public id characters. The quotes are discarded -// and the results are returned. -// -bool DTDScanner::scanPublicLiteral(XMLBuffer& toFill) -{ - toFill.reset(); - - // Get the next char which must be a single or double quote - XMLCh quoteCh; - if (!fReaderMgr->skipIfQuote(quoteCh)) { - fScanner->emitError(XMLErrs::ExpectedQuotedString); - return false; - } - - while (true) - { - const XMLCh nextCh = fReaderMgr->getNextChar(); - - // Watch for EOF - if (!nextCh) - ThrowXML(UnexpectedEOFException, XMLExcepts::Gen_UnexpectedEOF); - - if (nextCh == quoteCh) - break; - - // - // If its not a valid public id char, then report it but keep going - // since that's the best recovery scheme. - // - if (!XMLReader::isPublicIdChar(nextCh)) - { - XMLCh tmpBuf[9]; - XMLString::binToText - ( - nextCh - , tmpBuf - , 8 - , 16 - ); - fScanner->emitError(XMLErrs::InvalidPublicIdChar, tmpBuf); - } - - toFill.append(nextCh); - } - return true; -} - - -// -// This method handles scanning in a quoted system literal. It expects to -// start on the open quote and returns after eating the ending quote. There -// are not really any restrictions on the contents of system literals. -// -bool DTDScanner::scanSystemLiteral(XMLBuffer& toFill) -{ - toFill.reset(); - - // Get the next char which must be a single or double quote - XMLCh quoteCh; - if (!fReaderMgr->skipIfQuote(quoteCh)) { - fScanner->emitError(XMLErrs::ExpectedQuotedString); - return false; - } - - while (true) - { - const XMLCh nextCh = fReaderMgr->getNextChar(); - - // Watch for EOF - if (!nextCh) - ThrowXML(UnexpectedEOFException, XMLExcepts::Gen_UnexpectedEOF); - - // Break out on terminating quote - if (nextCh == quoteCh) - break; - - toFill.append(nextCh); - } - return true; -} - - - -// -// This method is called to scan a text decl line, which can be the first -// line in an external entity or external subset. -// -// On entry the <? has been scanned, and next should be 'xml' followed by -// some whitespace, version string, etc... -// [77] TextDecl::= '<?xml' VersionInfo? EncodingDecl S? '?>' -// -void DTDScanner::scanTextDecl() -{ - // Skip any subsequent whitespace before the version string - fReaderMgr->skipPastSpaces(); - - // Next should be the version string - XMLBufBid bbVersion(fBufMgr); - if (fReaderMgr->skippedString(XMLUni::fgVersionString)) - { - if (!scanEq()) - { - fScanner->emitError(XMLErrs::ExpectedEqSign); - fReaderMgr->skipPastChar(chCloseAngle); - return; - } - - // - // Followed by a single or double quoted version. Get a buffer for - // the string. - // - if (!getQuotedString(bbVersion.getBuffer())) - { - fScanner->emitError(XMLErrs::BadXMLVersion); - fReaderMgr->skipPastChar(chCloseAngle); - return; - } - - // If its not our supported version, issue an error but continue - if (XMLString::compareString(bbVersion.getRawBuffer(), XMLUni::fgSupportedVersion)) - fScanner->emitError(XMLErrs::UnsupportedXMLVersion, bbVersion.getRawBuffer()); - } - - // Ok, now we must have an encoding string - XMLBufBid bbEncoding(fBufMgr); - fReaderMgr->skipPastSpaces(); - bool gotEncoding = false; - if (fReaderMgr->skippedString(XMLUni::fgEncodingString)) - { - // There must be a equal sign next - if (!scanEq()) - { - fScanner->emitError(XMLErrs::ExpectedEqSign); - fReaderMgr->skipPastChar(chCloseAngle); - return; - } - - // Followed by a single or double quoted version string - getQuotedString(bbEncoding.getBuffer()); - if (bbEncoding.isEmpty()) - { - fScanner->emitError(XMLErrs::BadXMLEncoding, bbEncoding.getRawBuffer()); - fReaderMgr->skipPastChar(chCloseAngle); - return; - } - - // Indicate that we got an encoding - gotEncoding = true; - } - - // - // Encoding declarations are required in the external entity - // if there is a text declaration present - // - if (!gotEncoding) - { - fScanner->emitError(XMLErrs::EncodingRequired); - fReaderMgr->skipPastChar(chCloseAngle); - return; - - } - - fReaderMgr->skipPastSpaces(); - if (!fReaderMgr->skippedChar(chQuestion)) - { - fScanner->emitError(XMLErrs::UnterminatedXMLDecl); - fReaderMgr->skipPastChar(chCloseAngle); - } - else if (!fReaderMgr->skippedChar(chCloseAngle)) - { - fScanner->emitError(XMLErrs::UnterminatedXMLDecl); - fReaderMgr->skipPastChar(chCloseAngle); - } - - // - // If we have a document type handler and advanced callbacks are on, - // then call the TextDecl callback - // - if (fDocTypeHandler) - { - fDocTypeHandler->TextDecl - ( - bbVersion.getRawBuffer() - , bbEncoding.getRawBuffer() - ); - } - - // - // If we got an encoding string, then we have to call back on the reader - // to tell it what the encoding is. - // - if (!bbEncoding.isEmpty()) - { - if (!fReaderMgr->getCurrentReader()->setEncoding(bbEncoding.getRawBuffer())) - fScanner->emitError(XMLErrs::ContradictoryEncoding, bbEncoding.getRawBuffer()); - } -} diff --git a/src/validators/DTD/DTDScanner.hpp b/src/validators/DTD/DTDScanner.hpp deleted file mode 100644 index e9308004179b45c20cae721ebdce8d21bb2f5b5b..0000000000000000000000000000000000000000 --- a/src/validators/DTD/DTDScanner.hpp +++ /dev/null @@ -1,343 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999-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$ - * Revision 1.4 2001/06/21 14:25:56 knoaman - * Fix for bug 1946 - * - * Revision 1.3 2001/05/11 13:27:10 tng - * Copyright update. - * - * Revision 1.2 2001/04/19 18:17:22 tng - * Schema: SchemaValidator update, and use QName in Content Model - * - * Revision 1.1 2001/03/21 21:56:20 tng - * Schema: Add Schema Grammar, Schema Validator, and split the DTDValidator into DTDValidator, DTDScanner, and DTDGrammar. - * - */ - - - -#if !defined(DTDSCANNER_HPP) -#define DTDSCANNER_HPP - -#include <validators/DTD/DTDGrammar.hpp> -#include <validators/DTD/DTDEntityDecl.hpp> - -/* - * Default implementation of an XML DTD scanner. - */ -class DocTypeHandler; - -class VALIDATORS_EXPORT DTDScanner -{ -public: - // ----------------------------------------------------------------------- - // Class specific types - // - // NOTE: This should really be private, but some of the compilers we - // have to support cannot understand that. - // - // EntityExpRes - // Returned from scanEntityRef() to indicate how the expanded text - // was treated. - // ----------------------------------------------------------------------- - enum EntityExpRes - { - EntityExp_Failed - , EntityExp_Pushed - , EntityExp_Returned - }; - - - // ----------------------------------------------------------------------- - // Constructors and Destructor - // ----------------------------------------------------------------------- - DTDScanner(DTDGrammar* dtdGrammar, NameIdPool<DTDEntityDecl>* entityDeclPool, DocTypeHandler* const docTypeHandler); - virtual ~DTDScanner(); - - // ----------------------------------------------------------------------- - // Getter methods - // ----------------------------------------------------------------------- - DocTypeHandler* getDocTypeHandler(); - const DocTypeHandler* getDocTypeHandler() const; - - // ----------------------------------------------------------------------- - // Setter methods - // - // setScannerInfo() is called by the scanner to tell the DTDScanner - // about the stuff it needs to have access to. - // ----------------------------------------------------------------------- - void setScannerInfo - ( - XMLScanner* const owningScanner - , ReaderMgr* const readerMgr - , XMLBufferMgr* const bufMgr - ); - - void setDocTypeHandler - ( - DocTypeHandler* const handlerToSet - ); - - void scanDocTypeDecl(const bool reuseGrammar); - -private: - // ----------------------------------------------------------------------- - // Private class types - // ----------------------------------------------------------------------- - enum IDTypes - { - IDType_Public - , IDType_External - , IDType_Either - }; - - - // ----------------------------------------------------------------------- - // Private DTD scanning methods. These are all in XMLValidator2.cpp - // ----------------------------------------------------------------------- - bool checkForPERef - ( - const bool spaceRequired - , const bool inLiteral - , const bool inMarkup - , const bool throwEndOfExt = false - ); - bool expandPERef - ( - const bool scanExternal - , const bool inLiteral - , const bool inMarkup - , const bool throwEndOfExt = false - ); - bool getQuotedString(XMLBuffer& toFill); - XMLAttDef* scanAttDef(DTDElementDecl& elemDecl, XMLBuffer& bufToUse); - bool scanAttValue - ( - const XMLCh* const attrName - , XMLBuffer& toFill - , const XMLAttDef::AttTypes type - ); - void scanAttListDecl(); - ContentSpecNode* scanChildren - ( - const DTDElementDecl& elemDecl - , XMLBuffer& bufToUse - ); - bool scanCharRef(XMLCh& toFill, XMLCh& second); - void scanComment(); - bool scanContentSpec(DTDElementDecl& toFill); - void scanDefaultDecl(DTDAttDef& toFill); - void scanElementDecl(); - void scanEntityDecl(); - bool scanEntityDef(); - bool scanEntityLiteral(XMLBuffer& toFill, const bool isPE); - bool scanEntityDef(DTDEntityDecl& decl, const bool isPEDecl); - EntityExpRes scanEntityRef(XMLCh& firstCh, XMLCh& secondCh, bool& escaped); - bool scanEnumeration - ( - const DTDAttDef& attDef - , XMLBuffer& toFill - , const bool notation - ); - bool scanEq(); - void scanExtSubsetDecl(const bool inIncludeSect); - bool scanId - ( - XMLBuffer& pubIdToFill - , XMLBuffer& sysIdToFill - , const IDTypes whatKind - ); - void scanIgnoredSection(); - bool scanInternalSubset(); - void scanMarkupDecl(const bool parseTextDecl); - bool scanMixed(DTDElementDecl& toFill); - void scanNotationDecl(); - void scanPI(); - bool scanPublicLiteral(XMLBuffer& toFill); - bool scanSystemLiteral(XMLBuffer& toFill); - void scanTextDecl(); - bool isReadingExternalEntity(); - - - // ----------------------------------------------------------------------- - // Private data members - // - // fDocTypeHandler - // This holds the optional doc type handler that can be installed - // and used to call back for all markup events. It is DTD specific. - // - // fDumAttDef - // fDumElemDecl - // fDumEntityDecl - // These are dummy objects into which mark decls are parsed when - // they are just overrides of previously declared markup decls. In - // such situations, the first one wins but we need to have somewhere - // to parse them into. So these are lazily created and used as needed - // when such markup decls are seen. - // - // fInternalSubset - // This is used to track whether we are in the internal subset or not, - // in which case we are in the external subset. - // - // fNextAttrId - // Since att defs are per-element, we don't have a validator wide - // attribute def pool. So we use a simpler data structure in each - // element decl to store its att defs, and we use this simple counter - // to apply a unique id to each new attribute. - // - // fDTDGrammar - // The DTD information we scanned like element decl, attribute decl - // are stored in this Grammar. - // - // fBufMgr - // This is the buffer manager of the scanner. This is provided as a - // convenience so that the DTDScanner doesn't have to create its own - // buffer manager during the parse process. - // - // fReaderMgr - // This is a pointer to the reader manager that is being used by the scanner. - // - // fScanner - // The pointer to the scanner to which this DTDScanner belongs - // - // fPEntityDeclPool - // This is a pool of EntityDecl objects, which contains all of the - // parameter entities that are declared in the DTD subsets. - // - // fEntityDeclPool - // This is a pool of EntityDecl objects, which contains all of the - // general entities that are declared in the DTD subsets. It is - // owned by the Scanner as Schema Grammar may also need access to - // this pool for entity reference. - // - // fEmptyNamespaceId - // The uri for all DTD decls - // - // fDocTypeReaderId - // The original reader in the fReaderMgr - to be compared against the - // current reader to decide whether we are processing an external/internal - // declaration - // ----------------------------------------------------------------------- - DocTypeHandler* fDocTypeHandler; - DTDAttDef* fDumAttDef; - DTDElementDecl* fDumElemDecl; - DTDEntityDecl* fDumEntityDecl; - bool fInternalSubset; - unsigned int fNextAttrId; - DTDGrammar* fDTDGrammar; - XMLBufferMgr* fBufMgr; - ReaderMgr* fReaderMgr; - XMLScanner* fScanner; - NameIdPool<DTDEntityDecl>* fPEntityDeclPool; - NameIdPool<DTDEntityDecl>* fEntityDeclPool; - unsigned int fEmptyNamespaceId; - unsigned int fDocTypeReaderId; -}; - - -// --------------------------------------------------------------------------- -// DTDScanner: Getter methods -// --------------------------------------------------------------------------- -inline DocTypeHandler* DTDScanner::getDocTypeHandler() -{ - return fDocTypeHandler; -} - -inline const DocTypeHandler* DTDScanner::getDocTypeHandler() const -{ - return fDocTypeHandler; -} - - -// --------------------------------------------------------------------------- -// DTDScanner: Setter methods -// --------------------------------------------------------------------------- -inline void DTDScanner::setDocTypeHandler(DocTypeHandler* const handlerToSet) -{ - fDocTypeHandler = handlerToSet; -} - -// ----------------------------------------------------------------------- -// Setter methods -// ----------------------------------------------------------------------- -inline void DTDScanner::setScannerInfo(XMLScanner* const owningScanner - , ReaderMgr* const readerMgr - , XMLBufferMgr* const bufMgr) -{ - // We don't own any of these, we just reference them - fScanner = owningScanner; - fReaderMgr = readerMgr; - fBufMgr = bufMgr; - - if (fScanner->getDoNamespaces()) - fEmptyNamespaceId = fScanner->getEmptyNamespaceId(); - else - fEmptyNamespaceId = 0; - - fDocTypeReaderId = fReaderMgr->getCurrentReaderNum(); -} - -// ----------------------------------------------------------------------- -// Helper methods -// ----------------------------------------------------------------------- -inline bool DTDScanner::isReadingExternalEntity() { - return (fDocTypeReaderId != fReaderMgr->getCurrentReaderNum()); -} - -#endif diff --git a/src/validators/DTD/DTDValidator.cpp b/src/validators/DTD/DTDValidator.cpp deleted file mode 100644 index b83debc7535a3b621cf9b24c197c3a1645d4e2b8..0000000000000000000000000000000000000000 --- a/src/validators/DTD/DTDValidator.cpp +++ /dev/null @@ -1,614 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999-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/>. - */ - -/* - * $Id$ - */ - - -// --------------------------------------------------------------------------- -// Includes -// --------------------------------------------------------------------------- -#include <util/Janitor.hpp> -#include <util/XMLUniDefs.hpp> -#include <util/XMLUni.hpp> -#include <internal/ReaderMgr.hpp> -#include <internal/XMLScanner.hpp> -#include <validators/DTD/DTDValidator.hpp> - -// --------------------------------------------------------------------------- -// DTDValidator: Constructors and Destructor -// --------------------------------------------------------------------------- -DTDValidator::DTDValidator(XMLErrorReporter* const errReporter) : - - XMLValidator(errReporter) - , fDTDGrammar(0) -{ - reset(); -} - -DTDValidator::~DTDValidator() -{ -} - - -// --------------------------------------------------------------------------- -// DTDValidator: Implementation of the XMLValidator interface -// --------------------------------------------------------------------------- -int DTDValidator::checkContent(XMLElementDecl* const elemDecl - , QName** const children - , const unsigned int childCount) -{ - // - // Look up the element id in our element decl pool. This will get us - // the element decl in our own way of looking at them. - // - if (!elemDecl) - ThrowXML(RuntimeException, XMLExcepts::Val_InvalidElemId); - - // - // Get the content spec type of this element. This will tell us what - // to do to validate it. - // - const DTDElementDecl::ModelTypes modelType = ((DTDElementDecl*) elemDecl)->getModelType(); - - if (modelType == DTDElementDecl::Empty) - { - // - // We can do this one here. It cannot have any children. If it does - // we return 0 as the index of the first bad child. - // - if (childCount) - return 0; - } - else if (modelType == DTDElementDecl::Any) - { - // We pass no judgement on this one, anything goes - } - else if ((modelType == DTDElementDecl::Mixed_Simple) - || (modelType == DTDElementDecl::Children)) - { - // Get the element's content model or fault it in - const XMLContentModel* elemCM = elemDecl->getContentModel(); - - // Ask it to validate and return its return - return elemCM->validateContent(children, childCount, getScanner()->getEmptyNamespaceId()); - } - else - { - ThrowXML(RuntimeException, XMLExcepts::CM_UnknownCMType); - } - - // Went ok, so return success - return -1; -} - - -void DTDValidator::faultInAttr(XMLAttr& toFill, const XMLAttDef& attDef) const -{ - // - // At this level, we cannot set the URI id. So we just set it to zero - // and leave it at that. The scanner, who called us, will look at the - // prefix we stored (if any), resolve it, and store the URL id if any. - // - const XMLCh* fullName = attDef.getFullName(); - const int colonInd = XMLString::indexOf(fullName, chColon); - if (colonInd == -1) - { - // There is no prefix, so we just do a simple and quick setting - toFill.set - ( - 0 - , fullName - , XMLUni::fgZeroLenString - , attDef.getValue() - , attDef.getType() - ); - } - else - { - // - // There is a colon, so we have to split apart the name and prefix - // part. - // - XMLCh* tmpNameBuf = XMLString::replicate(fullName); - ArrayJanitor<XMLCh> janNameBuf(tmpNameBuf); - - // Put a null where the colon is, to split it into two strings - tmpNameBuf[colonInd] = chNull; - - // - // And now we can set the attribute object with the prefix and name - // parts. - // - toFill.set - ( - 0 - , &tmpNameBuf[colonInd+1] - , tmpNameBuf - , attDef.getValue() - , attDef.getType() - ); - } -} - -void DTDValidator::reset() -{ -} - - -bool DTDValidator::requiresNamespaces() const -{ - // Namespaces are not supported for DTDs - return false; -} - - -void -DTDValidator::validateAttrValue(const XMLAttDef* attDef - , const XMLCh* const attrValue) -{ - // - // Get quick refs to lost of of the stuff in the passed objects in - // order to simplify the code below, which will reference them very - // often. - // - const XMLAttDef::AttTypes type = attDef->getType(); - const XMLAttDef::DefAttTypes defType = attDef->getDefaultType(); - const XMLCh* const valueText = attDef->getValue(); - const XMLCh* const fullName = attDef->getFullName(); - const XMLCh* const enumList = attDef->getEnumeration(); - - // - // If the default type is fixed, then make sure the passed value maps - // to the fixed value. - // - if (defType == XMLAttDef::Fixed) - { - if (XMLString::compareString(attrValue, valueText)) - emitError(XMLValid::NotSameAsFixedValue, fullName, attrValue, valueText); - } - - // - // If its a CDATA attribute, then we are done with any DTD level - // validation else do the rest. - // - if (type == XMLAttDef::CData) - return; - - // An empty string cannot be valid for any of the other types - if (!attrValue[0]) - { - emitError(XMLValid::InvalidEmptyAttValue, fullName); - return; - } - - // See whether we are doing multiple values or not - const bool multipleValues = - ( - (type == XMLAttDef::IDRefs) - || (type == XMLAttDef::Entities) - || (type == XMLAttDef::NmTokens) - || (type == XMLAttDef::Notation) - || (type == XMLAttDef::Enumeration) - ); - - // And whether we must check for a first name char - const bool firstNameChar = - ( - (type == XMLAttDef::ID) - || (type == XMLAttDef::IDRef) - || (type == XMLAttDef::IDRefs) - || (type == XMLAttDef::Entity) - || (type == XMLAttDef::Entities) - || (type == XMLAttDef::Notation) - ); - - // Whether it requires ref checking stuff - const bool isARefType - ( - (type == XMLAttDef::ID) - || (type == XMLAttDef::IDRef) - || (type == XMLAttDef::IDRefs) - ); - - // Some trigger flags to avoid issuing redundant errors and whatnot - bool sawOneValue; - bool alreadyCapped = false; - - // - // Make a copy of the text that we can mangle and get a pointer we can - // move through the value - // - - // Use a stack-based buffer, when possible... - XMLCh tempBuffer[100]; - - XMLCh* pszTmpVal = 0; - - ArrayJanitor<XMLCh> janTmpVal(0); - - if (XMLString::stringLen(attrValue) < sizeof(tempBuffer) / sizeof(tempBuffer[0])) - { - XMLString::copyString(tempBuffer, attrValue); - pszTmpVal = tempBuffer; - } - else - { - janTmpVal.reset(XMLString::replicate(attrValue)); - pszTmpVal = janTmpVal.get(); - } - - XMLCh* valPtr = pszTmpVal; - - while (true) - { - // Reset the trigger flags - sawOneValue = false; - - // - // Make sure the first character is a valid first name char, i.e. - // if its a Name value. For NmToken values we don't treat the first - // char any differently. - // - if (firstNameChar) - { - // If its not, emit and error but try to keep going - if (!XMLReader::isFirstNameChar(*valPtr)) - emitError(XMLValid::AttrValNotName, fullName); - valPtr++; - } - - // Make sure all the remaining chars are valid name chars - while (*valPtr) - { - // - // If we hit a whitespace, its either a break between two - // or more values, or an error if we have a single value. - // - if (XMLReader::isWhitespace(*valPtr)) - { - if (!multipleValues) - { - emitError(XMLValid::NoMultipleValues, fullName); - return; - } - break; - } - - if (!XMLReader::isNameChar(*valPtr)) - { - emitError(XMLValid::AttrValNotName, fullName); - return; - } - valPtr++; - } - - // - // Cap it off at the current non-name char. If already capped, - // then remember this. - // - if (!(*valPtr)) - alreadyCapped = true; - *valPtr = 0; - - // - // If this type of attribute requires that we track reference - // stuff, then handle that. - // - if (isARefType) - { - if ((type == XMLAttDef::ID) - || (type == XMLAttDef::IDRef) - || (type == XMLAttDef::IDRefs)) - { - XMLRefInfo* find = getScanner()->getIDRefList()->get(pszTmpVal); - if (find) - { - if (find->getDeclared() && (type == XMLAttDef::ID)) - emitError(XMLValid::ReusedIDValue, pszTmpVal); - } - else - { - find = new XMLRefInfo(pszTmpVal); - getScanner()->getIDRefList()->put((void*)find->getRefName(), find); - } - - // - // Mark it declared or used, which might be redundant in some cases - // but not worth checking - // - if (type == XMLAttDef::ID) - find->setDeclared(true); - else - find->setUsed(true); - } - } - else if ((type == XMLAttDef::Entity) || (type == XMLAttDef::Entities)) - { - // - // If its refering to a entity, then look up the name in the - // general entity pool. If not there, then its an error. If its - // not an external unparsed entity, then its an error. - // - const XMLEntityDecl* decl = getScanner()->getEntityDecl(pszTmpVal); - if (decl) - { - if (!decl->isUnparsed()) - emitError(XMLValid::BadEntityRefAttr, fullName); - } - else - { - emitError - ( - XMLValid::UnknownEntityRefAttr - , fullName - , pszTmpVal - ); - } - } - else if ((type == XMLAttDef::Notation) || (type == XMLAttDef::Enumeration)) - { - // - // Make sure that this value maps to one of the enumeration or - // notation values in the enumList parameter. We don't have to - // look it up in the notation pool (if a notation) because we - // will look up the enumerated values themselves. If they are in - // the notation pool (after the DTD is parsed), then obviously - // this value will be legal since it matches one of them. - // - if (!XMLString::isInList(pszTmpVal, enumList)) - emitError(XMLValid::DoesNotMatchEnumList, fullName); - } - - // If not doing multiple values, then we are done - if (!multipleValues) - break; - - // - // If we are at the end, then break out now, else move up to the - // next char and update the base pointer. - // - if (alreadyCapped) - break; - - valPtr++; - pszTmpVal = valPtr; - } - -} - -void DTDValidator::preContentValidation(bool reuseGrammar) -{ - // - // Lets enumerate all of the elements in the element decl pool - // and put out an error for any that did not get declared. - // We also check all of the attributes as well. - // - NameIdPoolEnumerator<DTDElementDecl> elemEnum = fDTDGrammar->getElemEnumerator(); - while (elemEnum.hasMoreElements()) - { - const DTDElementDecl& curElem = elemEnum.nextElement(); - const DTDElementDecl::CreateReasons reason = curElem.getCreateReason(); - - // - // See if this element decl was ever marked as declared. If - // not, then put out an error. In some cases its just - // a warning, such as being referenced in a content model. - // - if (reason != XMLElementDecl::Declared) - { - if (reason == XMLElementDecl::AttList) - { - getScanner()->emitError - ( - XMLErrs::UndeclaredElemInAttList - , curElem.getFullName() - ); - } - else if (reason == XMLElementDecl::AsRootElem) - { - // It's ok that the root element is not declared in the DTD - /* - emitError - ( - XMLValid::UndeclaredElemInDocType - , curElem.getFullName() - );*/ - } - else if (reason == XMLElementDecl::InContentModel) - { - getScanner()->emitError - ( - XMLErrs::UndeclaredElemInCM - , curElem.getFullName() - ); - } - else - { - #if defined(XERCES_DEBUG) - if(reuseGrammar && reason == XMLElementDecl::JustFaultIn){ - } - else - ThrowXML(RuntimeException, XMLExcepts::DTD_UnknownCreateReason); - #endif - } - } - - // - // Check all of the attributes of the current element. - // We check for: - // - // 1) Multiple ID attributes - // 2) That all of the default values of attributes are - // valid for their type. - // 3) That for any notation types, that their lists - // of possible values refer to declared notations. - // - XMLAttDefList& attDefList = curElem.getAttDefList(); - bool seenId = false; - while (attDefList.hasMoreElements()) - { - const XMLAttDef& curAttDef = attDefList.nextElement(); - - if (curAttDef.getType() == XMLAttDef::ID) - { - if (seenId) - { - emitError - ( - XMLValid::MultipleIdAttrs - , curElem.getFullName() - ); - break; - } - - seenId = true; - } - else if (curAttDef.getType() == XMLAttDef::Notation) - { - // - // We need to verify that all of its possible values - // (in the enum list) refer to valid notations. - // - XMLCh* list = XMLString::replicate(curAttDef.getEnumeration()); - ArrayJanitor<XMLCh> janList(list); - - // - // Search forward for a space or a null. If a null, - // we are done. If a space, cap it and look it up. - // - bool breakFlag = false; - XMLCh* listPtr = list; - XMLCh* lastPtr = listPtr; - while (true) - { - while (*listPtr && (*listPtr != chSpace)) - listPtr++; - - // - // If at the end, indicate we need to break after - // this one. Else, cap it off here. - // - if (!*listPtr) - breakFlag = true; - else - *listPtr = chNull; - - if (!fDTDGrammar->getNotationDecl(lastPtr)) - { - emitError - ( - XMLValid::UnknownNotRefAttr - , curAttDef.getFullName() - , lastPtr - ); - } - - // Break out if we hit the end last time - if (breakFlag) - break; - - // Else move upwards and try again - listPtr++; - lastPtr = listPtr; - } - } - - // If it has a default/fixed value, then validate it - if (curAttDef.getValue()) - { - validateAttrValue - ( - &curAttDef - , curAttDef.getValue() - ); - } - } - } - - // - // And enumerate all of the general entities. If any of them - // reference a notation, then make sure the notation exists. - // - NameIdPoolEnumerator<DTDEntityDecl> entEnum = getScanner()->getEntityEnumerator(); - while (entEnum.hasMoreElements()) - { - const DTDEntityDecl& curEntity = entEnum.nextElement(); - - if (!curEntity.getNotationName()) - continue; - - // It has a notation name, so look it up - if (!fDTDGrammar->getNotationDecl(curEntity.getNotationName())) - { - emitError - ( - XMLValid::NotationNotDeclared - , curEntity.getNotationName() - ); - } - } -} - -void DTDValidator::postParseValidation() -{ - // - // At this time, there is nothing to do here. The scanner itself handles - // ID/IDREF validation, since that is the same no matter what kind of - // validator. - // -} diff --git a/src/validators/DTD/DTDValidator.hpp b/src/validators/DTD/DTDValidator.hpp deleted file mode 100644 index ff24dca150b8880e4239a8d02d7ef84f0af9d0f0..0000000000000000000000000000000000000000 --- a/src/validators/DTD/DTDValidator.hpp +++ /dev/null @@ -1,228 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999-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$ - * Revision 1.13 2001/11/13 13:25:28 tng - * Deprecate function XMLValidator::checkRootElement. - * - * Revision 1.12 2001/06/05 16:51:20 knoaman - * Add 'const' to getGrammar - submitted by Peter A. Volchek. - * - * Revision 1.11 2001/05/11 13:27:11 tng - * Copyright update. - * - * Revision 1.10 2001/05/03 20:34:37 tng - * Schema: SchemaValidator update - * - * Revision 1.9 2001/04/19 18:17:23 tng - * Schema: SchemaValidator update, and use QName in Content Model - * - * Revision 1.8 2001/03/21 21:56:21 tng - * Schema: Add Schema Grammar, Schema Validator, and split the DTDValidator into DTDValidator, DTDScanner, and DTDGrammar. - * - * Revision 1.7 2001/02/26 19:22:08 tng - * Schema: add parameter prefix in findElem and findAttr. - * - * Revision 1.6 2000/08/09 22:08:48 jpolast - * added const XMLCh* getURIText() as per XMLValidator. - * allows parsers to use const URIs instead of appending - * to a XMLBuffer. - * - * Revision 1.5 2000/04/06 19:00:07 roddey - * Added a getter for the doc type handler. - * - * Revision 1.4 2000/02/24 20:16:49 abagchi - * Swat for removing Log from API docs - * - * Revision 1.3 2000/02/09 21:42:38 abagchi - * Copyright swat - * - * Revision 1.2 2000/01/12 23:52:48 roddey - * These are trivial changes required to get the C++ and Java versions - * of error messages more into sync. Mostly it was where the Java version - * was passing out one or more parameter than the C++ version was. In - * some cases the change just required an extra parameter to get the - * needed info to the place where the error was issued. - * - * Revision 1.1.1.1 1999/11/09 01:03:36 twl - * Initial checkin - * - * Revision 1.5 1999/11/08 20:45:41 rahul - * Swat for adding in Product name and CVS comment log variable. - * - */ - - - -#if !defined(DTDVALIDATOR_HPP) -#define DTDVALIDATOR_HPP - -#include <util/NameIdPool.hpp> -#include <framework/XMLValidator.hpp> -#include <validators/DTD/DTDGrammar.hpp> - -class XMLMsgLoader; - - -// -// This is a derivative of the abstract validator interface. This class -// implements a validator that supports standard XML 1.0 DTD semantics. -// This class handles scanning the internal and external subsets of the -// DTD, and provides the standard validation services against the DTD info -// it found. -// -class VALIDATORS_EXPORT DTDValidator : public XMLValidator -{ -public: - // ----------------------------------------------------------------------- - // Constructors and Destructor - // ----------------------------------------------------------------------- - DTDValidator(XMLErrorReporter* const errReporter = 0); - virtual ~DTDValidator(); - - // ----------------------------------------------------------------------- - // Implementation of the XMLValidator interface - // ----------------------------------------------------------------------- - virtual int checkContent - ( - XMLElementDecl* const elemDecl - , QName** const children - , const unsigned int childCount - ); - - virtual void faultInAttr - ( - XMLAttr& toFill - , const XMLAttDef& attDef - ) const; - - virtual void preContentValidation(bool reuseGrammar); - - virtual void postParseValidation(); - - virtual void reset(); - - virtual bool requiresNamespaces() const; - - virtual void validateAttrValue - ( - const XMLAttDef* attDef - , const XMLCh* const attrValue - ); - virtual void validateElement - ( - const XMLElementDecl* elemDef - ); - virtual Grammar* getGrammar() const; - virtual void setGrammar(Grammar* aGrammar); - - // ----------------------------------------------------------------------- - // Virtual DTD handler interface. - // ----------------------------------------------------------------------- - virtual bool handlesDTD() const; - - // ----------------------------------------------------------------------- - // Virtual Schema handler interface. handlesSchema() always return false. - // ----------------------------------------------------------------------- - virtual bool handlesSchema() const; - -private: - - // ----------------------------------------------------------------------- - // Private data members - // - // fDTDGrammar - // The DTD information stored. - // - // ----------------------------------------------------------------------- - DTDGrammar* fDTDGrammar; -}; - -// --------------------------------------------------------------------------- -// Virtual interface -// --------------------------------------------------------------------------- -inline Grammar* DTDValidator::getGrammar() const { - return fDTDGrammar; -} - -inline void DTDValidator::setGrammar(Grammar* aGrammar) { - fDTDGrammar = (DTDGrammar*) aGrammar; -} - -inline void DTDValidator::validateElement (const XMLElementDecl* elemDef) { - // no special DTD Element validation -} - -// --------------------------------------------------------------------------- -// DTDValidator: DTD handler interface -// --------------------------------------------------------------------------- -inline bool DTDValidator::handlesDTD() const -{ - // We definitely want to handle DTD scanning - return true; -} - -// --------------------------------------------------------------------------- -// DTDValidator: Schema handler interface -// --------------------------------------------------------------------------- -inline bool DTDValidator::handlesSchema() const -{ - // No Schema scanning - return false; -} - -#endif diff --git a/src/validators/DTD/DocTypeHandler.hpp b/src/validators/DTD/DocTypeHandler.hpp deleted file mode 100644 index e596ffca0dce43c72e42681733f896d9ecbfaefe..0000000000000000000000000000000000000000 --- a/src/validators/DTD/DocTypeHandler.hpp +++ /dev/null @@ -1,202 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999-2000 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$ - * Revision 1.5 2001/06/19 16:43:46 tng - * Correct description of DocTypeHandler - * - * Revision 1.4 2000/03/02 19:55:39 roddey - * This checkin includes many changes done while waiting for the - * 1.1.0 code to be finished. I can't list them all here, but a list is - * available elsewhere. - * - * Revision 1.3 2000/02/24 20:16:49 abagchi - * Swat for removing Log from API docs - * - * Revision 1.2 2000/02/09 21:42:39 abagchi - * Copyright swat - * - * Revision 1.1.1.1 1999/11/09 01:03:21 twl - * Initial checkin - * - * Revision 1.2 1999/11/08 20:45:43 rahul - * Swat for adding in Product name and CVS comment log variable. - * - */ - - - -#if !defined(DOCTYPEHANDLER_HPP) -#define DOCTYPEHANDLER_HPP - -#include <util/XercesDefs.hpp> -#include <framework/XMLNotationDecl.hpp> -#include <validators/DTD/DTDAttDef.hpp> -#include <validators/DTD/DTDElementDecl.hpp> -#include <validators/DTD/DTDEntityDecl.hpp> - - -// -// This abstract class defines the document type handler API's which can be -// used to process the DTD events generated by the DTDScanner as it scans the -// internal and external subset. - -class VALIDATORS_EXPORT DocTypeHandler -{ -public: - // ----------------------------------------------------------------------- - // Constructors and Destructor - // ----------------------------------------------------------------------- - DocTypeHandler() - { - } - - virtual ~DocTypeHandler() - { - } - - - // ----------------------------------------------------------------------- - // The document type handler virtual handler interface - // ----------------------------------------------------------------------- - virtual void attDef - ( - const DTDElementDecl& elemDecl - , const DTDAttDef& attDef - , const bool ignoring - ) = 0; - - virtual void doctypeComment - ( - const XMLCh* const comment - ) = 0; - - virtual void doctypeDecl - ( - const DTDElementDecl& elemDecl - , const XMLCh* const publicId - , const XMLCh* const systemId - , const bool hasIntSubset - ) = 0; - - virtual void doctypePI - ( - const XMLCh* const target - , const XMLCh* const data - ) = 0; - - virtual void doctypeWhitespace - ( - const XMLCh* const chars - , const unsigned int length - ) = 0; - - virtual void elementDecl - ( - const DTDElementDecl& decl - , const bool isIgnored - ) = 0; - - virtual void endAttList - ( - const DTDElementDecl& elemDecl - ) = 0; - - virtual void endIntSubset() = 0; - - virtual void endExtSubset() = 0; - - virtual void entityDecl - ( - const DTDEntityDecl& entityDecl - , const bool isPEDecl - , const bool isIgnored - ) = 0; - - virtual void resetDocType() = 0; - - virtual void notationDecl - ( - const XMLNotationDecl& notDecl - , const bool isIgnored - ) = 0; - - virtual void startAttList - ( - const DTDElementDecl& elemDecl - ) = 0; - - virtual void startIntSubset() = 0; - - virtual void startExtSubset() = 0; - - virtual void TextDecl - ( - const XMLCh* const versionStr - , const XMLCh* const encodingStr - ) = 0; - - -private: - // ----------------------------------------------------------------------- - // Unimplemented constructors and operators - // ----------------------------------------------------------------------- - DocTypeHandler(const DocTypeHandler&); - void operator=(const DocTypeHandler&); -}; - -#endif diff --git a/src/validators/DTD/Makefile.in b/src/validators/DTD/Makefile.in deleted file mode 100644 index 0f9f9ba8d8d2c34fa6c25ded31372710c8d78f3b..0000000000000000000000000000000000000000 --- a/src/validators/DTD/Makefile.in +++ /dev/null @@ -1,169 +0,0 @@ -# -# The Apache Software License, Version 1.1 -# -# Copyright (c) 1999-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$ -# Revision 1.11 2001/07/06 17:12:10 tng -# Automatic build of single-threaded library. By Martin Kalen. -# -# Revision 1.10 2001/06/27 17:09:47 tng -# [Bug 1147] Headers install in wrong directory. By Murray Cumming. -# -# Revision 1.9 2001/05/11 13:27:11 tng -# Copyright update. -# -# Revision 1.8 2001/03/21 21:56:22 tng -# Schema: Add Schema Grammar, Schema Validator, and split the DTDValidator into DTDValidator, DTDScanner, and DTDGrammar. -# -# Revision 1.7 2001/02/16 14:58:56 tng -# Schema: Update Makefile, configure files, project files, and include path in -# certain cpp files because of the move of the common Content Model files. By Pei Yong Zhang. -# -# Revision 1.6 2000/03/01 22:30:04 abagchi -# Object files are now created directly under obj directory -# -# Revision 1.5 2000/02/04 23:48:54 abagchi -# Made sure all targets are appended with :: not single : -# -# Revision 1.4 2000/02/01 23:44:01 abagchi -# AS/400 related change -# -# Revision 1.3 1999/12/14 23:53:36 rahulj -# Removed the offending Ctrl-M's from the commit message -# logs which was giving packaging problems. -# -# PR: -# Obtained from: -# Submitted by: -# Reviewed by: -# -# Revision 1.2 1999/11/23 02:01:05 rahulj -# Code now works under HPUX 11. Tested inmemory message loader. -# Revamped makefiles. Builds with both DCE threads as well as pthread libraries. -# -# Revision 1.1.1.1 1999/11/09 01:03:42 twl -# Initial checkin -# -# Revision 1.3 1999/11/08 20:45:43 rahul -# Swat for adding in Product name and CVS comment log variable. -#: -# - -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 = DTD - -VALIDATORS_DTD_CPP_PUBHEADERS = \ - DTDAttDef.hpp \ - DTDAttDefList.hpp \ - DTDElementDecl.hpp \ - DTDEntityDecl.hpp \ - DTDGrammar.hpp \ - DTDScanner.hpp \ - DTDValidator.hpp \ - DocTypeHandler.hpp - -VALIDATORS_DTD_CPP_PRIVHEADERS = - -VALIDATORS_DTD_C_FILES = - -VALIDATORS_DTD_CPP_OBJECTS = \ - DTDAttDef.$(TO) \ - DTDAttDefList.$(TO) \ - DTDElementDecl.$(TO) \ - DTDGrammar.$(TO) \ - DTDScanner.$(TO) \ - DTDValidator.$(TO) - -all:: includes $(VALIDATORS_DTD_CPP_OBJECTS) - -includes:: pubheaders $(VALIDATORS_DTD_C_FILES) - -pubheaders:: - -mkdir -p $(XML_INC_DIR)/$(MODULE)/$(SUBMODULE) - $(CP) $(VALIDATORS_DTD_CPP_PUBHEADERS) $(VALIDATORS_DTD_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_DTD_CPP_OBJECTS)) - -distclean:: clean - $(RM) Makefile $(DEPFILE) - @echo "Removing all $(MODULE)/$(SUBMODULE) header files ..." - $(RM2) $(addprefix $(XML_INC_DIR)/$(MODULE)/$(SUBMODULE)/,$(VALIDATORS_DTD_CPP_PUBHEADERS)) - -install:: - -mkdir -p $(PREFIX_INCLUDE)/$(MODULE)/$(SUBMODULE) - $(CP) $(VALIDATORS_DTD_CPP_PUBHEADERS) $(VALIDATORS_DTD_C_FILES) $(PREFIX_INCLUDE)/$(MODULE)/$(SUBMODULE) diff --git a/src/validators/Makefile.in b/src/validators/Makefile.in deleted file mode 100644 index 46486f8f10576baa27e4bfdb3007335d1d0dbaca..0000000000000000000000000000000000000000 --- a/src/validators/Makefile.in +++ /dev/null @@ -1,173 +0,0 @@ -# -# The Apache Software License, Version 1.1 -# -# Copyright (c) 1999-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$ -# Revision 1.6 2001/07/08 20:13:04 jberry -# Simplify file existance checks -# -# Revision 1.5 2001/07/08 19:54:35 jberry -# Fix clean and distclean targets; broken because rm fails if passed no files -# -# Revision 1.4 2001/07/06 17:12:09 tng -# Automatic build of single-threaded library. By Martin Kalen. -# -# Revision 1.3 2001/06/27 17:09:45 tng -# [Bug 1147] Headers install in wrong directory. By Murray Cumming. -# -# Revision 1.2 2001/05/11 13:27:06 tng -# Copyright update. -# -# Revision 1.1 2001/02/27 18:48:22 tng -# Schema: Add SchemaAttDef, SchemaElementDecl, SchemaAttDefList. -# -# -# - -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@ -NETACCESSOR = @netaccessor@ -THREADS = @threads@ - -MODULE = validators - -include ../Makefile.incl - -VALIDATORS_CPP_PUBHEADERS = - -VALIDATORS_CPP_PRIVHEADERS = - -VALIDATORS_C_FILES = - -VALIDATORS_CPP_OBJECTS = - -all:: includes $(VALIDATORS_CPP_OBJECTS) common datatype DTD schema - -includes:: pubheaders $(VALIDATORS_C_FILES) - cd common ; $(MAKE) $@ ; cd .. - cd datatype ; $(MAKE) $@ ; cd .. - cd DTD ; $(MAKE) $@ ; cd .. - cd schema ; $(MAKE) $@ ; cd .. - - -common:: - cd common ; $(MAKE) ; cd .. - - -datatype:: - cd datatype ; $(MAKE) ; cd .. - - -DTD:: - cd DTD ; $(MAKE) ; cd .. - - -schema:: - cd schema ; $(MAKE) ; cd .. - - -pubheaders:: - -mkdir -p $(XML_INC_DIR)/$(MODULE) - - -# this may generate unnecessary dependencies, but it makes life easier -depend:: includes - $(MAKE_DEPEND) $(XML_INCL) *.cpp > $(DEPFILE) - - -clean:: - @echo "Making clean in $(MODULE) ..." -ifneq ($(strip $(VALIDATORS_CPP_OBJECTS)),) - $(RM2) $(addprefix $(XML_OBJ_DIR)/,$(VALIDATORS_CPP_OBJECTS)) -endif - cd common ; $(MAKE) $@ ; cd .. - cd datatype ; $(MAKE) $@ ; cd .. - cd DTD ; $(MAKE) $@ ; cd .. - cd schema ; $(MAKE) $@ ; cd .. - - - -distclean:: clean - $(RM) Makefile $(DEPFILE) - @echo "Removing all $(MODULE) header files ..." -ifneq ($(strip $(VALIDATORS_CPP_PUBHEADERS)),) - $(RM2) $(addprefix $(XML_INC_DIR)/$(MODULE)/,$(VALIDATORS_CPP_PUBHEADERS)) -endif -ifneq ($(strip $(VALIDATORS_C_FILES)),) - $(RM2) $(addprefix $(XML_INC_DIR)/$(MODULE)/,$(VALIDATORS_C_FILES)) -endif - cd common ; $(MAKE) $@ ; cd .. - cd datatype ; $(MAKE) $@ ; cd .. - cd DTD ; $(MAKE) $@ ; cd .. - cd schema ; $(MAKE) $@ ; cd .. - - -install:: - -mkdir -p $(PREFIX_INCLUDE)/$(MODULE) - cd common ; $(MAKE) $@ ; cd .. - cd datatype ; $(MAKE) $@ ; cd .. - cd DTD ; $(MAKE) $@ ; cd .. - cd schema ; $(MAKE) $@ ; cd .. diff --git a/src/validators/common/AllContentModel.cpp b/src/validators/common/AllContentModel.cpp deleted file mode 100644 index 76feda46c2e1cb7909b5f6438d53a3ed03d356a0..0000000000000000000000000000000000000000 --- a/src/validators/common/AllContentModel.cpp +++ /dev/null @@ -1,376 +0,0 @@ -/* - * 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$ - * Revision 1.3 2001/11/21 14:30:13 knoaman - * Fix for UPA checking. - * - * Revision 1.2 2001/08/27 12:19:00 tng - * Schema: AllContentModel UPA Check typo fix - * - * Revision 1.1 2001/08/24 12:48:48 tng - * Schema: AllContentModel - * - */ - - -// --------------------------------------------------------------------------- -// Includes -// --------------------------------------------------------------------------- -#include <util/RuntimeException.hpp> -#include <framework/XMLElementDecl.hpp> -#include <framework/XMLValidator.hpp> -#include <validators/common/ContentSpecNode.hpp> -#include <validators/common/AllContentModel.hpp> -#include <validators/schema/SubstitutionGroupComparator.hpp> -#include <validators/schema/XercesElementWildcard.hpp> - -// --------------------------------------------------------------------------- -// AllContentModel: Constructors and Destructor -// --------------------------------------------------------------------------- -AllContentModel::AllContentModel(ContentSpecNode* const parentContentSpec - , const bool isMixed) : - fCount(0) - , fChildren(0) - , fChildOptional(0) - , fNumRequired(0) - , fIsMixed(isMixed) -{ - // - // Create a vector of unsigned ints that will be filled in with the - // ids of the child nodes. It will be expanded as needed but we give - // it an initial capacity of 64 which should be more than enough for - // 99% of the scenarios. - // - - ValueVectorOf<QName*> children(64); - ValueVectorOf<bool> childOptional(64); - - // - // Get the parent element's content spec. This is the head of the tree - // of nodes that describes the content model. We will iterate this - // tree. - // - ContentSpecNode* curNode = parentContentSpec; - if (!curNode) - ThrowXML(RuntimeException, XMLExcepts::CM_NoParentCSN); - - // And now call the private recursive method that iterates the tree - buildChildList(curNode, children, childOptional); - - // - // And now we know how many elements we need in our member list. So - // fill them in. - // - fCount = children.size(); - fChildren = new QName*[fCount]; - fChildOptional = new bool[fCount]; - for (unsigned int index = 0; index < fCount; index++) { - fChildren[index] = children.elementAt(index); - fChildOptional[index] = childOptional.elementAt(index); - } -} - -AllContentModel::~AllContentModel() -{ - delete [] fChildren; - delete [] fChildOptional; -} - -// --------------------------------------------------------------------------- -// AllContentModel: Implementation of the ContentModel virtual interface -// --------------------------------------------------------------------------- -// -//Under the XML Schema mixed model, -//the order and number of child elements appearing in an instance -//must agree with -//the order and number of child elements specified in the model. -// -int -AllContentModel::validateContent( QName** const children - , const unsigned int childCount - , const unsigned int emptyNamespaceId) const -{ - // If <all> had minOccurs of zero and there are - // no children to validate, trivially validate - if (!fNumRequired && !childCount) - return -1; - - // Check for duplicate element - bool* elementSeen = new bool[fCount]; - - // initialize the array - for (unsigned int i = 0; i < fCount; i++) - elementSeen[i] = false; - - // keep track of the required element seen - unsigned int numRequiredSeen = 0; - - for (unsigned int outIndex = 0; outIndex < childCount; outIndex++) { - // Get the current child out of the source index - const QName* curChild = children[outIndex]; - - // If its PCDATA, then we just accept that - if (fIsMixed && curChild->getURI() == XMLElementDecl::fgPCDataElemId) - continue; - - // And try to find it in our list - unsigned int inIndex = 0; - for (; inIndex < fCount; inIndex++) - { - const QName* inChild = fChildren[inIndex]; - if ((inChild->getURI() == curChild->getURI()) && - (!XMLString::compareString(inChild->getLocalPart(), curChild->getLocalPart()))) { - // found it - // If this element was seen already, indicate an error was - // found at the duplicate index. - if (elementSeen[inIndex]) { - delete [] elementSeen; - return outIndex; - } - else - elementSeen[inIndex] = true; - - if (!fChildOptional[inIndex]) - numRequiredSeen++; - - break; - } - } - - // We did not find this one, so the validation failed - if (inIndex == fCount) { - delete [] elementSeen; - return outIndex; - } - - } - - delete [] elementSeen; - - // Were all the required elements of the <all> encountered? - if (numRequiredSeen != fNumRequired) { - return childCount; - } - - // Everything seems to be ok, so return success - // success - return -1; -} - - -int AllContentModel::validateContentSpecial(QName** const children - , const unsigned int childCount - , const unsigned int emptyNamespaceId - , GrammarResolver* const pGrammarResolver - , XMLStringPool* const pStringPool) const -{ - - SubstitutionGroupComparator comparator(pGrammarResolver, pStringPool); - - // If <all> had minOccurs of zero and there are - // no children to validate, trivially validate - if (!fNumRequired && !childCount) - return -1; - - // Check for duplicate element - bool* elementSeen = new bool[fCount]; - - // initialize the array - for (unsigned int i = 0; i < fCount; i++) - elementSeen[i] = false; - - // keep track of the required element seen - unsigned int numRequiredSeen = 0; - - for (unsigned int outIndex = 0; outIndex < childCount; outIndex++) { - // Get the current child out of the source index - QName* const curChild = children[outIndex]; - - // If its PCDATA, then we just accept that - if (fIsMixed && curChild->getURI() == XMLElementDecl::fgPCDataElemId) - continue; - - // And try to find it in our list - unsigned int inIndex = 0; - for (; inIndex < fCount; inIndex++) - { - QName* const inChild = fChildren[inIndex]; - if ( comparator.isEquivalentTo(curChild, inChild)) { - // match - // If this element was seen already, indicate an error was - // found at the duplicate index. - if (elementSeen[inIndex]) { - delete [] elementSeen; - return outIndex; - } - else - elementSeen[inIndex] = true; - - if (!fChildOptional[inIndex]) - numRequiredSeen++; - - break; - } - } - - // We did not find this one, so the validation failed - if (inIndex == fCount) { - delete [] elementSeen; - return outIndex; - } - - } - - delete [] elementSeen; - - // Were all the required elements of the <all> encountered? - if (numRequiredSeen != fNumRequired) { - return childCount; - } - - // Everything seems to be ok, so return success - // success - return -1; - -} - -void AllContentModel::checkUniqueParticleAttribution - ( - SchemaGrammar* const pGrammar - , GrammarResolver* const pGrammarResolver - , XMLStringPool* const pStringPool - , XMLValidator* const pValidator - , unsigned int* const pContentSpecOrgURI - ) -{ - SubstitutionGroupComparator comparator(pGrammarResolver, pStringPool); - - unsigned int i, j; - - // rename back - for (i = 0; i < fCount; i++) { - unsigned int orgURIIndex = fChildren[i]->getURI(); - fChildren[i]->setURI(pContentSpecOrgURI[orgURIIndex]); - } - - // check whether there is conflict between any two leaves - for (i = 0; i < fCount; i++) { - for (j = i+1; j < fCount; j++) { - // If this is text in a Schema mixed content model, skip it. - if ( fIsMixed && - (( fChildren[i]->getURI() == XMLElementDecl::fgPCDataElemId) || - ( fChildren[j]->getURI() == XMLElementDecl::fgPCDataElemId))) - continue; - - if (XercesElementWildcard::conflict(pGrammar, - ContentSpecNode::Leaf, - fChildren[i], - ContentSpecNode::Leaf, - fChildren[j], - &comparator)) { - pValidator->emitError(XMLValid::UniqueParticleAttributionFail, - fChildren[i]->getRawName(), - fChildren[j]->getRawName()); - } - } - } -} - -// --------------------------------------------------------------------------- -// AllContentModel: Private helper methods -// --------------------------------------------------------------------------- -void -AllContentModel::buildChildList(ContentSpecNode* const curNode - , ValueVectorOf<QName*>& toFill - , ValueVectorOf<bool>& toOptional) -{ - // Get the type of spec node our current node is - const ContentSpecNode::NodeTypes curType = curNode->getType(); - - if (curType == ContentSpecNode::All) - { - // Get both the child node pointers - ContentSpecNode* leftNode = curNode->getFirst(); - ContentSpecNode* rightNode = curNode->getSecond(); - - // Recurse on the left and right nodes - buildChildList(leftNode, toFill, toOptional); - buildChildList(rightNode, toFill, toOptional); - } - else if (curType == ContentSpecNode::Leaf) - { - // At leaf, add the element to list of elements permitted in the all - toFill.addElement(curNode->getElement()); - toOptional.addElement(false); - fNumRequired++; - } - else if (curType == ContentSpecNode::ZeroOrOne) - { - // At ZERO_OR_ONE node, subtree must be an element - // that was specified with minOccurs=0, maxOccurs=1 - ContentSpecNode* leftNode = curNode->getFirst(); - if (leftNode->getType() != ContentSpecNode::Leaf) - ThrowXML(RuntimeException, XMLExcepts::CM_UnknownCMSpecType); - - toFill.addElement(leftNode->getElement()); - toOptional.addElement(true); - } - else - ThrowXML(RuntimeException, XMLExcepts::CM_UnknownCMSpecType); -} - diff --git a/src/validators/common/AllContentModel.hpp b/src/validators/common/AllContentModel.hpp deleted file mode 100644 index 94ba5b52754b85557f81268083bc1f97ff9ee932..0000000000000000000000000000000000000000 --- a/src/validators/common/AllContentModel.hpp +++ /dev/null @@ -1,193 +0,0 @@ -/* - * 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$ - * Revision 1.2 2001/11/21 14:30:13 knoaman - * Fix for UPA checking. - * - * Revision 1.1 2001/08/24 12:48:48 tng - * Schema: AllContentModel - * - */ - - -#if !defined(ALLCONTENTMODEL_HPP) -#define ALLCONTENTMODEL_HPP - -#include <util/ValueVectorOf.hpp> -#include <framework/XMLContentModel.hpp> -#include <validators/common/ContentLeafNameTypeVector.hpp> - -class ContentSpecNode; - -// -// AllContentModel is a derivative of the abstract content model base -// class that handles the special case of <all> feature in schema. If a model -// is <all>, all non-optional children must appear -// -// So, all we have to do is to keep an array of the possible children and -// validate by just looking up each child being validated by looking it up -// in the list, and make sure all non-optional children appear. -// -class AllContentModel : public XMLContentModel -{ -public : - // ----------------------------------------------------------------------- - // Constructors and Destructor - // ----------------------------------------------------------------------- - AllContentModel - ( - ContentSpecNode* const parentContentSpec - , const bool isMixed - ); - - ~AllContentModel(); - - // ----------------------------------------------------------------------- - // Implementation of the ContentModel virtual interface - // ----------------------------------------------------------------------- - virtual int validateContent - ( - QName** const children - , const unsigned int childCount - , const unsigned int emptyNamespaceId - ) const; - - virtual int validateContentSpecial - ( - QName** const children - , const unsigned int childCount - , const unsigned int emptyNamespaceId - , GrammarResolver* const pGrammarResolver - , XMLStringPool* const pStringPool - ) const; - - virtual ContentLeafNameTypeVector* getContentLeafNameTypeVector() const ; - - virtual unsigned int getNextState(const unsigned int currentState, - const unsigned int elementIndex) const; - - virtual void checkUniqueParticleAttribution - ( - SchemaGrammar* const pGrammar - , GrammarResolver* const pGrammarResolver - , XMLStringPool* const pStringPool - , XMLValidator* const pValidator - , unsigned int* const pContentSpecOrgURI - ) ; - -private : - // ----------------------------------------------------------------------- - // Private helper methods - // ----------------------------------------------------------------------- - void buildChildList - ( - ContentSpecNode* const curNode - , ValueVectorOf<QName*>& toFill - , ValueVectorOf<bool>& toType - ); - - // ----------------------------------------------------------------------- - // Unimplemented constructors and operators - // ----------------------------------------------------------------------- - AllContentModel(); - AllContentModel(const AllContentModel&); - void operator=(const AllContentModel&); - - - // ----------------------------------------------------------------------- - // Private data members - // - // fCount - // The count of possible children in the fChildren member. - // - // fChildren - // The list of possible children that we have to accept. This array - // is allocated as large as needed in the constructor. - // - // fChildOptional - // The corresponding list of optional state of each child in fChildren - // True if the child is optional (i.e. minOccurs = 0). - // - // fNumRequired - // The number of required children in <all> (i.e. minOccurs = 1) - // - // fIsMixed - // AllContentModel with mixed PCDATA. - // ----------------------------------------------------------------------- - unsigned int fCount; - QName** fChildren; - bool* fChildOptional; - unsigned int fNumRequired; - bool fIsMixed; - -}; - -inline ContentLeafNameTypeVector* AllContentModel::getContentLeafNameTypeVector() const -{ - return 0; -} - -inline unsigned int -AllContentModel::getNextState(const unsigned int currentState, - const unsigned int elementIndex) const { - - return XMLContentModel::gInvalidTrans; -} - -#endif - diff --git a/src/validators/common/CMAny.cpp b/src/validators/common/CMAny.cpp deleted file mode 100644 index 9acab5b40e786a12c66b633444f0988ebeeee32d..0000000000000000000000000000000000000000 --- a/src/validators/common/CMAny.cpp +++ /dev/null @@ -1,167 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999-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$ - * Revision 1.6 2001/08/08 13:23:27 knoaman - * Fix condition check. - * - * Revision 1.5 2001/07/09 15:22:35 knoaman - * complete <any> declaration. - * - * Revision 1.4 2001/06/07 20:58:38 tng - * Fix no newline at the end warning. By Pei Yong Zhang. - * - * Revision 1.3 2001/05/11 13:27:14 tng - * Copyright update. - * - * Revision 1.2 2001/05/03 21:02:27 tng - * Schema: Add SubstitutionGroupComparator and update exception messages. By Pei Yong Zhang. - * - * Revision 1.1 2001/02/27 14:48:45 tng - * Schema: Add CMAny and ContentLeafNameTypeVector, by Pei Yong Zhang - * - */ - -// --------------------------------------------------------------------------- -// Includes -// --------------------------------------------------------------------------- -#include <util/XercesDefs.hpp> -#include <util/RuntimeException.hpp> -#include <validators/common/CMStateSet.hpp> -#include <validators/common/CMAny.hpp> - -// --------------------------------------------------------------------------- -// CMUnaryOp: Constructors and Destructor -// --------------------------------------------------------------------------- -CMAny::CMAny( const ContentSpecNode::NodeTypes type - , const unsigned int URI - , const unsigned int position ) : - CMNode(type) - , fURI(URI) - , fPosition(position) -{ - if ((type & 0x0f) != ContentSpecNode::Any - && (type & 0x0f) != ContentSpecNode::Any_Other - && (type & 0x0f) != ContentSpecNode::Any_NS) - { - ThrowXML1(RuntimeException, - XMLExcepts::CM_NotValidSpecTypeForNode, - "CMAny"); - } - -} - -CMAny::~CMAny() -{ -} - -// --------------------------------------------------------------------------- -// Getter methods -// --------------------------------------------------------------------------- -unsigned int CMAny::getURI() const -{ - return fURI; -} - -unsigned int CMAny::getPosition() const -{ - return fPosition; -} - -// --------------------------------------------------------------------------- -// Setter methods -// --------------------------------------------------------------------------- -void CMAny::setPosition(const unsigned int newPosition) -{ - fPosition = newPosition; -} - -// --------------------------------------------------------------------------- -// Implementation of public CMNode virtual interface -// --------------------------------------------------------------------------- -bool CMAny::isNullable() const -{ - // Leaf nodes are never nullable unless its an epsilon node - return (fPosition == -1); -} - -// --------------------------------------------------------------------------- -// Implementation of protected CMNode virtual interface -// --------------------------------------------------------------------------- -void CMAny::calcFirstPos(CMStateSet& toSet) const -{ - // If we are an epsilon node, then the first pos is an empty set - if (fPosition == -1) - toSet.zeroBits(); - else - // Otherwise, its just the one bit of our position - toSet.setBit(fPosition); - - return; -} - -void CMAny::calcLastPos(CMStateSet& toSet) const -{ - // If we are an epsilon node, then the last pos is an empty set - if (fPosition == -1) - toSet.zeroBits(); - // Otherwise, its just the one bit of our position - else - toSet.setBit(fPosition); - - return; -} diff --git a/src/validators/common/CMAny.hpp b/src/validators/common/CMAny.hpp deleted file mode 100644 index 079418ed4dbabbc3aa2209e9e75715c1cb772ef8..0000000000000000000000000000000000000000 --- a/src/validators/common/CMAny.hpp +++ /dev/null @@ -1,133 +0,0 @@ -/* - * 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$ - * Revision 1.2 2001/05/11 13:27:14 tng - * Copyright update. - * - * Revision 1.1 2001/02/27 14:48:46 tng - * Schema: Add CMAny and ContentLeafNameTypeVector, by Pei Yong Zhang - * - */ - -#if !defined(CMANY_HPP) -#define CMANY_HPP - -#include <util/XercesDefs.hpp> -#include <validators/common/CMNode.hpp> - -class CMStateSet; - -class CMAny : public CMNode -{ -public : - // ----------------------------------------------------------------------- - // Constructors - // ----------------------------------------------------------------------- - CMAny - ( - const ContentSpecNode::NodeTypes type - , const unsigned int URI - , const unsigned int position - ); - ~CMAny(); - - // ----------------------------------------------------------------------- - // Getter methods - // ----------------------------------------------------------------------- - unsigned int getURI() const; - - unsigned int getPosition() const; - - // ----------------------------------------------------------------------- - // Setter methods - // ----------------------------------------------------------------------- - void setPosition(const unsigned int newPosition); - - // ----------------------------------------------------------------------- - // Implementation of the public CMNode virtual interface - // ----------------------------------------------------------------------- - bool isNullable() const; - - -protected : - // ----------------------------------------------------------------------- - // Implementation of the protected CMNode virtual interface - // ----------------------------------------------------------------------- - void calcFirstPos(CMStateSet& toSet) const; - void calcLastPos(CMStateSet& toSet) const; - -private : - // ----------------------------------------------------------------------- - // Private data members - // - // fURI; - // URI of the any content model. This value is set if the type is - // of the following: - // XMLContentSpec.CONTENTSPECNODE_ANY, - // XMLContentSpec.CONTENTSPECNODE_ANY_OTHER. - // - // fPosition - // Part of the algorithm to convert a regex directly to a DFA - // numbers each leaf sequentially. If its -1, that means its an - // epsilon node. Zero and greater are non-epsilon positions. - // ----------------------------------------------------------------------- - unsigned int fURI; - unsigned int fPosition; -}; - -#endif diff --git a/src/validators/common/CMBinaryOp.cpp b/src/validators/common/CMBinaryOp.cpp deleted file mode 100644 index 2f07ebfac635f7cb9a9932e327565e080e83f71a..0000000000000000000000000000000000000000 --- a/src/validators/common/CMBinaryOp.cpp +++ /dev/null @@ -1,206 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999-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$ - * Revision 1.3 2001/05/11 13:27:15 tng - * Copyright update. - * - * Revision 1.2 2001/02/16 14:58:57 tng - * Schema: Update Makefile, configure files, project files, and include path in - * certain cpp files because of the move of the common Content Model files. By Pei Yong Zhang. - * - * Revision 1.1 2001/02/16 14:17:29 tng - * Schema: Move the common Content Model files that are shared by DTD - * and schema from 'DTD' folder to 'common' folder. By Pei Yong Zhang. - * - * Revision 1.3 2000/03/02 19:55:37 roddey - * This checkin includes many changes done while waiting for the - * 1.1.0 code to be finished. I can't list them all here, but a list is - * available elsewhere. - * - * Revision 1.2 2000/02/09 21:42:36 abagchi - * Copyright swatswat - * - * Revision 1.1.1.1 1999/11/09 01:03:00 twl - * Initial checkin - * - * Revision 1.2 1999/11/08 20:45:35 rahul - * Swat for adding in Product name and CVS comment log variable. - * - */ - - -// --------------------------------------------------------------------------- -// Includes -// --------------------------------------------------------------------------- -#include <util/XercesDefs.hpp> -#include <util/RuntimeException.hpp> -#include <validators/common/ContentSpecNode.hpp> -#include <validators/common/CMBinaryOp.hpp> -#include <validators/common/CMStateSet.hpp> - - -// --------------------------------------------------------------------------- -// CMBinaryOp: Constructors -// --------------------------------------------------------------------------- -CMBinaryOp::CMBinaryOp( const ContentSpecNode::NodeTypes type - , CMNode* const leftToAdopt - , CMNode* const rightToAdopt) : - CMNode(type) - , fLeftChild(leftToAdopt) - , fRightChild(rightToAdopt) -{ - // Insure that its one of the types we require - if ((type != ContentSpecNode::Choice) - && (type != ContentSpecNode::Sequence)) - { - ThrowXML(RuntimeException, XMLExcepts::CM_BinOpHadUnaryType); - } -} - -CMBinaryOp::~CMBinaryOp() -{ - delete fLeftChild; - delete fRightChild; -} - - -// --------------------------------------------------------------------------- -// CMBinaryOp: Getter methods -// --------------------------------------------------------------------------- -const CMNode* CMBinaryOp::getLeft() const -{ - return fLeftChild; -} - -CMNode* CMBinaryOp::getLeft() -{ - return fLeftChild; -} - -const CMNode* CMBinaryOp::getRight() const -{ - return fRightChild; -} - -CMNode* CMBinaryOp::getRight() -{ - return fRightChild; -} - - -// --------------------------------------------------------------------------- -// CMBinaryOp: Implementation of the public CMNode virtual interface -// --------------------------------------------------------------------------- -bool CMBinaryOp::isNullable() const -{ - // - // If its an alternation, then if either child is nullable then - // this node is nullable. If its a concatenation, then both of - // them have to be nullable. - // - if (getType() == ContentSpecNode::Choice) - return (fLeftChild->isNullable() || fRightChild->isNullable()); - - return (fLeftChild->isNullable() && fRightChild->isNullable()); -} - - -// --------------------------------------------------------------------------- -// CMBinaryOp: Implementation of the protected CMNode virtual interface -// --------------------------------------------------------------------------- -void CMBinaryOp::calcFirstPos(CMStateSet& toSet) const -{ - if (getType() == ContentSpecNode::Choice) - { - // Its the the union of the first positions of our children. - toSet = fLeftChild->getFirstPos(); - toSet |= fRightChild->getFirstPos(); - } - else if (getType() == ContentSpecNode::Sequence) - { - // - // If our left child is nullable, then its the union of our - // children's first positions. Else is our left child's first - // positions. - // - toSet = fLeftChild->getFirstPos(); - if (fLeftChild->isNullable()) - toSet |= fRightChild->getFirstPos(); - } -} - -void CMBinaryOp::calcLastPos(CMStateSet& toSet) const -{ - if (getType() == ContentSpecNode::Choice) - { - // Its the the union of the first positions of our children. - toSet = fLeftChild->getLastPos(); - toSet |= fRightChild->getLastPos(); - } - else if (getType() == ContentSpecNode::Sequence) - { - // - // If our right child is nullable, then its the union of our - // children's last positions. Else is our right child's last - // positions. - // - toSet = fRightChild->getLastPos(); - if (fRightChild->isNullable()) - toSet |= fLeftChild->getLastPos(); - } -} diff --git a/src/validators/common/CMBinaryOp.hpp b/src/validators/common/CMBinaryOp.hpp deleted file mode 100644 index c527f9c76c8262e220ae9c8182bf9fae97e83975..0000000000000000000000000000000000000000 --- a/src/validators/common/CMBinaryOp.hpp +++ /dev/null @@ -1,148 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999-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$ - * Revision 1.3 2001/05/11 13:27:16 tng - * Copyright update. - * - * Revision 1.2 2001/02/16 14:58:57 tng - * Schema: Update Makefile, configure files, project files, and include path in - * certain cpp files because of the move of the common Content Model files. By Pei Yong Zhang. - * - * Revision 1.1 2001/02/16 14:17:29 tng - * Schema: Move the common Content Model files that are shared by DTD - * and schema from 'DTD' folder to 'common' folder. By Pei Yong Zhang. - * - * Revision 1.4 2000/03/02 19:55:37 roddey - * This checkin includes many changes done while waiting for the - * 1.1.0 code to be finished. I can't list them all here, but a list is - * available elsewhere. - * - * Revision 1.3 2000/02/24 20:16:47 abagchi - * Swat for removing Log from API docs - * - * Revision 1.2 2000/02/09 21:42:36 abagchi - * Copyright swat - * - * Revision 1.1.1.1 1999/11/09 01:03:02 twl - * Initial checkin - * - * Revision 1.2 1999/11/08 20:45:35 rahul - * Swat for adding in Product name and CVS comment log variable. - * - */ - -#if !defined(CMBINARYOP_HPP) -#define CMBINARYOP_HPP - -#include <util/XercesDefs.hpp> -#include <validators/common/CMNode.hpp> - -class CMStateSet; - -class CMBinaryOp : public CMNode -{ -public : - // ----------------------------------------------------------------------- - // Constructors - // ----------------------------------------------------------------------- - CMBinaryOp - ( - const ContentSpecNode::NodeTypes type - , CMNode* const leftToAdopt - , CMNode* const rightToAdopt - ); - ~CMBinaryOp(); - - - // ----------------------------------------------------------------------- - // Getter methods - // ----------------------------------------------------------------------- - const CMNode* getLeft() const; - CMNode* getLeft(); - const CMNode* getRight() const; - CMNode* getRight(); - - - // ----------------------------------------------------------------------- - // Implementation of the public CMNode virtual interface - // ----------------------------------------------------------------------- - bool isNullable() const; - - -protected : - // ----------------------------------------------------------------------- - // Implementation of the protected CMNode virtual interface - // ----------------------------------------------------------------------- - void calcFirstPos(CMStateSet& toSet) const; - void calcLastPos(CMStateSet& toSet) const; - - -private : - // ----------------------------------------------------------------------- - // Private data members - // - // fLeftChild - // fRightChild - // These are the references to the two nodes that are on either side - // of this binary operation. We own them both. - // ----------------------------------------------------------------------- - CMNode* fLeftChild; - CMNode* fRightChild; -}; - -#endif diff --git a/src/validators/common/CMLeaf.hpp b/src/validators/common/CMLeaf.hpp deleted file mode 100644 index 6098126d259b8d451aac6010c640c92899e6946e..0000000000000000000000000000000000000000 --- a/src/validators/common/CMLeaf.hpp +++ /dev/null @@ -1,311 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999-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$ - * Revision 1.6 2001/12/06 17:52:17 tng - * Performance Enhancement. The QName that was passed to the CMLeaf - * constructor was always being copied, even though the CMLeaf objects - * only existed during construction of a DFA. In most cases the original - * QName that was passed into the CMLeaf constructor continued to exist long - * after the CMLeaf was destroyed; in some cases the QName was constructed - * specifically to be passed to the CMLeaf constructor. Added a second CMLeaf constructor that indicated the QName passed in was to be adopted; otherwise the CMLeaf constructor just sets a reference to the QName passed in. - * By Henry Zongaro. - * - * Revision 1.5 2001/10/03 15:08:45 tng - * typo fix: remove the extra space which may confuse some compilers while constructing the qname. - * - * Revision 1.4 2001/05/11 13:27:16 tng - * Copyright update. - * - * Revision 1.3 2001/04/19 18:17:27 tng - * Schema: SchemaValidator update, and use QName in Content Model - * - * Revision 1.2 2001/02/16 14:58:57 tng - * Schema: Update Makefile, configure files, project files, and include path in - * certain cpp files because of the move of the common Content Model files. By Pei Yong Zhang. - * - * Revision 1.1 2001/02/16 14:17:29 tng - * Schema: Move the common Content Model files that are shared by DTD - * and schema from 'DTD' folder to 'common' folder. By Pei Yong Zhang. - * - * Revision 1.5 2000/03/28 19:43:25 roddey - * Fixes for signed/unsigned warnings. New work for two way transcoding - * stuff. - * - * Revision 1.4 2000/03/02 19:55:37 roddey - * This checkin includes many changes done while waiting for the - * 1.1.0 code to be finished. I can't list them all here, but a list is - * available elsewhere. - * - * Revision 1.3 2000/02/24 20:16:47 abagchi - * Swat for removing Log from API docs - * - * Revision 1.2 2000/02/09 21:42:36 abagchi - * Copyright swat - * - * Revision 1.1.1.1 1999/11/09 01:03:04 twl - * Initial checkin - * - * Revision 1.2 1999/11/08 20:45:36 rahul - * Swat for adding in Product name and CVS comment log variable. - * - */ - -#if !defined(CMLEAF_HPP) -#define CMLEAF_HPP - -#include <util/XercesDefs.hpp> -#include <util/RuntimeException.hpp> -#include <validators/common/ContentSpecNode.hpp> -#include <validators/common/CMNode.hpp> -#include <validators/common/CMStateSet.hpp> - -// -// This class represents a leaf in the content spec node tree of an -// element's content model. It just has an element qname and a position value, -// the latter of which is used during the building of a DFA. -// -class CMLeaf : public CMNode -{ -public : - // ----------------------------------------------------------------------- - // Constructors - // ----------------------------------------------------------------------- - CMLeaf - ( - QName* const element - , const unsigned int position = ~0 - ); - CMLeaf - ( - QName* const element - , const unsigned int position - , const bool adopt - ); - ~CMLeaf(); - - - // ----------------------------------------------------------------------- - // Getter methods - // ----------------------------------------------------------------------- - QName* getElement(); - const QName* getElement() const; - unsigned int getPosition() const; - - - // ----------------------------------------------------------------------- - // Setter methods - // ----------------------------------------------------------------------- - void setPosition(const unsigned int newPosition); - - - // ----------------------------------------------------------------------- - // Implementation of public CMNode virtual interface - // ----------------------------------------------------------------------- - bool isNullable() const; - - -protected : - // ----------------------------------------------------------------------- - // Implementation of protected CMNode virtual interface - // ----------------------------------------------------------------------- - void calcFirstPos(CMStateSet& toSet) const; - void calcLastPos(CMStateSet& toSet) const; - - -private : - // ----------------------------------------------------------------------- - // Private data members - // - // fElement - // This is the element that this leaf represents. - // - // fPosition - // Part of the algorithm to convert a regex directly to a DFA - // numbers each leaf sequentially. If its -1, that means its an - // epsilon node. All others are non-epsilon positions. - // - // fAdopt - // This node is responsible for the storage of the fElement QName. - // ----------------------------------------------------------------------- - QName* fElement; - unsigned int fPosition; - bool fAdopt; -}; - - -// ----------------------------------------------------------------------- -// Constructors -// ----------------------------------------------------------------------- -inline CMLeaf::CMLeaf( QName* const element - , const unsigned int position) : - CMNode(ContentSpecNode::Leaf) - , fElement(0) - , fPosition(position) - , fAdopt(false) -{ - if (!element) - { - fElement = new QName(XMLUni::fgZeroLenString - , XMLUni::fgZeroLenString - , XMLElementDecl::fgInvalidElemId); - // We have to be responsible for this QName - override default fAdopt - fAdopt = true; - } - else - { - fElement = element; - } -} - -inline CMLeaf::CMLeaf( QName* const element - , const unsigned int position - , const bool adopt) : - CMNode(ContentSpecNode::Leaf) - , fElement(0) - , fPosition(position) - , fAdopt(adopt) -{ - if (!element) - { - fElement = new QName(XMLUni::fgZeroLenString - , XMLUni::fgZeroLenString - , XMLElementDecl::fgInvalidElemId); - // We have to be responsible for this QName - override adopt parameter - fAdopt = true; - } - else - { - fElement = element; - } -} - -inline CMLeaf::~CMLeaf() -{ - if (fAdopt) - delete fElement; -} - - -// --------------------------------------------------------------------------- -// Getter methods -// --------------------------------------------------------------------------- -inline QName* CMLeaf::getElement() -{ - return fElement; -} - -inline const QName* CMLeaf::getElement() const -{ - return fElement; -} - -inline unsigned int CMLeaf::getPosition() const -{ - return fPosition; -} - - -// --------------------------------------------------------------------------- -// Setter methods -// --------------------------------------------------------------------------- -inline void CMLeaf::setPosition(const unsigned int newPosition) -{ - fPosition = newPosition; -} - - -// --------------------------------------------------------------------------- -// Implementation of public CMNode virtual interface -// --------------------------------------------------------------------------- -inline bool CMLeaf::isNullable() const -{ - // Leaf nodes are never nullable unless its an epsilon node - return (fPosition == -1); -} - - -// --------------------------------------------------------------------------- -// Implementation of protected CMNode virtual interface -// --------------------------------------------------------------------------- -inline void CMLeaf::calcFirstPos(CMStateSet& toSet) const -{ - // If we are an epsilon node, then the first pos is an empty set - if (fPosition == -1) - { - toSet.zeroBits(); - return; - } - - // Otherwise, its just the one bit of our position - toSet.setBit(fPosition); -} - -inline void CMLeaf::calcLastPos(CMStateSet& toSet) const -{ - // If we are an epsilon node, then the last pos is an empty set - if (fPosition == -1) - { - toSet.zeroBits(); - return; - } - - // Otherwise, its just the one bit of our position - toSet.setBit(fPosition); -} - -#endif diff --git a/src/validators/common/CMNode.hpp b/src/validators/common/CMNode.hpp deleted file mode 100644 index d3ad0ad74699e09d8e5f71c1f7edf6c5bc503634..0000000000000000000000000000000000000000 --- a/src/validators/common/CMNode.hpp +++ /dev/null @@ -1,245 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999-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$ - * Revision 1.3 2001/05/11 13:27:17 tng - * Copyright update. - * - * Revision 1.2 2001/02/16 14:58:57 tng - * Schema: Update Makefile, configure files, project files, and include path in - * certain cpp files because of the move of the common Content Model files. By Pei Yong Zhang. - * - * Revision 1.1 2001/02/16 14:17:29 tng - * Schema: Move the common Content Model files that are shared by DTD - * and schema from 'DTD' folder to 'common' folder. By Pei Yong Zhang. - * - * Revision 1.5 2000/03/28 19:43:25 roddey - * Fixes for signed/unsigned warnings. New work for two way transcoding - * stuff. - * - * Revision 1.4 2000/03/02 19:55:37 roddey - * This checkin includes many changes done while waiting for the - * 1.1.0 code to be finished. I can't list them all here, but a list is - * available elsewhere. - * - * Revision 1.3 2000/02/24 20:16:48 abagchi - * Swat for removing Log from API docs - * - * Revision 1.2 2000/02/09 21:42:36 abagchi - * Copyright swat - * - * Revision 1.1.1.1 1999/11/09 01:03:05 twl - * Initial checkin - * - * Revision 1.2 1999/11/08 20:45:36 rahul - * Swat for adding in Product name and CVS comment log variable. - * - */ - -#if !defined(CMNODE_HPP) -#define CMNODE_HPP - -#include <util/XercesDefs.hpp> -#include <validators/common/ContentSpecNode.hpp> -#include <validators/common/CMStateSet.hpp> - - -class CMNode -{ -public : - // ----------------------------------------------------------------------- - // Constructors and Destructors - // ----------------------------------------------------------------------- - CMNode(const ContentSpecNode::NodeTypes type); - virtual ~CMNode(); - - - // ----------------------------------------------------------------------- - // Virtual methods to be provided derived node classes - // ----------------------------------------------------------------------- - virtual bool isNullable() const = 0; - - - // ----------------------------------------------------------------------- - // Getter methods - // ----------------------------------------------------------------------- - ContentSpecNode::NodeTypes getType() const; - const CMStateSet& getFirstPos() const; - const CMStateSet& getLastPos() const; - - - // ----------------------------------------------------------------------- - // Setter methods - // ----------------------------------------------------------------------- - void setMaxStates(const unsigned int maxStates); - - -protected : - // ----------------------------------------------------------------------- - // Protected, abstract methods - // ----------------------------------------------------------------------- - virtual void calcFirstPos(CMStateSet& toUpdate) const = 0; - virtual void calcLastPos(CMStateSet& toUpdate) const = 0; - - -private : - // ----------------------------------------------------------------------- - // Unimplemented constructors and operators - // ----------------------------------------------------------------------- - CMNode(); - CMNode(const CMNode&); - void operator=(const CMNode&); - - - // ----------------------------------------------------------------------- - // Private data members - // - // fType - // The type of node. This indicates whether its a leaf or an - // operation. - // - // fFirstPos - // The set of NFA states that represent the entry states of this - // node in the DFA. - // - // fLastPos - // The set of NFA states that represent the final states of this - // node in the DFA. - // - // fMaxStates - // The maximum number of states that the NFA has, which means the - // max number of NFA states that have to be traced in the state - // sets during the building of the DFA. Its unfortunate that it - // has to be stored redundantly, but we need to fault in the - // state set members and they have to be sized to this size. - // ----------------------------------------------------------------------- - ContentSpecNode::NodeTypes fType; - CMStateSet* fFirstPos; - CMStateSet* fLastPos; - unsigned int fMaxStates; -}; - - - -// --------------------------------------------------------------------------- -// CMNode: Constructors and Destructors -// --------------------------------------------------------------------------- -inline CMNode::CMNode(const ContentSpecNode::NodeTypes type) : - - fType(type) - , fFirstPos(0) - , fLastPos(0) - , fMaxStates(~0) -{ -} - -inline CMNode::~CMNode() -{ - // Clean up any position sets that got created - delete fFirstPos; - delete fLastPos; -} - - -// --------------------------------------------------------------------------- -// CMNode: Getter methods -// --------------------------------------------------------------------------- -inline ContentSpecNode::NodeTypes CMNode::getType() const -{ - return fType; -} - -inline const CMStateSet& CMNode::getFirstPos() const -{ - // - // Fault in the state set if needed. Since we can't use mutable members - // cast off the const'ness. - // - if (!fFirstPos) - { - CMNode* unconstThis = (CMNode*)this; - unconstThis->fFirstPos = new CMStateSet(fMaxStates); - unconstThis->calcFirstPos(*fFirstPos); - } - return *fFirstPos; -} - -inline const CMStateSet& CMNode::getLastPos() const -{ - // - // Fault in the state set if needed. Since we can't use mutable members - // cast off the const'ness. - // - if (!fLastPos) - { - CMNode* unconstThis = (CMNode*)this; - unconstThis->fLastPos = new CMStateSet(fMaxStates); - unconstThis->calcLastPos(*fLastPos); - } - return *fLastPos; -} - - -// --------------------------------------------------------------------------- -// CMNode: Setter methods -// --------------------------------------------------------------------------- -inline void CMNode::setMaxStates(const unsigned int maxStates) -{ - fMaxStates = maxStates; -} - -#endif diff --git a/src/validators/common/CMStateSet.hpp b/src/validators/common/CMStateSet.hpp deleted file mode 100644 index 05a6466d3b3735391c03ac160068db402ec81111..0000000000000000000000000000000000000000 --- a/src/validators/common/CMStateSet.hpp +++ /dev/null @@ -1,388 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999-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$ - * Revision 1.5 2001/08/16 21:51:43 peiyongz - * hashCode() added - * - * Revision 1.4 2001/05/11 13:27:17 tng - * Copyright update. - * - * Revision 1.3 2001/05/03 21:02:28 tng - * Schema: Add SubstitutionGroupComparator and update exception messages. By Pei Yong Zhang. - * - * Revision 1.2 2001/02/27 14:48:46 tng - * Schema: Add CMAny and ContentLeafNameTypeVector, by Pei Yong Zhang - * - * Revision 1.1 2001/02/16 14:17:29 tng - * Schema: Move the common Content Model files that are shared by DTD - * and schema from 'DTD' folder to 'common' folder. By Pei Yong Zhang. - * - * Revision 1.4 2000/03/02 19:55:37 roddey - * This checkin includes many changes done while waiting for the - * 1.1.0 code to be finished. I can't list them all here, but a list is - * available elsewhere. - * - * Revision 1.3 2000/02/24 20:16:48 abagchi - * Swat for removing Log from API docs - * - * Revision 1.2 2000/02/09 21:42:36 abagchi - * Copyright swat - * - * Revision 1.1.1.1 1999/11/09 01:03:06 twl - * Initial checkin - * - * Revision 1.3 1999/11/08 20:45:36 rahul - * Swat for adding in Product name and CVS comment log variable. - * - */ - -// DESCRIPTION: -// -// This class is a specialized bitset class for the content model code of -// the validator. It assumes that its never called with two objects of -// different bit counts, and that bit sets smaller than 64 bits are far -// and away the most common. So it can be a lot more optimized than a general -// purpose utility bitset class -// - -#if !defined(CMSTATESET_HPP) -#define CMSTATESET_HPP - -#include <util/XercesDefs.hpp> -#include <util/ArrayIndexOutOfBoundsException.hpp> -#include <framework/XMLValidityCodes.hpp> -#include <string.h> -#include <memory.h> - - -class CMStateSet -{ -public : - // ----------------------------------------------------------------------- - // Constructors and Destructor - // ----------------------------------------------------------------------- - CMStateSet(const unsigned int bitCount) : - - fBitCount(bitCount) - , fByteArray(0) - { - // - // See if we need to allocate the byte array or whether we can live - // within the 64 bit high performance scheme. - // - if (fBitCount > 64) - { - fByteCount = fBitCount / 8; - if (fBitCount % 8) - fByteCount++; - fByteArray = new XMLByte[fByteCount]; - } - - // Init all the bits to zero - zeroBits(); - } - - - /* - * This method with the 'for' statement (commented out) cannot be made inline - * because the antiquated CC (CFront) compiler under HPUX 10.20 does not allow - * the 'for' statement inside any inline method. Unfortunately, - * we have to support it. So instead, we use memcpy(). - */ - - CMStateSet(const CMStateSet& toCopy) : - fBitCount(toCopy.fBitCount) - , fByteArray(0) - { - // - // See if we need to allocate the byte array or whether we can live - // within the 64 bit high performance scheme. - // - if (fBitCount > 64) - { - fByteCount = fBitCount / 8; - if (fBitCount % 8) - fByteCount++; - fByteArray = new XMLByte[fByteCount]; - - memcpy((void *) fByteArray, - (const void *) toCopy.fByteArray, - fByteCount * sizeof(XMLByte)); - - // for (unsigned int index = 0; index < fByteCount; index++) - // fByteArray[index] = toCopy.fByteArray[index]; - } - else - { - fBits1 = toCopy.fBits1; - fBits2 = toCopy.fBits2; - } - } - - ~CMStateSet() - { - if (fByteArray) - delete [] fByteArray; - } - - - // ----------------------------------------------------------------------- - // Set manipulation methods - // ----------------------------------------------------------------------- - void operator&=(const CMStateSet& setToAnd) - { - if (fBitCount < 65) - { - fBits1 &= setToAnd.fBits1; - fBits2 &= setToAnd.fBits2; - } - else - { - for (unsigned int index = 0; index < fByteCount; index++) - fByteArray[index] &= setToAnd.fByteArray[index]; - } - } - - void operator|=(const CMStateSet& setToOr) - { - if (fBitCount < 65) - { - fBits1 |= setToOr.fBits1; - fBits2 |= setToOr.fBits2; - } - else - { - for (unsigned int index = 0; index < fByteCount; index++) - fByteArray[index] |= setToOr.fByteArray[index]; - } - } - - bool operator==(const CMStateSet& setToCompare) const - { - if (fBitCount != setToCompare.fBitCount) - return false; - - if (fBitCount < 65) - { - return ((fBits1 == setToCompare.fBits1) - && (fBits2 == setToCompare.fBits2)); - } - - for (unsigned int index = 0; index < fByteCount; index++) - { - if (fByteArray[index] != setToCompare.fByteArray[index]) - return false; - } - return true; - } - - CMStateSet& operator=(const CMStateSet& srcSet) - { - if (this == &srcSet) - return *this; - - // They have to be the same size - if (fBitCount != srcSet.fBitCount) - ThrowXML(RuntimeException, XMLExcepts::Bitset_NotEqualSize); - - if (fBitCount < 65) - { - fBits1 = srcSet.fBits1; - fBits2 = srcSet.fBits2; - } - else - { - for (unsigned int index = 0; index < fByteCount; index++) - fByteArray[index] = srcSet.fByteArray[index]; - } - return *this; - } - - - bool getBit(const unsigned int bitToGet) const - { - if (bitToGet >= fBitCount) - ThrowXML(ArrayIndexOutOfBoundsException, XMLExcepts::Bitset_BadIndex); - - if (fBitCount < 65) - { - unsigned int mask = (0x1UL << (bitToGet % 32)); - if (bitToGet < 32) - return ((fBits1 & mask) != 0); - else - return ((fBits2 & mask) != 0); - } - - // Create the mask and byte values - const XMLByte mask1 = XMLByte(0x1 << (bitToGet % 8)); - const unsigned int byteOfs = bitToGet >> 3; - - // And access the right bit and byte - return ((fByteArray[byteOfs] & mask1) != 0); - } - - bool isEmpty() const - { - if (fBitCount < 65) - return ((fBits1 == 0) && (fBits2 == 0)); - - for (unsigned int index = 0; index < fByteCount; index++) - { - if (fByteArray[index] != 0) - return false; - } - return true; - } - - void setBit(const unsigned int bitToSet) - { - if (bitToSet >= fBitCount) - ThrowXML(ArrayIndexOutOfBoundsException, XMLExcepts::Bitset_BadIndex); - - if (fBitCount < 65) - { - const unsigned int mask = (0x1UL << (bitToSet % 32)); - if (bitToSet < 32) - { - fBits1 &= ~mask; - fBits1 |= mask; - } - else - { - fBits2 &= ~mask; - fBits2 |= mask; - } - } - else - { - // Create the mask and byte values - const XMLByte mask1 = XMLByte(0x1 << (bitToSet % 8)); - const unsigned int byteOfs = bitToSet >> 3; - - // And access the right bit and byte - fByteArray[byteOfs] &= ~mask1; - fByteArray[byteOfs] |= mask1; - } - } - - void zeroBits() - { - if (fBitCount < 65) - { - fBits1 = 0; - fBits2 = 0; - } - else - { - for (unsigned int index = 0; index < fByteCount; index++) - fByteArray[index] = 0; - } - } - - int hashCode() const - { - if (fBitCount < 65) - { - return fBits1+ fBits2 * 31; - } - else - { - int hash = 0; - for (int index = fByteCount - 1; index >= 0; index--) - hash = fByteArray[index] + hash * 31; - return hash; - } - - } - -private : - // ----------------------------------------------------------------------- - // Unimplemented constructors and operators - // ----------------------------------------------------------------------- - CMStateSet(); - - - // ----------------------------------------------------------------------- - // Private data members - // - // fBitCount - // The count of bits that the outside world wants to support, - // so its the max bit index plus one. - // - // fByteCount - // If the bit count is > 64, then we use the fByteArray member to - // store the bits, and this indicates its size in bytes. Otherwise - // its value is meaningless and unset. - // - // fBits1 - // fBits2 - // When the bit count is <= 64 (very common), these hold the bits. - // Otherwise, the fByteArray member holds htem. - // - // fByteArray - // The array of bytes used when the bit count is > 64. It is - // allocated as required. - // ----------------------------------------------------------------------- - unsigned int fBitCount; - unsigned int fByteCount; - unsigned int fBits1; - unsigned int fBits2; - XMLByte* fByteArray; -}; - -#endif diff --git a/src/validators/common/CMUnaryOp.cpp b/src/validators/common/CMUnaryOp.cpp deleted file mode 100644 index 6236328338d511e0e4df91751515ebd49d822471..0000000000000000000000000000000000000000 --- a/src/validators/common/CMUnaryOp.cpp +++ /dev/null @@ -1,161 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999-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$ - * Revision 1.4 2001/05/11 13:27:17 tng - * Copyright update. - * - * Revision 1.3 2001/02/27 14:48:47 tng - * Schema: Add CMAny and ContentLeafNameTypeVector, by Pei Yong Zhang - * - * Revision 1.2 2001/02/16 14:58:57 tng - * Schema: Update Makefile, configure files, project files, and include path in - * certain cpp files because of the move of the common Content Model files. By Pei Yong Zhang. - * - * Revision 1.1 2001/02/16 14:17:29 tng - * Schema: Move the common Content Model files that are shared by DTD - * and schema from 'DTD' folder to 'common' folder. By Pei Yong Zhang. - * - * Revision 1.3 2000/03/02 19:55:37 roddey - * This checkin includes many changes done while waiting for the - * 1.1.0 code to be finished. I can't list them all here, but a list is - * available elsewhere. - * - * Revision 1.2 2000/02/09 21:42:37 abagchi - * Copyright swatswat - * - * Revision 1.1.1.1 1999/11/09 01:03:08 twl - * Initial checkin - * - * Revision 1.2 1999/11/08 20:45:37 rahul - * Swat for adding in Product name and CVS comment log variable. - * - */ - - -// --------------------------------------------------------------------------- -// Includes -// --------------------------------------------------------------------------- -#include <util/XercesDefs.hpp> -#include <util/RuntimeException.hpp> -#include <validators/common/CMStateSet.hpp> -#include <validators/common/CMUnaryOp.hpp> - - -// --------------------------------------------------------------------------- -// CMUnaryOp: Constructors and Destructor -// --------------------------------------------------------------------------- -CMUnaryOp::CMUnaryOp( const ContentSpecNode::NodeTypes type - , CMNode* const nodeToAdopt) : - CMNode(type) - , fChild(nodeToAdopt) -{ - // Insure that its one of the types we require - if ((type != ContentSpecNode::ZeroOrOne) - && (type != ContentSpecNode::ZeroOrMore) - && (type != ContentSpecNode::OneOrMore)) - { - ThrowXML(RuntimeException, XMLExcepts::CM_UnaryOpHadBinType); - } -} - -CMUnaryOp::~CMUnaryOp() -{ - delete fChild; -} - - -// --------------------------------------------------------------------------- -// CMUnaryOp: Getter methods -// --------------------------------------------------------------------------- -const CMNode* CMUnaryOp::getChild() const -{ - return fChild; -} - -CMNode* CMUnaryOp::getChild() -{ - return fChild; -} - - -// --------------------------------------------------------------------------- -// CMUnaryOp: Implementation of the public CMNode virtual interface -// --------------------------------------------------------------------------- -bool CMUnaryOp::isNullable() const -{ - if (getType() == ContentSpecNode::OneOrMore) - return fChild->isNullable(); - else - return true; -} - - -// --------------------------------------------------------------------------- -// CMUnaryOp: Implementation of the protected CMNode virtual interface -// --------------------------------------------------------------------------- -void CMUnaryOp::calcFirstPos(CMStateSet& toSet) const -{ - // Its just based on our child node's first pos - toSet = fChild->getFirstPos(); -} - -void CMUnaryOp::calcLastPos(CMStateSet& toSet) const -{ - // Its just based on our child node's last pos - toSet = fChild->getLastPos(); -} diff --git a/src/validators/common/CMUnaryOp.hpp b/src/validators/common/CMUnaryOp.hpp deleted file mode 100644 index af11ead5dfeec57a44852411d401d9f94741a4d5..0000000000000000000000000000000000000000 --- a/src/validators/common/CMUnaryOp.hpp +++ /dev/null @@ -1,145 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999-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$ - * Revision 1.3 2001/05/11 13:27:17 tng - * Copyright update. - * - * Revision 1.2 2001/02/16 14:58:57 tng - * Schema: Update Makefile, configure files, project files, and include path in - * certain cpp files because of the move of the common Content Model files. By Pei Yong Zhang. - * - * Revision 1.1 2001/02/16 14:17:29 tng - * Schema: Move the common Content Model files that are shared by DTD - * and schema from 'DTD' folder to 'common' folder. By Pei Yong Zhang. - * - * Revision 1.4 2000/03/02 19:55:37 roddey - * This checkin includes many changes done while waiting for the - * 1.1.0 code to be finished. I can't list them all here, but a list is - * available elsewhere. - * - * Revision 1.3 2000/02/24 20:16:48 abagchi - * Swat for removing Log from API docs - * - * Revision 1.2 2000/02/09 21:42:37 abagchi - * Copyright swat - * - * Revision 1.1.1.1 1999/11/09 01:03:11 twl - * Initial checkin - * - * Revision 1.2 1999/11/08 20:45:37 rahul - * Swat for adding in Product name and CVS comment log variable. - * - */ - - -#if !defined(CMUNARYOP_HPP) -#define CMUNARYOP_HPP - -#include <util/XercesDefs.hpp> -#include <validators/common/CMNode.hpp> -#include <validators/common/ContentSpecNode.hpp> - -class CMStateSet; - -class CMUnaryOp : public CMNode -{ -public : - // ----------------------------------------------------------------------- - // Constructors and Destructor - // ----------------------------------------------------------------------- - CMUnaryOp - ( - const ContentSpecNode::NodeTypes type - , CMNode* const nodeToAdopt - ); - ~CMUnaryOp(); - - - // ----------------------------------------------------------------------- - // Getter methods - // ----------------------------------------------------------------------- - const CMNode* getChild() const; - CMNode* getChild(); - - - // ----------------------------------------------------------------------- - // Implementation of the public CMNode virtual interface - // ----------------------------------------------------------------------- - bool isNullable() const; - - -protected : - // ----------------------------------------------------------------------- - // Implementation of the protected CMNode virtual interface - // ----------------------------------------------------------------------- - void calcFirstPos(CMStateSet& toSet) const; - void calcLastPos(CMStateSet& toSet) const; - - -private : - // ----------------------------------------------------------------------- - // Private data members - // - // fChild - // This is the reference to the one child that we have for this - // unary operation. We own it. - // ----------------------------------------------------------------------- - CMNode* fChild; -}; - -#endif diff --git a/src/validators/common/ContentLeafNameTypeVector.cpp b/src/validators/common/ContentLeafNameTypeVector.cpp deleted file mode 100644 index 5ad86f4258812fc6f634285ad424ce73d859683f..0000000000000000000000000000000000000000 --- a/src/validators/common/ContentLeafNameTypeVector.cpp +++ /dev/null @@ -1,166 +0,0 @@ -/* - * 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$ - * Revision 1.3 2001/05/11 13:27:17 tng - * Copyright update. - * - * Revision 1.2 2001/04/19 18:17:28 tng - * Schema: SchemaValidator update, and use QName in Content Model - * - * Revision 1.1 2001/02/27 14:48:49 tng - * Schema: Add CMAny and ContentLeafNameTypeVector, by Pei Yong Zhang - * - */ - - -// --------------------------------------------------------------------------- -// Includes -// --------------------------------------------------------------------------- -#include <util/XercesDefs.hpp> -#include <validators/common/ContentLeafNameTypeVector.hpp> - -// --------------------------------------------------------------------------- -// ContentLeafNameTypeVector: Constructors and Destructor -// --------------------------------------------------------------------------- -ContentLeafNameTypeVector::ContentLeafNameTypeVector() -: fLeafNames(0) -, fLeafTypes(0) -, fLeafCount(0) -{ -} - -ContentLeafNameTypeVector::ContentLeafNameTypeVector - ( QName** const names - , ContentSpecNode::NodeTypes* const types - , const unsigned int count - ) -: fLeafNames(0) -, fLeafTypes(0) -, fLeafCount(0) -{ - setValues(names, types, count); -} - -/*** -copy ctor -***/ -ContentLeafNameTypeVector::ContentLeafNameTypeVector - (const ContentLeafNameTypeVector& toCopy) - :fLeafNames(0) - ,fLeafTypes(0) - ,fLeafCount(0) -{ - fLeafCount=toCopy.getLeafCount(); - init(fLeafCount); - - for (unsigned int i=0; i<this->fLeafCount; i++) - { - fLeafNames[i] = toCopy.getLeafNameAt(i); - fLeafTypes[i] = toCopy.getLeafTypeAt(i); - } -} - -ContentLeafNameTypeVector::~ContentLeafNameTypeVector() -{ - cleanUp(); -} - -// --------------------------------------------------------------------------- -// ContentSpecType: Setter methods -// --------------------------------------------------------------------------- -void ContentLeafNameTypeVector::setValues - ( - QName** const names - , ContentSpecNode::NodeTypes* const types - , const unsigned int count - ) -{ - cleanUp(); - init(count); - - for (unsigned int i=0; i<count; i++) - { - fLeafNames[i] = names[i]; - fLeafTypes[i] = types[i]; - } -} - -// --------------------------------------------------------------------------- -// ContentLeafNameTypeVector: Getter methods -// --------------------------------------------------------------------------- -QName* ContentLeafNameTypeVector::getLeafNameAt(const unsigned int pos) const -{ - if (pos >= fLeafCount) - ThrowXML(ArrayIndexOutOfBoundsException, XMLExcepts::Vector_BadIndex); - - return fLeafNames[pos]; -} - -const ContentSpecNode::NodeTypes ContentLeafNameTypeVector::getLeafTypeAt - (const unsigned int pos) const -{ - if (pos >= fLeafCount) - ThrowXML(ArrayIndexOutOfBoundsException, XMLExcepts::Vector_BadIndex); - - return fLeafTypes[pos]; -} - -const unsigned int ContentLeafNameTypeVector::getLeafCount() const -{ - return fLeafCount; -} diff --git a/src/validators/common/ContentLeafNameTypeVector.hpp b/src/validators/common/ContentLeafNameTypeVector.hpp deleted file mode 100644 index b56b34565858540d93730e03eabc7c52abe7fb51..0000000000000000000000000000000000000000 --- a/src/validators/common/ContentLeafNameTypeVector.hpp +++ /dev/null @@ -1,160 +0,0 @@ -/* - * 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$ - * Revision 1.4 2001/08/07 15:21:20 knoaman - * The value of 'fLeafCount' was not set. - * - * Revision 1.3 2001/05/11 13:27:17 tng - * Copyright update. - * - * Revision 1.2 2001/04/19 18:17:28 tng - * Schema: SchemaValidator update, and use QName in Content Model - * - * Revision 1.1 2001/02/27 14:48:49 tng - * Schema: Add CMAny and ContentLeafNameTypeVector, by Pei Yong Zhang - * - */ - - -#if !defined(CONTENTLEAFNAMETYPEVECTOR_HPP) -#define CONTENTLEAFNAMETYPEVECTOR_HPP - -#include <util/XercesDefs.hpp> -#include <util/ValueVectorOf.hpp> -#include <validators/common/ContentSpecNode.hpp> - -class ContentLeafNameTypeVector -{ -public : - // ----------------------------------------------------------------------- - // Class specific types - // ----------------------------------------------------------------------- - - - // ----------------------------------------------------------------------- - // Constructors and Destructor - // ----------------------------------------------------------------------- - ContentLeafNameTypeVector(); - ContentLeafNameTypeVector - ( - QName** const qName - , ContentSpecNode::NodeTypes* const types - , const unsigned int count - ); - - ~ContentLeafNameTypeVector(); - - ContentLeafNameTypeVector(const ContentLeafNameTypeVector&); - - // ----------------------------------------------------------------------- - // Getter methods - // ----------------------------------------------------------------------- - QName* getLeafNameAt(const unsigned int pos) const; - - const ContentSpecNode::NodeTypes getLeafTypeAt(const unsigned int pos) const; - const unsigned int getLeafCount() const; - - // ----------------------------------------------------------------------- - // Setter methods - // ----------------------------------------------------------------------- - void setValues - ( - QName** const qName - , ContentSpecNode::NodeTypes* const types - , const unsigned int count - ); - - // ----------------------------------------------------------------------- - // Miscellaneous - // ----------------------------------------------------------------------- - -private : - // ----------------------------------------------------------------------- - // Unimplemented constructors and operators - // ----------------------------------------------------------------------- - void operator=(const ContentLeafNameTypeVector&); - - // ----------------------------------------------------------------------- - // helper methods - // ----------------------------------------------------------------------- - void cleanUp(); - void init(const unsigned int); - - // ----------------------------------------------------------------------- - // Private Data Members - // - // ----------------------------------------------------------------------- - QName** fLeafNames; - ContentSpecNode::NodeTypes *fLeafTypes; - unsigned int fLeafCount; -}; - -inline void ContentLeafNameTypeVector::cleanUp() -{ - delete [] fLeafNames; - delete [] fLeafTypes; -} - -inline void ContentLeafNameTypeVector::init(const unsigned int size) -{ - fLeafNames = new QName*[size]; - fLeafTypes = new ContentSpecNode::NodeTypes [size]; - fLeafCount = size; -} - -#endif diff --git a/src/validators/common/ContentSpecNode.cpp b/src/validators/common/ContentSpecNode.cpp deleted file mode 100644 index 7b58b45bb2b28bd1e6d34a3eaab168a9185a8707..0000000000000000000000000000000000000000 --- a/src/validators/common/ContentSpecNode.cpp +++ /dev/null @@ -1,215 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999-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/>. - */ - -/* - * $Id$ - */ - - -// --------------------------------------------------------------------------- -// Includes -// --------------------------------------------------------------------------- -#include <util/Janitor.hpp> -#include <util/XMLUniDefs.hpp> -#include <util/XMLUni.hpp> -#include <framework/XMLNotationDecl.hpp> -#include <framework/XMLBuffer.hpp> -#include <validators/common/ContentSpecNode.hpp> -#include <validators/DTD/DTDValidator.hpp> - -// --------------------------------------------------------------------------- -// ContentSpecNode: Copy Constructor -// -// Note: this copy constructor has dependency on various get*() methods -// and shall be placed after those method's declaration. -// aka inline function compilation error on AIX 4.2, xlC 3 r ev.1 -// --------------------------------------------------------------------------- - -ContentSpecNode::ContentSpecNode(const ContentSpecNode& toCopy) -{ - const QName* tempElement = toCopy.getElement(); - if (tempElement) - fElement = new QName(tempElement); - else - fElement = 0; - - const ContentSpecNode *tmp = toCopy.getFirst(); - if (tmp) - fFirst = new ContentSpecNode(*tmp); - else - fFirst = 0; - - tmp = toCopy.getSecond(); - if (tmp) - fSecond = new ContentSpecNode(*tmp); - else - fSecond = 0; - - fType = toCopy.getType(); - fAdoptFirst = true; - fAdoptSecond = true; - fMinOccurs = toCopy.getMinOccurs(); - fMaxOccurs = toCopy.getMaxOccurs(); -} - -// --------------------------------------------------------------------------- -// Local methods -// --------------------------------------------------------------------------- -static void formatNode( const ContentSpecNode* const curNode - , const ContentSpecNode::NodeTypes parentType - , XMLBuffer& bufToFill) -{ - if (!curNode) - return; - - const ContentSpecNode* first = curNode->getFirst(); - const ContentSpecNode* second = curNode->getSecond(); - const ContentSpecNode::NodeTypes curType = curNode->getType(); - - // Get the type of the first node - const ContentSpecNode::NodeTypes firstType = first ? - first->getType() : - ContentSpecNode::Leaf; - - // Calculate the parens flag for the rep nodes - bool doRepParens = false; - if (((firstType != ContentSpecNode::Leaf) - && (parentType != ContentSpecNode::UnknownType)) - || ((firstType == ContentSpecNode::Leaf) - && (parentType == ContentSpecNode::UnknownType))) - { - doRepParens = true; - } - - // Now handle our type - switch(curType) - { - case ContentSpecNode::Leaf : - if (curNode->getElement()->getURI() == XMLElementDecl::fgPCDataElemId) - bufToFill.append(XMLElementDecl::fgPCDataElemName); - else - bufToFill.append(curNode->getElement()->getRawName()); - break; - - case ContentSpecNode::ZeroOrOne : - if (doRepParens) - bufToFill.append(chOpenParen); - formatNode(first, curType, bufToFill); - if (doRepParens) - bufToFill.append(chCloseParen); - bufToFill.append(chQuestion); - break; - - case ContentSpecNode::ZeroOrMore : - if (doRepParens) - bufToFill.append(chOpenParen); - formatNode(first, curType, bufToFill); - if (doRepParens) - bufToFill.append(chCloseParen); - bufToFill.append(chAsterisk); - break; - - case ContentSpecNode::OneOrMore : - if (doRepParens) - bufToFill.append(chOpenParen); - formatNode(first, curType, bufToFill); - if (doRepParens) - bufToFill.append(chCloseParen); - bufToFill.append(chPlus); - break; - - case ContentSpecNode::Choice : - if (parentType != curType) - bufToFill.append(chOpenParen); - formatNode(first, curType, bufToFill); - bufToFill.append(chPipe); - formatNode(second, curType, bufToFill); - if (parentType != curType) - bufToFill.append(chCloseParen); - break; - - case ContentSpecNode::Sequence : - if (parentType != curType) - bufToFill.append(chOpenParen); - formatNode(first, curType, bufToFill); - bufToFill.append(chComma); - formatNode(second, curType, bufToFill); - if (parentType != curType) - bufToFill.append(chCloseParen); - break; - } -} - - -// --------------------------------------------------------------------------- -// ContentSpecNode: Miscellaneous -// --------------------------------------------------------------------------- -void ContentSpecNode::formatSpec(XMLBuffer& bufToFill) const -{ - // Clean out the buffer first - bufToFill.reset(); - - if (fType == ContentSpecNode::Leaf) - bufToFill.append(chOpenParen); - formatNode - ( - this - , UnknownType - , bufToFill - ); - if (fType == ContentSpecNode::Leaf) - bufToFill.append(chCloseParen); -} diff --git a/src/validators/common/ContentSpecNode.hpp b/src/validators/common/ContentSpecNode.hpp deleted file mode 100644 index d372fec6a12520916191d456edefb32c9ed817ec..0000000000000000000000000000000000000000 --- a/src/validators/common/ContentSpecNode.hpp +++ /dev/null @@ -1,501 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999-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$ - * Revision 1.19 2001/12/06 17:50:42 tng - * Performance Enhancement. The ContentSpecNode constructor always copied the QName - * that was passed to it. Added a second constructor that allows the QName to be just assigned, not copied. - * That was because there are some cases in which a temporary QName was constructed, passed to ContentSpecNode, and then deleted. - * There were examples of that in TraverseSchema and DTDScanner. - * By Henry Zongaro. - * - * Revision 1.18 2001/11/07 21:50:28 tng - * Fix comment log that lead to error. - * - * Revision 1.17 2001/11/07 21:12:15 tng - * Performance: Create QName in ContentSpecNode only if it is a leaf/Any/PCDataNode. - * - * Revision 1.16 2001/08/28 20:21:08 peiyongz - * * AIX 4.2, xlC 3 rev.1 compilation error: get*() declared with external linkage - * and called or defined before being declared as inline - * - * Revision 1.15 2001/08/24 12:48:48 tng - * Schema: AllContentModel - * - * Revision 1.14 2001/08/23 11:54:26 tng - * Add newline at the end and various typo fixes. - * - * Revision 1.13 2001/08/22 16:04:07 tng - * ContentSpecNode copy constructor should copy Min and Max as well. - * - * Revision 1.12 2001/08/21 18:47:42 peiyongz - * AIX 4.2, xlC 3 rev.1 compilation error: dtor() declared with external linkage - * and called or defined before being declared as inline - * - * Revision 1.11 2001/08/21 16:06:11 tng - * Schema: Unique Particle Attribution Constraint Checking. - * - * Revision 1.10 2001/08/20 13:18:58 tng - * bug in ContentSpecNode copy constructor. - * - * Revision 1.9 2001/07/24 18:33:13 knoaman - * Added support for <group> + extra constraint checking for complexType - * - * Revision 1.8 2001/07/09 15:22:36 knoaman - * complete <any> declaration. - * - * Revision 1.7 2001/05/11 13:27:18 tng - * Copyright update. - * - * Revision 1.6 2001/05/10 16:33:08 knoaman - * Traverse Schema Part III + error messages. - * - * Revision 1.5 2001/05/03 20:34:39 tng - * Schema: SchemaValidator update - * - * Revision 1.4 2001/04/19 18:17:29 tng - * Schema: SchemaValidator update, and use QName in Content Model - * - * Revision 1.3 2001/03/21 21:56:26 tng - * Schema: Add Schema Grammar, Schema Validator, and split the DTDValidator into DTDValidator, DTDScanner, and DTDGrammar. - * - * Revision 1.2 2001/02/27 14:48:49 tng - * Schema: Add CMAny and ContentLeafNameTypeVector, by Pei Yong Zhang - * - * Revision 1.1 2001/02/16 14:17:29 tng - * Schema: Move the common Content Model files that are shared by DTD - * and schema from 'DTD' folder to 'common' folder. By Pei Yong Zhang. - * - * Revision 1.4 2000/03/02 19:55:38 roddey - * This checkin includes many changes done while waiting for the - * 1.1.0 code to be finished. I can't list them all here, but a list is - * available elsewhere. - * - * Revision 1.3 2000/02/24 20:16:48 abagchi - * Swat for removing Log from API docs - * - * Revision 1.2 2000/02/09 21:42:37 abagchi - * Copyright swat - * - * Revision 1.1.1.1 1999/11/09 01:03:14 twl - * Initial checkin - * - * Revision 1.2 1999/11/08 20:45:38 rahul - * Swat for adding in Product name and CVS comment log variable. - * - */ - - -#if !defined(CONTENTSPECNODE_HPP) -#define CONTENTSPECNODE_HPP - -#include <framework/XMLElementDecl.hpp> -#include <util/XercesDefs.hpp> - -class XMLBuffer; -class Grammar; - - -class ContentSpecNode -{ -public : - // ----------------------------------------------------------------------- - // Class specific types - // ----------------------------------------------------------------------- - enum NodeTypes - { - Leaf = 0 - , ZeroOrOne - , ZeroOrMore - , OneOrMore - , Choice - , Sequence - , Any - , Any_Other - , Any_NS = 8 - , All = 9 - , Any_Lax = 22 - , Any_Other_Lax = 23 - , Any_NS_Lax = 24 - , Any_Skip = 38 - , Any_Other_Skip = 39 - , Any_NS_Skip = 40 - - , UnknownType = -1 - }; - - - // ----------------------------------------------------------------------- - // Constructors and Destructor - // ----------------------------------------------------------------------- - ContentSpecNode(); - ContentSpecNode(QName* const toAdopt); - ContentSpecNode(QName* const toAdopt, const bool copyQName); - ContentSpecNode - ( - const NodeTypes type - , ContentSpecNode* const firstToAdopt - , ContentSpecNode* const secondToAdopt - , const bool adoptFirst = true - , const bool adoptSecond = true - ); - ContentSpecNode(const ContentSpecNode&); - ~ContentSpecNode(); - - // ----------------------------------------------------------------------- - // Getter methods - // ----------------------------------------------------------------------- - QName* getElement(); - const QName* getElement() const; - ContentSpecNode* getFirst(); - const ContentSpecNode* getFirst() const; - ContentSpecNode* getSecond(); - const ContentSpecNode* getSecond() const; - NodeTypes getType() const; - ContentSpecNode* orphanFirst(); - ContentSpecNode* orphanSecond(); - unsigned int getMinOccurs() const; - unsigned int getMaxOccurs() const; - bool isFirstAdopted() const; - bool isSecondAdopted() const; - - - // ----------------------------------------------------------------------- - // Setter methods - // ----------------------------------------------------------------------- - void setElement(QName* const toAdopt); - void setFirst(ContentSpecNode* const toAdopt); - void setSecond(ContentSpecNode* const toAdopt); - void setType(const NodeTypes type); - void setMinOccurs(unsigned int min); - void setMaxOccurs(unsigned int max); - void setAdoptFirst(bool adoptFirst); - void setAdoptSecond(bool adoptSecond); - - - // ----------------------------------------------------------------------- - // Miscellaneous - // ----------------------------------------------------------------------- - void formatSpec (XMLBuffer& bufToFill) const; - - -private : - // ----------------------------------------------------------------------- - // Unimplemented constructors and operators - // ----------------------------------------------------------------------- - - - - // ----------------------------------------------------------------------- - // Private Data Members - // - // fElement - // If the type is Leaf/Any*, then this is the qName of the element. If the URI - // is fgPCDataElemId, then its a PCData node. Else, it is zero. - // - // fFirst - // fSecond - // The optional first and second nodes. The fType field indicates - // which of these are valid. The validaty constraints are: - // - // Leaf = Neither valid - // ZeroOrOne, ZeroOrMore = First - // Choice, Sequence, All = First and Second - // Any* = Neither valid - // - // fType - // The type of node. This controls how many of the child node fields - // are used. - // - // fAdoptFirst - // Indicate if this ContentSpecNode adopts the fFirst, and is responsible - // for deleting it. - // - // fAdoptSecond - // Indicate if this ContentSpecNode adopts the fSecond, and is responsible - // for deleting it. - // - // fMinOccurs - // Indicate the minimum times that this node can occur - // - // fMaxOccurs - // Indicate the maximum times that this node can occur - // -1 (Unbounded), default (1) - // ----------------------------------------------------------------------- - QName* fElement; - ContentSpecNode* fFirst; - ContentSpecNode* fSecond; - NodeTypes fType; - bool fAdoptFirst; - bool fAdoptSecond; - unsigned int fMinOccurs; - unsigned int fMaxOccurs; -}; - -// --------------------------------------------------------------------------- -// ContentSpecNode: Constructors and Destructor -// --------------------------------------------------------------------------- -inline ContentSpecNode::ContentSpecNode() : - - fElement(0) - , fFirst(0) - , fSecond(0) - , fType(ContentSpecNode::Leaf) - , fAdoptFirst(true) - , fAdoptSecond(true) - , fMinOccurs(1) - , fMaxOccurs(1) -{ -} - -inline -ContentSpecNode::ContentSpecNode(QName* const element) : - - fElement(0) - , fFirst(0) - , fSecond(0) - , fType(ContentSpecNode::Leaf) - , fAdoptFirst(true) - , fAdoptSecond(true) - , fMinOccurs(1) - , fMaxOccurs(1) -{ - if (element) - fElement = new QName(element); -} - -inline -ContentSpecNode::ContentSpecNode(QName* const element - , const bool copyQName) : - - fElement(0) - , fFirst(0) - , fSecond(0) - , fType(ContentSpecNode::Leaf) - , fAdoptFirst(true) - , fAdoptSecond(true) - , fMinOccurs(1) - , fMaxOccurs(1) -{ - if (copyQName) - { - if (element) - fElement = new QName(element); - } - else - { - fElement = element; - } -} - -inline -ContentSpecNode::ContentSpecNode(const NodeTypes type - , ContentSpecNode* const firstAdopt - , ContentSpecNode* const secondAdopt - , const bool adoptFirst - , const bool adoptSecond) : - - fElement(0) - , fFirst(firstAdopt) - , fSecond(secondAdopt) - , fType(type) - , fAdoptFirst(adoptFirst) - , fAdoptSecond(adoptSecond) - , fMinOccurs(1) - , fMaxOccurs(1) -{ -} - - -inline ContentSpecNode::~ContentSpecNode() -{ - // Delete our children, which cause recursive cleanup - if (fAdoptFirst) { - delete fFirst; - } - - if (fAdoptSecond) { - delete fSecond; - } - - delete fElement; -} - -// --------------------------------------------------------------------------- -// ContentSpecNode: Getter methods -// --------------------------------------------------------------------------- -inline QName* ContentSpecNode::getElement() -{ - return fElement; -} - -inline const QName* ContentSpecNode::getElement() const -{ - return fElement; -} - -inline ContentSpecNode* ContentSpecNode::getFirst() -{ - return fFirst; -} - -inline const ContentSpecNode* ContentSpecNode::getFirst() const -{ - return fFirst; -} - -inline ContentSpecNode* ContentSpecNode::getSecond() -{ - return fSecond; -} - -inline const ContentSpecNode* ContentSpecNode::getSecond() const -{ - return fSecond; -} - -inline ContentSpecNode::NodeTypes ContentSpecNode::getType() const -{ - return fType; -} - -inline ContentSpecNode* ContentSpecNode::orphanFirst() -{ - ContentSpecNode* retNode = fFirst; - fFirst = 0; - return retNode; -} - -inline ContentSpecNode* ContentSpecNode::orphanSecond() -{ - ContentSpecNode* retNode = fSecond; - fSecond = 0; - return retNode; -} - -inline unsigned int ContentSpecNode::getMinOccurs() const -{ - return fMinOccurs; -} - -inline unsigned int ContentSpecNode::getMaxOccurs() const -{ - return fMaxOccurs; -} - -inline bool ContentSpecNode::isFirstAdopted() const -{ - return fAdoptFirst; -} - -inline bool ContentSpecNode::isSecondAdopted() const -{ - return fAdoptSecond; -} - - -// --------------------------------------------------------------------------- -// ContentSpecType: Setter methods -// --------------------------------------------------------------------------- -inline void ContentSpecNode::setElement(QName* const element) -{ - delete fElement; - fElement = 0; - if (element) - fElement = new QName(element); -} - -inline void ContentSpecNode::setFirst(ContentSpecNode* const toAdopt) -{ - if (fAdoptFirst) - delete fFirst; - fFirst = toAdopt; -} - -inline void ContentSpecNode::setSecond(ContentSpecNode* const toAdopt) -{ - if (fAdoptSecond) - delete fSecond; - fSecond = toAdopt; -} - -inline void ContentSpecNode::setType(const NodeTypes type) -{ - fType = type; -} - -inline void ContentSpecNode::setMinOccurs(unsigned int min) -{ - fMinOccurs = min; -} - -inline void ContentSpecNode::setMaxOccurs(unsigned int max) -{ - fMaxOccurs = max; -} - -inline void ContentSpecNode::setAdoptFirst(bool newState) -{ - fAdoptFirst = newState; -} - -inline void ContentSpecNode::setAdoptSecond(bool newState) -{ - fAdoptSecond = newState; -} - -#endif diff --git a/src/validators/common/DFAContentModel.cpp b/src/validators/common/DFAContentModel.cpp deleted file mode 100644 index 10e9e551222d356121f9e0b4e2b6ca14c05ed76d..0000000000000000000000000000000000000000 --- a/src/validators/common/DFAContentModel.cpp +++ /dev/null @@ -1,1264 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999-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$ - * Revision 1.29 2001/12/10 21:42:55 peiyongz - * Memory Leak: fLeafNameTypeVector - * - * Revision 1.28 2001/12/06 17:52:17 tng - * Performance Enhancement. The QName that was passed to the CMLeaf - * constructor was always being copied, even though the CMLeaf objects - * only existed during construction of a DFA. In most cases the original - * QName that was passed into the CMLeaf constructor continued to exist long - * after the CMLeaf was destroyed; in some cases the QName was constructed - * specifically to be passed to the CMLeaf constructor. Added a second CMLeaf constructor that indicated the QName passed in was to be adopted; otherwise the CMLeaf constructor just sets a reference to the QName passed in. - * By Henry Zongaro. - * - * Revision 1.27 2001/11/21 14:30:13 knoaman - * Fix for UPA checking. - * - * Revision 1.26 2001/11/07 21:10:46 tng - * Performance: move getRawName() to outer loop so that it is called only once per outer loop. - * - * Revision 1.25 2001/10/04 15:08:55 knoaman - * Add support for circular import. - * - * Revision 1.24 2001/09/14 14:50:22 tng - * Schema: Fix some wildcard bugs, and some retrieving qualified/unqualified element decl problems. - * - * Revision 1.23 2001/08/24 12:48:48 tng - * Schema: AllContentModel - * - * Revision 1.22 2001/08/22 16:58:55 tng - * typo: should issue the name of second element. - * - * Revision 1.21 2001/08/21 16:50:23 tng - * Schema: Unique Particle Attribution Constraint Checking. - * - * Revision 1.20 2001/08/21 16:06:11 tng - * Schema: Unique Particle Attribution Constraint Checking. - * - * Revision 1.19 2001/08/17 16:12:51 peiyongz - * Fix to memory leak in buildDFA(), patch from Nick Chiang (nchiang@ss8.com) - * - * Revision 1.18 2001/08/16 21:52:40 peiyongz - * stateTable created to optimize the identification of new state created. - * - * Revision 1.17 2001/07/31 17:45:25 peiyongz - * Fix: memory leak in postTreeBuildInit() - * - * Revision 1.16 2001/07/24 20:00:33 peiyongz - * Memory Leak fix: Bugzilla #2707 reported by Francois Rioux - * - * + | DESCRIPTION | - * + There are some memory leaks in the buildDFA method : - * + the first QName allocated object - * + the nodeOrgContent - * + fHeadNode - * - * Revision 1.15 2001/07/09 15:22:36 knoaman - * complete <any> declaration. - * - * Revision 1.14 2001/06/13 20:50:56 peiyongz - * fIsMixed: to handle mixed Content Model - * - * Revision 1.13 2001/06/12 19:07:14 peiyongz - * Memory leak: fixed by Erik Rydgren - * - * Revision 1.12 2001/06/12 17:30:49 knoaman - * Fix Typo - * - * Revision 1.11 2001/06/07 21:08:20 tng - * Fix unsigned/signed warning from Linux. By Pei Yong Zhang. - * - * Revision 1.10 2001/05/28 20:52:44 tng - * Schema: move static data gInvalidTrans, gEOCFakeId, gEpsilonFakeId to XMLContentModel for others to access - * - * Revision 1.9 2001/05/11 13:27:18 tng - * Copyright update. - * - * Revision 1.8 2001/05/03 21:02:29 tng - * Schema: Add SubstitutionGroupComparator and update exception messages. By Pei Yong Zhang. - * - * Revision 1.7 2001/04/19 18:17:30 tng - * Schema: SchemaValidator update, and use QName in Content Model - * - * Revision 1.6 2001/03/21 21:56:27 tng - * Schema: Add Schema Grammar, Schema Validator, and split the DTDValidator into DTDValidator, DTDScanner, and DTDGrammar. - * - * Revision 1.5 2001/03/21 19:29:51 tng - * Schema: Content Model Updates, by Pei Yong Zhang. - * - * Revision 1.4 2001/02/27 18:32:31 tng - * Schema: Use XMLElementDecl instead of DTDElementDecl in Content Model. - * - * Revision 1.3 2001/02/27 14:48:51 tng - * Schema: Add CMAny and ContentLeafNameTypeVector, by Pei Yong Zhang - * - * Revision 1.2 2001/02/16 14:58:57 tng - * Schema: Update Makefile, configure files, project files, and include path in - * certain cpp files because of the move of the common Content Model files. By Pei Yong Zhang. - * - * Revision 1.1 2001/02/16 14:17:29 tng - * Schema: Move the common Content Model files that are shared by DTD - * and schema from 'DTD' folder to 'common' folder. By Pei Yong Zhang. - * - * Revision 1.5 2000/03/28 19:43:25 roddey - * Fixes for signed/unsigned warnings. New work for two way transcoding - * stuff. - * - * Revision 1.4 2000/03/08 23:52:34 roddey - * Got rid of the use of -1 to represent an invalid transition state, - * and just created a const value that is unsigned. This should make - * some compilers happier. - * - * Revision 1.3 2000/03/02 19:55:38 roddey - * This checkin includes many changes done while waiting for the - * 1.1.0 code to be finished. I can't list them all here, but a list is - * available elsewhere. - * - * Revision 1.2 2000/02/09 21:42:37 abagchi - * Copyright swatswat - * - * Revision 1.1.1.1 1999/11/09 01:03:17 twl - * Initial checkin - * - * Revision 1.2 1999/11/08 20:45:38 rahul - * Swat for adding in Product name and CVS comment log variable. - * - */ - - -// --------------------------------------------------------------------------- -// Includes -// --------------------------------------------------------------------------- -#include <util/RuntimeException.hpp> -#include <framework/XMLBuffer.hpp> -#include <framework/XMLElementDecl.hpp> -#include <framework/XMLValidator.hpp> -#include <validators/common/CMAny.hpp> -#include <validators/common/CMBinaryOp.hpp> -#include <validators/common/CMLeaf.hpp> -#include <validators/common/CMUnaryOp.hpp> -#include <validators/common/DFAContentModel.hpp> -#include <validators/common/ContentSpecNode.hpp> -#include <validators/common/Grammar.hpp> -#include <validators/schema/SchemaSymbols.hpp> -#include <validators/schema/SubstitutionGroupComparator.hpp> -#include <validators/schema/XercesElementWildcard.hpp> -#include <util/RefHashTableOf.hpp> -#include <util/HashCMStateSet.hpp> -#include <util/XMLInteger.hpp> - - -// --------------------------------------------------------------------------- -// DFAContentModel: Constructors and Destructor -// --------------------------------------------------------------------------- -DFAContentModel::DFAContentModel(const bool dtd - , ContentSpecNode* const elemContentSpec) : - - fElemMap(0) - , fElemMapType(0) - , fElemMapSize(0) - , fEmptyOk(false) - , fEOCPos(0) - , fFinalStateFlags(0) - , fFollowList(0) - , fHeadNode(0) - , fLeafCount(0) - , fLeafList(0) - , fTransTable(0) - , fTransTableSize(0) - , fDTD(dtd) - , fIsMixed(false) - , fLeafNameTypeVector(0) -{ - // And build the DFA data structures - buildDFA(elemContentSpec); -} - -DFAContentModel::DFAContentModel(const bool dtd - , ContentSpecNode* const elemContentSpec - , const bool isMixed ): - - fElemMap(0) - , fElemMapType(0) - , fElemMapSize(0) - , fEmptyOk(false) - , fEOCPos(0) - , fFinalStateFlags(0) - , fFollowList(0) - , fHeadNode(0) - , fLeafCount(0) - , fLeafList(0) - , fTransTable(0) - , fTransTableSize(0) - , fDTD(dtd) - , fIsMixed(isMixed) - , fLeafNameTypeVector(0) -{ - // And build the DFA data structures - buildDFA(elemContentSpec); -} - -DFAContentModel::~DFAContentModel() -{ - // - // Clean up all the stuff that is not just temporary representation - // data that was cleaned up after building the DFA. - // - delete [] fFinalStateFlags; - - unsigned index; - for (index = 0; index < fTransTableSize; index++) - delete [] fTransTable[index]; - delete [] fTransTable; - - for (index = 0; index < fLeafCount; index++) - delete fElemMap[index]; - delete [] fElemMap; - - delete [] fElemMapType; - delete [] fLeafListType; - - delete fLeafNameTypeVector; -} - - -// --------------------------------------------------------------------------- -// DFAContentModel: Implementation of the ContentModel virtual interface -// --------------------------------------------------------------------------- -int -DFAContentModel::validateContent( QName** const children - , const unsigned int childCount - , const unsigned int emptyNamespaceId) const -{ - // - // If there are no children, then either we fail on the 0th element - // or we return success. It depends upon whether this content model - // accepts empty content, which we determined earlier. - // - if (!childCount) - { - // success -1 - return fEmptyOk ? -1 : 0; - } - - // - // Lets loop through the children in the array and move our way - // through the states. Note that we use the fElemMap array to map - // an element index to a state index. - // - unsigned int curState = 0; - unsigned int nextState = 0; - unsigned int childIndex = 0; - for (; childIndex < childCount; childIndex++) - { - // Get the current element index out - const QName* curElem = children[childIndex]; - const XMLCh* curElemRawName = 0; - if (fDTD) - curElemRawName = curElem->getRawName(); - - // If this is text in a Schema mixed content model, skip it. - if ( fIsMixed && - ( curElem->getURI() == XMLElementDecl::fgPCDataElemId)) - continue; - - // Look up this child in our element map - unsigned int elemIndex = 0; - for (; elemIndex < fElemMapSize; elemIndex++) - { - const QName* inElem = fElemMap[elemIndex]; - if (fDTD) { - if (!XMLString::compareString(inElem->getRawName(), curElemRawName)) { - nextState = fTransTable[curState][elemIndex]; - if (nextState != XMLContentModel::gInvalidTrans) - break; - } - } - else { - ContentSpecNode::NodeTypes type = fElemMapType[elemIndex]; - if (type == ContentSpecNode::Leaf) - { - if ((inElem->getURI() == curElem->getURI()) && - (!XMLString::compareString(inElem->getLocalPart(), curElem->getLocalPart()))) { - nextState = fTransTable[curState][elemIndex]; - if (nextState != XMLContentModel::gInvalidTrans) - break; - } - } - else if ((type & 0x0f)== ContentSpecNode::Any) - { - nextState = fTransTable[curState][elemIndex]; - if (nextState != XMLContentModel::gInvalidTrans) - break; - } - else if ((type & 0x0f) == ContentSpecNode::Any_NS) - { - if (inElem->getURI() == curElem->getURI()) - { - nextState = fTransTable[curState][elemIndex]; - if (nextState != XMLContentModel::gInvalidTrans) - break; - } - } - else if ((type & 0x0f) == ContentSpecNode::Any_Other) - { - if (inElem->getURI() != curElem->getURI()) { - nextState = fTransTable[curState][elemIndex]; - if (nextState != XMLContentModel::gInvalidTrans) - break; - } - } - } - }//for elemIndex - - // If "nextState" is -1, we found a match, but the transition is invalid - if (nextState == XMLContentModel::gInvalidTrans) - return childIndex; - - // If we didn't find it, then obviously not valid - if (elemIndex == fElemMapSize) - return childIndex; - - curState = nextState; - nextState = 0; - - }//for childIndex - - // - // We transitioned all the way through the input list. However, that - // does not mean that we ended in a final state. So check whether - // our ending state is a final state. - // - if (!fFinalStateFlags[curState]) - return childIndex; - - //success - return -1; -} - -int DFAContentModel::validateContentSpecial(QName** const children - , const unsigned int childCount - , const unsigned int emptyNamespaceId - , GrammarResolver* const pGrammarResolver - , XMLStringPool* const pStringPool) const -{ - - SubstitutionGroupComparator comparator(pGrammarResolver, pStringPool); - - if (childCount == 0) - return fEmptyOk ? -1 : 0; - - // - // Lets loop through the children in the array and move our way - // through the states. Note that we use the fElemMap array to map - // an element index to a state index. - // - unsigned int curState = 0; - unsigned int nextState = 0; - unsigned int childIndex = 0; - for (; childIndex < childCount; childIndex++) - { - // Get the current element index out - QName* curElem = children[childIndex]; - - // If this is text in a Schema mixed content model, skip it. - if ( fIsMixed && - ( curElem->getURI() == XMLElementDecl::fgPCDataElemId)) - continue; - - // Look up this child in our element map - unsigned int elemIndex = 0; - for (; elemIndex < fElemMapSize; elemIndex++) - { - QName* inElem = fElemMap[elemIndex]; - ContentSpecNode::NodeTypes type = fElemMapType[elemIndex]; - if (type == ContentSpecNode::Leaf) - { - if (comparator.isEquivalentTo(curElem, inElem) ) - { - nextState = fTransTable[curState][elemIndex]; - if (nextState != XMLContentModel::gInvalidTrans) - break; - } - - } - else if ((type & 0x0f)== ContentSpecNode::Any) - { - nextState = fTransTable[curState][elemIndex]; - if (nextState != XMLContentModel::gInvalidTrans) - break; - } - else if ((type & 0x0f) == ContentSpecNode::Any_NS) - { - if (inElem->getURI() == curElem->getURI()) - { - nextState = fTransTable[curState][elemIndex]; - if (nextState != XMLContentModel::gInvalidTrans) - break; - } - } - else if ((type & 0x0f) == ContentSpecNode::Any_Other) - { - if (inElem->getURI() != curElem->getURI()) - { - nextState = fTransTable[curState][elemIndex]; - if (nextState != XMLContentModel::gInvalidTrans) - break; - } - } - }//for elemIndex - - // If "nextState" is -1, we found a match, but the transition is invalid - if (nextState == XMLContentModel::gInvalidTrans) - return childIndex; - - // If we didn't find it, then obviously not valid - if (elemIndex == fElemMapSize) - return childIndex; - - curState = nextState; - nextState = 0; - - }//for childIndex - - // - // We transitioned all the way through the input list. However, that - // does not mean that we ended in a final state. So check whether - // our ending state is a final state. - // - if (!fFinalStateFlags[curState]) - return childIndex; - - //success - return -1; -} - - -// --------------------------------------------------------------------------- -// DFAContentModel: Private helper methods -// --------------------------------------------------------------------------- -void DFAContentModel::buildDFA(ContentSpecNode* const curNode) -{ - unsigned int index; - - - // - // The first step we need to take is to rewrite the content model using - // our CMNode objects, and in the process get rid of any repetition short - // cuts, converting them into '*' style repetitions or getting rid of - // repetitions altogether. - // - // The conversions done are: - // - // x+ -> (x|x*) - // x? -> (x|epsilon) - // - // This is a relatively complex scenario. What is happening is that we - // create a top level binary node of which the special EOC value is set - // as the right side node. The the left side is set to the rewritten - // syntax tree. The source is the original content model info from the - // decl pool. The rewrite is done by buildSyntaxTree() which recurses the - // decl pool's content of the element and builds a new tree in the - // process. - // - // Note that, during this operation, we set each non-epsilon leaf node's - // DFA state position and count the number of such leafs, which is left - // in the fLeafCount member. - // - CMLeaf* nodeEOC = new CMLeaf(new QName(XMLUni::fgZeroLenString, - XMLUni::fgZeroLenString, - XMLContentModel::gEOCFakeId) - , ~0 - , true); - CMNode* nodeOrgContent = buildSyntaxTree(curNode); - fHeadNode = new CMBinaryOp - ( - ContentSpecNode::Sequence - , nodeOrgContent - , nodeEOC - ); - - // - // And handle specially the EOC node, which also must be numbered and - // counted as a non-epsilon leaf node. It could not be handled in the - // above tree build because it was created before all that started. We - // save the EOC position since its used during the DFA building loop. - // - fEOCPos = fLeafCount; - nodeEOC->setPosition(fLeafCount++); - - // - // Ok, so now we have to iterate the new tree and do a little more work - // now that we know the leaf count. One thing we need to do is to - // calculate the first and last position sets of each node. This is - // cached away in each of the nodes. - // - // Along the way we also set the leaf count in each node as the maximum - // state count. They must know this in order to create their first/last - // position sets. - // - // We also need to build an array of references to the non-epsilon - // leaf nodes. Since we iterate here the same way as we did during the - // initial tree build (which built their position numbers, we will put - // them in the array according to their position values. - // - fLeafList = new CMLeaf*[fLeafCount]; - fLeafListType = new ContentSpecNode::NodeTypes[fLeafCount]; - postTreeBuildInit(fHeadNode, 0); - - // - // And, moving onward... We now need to build the follow position sets - // for all the nodes. So we allocate an array of pointers to state sets, - // one for each leaf node (i.e. each significant DFA position.) - // - fFollowList = new CMStateSet*[fLeafCount]; - for (index = 0; index < fLeafCount; index++) - fFollowList[index] = new CMStateSet(fLeafCount); - calcFollowList(fHeadNode); - - // - // Check to see whether this content model can handle an empty content, - // which is something we need to optimize by looking now before we - // throw away the info that would tell us that. - // - // If the left node of the head (the top level of the original content) - // is nullable, then its true. - // - fEmptyOk = nodeOrgContent->isNullable(); - - // - // And finally the big push... Now we build the DFA using all the states - // and the tree we've built up. First we set up the various data - // structures we are going to use while we do this. - // - // First of all we need an array of unique element ids in our content - // model. For each transition table entry, we need a set of contiguous - // indices to represent the transitions for a particular input element. - // So we need to a zero based range of indexes that map to element types. - // This element map provides that mapping. - // - fElemMap = new QName*[fLeafCount]; - fElemMapType = new ContentSpecNode::NodeTypes[fLeafCount]; - fElemMapSize = 0; - - - for (unsigned int outIndex = 0; outIndex < fLeafCount; outIndex++) - { - fElemMap[outIndex] = new QName(); - - if ( (fLeafListType[outIndex] & 0x0f) != ContentSpecNode::Leaf ) - if (!fLeafNameTypeVector) - fLeafNameTypeVector = new ContentLeafNameTypeVector(); - - // Get the current leaf's element index - const QName* element = fLeafList[outIndex]->getElement(); - const XMLCh* elementRawName = 0; - if (fDTD && element) - elementRawName = element->getRawName(); - - // See if the current leaf node's element index is in the list - unsigned int inIndex = 0; - - for (; inIndex < fElemMapSize; inIndex++) - { - const QName* inElem = fElemMap[inIndex]; - if (fDTD) { - if (!XMLString::compareString(inElem->getRawName(), elementRawName)) { - break; - } - } - else { - if ((fElemMapType[inIndex] == fLeafListType[outIndex]) && - (inElem->getURI() == element->getURI()) && - (!XMLString::compareString(inElem->getLocalPart(), element->getLocalPart()))) { - break; - } - } - } - - // If it was not in the list, then add it and bump the map size - if (inIndex == fElemMapSize) - { - fElemMap[fElemMapSize]->setValues(*element); - fElemMapType[fElemMapSize] = fLeafListType[outIndex]; - ++fElemMapSize; - } - } - - // set up the fLeafNameTypeVector object if there is one. - if (fLeafNameTypeVector) { - fLeafNameTypeVector->setValues(fElemMap, fElemMapType, fElemMapSize); - } - - /*** - * Optimization(Jan, 2001); We sort fLeafList according to - * elemIndex which is *uniquely* associated to each leaf. - * We are *assuming* that each element appears in at least one leaf. - **/ - // don't forget to delete it - - int *fLeafSorter = new int[fLeafCount + fElemMapSize]; - unsigned int fSortCount = 0; - - for (unsigned int elemIndex = 0; elemIndex < fElemMapSize; elemIndex++) - { - const QName* element = fElemMap[elemIndex]; - const XMLCh* elementRawName = 0; - if (fDTD && element) - elementRawName = element->getRawName(); - - for (unsigned int leafIndex = 0; leafIndex < fLeafCount; leafIndex++) - { - const QName* leaf = fLeafList[leafIndex]->getElement(); - const int leafType = fLeafListType[leafIndex]; - if (fDTD) { - if (!XMLString::compareString(leaf->getRawName(), elementRawName)) { - fLeafSorter[fSortCount++] = leafIndex; - } - } - else { - if ((fElemMapType[elemIndex] == fLeafListType[leafIndex]) && - (leaf->getURI() == element->getURI()) && - (!XMLString::compareString(leaf->getLocalPart(), element->getLocalPart()))) { - fLeafSorter[fSortCount++] = leafIndex; - } - } - } - fLeafSorter[fSortCount++] = -1; - } - - // - // Next lets create some arrays, some that that hold transient info - // during the DFA build and some that are permament. These are kind of - // sticky since we cannot know how big they will get, but we don't want - // to use any collection type classes because of performance. - // - // Basically they will probably be about fLeafCount*2 on average, but can - // be as large as 2^(fLeafCount*2), worst case. So we start with - // fLeafCount*4 as a middle ground. This will be very unlikely to ever - // have to expand though, it if does, the overhead will be somewhat ugly. - // - unsigned int curArraySize = fLeafCount * 4; - const CMStateSet** statesToDo = new const CMStateSet*[curArraySize]; - fFinalStateFlags = new bool[curArraySize]; - fTransTable = new unsigned int*[curArraySize]; - - // - // Ok we start with the initial set as the first pos set of the head node - // (which is the seq node that holds the content model and the EOC node.) - // - const CMStateSet* setT = new CMStateSet(fHeadNode->getFirstPos()); - - // - // Init our two state flags. Basically the unmarked state counter is - // always chasing the current state counter. When it catches up, that - // means we made a pass through that did not add any new states to the - // lists, at which time we are done. We could have used a expanding array - // of flags which we used to mark off states as we complete them, but - // this is easier though less readable maybe. - // - unsigned int unmarkedState = 0; - unsigned int curState = 0; - - // - // Init the first transition table entry, and put the initial state - // into the states to do list, then bump the current state. - // - fTransTable[curState] = makeDefStateList(); - statesToDo[curState] = setT; - curState++; - - // - // the stateTable is an auxiliary means to fast - // identification of new state created (instead - // of squential loop statesToDo to find out), - // while the role that statesToDo plays remain unchanged. - // - // TODO: in the future, we may change the 29 to something - // derived from curArraySize. - RefHashTableOf<XMLInteger> *stateTable = new RefHashTableOf<XMLInteger>(curArraySize, true, new HashCMStateSet()); - //stateTable->put((CMStateSet*)setT, new XMLInteger(0)); - - // - // Ok, almost done with the algorithm from hell... We now enter the - // loop where we go until the states done counter catches up with - // the states to do counter. - // - CMStateSet* newSet = 0; - while (unmarkedState < curState) - { - // - // Get the next unmarked state out of the list of states to do. - // And get the associated transition table entry. - // - setT = statesToDo[unmarkedState]; - unsigned int* transEntry = fTransTable[unmarkedState]; - - // Mark this one final if it contains the EOC state - fFinalStateFlags[unmarkedState] = setT->getBit(fEOCPos); - - // Bump up the unmarked state count, marking this state done - unmarkedState++; - - // Optimization(Jan, 2001) - unsigned int sorterIndex = 0; - // Optimization(Jan, 2001) - - // Loop through each possible input symbol in the element map - for (unsigned int elemIndex = 0; elemIndex < fElemMapSize; elemIndex++) - { - // - // Build up a set of states which is the union of all of the - // follow sets of DFA positions that are in the current state. If - // we gave away the new set last time through then create a new - // one. Otherwise, zero out the existing one. - // - if (!newSet) - newSet = new CMStateSet(fLeafCount); - else - newSet->zeroBits(); - -#ifdef OBSOLETED -// unoptimized code - for (unsigned int leafIndex = 0; leafIndex < fLeafCount; leafIndex++) - { - // If this leaf index (DFA position) is in the current set... - if (setT->getBit(leafIndex)) - { - // - // If this leaf is the current input symbol, then we want - // to add its follow list to the set of states to transition - // to from the current state. - // - const QName* leaf = fLeafList[leafIndex]->getElement(); - const QName* element = fElemMap[elemIndex]; - if (fDTD) { - if (!XMLString::compareString(leaf->getRawName(), element->getRawName())) { - *newSet |= *fFollowList[leafIndex]; - } - } - else { - if ((leaf->getURI() == element->getURI()) && - (!XMLString::compareString(leaf->getLocalPart(), element->getLocalPart()))) { - *newSet |= *fFollowList[leafIndex]; - } - } - } - } // for leafIndex -#endif - - // Optimization(Jan, 2001) - int leafIndex = fLeafSorter[sorterIndex++]; - - while (leafIndex != -1) - { - // If this leaf index (DFA position) is in the current set... - if (setT->getBit(leafIndex)) - { - // - // If this leaf is the current input symbol, then we - // want to add its follow list to the set of states to - // transition to from the current state. - // - *newSet |= *fFollowList[leafIndex]; - } - leafIndex = fLeafSorter[sorterIndex++]; - } // while (leafIndex != -1) - - // - // If this new set is not empty, then see if its in the list - // of states to do. If not, then add it. - // - if (!newSet->isEmpty()) - { - // - // Search the 'states to do' list to see if this new - // state set is already in there. - // - /*** - unsigned int stateIndex = 0; - for (; stateIndex < curState; stateIndex++) - { - if (*statesToDo[stateIndex] == *newSet) - break; - } - ***/ - - XMLInteger *stateObj = (XMLInteger*) (stateTable->get(newSet)); - unsigned int stateIndex = (stateObj == 0 ? curState : stateObj->intValue()); - - // If we did not find it, then add it - if (stateIndex == curState) - { - // - // Put this new state into the states to do and init - // a new entry at the same index in the transition - // table. - // - statesToDo[curState] = newSet; - fTransTable[curState] = makeDefStateList(); - stateTable->put(newSet, new XMLInteger(curState)); - - // We now have a new state to do so bump the count - curState++; - - // - // Null out the new set to indicate we adopted it. This - // will cause the creation of a new set on the next time - // around the loop. - // - newSet = 0; - } - - // - // Now set this state in the transition table's entry for this - // element (using its index), with the DFA state we will move - // to from the current state when we see this input element. - // - transEntry[elemIndex] = stateIndex; - - // Expand the arrays if we're full - if (curState == curArraySize) - { - // - // Yikes, we overflowed the initial array size, so we've - // got to expand all of these arrays. So adjust up the - // size by 50% and allocate new arrays. - // - const unsigned int newSize = (unsigned int)(curArraySize * 1.5); - const CMStateSet** newToDo = new const CMStateSet*[newSize]; - bool* newFinalFlags = new bool[newSize]; - unsigned int** newTransTable = new unsigned int*[newSize]; - - // Copy over all of the existing content - for (unsigned int expIndex = 0; expIndex < curArraySize; expIndex++) - { - newToDo[expIndex] = statesToDo[expIndex]; - newFinalFlags[expIndex] = fFinalStateFlags[expIndex]; - newTransTable[expIndex] = fTransTable[expIndex]; - } - - // Clean up the old stuff - delete [] statesToDo; - delete [] fFinalStateFlags; - delete [] fTransTable; - - // Store the new array size and pointers - curArraySize = newSize; - statesToDo = newToDo; - fFinalStateFlags = newFinalFlags; - fTransTable = newTransTable; - } //if (curState == curArraySize) - } //if (!newSet->isEmpty()) - } // for elemIndex - } //while - - // Store the current state count in the trans table size - fTransTableSize = curState; - - // If the last temp set was not stored, then clean it up - if (newSet) - delete newSet; - - // - // Now we can clean up all of the temporary data that was needed during - // DFA build. - // - - // - // Note on memory leak: Bugzilla#2707: - // =================================== - // The CMBinary, pointed to by fHeadNode, shall be released by - // deleted by itself. - // - // Change has been made to postTreeBuildInit() such that fLeafList[] - // would maintain its **OWN** copy of CMLeaf to avoid double deletion - // of CMLeaf. - // - - delete fHeadNode; - - for (index = 0; index < fLeafCount; index++) - delete fFollowList[index]; - delete [] fFollowList; - - // - // removeAll() will delete all data, XMLInteger, - // while the keys are to be deleted by the - // deletion of statesToDo. - // - delete stateTable; - - for (index = 0; index < curState; index++) - delete (CMStateSet*)statesToDo[index]; - delete [] statesToDo; - - for (index = 0; index < fLeafCount; index++) - delete fLeafList[index]; - delete [] fLeafList; - - delete [] fLeafSorter; - -} - - -CMNode* DFAContentModel::buildSyntaxTree(ContentSpecNode* const curNode) -{ - // Initialize a return node pointer - CMNode* retNode = 0; - - // Get the spec type of the passed node - const ContentSpecNode::NodeTypes curType = curNode->getType(); - - if ((curType & 0x0f) == ContentSpecNode::Any - || (curType & 0x0f) == ContentSpecNode::Any_Other - || (curType & 0x0f) == ContentSpecNode::Any_NS) - { - retNode = new CMAny(curType, curNode->getElement()->getURI(), fLeafCount++); - } - else if (curType == ContentSpecNode::Leaf) - { - // - // Create a new leaf node, and pass it the current leaf count, which - // is its DFA state position. Bump the leaf count after storing it. - // This makes the positions zero based since we store first and then - // increment. - // - retNode = new CMLeaf(curNode->getElement(), fLeafCount++); - } - else - { - // - // Its not a leaf, so we have to recurse its left and maybe right - // nodes. Save both values before we recurse and trash the node. - // - ContentSpecNode* leftNode = curNode->getFirst(); - ContentSpecNode* rightNode = curNode->getSecond(); - - if ((curType == ContentSpecNode::Choice) - || (curType == ContentSpecNode::Sequence)) - { - // - // Recurse on both children, and return a binary op node with the - // two created sub nodes as its children. The node type is the - // same type as the source. - // - CMNode* newLeft = buildSyntaxTree(leftNode); - CMNode* newRight = buildSyntaxTree(rightNode); - retNode = new CMBinaryOp(curType, newLeft, newRight); - } - else if (curType == ContentSpecNode::ZeroOrMore - || curType == ContentSpecNode::ZeroOrOne - || curType == ContentSpecNode::OneOrMore) - { - // This one is fine as is, just change to our form - retNode = new CMUnaryOp(curType, buildSyntaxTree(leftNode)); - } - else - { - ThrowXML(RuntimeException, XMLExcepts::CM_UnknownCMSpecType); - } - } - return retNode; -} - - -void DFAContentModel::calcFollowList(CMNode* const curNode) -{ - // Get the spec type of the passed node - const ContentSpecNode::NodeTypes curType = curNode->getType(); - - if (curType == ContentSpecNode::Choice) - { - // Just recurse - calcFollowList(((CMBinaryOp*)curNode)->getLeft()); - calcFollowList(((CMBinaryOp*)curNode)->getRight()); - } - else if (curType == ContentSpecNode::Sequence) - { - // Recurse before we process this node - calcFollowList(((CMBinaryOp*)curNode)->getLeft()); - calcFollowList(((CMBinaryOp*)curNode)->getRight()); - - // - // Now handle our level. We use our left child's last pos set and our - // right child's first pos set, so get them now for convenience. - // - const CMStateSet& last = ((CMBinaryOp*)curNode)->getLeft()->getLastPos(); - const CMStateSet& first = ((CMBinaryOp*)curNode)->getRight()->getFirstPos(); - - // - // Now, for every position which is in our left child's last set - // add all of the states in our right child's first set to the - // follow set for that position. - // - for (unsigned int index = 0; index < fLeafCount; index++) - { - if (last.getBit(index)) - *fFollowList[index] |= first; - } - } - else if (curType == ContentSpecNode::ZeroOrMore || - curType == ContentSpecNode::OneOrMore ) - { - // Recurse first - calcFollowList(((CMUnaryOp*)curNode)->getChild()); - - // - // Now handle our level. We use our own first and last position - // sets, so get them up front. - // - const CMStateSet& first = curNode->getFirstPos(); - const CMStateSet& last = curNode->getLastPos(); - - // - // For every position which is in our last position set, add all - // of our first position states to the follow set for that - // position. - // - for (unsigned int index = 0; index < fLeafCount; index++) - { - if (last.getBit(index)) - *fFollowList[index] |= first; - } - } - else if (curType == ContentSpecNode::ZeroOrOne) - { - // Recurse only - calcFollowList(((CMUnaryOp*)curNode)->getChild()); - } -} - - -// -// gInvalidTrans is used to represent bad transitions in the transition table -// entry for each state. So each entry is initialized to that value. This -// method creates a new entry and initializes it. -// -unsigned int* DFAContentModel::makeDefStateList() const -{ - unsigned int* retArray = new unsigned int[fElemMapSize]; - for (unsigned int index = 0; index < fElemMapSize; index++) - retArray[index] = XMLContentModel::gInvalidTrans; - return retArray; -} - - -int DFAContentModel::postTreeBuildInit( CMNode* const nodeCur - , const unsigned int curIndex) -{ - // Set the maximum states on this node - nodeCur->setMaxStates(fLeafCount); - - // Get the spec type of the passed node - const ContentSpecNode::NodeTypes curType = nodeCur->getType(); - - // Get a copy of the index we can modify - unsigned int newIndex = curIndex; - - // Recurse as required - if ( ((curType & 0x0f) == ContentSpecNode::Any) || - ((curType & 0x0f) == ContentSpecNode::Any_NS) || - ((curType & 0x0f) == ContentSpecNode::Any_Other) ) - { - fLeafList[newIndex] = new CMLeaf(new QName(XMLUni::fgZeroLenString - , XMLUni::fgZeroLenString - , ((CMAny*) nodeCur)->getURI()) - , ((CMAny*)nodeCur)->getPosition() - , true); - fLeafListType[newIndex] = curType; - ++newIndex; - } - else if ((curType == ContentSpecNode::Choice) - || (curType == ContentSpecNode::Sequence)) - { - newIndex = postTreeBuildInit(((CMBinaryOp*)nodeCur)->getLeft(), newIndex); - newIndex = postTreeBuildInit(((CMBinaryOp*)nodeCur)->getRight(), newIndex); - } - else if (curType == ContentSpecNode::ZeroOrMore || - curType == ContentSpecNode::ZeroOrOne || - curType == ContentSpecNode::OneOrMore) - { - newIndex = postTreeBuildInit(((CMUnaryOp*)nodeCur)->getChild(), newIndex); - } - else if (curType == ContentSpecNode::Leaf) - { - // - // Put this node in the leaf list at the current index if its - // a non-epsilon leaf. - // - if (((CMLeaf*)nodeCur)->getElement()->getURI() != XMLContentModel::gEpsilonFakeId) - { - // - // fLeafList make its own copy of the CMLeaf, so that - // delete[] fLeafList and delete the owner of the nodeCur - // will NOT delete the nodeCur --twice--, - // thuse to make delete the owner of the nodeCur possible. - // - fLeafList[newIndex] = new CMLeaf(((CMLeaf*)nodeCur)->getElement(), - ((CMLeaf*)nodeCur)->getPosition()); - fLeafListType[newIndex] = ContentSpecNode::Leaf; - ++newIndex; - } - } - else - { - ThrowXML(RuntimeException, XMLExcepts::CM_UnknownCMSpecType); - } - return newIndex; -} - - - -ContentLeafNameTypeVector* DFAContentModel::getContentLeafNameTypeVector() const -{ - //later change it to return the data member - return fLeafNameTypeVector; -}; - -void DFAContentModel::checkUniqueParticleAttribution (SchemaGrammar* const pGrammar, - GrammarResolver* const pGrammarResolver, - XMLStringPool* const pStringPool, - XMLValidator* const pValidator, - unsigned int* const pContentSpecOrgURI) -{ - - SubstitutionGroupComparator comparator(pGrammarResolver, pStringPool); - - unsigned int i, j, k; - - // Rename the URI back - for (i = 0; i < fElemMapSize; i++) { - - unsigned int orgURIIndex = fElemMap[i]->getURI(); - - if (orgURIIndex != XMLContentModel::gEOCFakeId) { - fElemMap[i]->setURI(pContentSpecOrgURI[orgURIIndex]); - } - } - - // Unique Particle Attribution - // store the conflict results between any two elements in fElemMap - // XMLContentModel::gInvalidTrans: not compared; 0: no conflict; 1: conflict - unsigned int** fConflictTable = new unsigned int*[fElemMapSize]; - - // initialize the conflict table - for (j = 0; j < fElemMapSize; j++) { - fConflictTable[j] = new unsigned int[fElemMapSize]; - for (k = j+1; k < fElemMapSize; k++) - fConflictTable[j][k] = XMLContentModel::gInvalidTrans; - } - - // for each state, check whether it has overlap transitions - for (i = 0; i < fTransTableSize; i++) { - for (j = 0; j < fElemMapSize; j++) { - for (k = j+1; k < fElemMapSize; k++) { - if (fTransTable[i][j] != XMLContentModel::gInvalidTrans && - fTransTable[i][k] != XMLContentModel::gInvalidTrans && - fConflictTable[j][k] == XMLContentModel::gInvalidTrans) { - - // If this is text in a Schema mixed content model, skip it. - if ( fIsMixed && - (( fElemMap[j]->getURI() == XMLElementDecl::fgPCDataElemId) || - ( fElemMap[k]->getURI() == XMLElementDecl::fgPCDataElemId))) - continue; - - if (XercesElementWildcard::conflict(pGrammar, - fElemMapType[j], - fElemMap[j], - fElemMapType[k], - fElemMap[k], - &comparator)) { - fConflictTable[j][k] = 1; - - XMLBuffer buf1; - if (((fElemMapType[j] & 0x0f) == ContentSpecNode::Any) || - ((fElemMapType[j] & 0x0f) == ContentSpecNode::Any_NS)) - buf1.set(SchemaSymbols::fgATTVAL_TWOPOUNDANY); - else if ((fElemMapType[j] & 0x0f) == ContentSpecNode::Any_Other) - buf1.set(SchemaSymbols::fgATTVAL_TWOPOUNDOTHER); - else - buf1.set(fElemMap[j]->getRawName()); - - XMLBuffer buf2; - if (((fElemMapType[k] & 0x0f) == ContentSpecNode::Any) || - ((fElemMapType[k] & 0x0f) == ContentSpecNode::Any_NS)) - buf2.set(SchemaSymbols::fgATTVAL_TWOPOUNDANY); - else if ((fElemMapType[k] & 0x0f) == ContentSpecNode::Any_Other) - buf2.set(SchemaSymbols::fgATTVAL_TWOPOUNDOTHER); - else - buf2.set(fElemMap[k]->getRawName()); - - pValidator->emitError(XMLValid::UniqueParticleAttributionFail, - buf1.getRawBuffer(), - buf2.getRawBuffer()); - } - else - fConflictTable[j][k] = 0; - } - } - } - } - - for (i = 0; i < fElemMapSize; i++) - delete [] fConflictTable[i]; - delete [] fConflictTable; -} - diff --git a/src/validators/common/DFAContentModel.hpp b/src/validators/common/DFAContentModel.hpp deleted file mode 100644 index 830579e029231198f4809f8708aea4df5bbdae92..0000000000000000000000000000000000000000 --- a/src/validators/common/DFAContentModel.hpp +++ /dev/null @@ -1,327 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999-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$ - * Revision 1.13 2001/11/21 14:30:13 knoaman - * Fix for UPA checking. - * - * Revision 1.12 2001/08/24 12:48:48 tng - * Schema: AllContentModel - * - * Revision 1.11 2001/08/21 16:06:11 tng - * Schema: Unique Particle Attribution Constraint Checking. - * - * Revision 1.10 2001/08/13 15:06:39 knoaman - * update <any> validation. - * - * Revision 1.9 2001/06/13 20:50:55 peiyongz - * fIsMixed: to handle mixed Content Model - * - * Revision 1.8 2001/05/11 13:27:18 tng - * Copyright update. - * - * Revision 1.7 2001/05/03 21:02:30 tng - * Schema: Add SubstitutionGroupComparator and update exception messages. By Pei Yong Zhang. - * - * Revision 1.6 2001/04/19 18:17:30 tng - * Schema: SchemaValidator update, and use QName in Content Model - * - * Revision 1.5 2001/03/21 21:56:27 tng - * Schema: Add Schema Grammar, Schema Validator, and split the DTDValidator into DTDValidator, DTDScanner, and DTDGrammar. - * - * Revision 1.4 2001/03/21 19:29:55 tng - * Schema: Content Model Updates, by Pei Yong Zhang. - * - * Revision 1.3 2001/02/27 18:32:32 tng - * Schema: Use XMLElementDecl instead of DTDElementDecl in Content Model. - * - * Revision 1.2 2001/02/27 14:48:52 tng - * Schema: Add CMAny and ContentLeafNameTypeVector, by Pei Yong Zhang - * - * Revision 1.1 2001/02/16 14:17:29 tng - * Schema: Move the common Content Model files that are shared by DTD - * and schema from 'DTD' folder to 'common' folder. By Pei Yong Zhang. - * - * Revision 1.4 2000/03/02 19:55:38 roddey - * This checkin includes many changes done while waiting for the - * 1.1.0 code to be finished. I can't list them all here, but a list is - * available elsewhere. - * - * Revision 1.3 2000/02/24 20:16:48 abagchi - * Swat for removing Log from API docs - * - * Revision 1.2 2000/02/09 21:42:37 abagchi - * Copyright swat - * - * Revision 1.1.1.1 1999/11/09 01:03:19 twl - * Initial checkin - * - * Revision 1.2 1999/11/08 20:45:38 rahul - * Swat for adding in Product name and CVS comment log variable. - * - */ - -#if !defined(DFACONTENTMODEL_HPP) -#define DFACONTENTMODEL_HPP - -#include <util/XercesDefs.hpp> -#include <util/ArrayIndexOutOfBoundsException.hpp> -#include <framework/XMLContentModel.hpp> -#include <validators/common/ContentLeafNameTypeVector.hpp> - -class ContentSpecNode; -class CMLeaf; -class CMNode; -class CMStateSet; - -// -// DFAContentModel is the heavy weight derivative of ContentModel that does -// all of the non-trivial element content validation. This guy does the full -// bore regular expression to DFA conversion to create a DFA that it then -// uses in its validation algorithm. -// -// NOTE: Upstream work insures that this guy will never see a content model -// with PCDATA in it. Any model with PCDATA is 'mixed' and is handled -// via the MixedContentModel class, since mixed models are very -// constrained in form and easily handled via a special case. This -// also makes our life much easier here. -// -class DFAContentModel : public XMLContentModel -{ -public: - // ----------------------------------------------------------------------- - // Constructors and Destructor - // ----------------------------------------------------------------------- - DFAContentModel(const bool dtd - , ContentSpecNode* const elemContentSpec); - - DFAContentModel(const bool dtd - , ContentSpecNode* const elemContentSpec - , const bool isMixed); - - virtual ~DFAContentModel(); - - - // ----------------------------------------------------------------------- - // Implementation of the virtual content model interface - // ----------------------------------------------------------------------- - virtual int validateContent - ( - QName** const children - , const unsigned int childCount - , const unsigned int emptyNamespaceId - ) const; - - virtual int validateContentSpecial - ( - QName** const children - , const unsigned int childCount - , const unsigned int emptyNamespaceId - , GrammarResolver* const pGrammarResolver - , XMLStringPool* const pStringPool - ) const; - - virtual void checkUniqueParticleAttribution - ( - SchemaGrammar* const pGrammar - , GrammarResolver* const pGrammarResolver - , XMLStringPool* const pStringPool - , XMLValidator* const pValidator - , unsigned int* const pContentSpecOrgURI - ) ; - - virtual ContentLeafNameTypeVector* getContentLeafNameTypeVector() const ; - - virtual unsigned int getNextState(const unsigned int currentState, - const unsigned int elementIndex) const; - -private : - // ----------------------------------------------------------------------- - // Unimplemented constructors and operators - // ----------------------------------------------------------------------- - DFAContentModel(); - DFAContentModel(const DFAContentModel&); - void operator=(const DFAContentModel&); - - - // ----------------------------------------------------------------------- - // Private helper methods - // ----------------------------------------------------------------------- - void buildDFA(ContentSpecNode* const curNode); - CMNode* buildSyntaxTree(ContentSpecNode* const curNode); - void calcFollowList(CMNode* const curNode); - unsigned int* makeDefStateList() const; - int postTreeBuildInit - ( - CMNode* const nodeCur - , const unsigned int curIndex - ); - - - // ----------------------------------------------------------------------- - // Private data members - // - // fElemMap - // fElemMapSize - // This is the map of unique input symbol elements to indices into - // each state's per-input symbol transition table entry. This is part - // of the built DFA information that must be kept around to do the - // actual validation. - // - // fElemMapType - // This is a map of whether the element map contains information - // related to ANY models. - // - // fEmptyOk - // This is an optimization. While building the transition table we - // can see whether this content model would approve of an empty - // content (which could happen if everything was optional.) So we - // set this flag and short circuit that check, which would otherwise - // be ugly and time consuming if we tried to determine it at each - // validation call. - // - // fEOCPos - // The NFA position of the special EOC (end of content) node. This - // is saved away since its used during the DFA build. - // - // fFinalStateFlags - // This is an array of booleans, one per state (there are - // fTransTableSize states in the DFA) that indicates whether that - // state is a final state. - // - // fFollowList - // The list of follow positions for each NFA position (i.e. for each - // non-epsilon leaf node.) This is only used during the building of - // the DFA, and is let go afterwards. - // - // fHeadNode - // This is the head node of our intermediate representation. It is - // only non-null during the building of the DFA (just so that it - // does not have to be passed all around.) Once the DFA is built, - // this is no longer required so its deleted. - // - // fLeafCount - // The count of leaf nodes. This is an important number that set some - // limits on the sizes of data structures in the DFA process. - // - // fLeafList - // An array of non-epsilon leaf nodes, which is used during the DFA - // build operation, then dropped. These are just references to nodes - // pointed to by fHeadNode, so we don't have to clean them up, just - // the actually leaf list array itself needs cleanup. - // - // fLeafListType - // Array mapping ANY types to the leaf list. - // - // fTransTable - // fTransTableSize - // This is the transition table that is the main by product of all - // of the effort here. It is an array of arrays of ints. The first - // dimension is the number of states we end up with in the DFA. The - // second dimensions is the number of unique elements in the content - // model (fElemMapSize). Each entry in the second dimension indicates - // the new state given that input for the first dimension's start - // state. - // - // The fElemMap array handles mapping from element indexes to - // positions in the second dimension of the transition table. - // - // fTransTableSize is the number of valid entries in the transition - // table, and in the other related tables such as fFinalStateFlags. - // - // fDTD - // Boolean to allow DTDs to validate even with namespace support. - // - // fIsMixed - // DFA ContentModel with mixed PCDATA. - // ----------------------------------------------------------------------- - QName** fElemMap; - ContentSpecNode::NodeTypes *fElemMapType; - unsigned int fElemMapSize; - bool fEmptyOk; - unsigned int fEOCPos; - bool* fFinalStateFlags; - CMStateSet** fFollowList; - CMNode* fHeadNode; - unsigned int fLeafCount; - CMLeaf** fLeafList; - ContentSpecNode::NodeTypes *fLeafListType; - unsigned int** fTransTable; - unsigned int fTransTableSize; - bool fDTD; - bool fIsMixed; - ContentLeafNameTypeVector *fLeafNameTypeVector; -}; - - -inline unsigned int -DFAContentModel::getNextState(const unsigned int currentState, - const unsigned int elementIndex) const { - - if (currentState == XMLContentModel::gInvalidTrans) { - return XMLContentModel::gInvalidTrans; - } - - if (currentState >= fTransTableSize || elementIndex >= fElemMapSize) { - ThrowXML(ArrayIndexOutOfBoundsException, XMLExcepts::Array_BadIndex); - } - - return fTransTable[currentState][elementIndex]; -} - -#endif - diff --git a/src/validators/common/Grammar.hpp b/src/validators/common/Grammar.hpp deleted file mode 100644 index 943e500deb196207d82459a9cbbd579fe4b2b12f..0000000000000000000000000000000000000000 --- a/src/validators/common/Grammar.hpp +++ /dev/null @@ -1,221 +0,0 @@ -/* - * 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$ - * Revision 1.6 2001/09/14 14:50:22 tng - * Schema: Fix some wildcard bugs, and some retrieving qualified/unqualified element decl problems. - * - * Revision 1.5 2001/05/28 20:56:18 tng - * Schema: Move getTargetNamespace as virtual function in base class Grammar - * - * Revision 1.4 2001/05/11 13:27:18 tng - * Copyright update. - * - * Revision 1.3 2001/05/03 20:34:40 tng - * Schema: SchemaValidator update - * - * Revision 1.2 2001/04/19 18:17:31 tng - * Schema: SchemaValidator update, and use QName in Content Model - * - * Revision 1.1 2001/03/21 21:56:27 tng - * Schema: Add Schema Grammar, Schema Validator, and split the DTDValidator into DTDValidator, DTDScanner, and DTDGrammar. - * - */ - - - -#if !defined(GRAMMAR_HPP) -#define GRAMMAR_HPP - -#include <framework/XMLElementDecl.hpp> -#include <framework/XMLEntityDecl.hpp> -#include <framework/XMLNotationDecl.hpp> - -// -// This abstract class specifies the interface for a Grammar -// - -class VALIDATORS_EXPORT Grammar -{ -public: - - // ----------------------------------------------------------------------- - // Class Specific Types - // - // DTDGrammarType - Indicate this Grammar is built from a DTD. - // SchemaGrammarType - Indicate this Grammar is built from a Schema. - // - // TOP_LEVEL_SCOPE - outermost scope level (i.e. global) of a declaration. - // For DTD, all element decls and attribute decls always - // have TOP_LEVEL_SCOPE. For schema, it may varies if - // it is inside a complex type. - // - // UNKNOWN_SCOPE - unknown scope level. None of the decls should have this. - // - // ----------------------------------------------------------------------- - enum GrammarType { - DTDGrammarType - , SchemaGrammarType - }; - - enum { - UNKNOWN_SCOPE = -2 - , TOP_LEVEL_SCOPE = -1 - }; - - // ----------------------------------------------------------------------- - // Constructors and Destructor - // ----------------------------------------------------------------------- - virtual ~Grammar(){}; - - // ----------------------------------------------------------------------- - // Virtual Getter methods - // ----------------------------------------------------------------------- - virtual GrammarType getGrammarType()=0; - virtual const XMLCh* getTargetNamespace() const =0; - - // Element Decl - virtual XMLElementDecl* findOrAddElemDecl - ( - const unsigned int uriId - , const XMLCh* const baseName - , const XMLCh* const prefixName - , const XMLCh* const qName - , unsigned int scope - , bool& wasAdded - ) = 0; - - virtual unsigned int getElemId - ( - const unsigned int uriId - , const XMLCh* const baseName - , const XMLCh* const qName - , unsigned int scope - ) const = 0; - - virtual const XMLElementDecl* getElemDecl - ( - const unsigned int uriId - , const XMLCh* const baseName - , const XMLCh* const qName - , unsigned int scope - ) const = 0; - - virtual XMLElementDecl* getElemDecl - ( - const unsigned int uriId - , const XMLCh* const baseName - , const XMLCh* const qName - , unsigned int scope - ) = 0; - - virtual const XMLElementDecl* getElemDecl - ( - const unsigned int elemId - ) const = 0; - - virtual XMLElementDecl* getElemDecl - ( - const unsigned int elemId - ) = 0; - - // Notation - virtual const XMLNotationDecl* getNotationDecl - ( - const XMLCh* const notName - ) const=0; - - virtual XMLNotationDecl* getNotationDecl - ( - const XMLCh* const notName - )=0; - - // ----------------------------------------------------------------------- - // Virtual Setter methods - // ----------------------------------------------------------------------- - virtual XMLElementDecl* putElemDecl - ( - const unsigned int uriId - , const XMLCh* const baseName - , const XMLCh* const prefixName - , const XMLCh* const qName - , unsigned int scope - ) = 0; - - virtual unsigned int putElemDecl - ( - XMLElementDecl* const elemDecl - ) const = 0; - - virtual unsigned int putNotationDecl - ( - XMLNotationDecl* const notationDecl - ) const=0; - - // ----------------------------------------------------------------------- - // Virtual methods - // ----------------------------------------------------------------------- - virtual void reset()=0; - -protected : - // ----------------------------------------------------------------------- - // Hidden constructors - // ----------------------------------------------------------------------- - Grammar() {}; -}; - -#endif diff --git a/src/validators/common/GrammarResolver.cpp b/src/validators/common/GrammarResolver.cpp deleted file mode 100644 index 9c32fd8dd47b4f4d834b873f123adf8842662b3b..0000000000000000000000000000000000000000 --- a/src/validators/common/GrammarResolver.cpp +++ /dev/null @@ -1,144 +0,0 @@ -/* - * 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.apache.org. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/* - * $Log$ - * Revision 1.5 2001/08/28 19:20:54 tng - * Schema: xsi:type support - * - * Revision 1.4 2001/07/24 18:33:13 knoaman - * Added support for <group> + extra constraint checking for complexType - * - * Revision 1.3 2001/06/07 20:58:39 tng - * Fix no newline at the end warning. By Pei Yong Zhang. - * - * Revision 1.2 2001/05/11 13:27:19 tng - * Copyright update. - * - * Revision 1.1 2001/03/21 21:56:28 tng - * Schema: Add Schema Grammar, Schema Validator, and split the DTDValidator into DTDValidator, DTDScanner, and DTDGrammar. - * - */ - -#include <validators/common/GrammarResolver.hpp> -#include <validators/datatype/DatatypeValidatorFactory.hpp> - -// --------------------------------------------------------------------------- -// GrammarResolver: Constructor and Destructor -// --------------------------------------------------------------------------- -GrammarResolver::GrammarResolver() : - fGrammarRegistry(0) - , fDataTypeReg(0) -{ - fGrammarRegistry = new RefHashTableOf<Grammar>(29, true); -} - -GrammarResolver::~GrammarResolver() -{ - delete fGrammarRegistry; - if (fDataTypeReg) - delete fDataTypeReg; -} - -// --------------------------------------------------------------------------- -// GrammarResolver: Getter methods -// --------------------------------------------------------------------------- - -DatatypeValidatorFactory* GrammarResolver::getDatatypeRegistry() -{ - if (!fDataTypeReg) { - fDataTypeReg = new DatatypeValidatorFactory(); - } - return fDataTypeReg; -} - -Grammar* GrammarResolver::getGrammar( const XMLCh* const nameSpaceKey ) -{ - if (!nameSpaceKey) { - return 0; - } - - return fGrammarRegistry->get( nameSpaceKey ); -} - -RefHashTableOfEnumerator<Grammar> -GrammarResolver::getGrammarEnumerator() const -{ - return RefHashTableOfEnumerator<Grammar>(fGrammarRegistry); -} - -bool GrammarResolver::containsNameSpace( const XMLCh* const nameSpaceKey ) -{ - return fGrammarRegistry->containsKey( nameSpaceKey ); -} - -void GrammarResolver::putGrammar( const XMLCh* const nameSpaceKey, Grammar* const grammarToAdopt ){ - fGrammarRegistry->put( (void*) nameSpaceKey, grammarToAdopt ); -} - -void GrammarResolver::removeGrammar( const XMLCh* const nameSpaceKey ) { - if ( containsNameSpace( nameSpaceKey ) ) - fGrammarRegistry->removeKey( nameSpaceKey ); -} - -void GrammarResolver::reset() { - fGrammarRegistry->removeAll(); - fStringPool.flushAll(); - if (fDataTypeReg) { - fDataTypeReg->resetRegistry(); - } -} diff --git a/src/validators/common/GrammarResolver.hpp b/src/validators/common/GrammarResolver.hpp deleted file mode 100644 index 2f3e64e768e3ff8a8b2b053299b5f4fafe0830b3..0000000000000000000000000000000000000000 --- a/src/validators/common/GrammarResolver.hpp +++ /dev/null @@ -1,187 +0,0 @@ -/* - * 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.apache.org. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. - */ - -/** - * $Id$ - */ - -#if !defined(GRAMMARRESOLVER_HPP) -#define GRAMMARRESOLVER_HPP - -#include <util/RefHashTableOf.hpp> -#include <util/StringPool.hpp> -#include <validators/common/Grammar.hpp> - - -class DatatypeValidator; -class DatatypeValidatorFactory; - - -/** - * This class embodies the representation of a Grammar pool Resolver. - * This class is called from the validator. - * - */ - -class GrammarResolver { -public: - - /** @name Constructor and Destructor */ - //@{ - /** - * - * Default Constructor - */ - GrammarResolver(); - - /** - * Destructor - */ - ~GrammarResolver(); - - //@} - - /** @name Getter methods */ - //@{ - /** - * Retrieve the DatatypeValidatorFactory Registry - * @return the DatatypeValidatorFactory Registry - */ - DatatypeValidatorFactory* getDatatypeRegistry(); - - /** - * Retrieve the grammar that is associated with the specified namespace key - * - * @param nameSpaceKey Namespace key into Grammar pool - * @return Grammar abstraction associated with the NameSpace key. - */ - Grammar* getGrammar( const XMLCh* const nameSpaceKey ) ; - - /** - * Get an enumeration of Grammar in the Grammar pool - * - * @return enumeration of Grammar in Grammar pool - */ - RefHashTableOfEnumerator<Grammar> getGrammarEnumerator() const; - - - /** - * Get a string pool of schema grammar element/attribute names/prefixes - * (used by TraverseSchema) - * - * @return a string pool of schema grammar element/attribute names/prefixes - */ - XMLStringPool* getStringPool(); - - /** - * Is the specified Namespace key in Grammar pool? - * - * @param nameSpaceKey Namespace key - * @return True if Namespace key association is in the Grammar pool. - */ - bool containsNameSpace( const XMLCh* const nameSpaceKey ); - - //@} - - /** @name GrammarResolver methods */ - //@{ - /** - * Add the Grammar with Namespace Key associated to the Grammar Pool. - * The Grammar will be owned by the Grammar Pool. - * - * @param nameSpaceKey Key to associate with Grammar abstraction - * @param grammarToAdopt Grammar abstraction used by validator. - */ - void putGrammar(const XMLCh* const nameSpaceKey, Grammar* const grammarToAdopt ); - - /** - * Remove the Grammar with Namespace Key associated from the Grammar Pool - * - * @param nameSpaceKey Key to associate with Grammar abstraction - */ - void removeGrammar( const XMLCh* const nameSpaceKey ); - - /** - * Reset internal Namespace/Grammar registry. - */ - void reset(); - - //@} - -private: - // ----------------------------------------------------------------------- - // Private data members - // - // fStringPool The string pool used by TraverseSchema to store - // element/attribute names and prefixes. - // - // fGrammarRegistry The Grammar Pool. It represents a mapping - // between Namespace and a Grammar - // fDataTypeReg DatatypeValidatorFactory register - // - // ----------------------------------------------------------------------- - XMLStringPool fStringPool; - RefHashTableOf<Grammar>* fGrammarRegistry; - DatatypeValidatorFactory* fDataTypeReg; -}; - -inline XMLStringPool* GrammarResolver::getStringPool() { - - return &fStringPool; -} - -#endif diff --git a/src/validators/common/Makefile.in b/src/validators/common/Makefile.in deleted file mode 100644 index 2094330ac509aa7ca20c7082b33ee971e0178c54..0000000000000000000000000000000000000000 --- a/src/validators/common/Makefile.in +++ /dev/null @@ -1,156 +0,0 @@ -# -# The Apache Software License, Version 1.1 -# -# Copyright (c) 1999-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$ -# Revision 1.7 2001/08/24 12:48:48 tng -# Schema: AllContentModel -# -# Revision 1.6 2001/07/06 17:12:10 tng -# Automatic build of single-threaded library. By Martin Kalen. -# -# Revision 1.5 2001/06/27 17:09:50 tng -# [Bug 1147] Headers install in wrong directory. By Murray Cumming. -# -# Revision 1.4 2001/05/11 13:27:19 tng -# Copyright update. -# -# Revision 1.3 2001/03/21 21:56:28 tng -# Schema: Add Schema Grammar, Schema Validator, and split the DTDValidator into DTDValidator, DTDScanner, and DTDGrammar. -# -# Revision 1.2 2001/02/27 14:48:53 tng -# Schema: Add CMAny and ContentLeafNameTypeVector, by Pei Yong Zhang -# -# Revision 1.1 2001/02/16 14:58:57 tng -# Schema: Update Makefile, configure files, project files, and include path in -# certain cpp files because of the move of the common Content Model files. By Pei Yong Zhang. -# -# - -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 = common - -VALIDATORS_COMMON_CPP_PUBHEADERS = \ - AllContentModel.hpp \ - CMAny.hpp \ - CMBinaryOp.hpp \ - CMLeaf.hpp \ - CMNode.hpp \ - CMStateSet.hpp \ - CMUnaryOp.hpp \ - ContentLeafNameTypeVector.hpp \ - ContentSpecNode.hpp \ - DFAContentModel.hpp \ - Grammar.hpp \ - GrammarResolver.hpp \ - MixedContentModel.hpp \ - SimpleContentModel.hpp - -VALIDATORS_COMMON_CPP_PRIVHEADERS = - -VALIDATORS_COMMON_C_FILES = - -VALIDATORS_COMMON_CPP_OBJECTS = \ - AllContentModel.$(TO) \ - CMAny.$(TO) \ - CMBinaryOp.$(TO) \ - CMUnaryOp.$(TO) \ - ContentLeafNameTypeVector.$(TO) \ - ContentSpecNode.$(TO) \ - DFAContentModel.$(TO) \ - GrammarResolver.$(TO) \ - MixedContentModel.$(TO) \ - SimpleContentModel.$(TO) - -all:: includes $(VALIDATORS_COMMON_CPP_OBJECTS) - -includes:: pubheaders $(VALIDATORS_COMMON_C_FILES) - -pubheaders:: - -mkdir -p $(XML_INC_DIR)/$(MODULE)/$(SUBMODULE) - $(CP) $(VALIDATORS_COMMON_CPP_PUBHEADERS) $(VALIDATORS_COMMON_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_COMMON_CPP_OBJECTS)) - -distclean:: clean - $(RM) Makefile $(DEPFILE) - @echo "Removing all $(MODULE)/$(SUBMODULE) header files ..." - $(RM2) $(addprefix $(XML_INC_DIR)/$(MODULE)/$(SUBMODULE)/,$(VALIDATORS_COMMON_CPP_PUBHEADERS)) - -install:: - -mkdir -p $(PREFIX_INCLUDE)/$(MODULE)/$(SUBMODULE) - $(CP) $(VALIDATORS_COMMON_CPP_PUBHEADERS) $(VALIDATORS_COMMON_C_FILES) $(PREFIX_INCLUDE)/$(MODULE)/$(SUBMODULE) diff --git a/src/validators/common/MixedContentModel.cpp b/src/validators/common/MixedContentModel.cpp deleted file mode 100644 index 00cb8e120ff24c0c7122335386d085fc1bfb1b5f..0000000000000000000000000000000000000000 --- a/src/validators/common/MixedContentModel.cpp +++ /dev/null @@ -1,478 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999-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$ - * Revision 1.13 2001/08/24 12:48:48 tng - * Schema: AllContentModel - * - * Revision 1.12 2001/08/21 16:06:11 tng - * Schema: Unique Particle Attribution Constraint Checking. - * - * Revision 1.11 2001/07/09 15:22:37 knoaman - * complete <any> declaration. - * - * Revision 1.10 2001/06/12 22:13:33 peiyongz - * validateContentSpecial() : apply SubstitutionGroupComparator.isEquivalentTo() - * - * Revision 1.9 2001/05/11 13:27:19 tng - * Copyright update. - * - * Revision 1.8 2001/05/03 21:02:30 tng - * Schema: Add SubstitutionGroupComparator and update exception messages. By Pei Yong Zhang. - * - * Revision 1.7 2001/04/19 18:17:32 tng - * Schema: SchemaValidator update, and use QName in Content Model - * - * Revision 1.6 2001/03/21 21:56:28 tng - * Schema: Add Schema Grammar, Schema Validator, and split the DTDValidator into DTDValidator, DTDScanner, and DTDGrammar. - * - * Revision 1.5 2001/03/21 19:29:57 tng - * Schema: Content Model Updates, by Pei Yong Zhang. - * - * Revision 1.4 2001/02/27 18:32:32 tng - * Schema: Use XMLElementDecl instead of DTDElementDecl in Content Model. - * - * Revision 1.3 2001/02/27 14:48:54 tng - * Schema: Add CMAny and ContentLeafNameTypeVector, by Pei Yong Zhang - * - * Revision 1.2 2001/02/16 14:58:57 tng - * Schema: Update Makefile, configure files, project files, and include path in - * certain cpp files because of the move of the common Content Model files. By Pei Yong Zhang. - * - * Revision 1.1 2001/02/16 14:17:29 tng - * Schema: Move the common Content Model files that are shared by DTD - * and schema from 'DTD' folder to 'common' folder. By Pei Yong Zhang. - * - * Revision 1.5 2000/05/15 22:31:32 andyh - * Replace #include<memory.h> with <string.h> everywhere. - * - * Revision 1.4 2000/03/18 00:00:05 roddey - * Initial updates for two way transcoding support - * - * Revision 1.3 2000/03/02 19:55:39 roddey - * This checkin includes many changes done while waiting for the - * 1.1.0 code to be finished. I can't list them all here, but a list is - * available elsewhere. - * - * Revision 1.2 2000/02/09 21:42:39 abagchi - * Copyright swatswat - * - * Revision 1.1.1.1 1999/11/09 01:03:43 twl - * Initial checkin - * - * Revision 1.3 1999/11/08 20:45:43 rahul - * Swat for adding in Product name and CVS comment log variable. - * - */ - - -// --------------------------------------------------------------------------- -// Includes -// --------------------------------------------------------------------------- -#include <string.h> -#include <util/RuntimeException.hpp> -#include <framework/XMLElementDecl.hpp> -#include <validators/common/ContentSpecNode.hpp> -#include <validators/common/MixedContentModel.hpp> -#include <validators/common/CMStateSet.hpp> -#include <validators/common/Grammar.hpp> -#include <validators/schema/SubstitutionGroupComparator.hpp> - -// --------------------------------------------------------------------------- -// MixedContentModel: Constructors and Destructor -// --------------------------------------------------------------------------- -MixedContentModel::MixedContentModel(const bool dtd - , ContentSpecNode* const parentContentSpec - , const bool ordered) : - fCount(0) - , fChildren(0) - , fChildTypes(0) - , fOrdered(ordered) - , fDTD(dtd) -{ - // - // Create a vector of unsigned ints that will be filled in with the - // ids of the child nodes. It will be expanded as needed but we give - // it an initial capacity of 64 which should be more than enough for - // 99% of the scenarios. - // - - ValueVectorOf<QName*> children(64); - ValueVectorOf<ContentSpecNode::NodeTypes> childTypes(64); - - // - // Get the parent element's content spec. This is the head of the tree - // of nodes that describes the content model. We will iterate this - // tree. - // - ContentSpecNode* curNode = parentContentSpec; - if (!curNode) - ThrowXML(RuntimeException, XMLExcepts::CM_NoParentCSN); - - // And now call the private recursive method that iterates the tree - buildChildList(curNode, children, childTypes); - - // - // And now we know how many elements we need in our member list. So - // fill them in. - // - fCount = children.size(); - fChildren = new QName*[fCount]; - fChildTypes = new ContentSpecNode::NodeTypes[fCount]; - for (unsigned int index = 0; index < fCount; index++) { - fChildren[index] = children.elementAt(index); - fChildTypes[index] = childTypes.elementAt(index); - } -} - -MixedContentModel::~MixedContentModel() -{ - delete [] fChildren; - delete [] fChildTypes; -} - - -// --------------------------------------------------------------------------- -// MixedContentModel: Getter methods -// --------------------------------------------------------------------------- -bool MixedContentModel::hasDups() const -{ - // Can't have dups if only one child - if (fCount == 1) - return false; - - for (unsigned int index = 0; index < fCount; index++) - { - const QName* curVal = fChildren[index]; - for (unsigned int iIndex = 0; iIndex < fCount; iIndex++) - { - if (iIndex == index) - continue; - - if (fDTD) { - if (!XMLString::compareString(curVal->getRawName(), fChildren[iIndex]->getRawName())) { - return true; - } - } - else { - if ((curVal->getURI() == fChildren[iIndex]->getURI()) && - (!XMLString::compareString(curVal->getLocalPart(), fChildren[iIndex]->getLocalPart()))) { - return true; - } - } - } - } - return false; -} - - -// --------------------------------------------------------------------------- -// MixedContentModel: Implementation of the ContentModel virtual interface -// --------------------------------------------------------------------------- -// -//Under the XML Schema mixed model, -//the order and number of child elements appearing in an instance -//must agree with -//the order and number of child elements specified in the model. -// -int -MixedContentModel::validateContent( QName** const children - , const unsigned int childCount - , const unsigned int emptyNamespaceId) const -{ - // must match order - if (fOrdered) { - unsigned int inIndex = 0; - for (unsigned int outIndex = 0; outIndex < childCount; outIndex++) { - - // Get the current child out of the source index - const QName* curChild = children[outIndex]; - - // If its PCDATA, then we just accept that - if (curChild->getURI() == XMLElementDecl::fgPCDataElemId) - continue; - - ContentSpecNode::NodeTypes type = fChildTypes[inIndex]; - const QName* inChild = fChildren[inIndex]; - - if (type == ContentSpecNode::Leaf) { - if (fDTD) { - if (XMLString::compareString(inChild->getRawName(), curChild->getRawName())) { - return outIndex; - } - } - else { - if ((inChild->getURI() != curChild->getURI()) || - (XMLString::compareString(inChild->getLocalPart(), curChild->getLocalPart()))) { - return outIndex; - } - } - } - else if (type == ContentSpecNode::Any) { - } - else if (type == ContentSpecNode::Any_NS) { - if (inChild->getURI() != curChild->getURI()) - return outIndex; - } - else if (type == ContentSpecNode::Any_Other) { - if (inChild->getURI() == curChild->getURI()) - return outIndex; - } - - // advance index - inIndex++; - } - } - - // can appear in any order - else { - for (unsigned int outIndex = 0; outIndex < childCount; outIndex++) { - // Get the current child out of the source index - const QName* curChild = children[outIndex]; - - // If its PCDATA, then we just accept that - if (curChild->getURI() == XMLElementDecl::fgPCDataElemId) - continue; - - // And try to find it in our list - unsigned int inIndex = 0; - for (; inIndex < fCount; inIndex++) - { - ContentSpecNode::NodeTypes type = fChildTypes[inIndex]; - const QName* inChild = fChildren[inIndex]; - - if (type == ContentSpecNode::Leaf) { - if (fDTD) { - if (!XMLString::compareString(inChild->getRawName(), curChild->getRawName())) { - break; - } - } - else { - if ((inChild->getURI() == curChild->getURI()) && - (!XMLString::compareString(inChild->getLocalPart(), curChild->getLocalPart()))) { - break; - } - } - } - else if (type == ContentSpecNode::Any) { - break; - } - else if (type == ContentSpecNode::Any_NS) { - if (inChild->getURI() == curChild->getURI()) - break; - } - else if (type == ContentSpecNode::Any_Other) { - if (inChild->getURI() != curChild->getURI()) - break; - } - - // REVISIT: What about checking for multiple ANY matches? - // The content model ambiguity *could* be checked - // by the caller before constructing the mixed - // content model. - } - // We did not find this one, so the validation failed - if (inIndex == fCount) - return outIndex; - } - } - - // Everything seems to be in order, so return success - // success - return -1; -} - - -int MixedContentModel::validateContentSpecial(QName** const children - , const unsigned int childCount - , const unsigned int emptyNamespaceId - , GrammarResolver* const pGrammarResolver - , XMLStringPool* const pStringPool) const -{ - - SubstitutionGroupComparator comparator(pGrammarResolver, pStringPool); - - // must match order - if (fOrdered) { - unsigned int inIndex = 0; - for (unsigned int outIndex = 0; outIndex < childCount; outIndex++) { - - // Get the current child out of the source index - QName* curChild = children[outIndex]; - - // If its PCDATA, then we just accept that - if (curChild->getURI() == XMLElementDecl::fgPCDataElemId) - continue; - - ContentSpecNode::NodeTypes type = fChildTypes[inIndex]; - QName* inChild = fChildren[inIndex]; - - if (type == ContentSpecNode::Leaf) { - if ( !comparator.isEquivalentTo(curChild, inChild)) - return outIndex; - } - else if (type == ContentSpecNode::Any) { - } - else if (type == ContentSpecNode::Any_NS) { - if (inChild->getURI() != curChild->getURI()) - return outIndex; - } - else if (type == ContentSpecNode::Any_Other) { - if (inChild->getURI() == curChild->getURI()) - return outIndex; - } - - // advance index - inIndex++; - } - } - - // can appear in any order - else { - for (unsigned int outIndex = 0; outIndex < childCount; outIndex++) { - // Get the current child out of the source index - QName* curChild = children[outIndex]; - - // If its PCDATA, then we just accept that - if (curChild->getURI() == XMLElementDecl::fgPCDataElemId) - continue; - - // And try to find it in our list - unsigned int inIndex = 0; - for (; inIndex < fCount; inIndex++) - { - ContentSpecNode::NodeTypes type = fChildTypes[inIndex]; - QName* inChild = fChildren[inIndex]; - - if (type == ContentSpecNode::Leaf) { - if ( comparator.isEquivalentTo(curChild, inChild)) - break; - } - else if (type == ContentSpecNode::Any) { - break; - } - else if (type == ContentSpecNode::Any_NS) { - if (inChild->getURI() == curChild->getURI()) - break; - } - else if (type == ContentSpecNode::Any_Other) { - if (inChild->getURI() != curChild->getURI()) - break; - } - - // REVISIT: What about checking for multiple ANY matches? - // The content model ambiguity *could* be checked - // by the caller before constructing the mixed - // content model. - } - // We did not find this one, so the validation failed - if (inIndex == fCount) - return outIndex; - } - } - - // Everything seems to be in order, so return success - // success - return -1; -} - -// --------------------------------------------------------------------------- -// MixedContentModel: Private helper methods -// --------------------------------------------------------------------------- -void -MixedContentModel::buildChildList( ContentSpecNode* const curNode - , ValueVectorOf<QName*>& toFill - , ValueVectorOf<ContentSpecNode::NodeTypes>& toType) -{ - // Get the type of spec node our current node is - const ContentSpecNode::NodeTypes curType = curNode->getType(); - - // If its a leaf, then store its id in the target list - if ((curType == ContentSpecNode::Leaf) || - (curType == ContentSpecNode::Any) || - (curType == ContentSpecNode::Any_Other) || - (curType == ContentSpecNode::Any_NS) ) - { - toFill.addElement(curNode->getElement()); - toType.addElement(curType); - return; - } - - // Get both the child node pointers - ContentSpecNode* leftNode = curNode->getFirst(); - ContentSpecNode* rightNode = curNode->getSecond(); - - // And recurse according to the type of node - if ((curType == ContentSpecNode::Choice) - || (curType == ContentSpecNode::Sequence)) - { - // Recurse on the left and right nodes - buildChildList(leftNode, toFill, toType); - - // The last node of a choice or sequence has a null right - if (rightNode) - buildChildList(rightNode, toFill, toType); - } - else if ((curType == ContentSpecNode::OneOrMore) - || (curType == ContentSpecNode::ZeroOrOne) - || (curType == ContentSpecNode::ZeroOrMore)) - { - // Just do the left node on this one - buildChildList(leftNode, toFill, toType); - } -} - diff --git a/src/validators/common/MixedContentModel.hpp b/src/validators/common/MixedContentModel.hpp deleted file mode 100644 index 0e4c5b1e656920f2f637f5423071996a218305e3..0000000000000000000000000000000000000000 --- a/src/validators/common/MixedContentModel.hpp +++ /dev/null @@ -1,267 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999-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$ - * Revision 1.12 2001/11/28 16:46:20 tng - * Schema fix: Check for invalid URI index first. - * - * Revision 1.11 2001/11/21 14:30:13 knoaman - * Fix for UPA checking. - * - * Revision 1.10 2001/08/21 16:06:11 tng - * Schema: Unique Particle Attribution Constraint Checking. - * - * Revision 1.9 2001/08/13 15:06:39 knoaman - * update <any> validation. - * - * Revision 1.8 2001/05/11 13:27:19 tng - * Copyright update. - * - * Revision 1.7 2001/05/03 21:02:31 tng - * Schema: Add SubstitutionGroupComparator and update exception messages. By Pei Yong Zhang. - * - * Revision 1.6 2001/04/19 18:17:33 tng - * Schema: SchemaValidator update, and use QName in Content Model - * - * Revision 1.5 2001/03/21 21:56:28 tng - * Schema: Add Schema Grammar, Schema Validator, and split the DTDValidator into DTDValidator, DTDScanner, and DTDGrammar. - * - * Revision 1.4 2001/03/21 19:29:58 tng - * Schema: Content Model Updates, by Pei Yong Zhang. - * - * Revision 1.3 2001/02/27 18:32:33 tng - * Schema: Use XMLElementDecl instead of DTDElementDecl in Content Model. - * - * Revision 1.2 2001/02/27 14:48:55 tng - * Schema: Add CMAny and ContentLeafNameTypeVector, by Pei Yong Zhang - * - * Revision 1.1 2001/02/16 14:17:29 tng - * Schema: Move the common Content Model files that are shared by DTD - * and schema from 'DTD' folder to 'common' folder. By Pei Yong Zhang. - * - * Revision 1.3 2000/02/24 20:16:49 abagchi - * Swat for removing Log from API docs - * - * Revision 1.2 2000/02/09 21:42:39 abagchi - * Copyright swat - * - * Revision 1.1.1.1 1999/11/09 01:03:45 twl - * Initial checkin - * - * Revision 1.3 1999/11/08 20:45:43 rahul - * Swat for adding in Product name and CVS comment log variable. - * - */ - - -#if !defined(MIXEDCONTENTMODEL_HPP) -#define MIXEDCONTENTMODEL_HPP - -#include <util/ValueVectorOf.hpp> -#include <framework/XMLContentModel.hpp> -#include <validators/common/ContentLeafNameTypeVector.hpp> - -class ContentSpecNode; - -// -// MixedContentModel is a derivative of the abstract content model base -// class that handles the special case of mixed model elements. If an element -// is mixed model, it has PCDATA as its first possible content, followed -// by an alternation of the possible children. The children cannot have any -// numeration or order, so it must look like this: -// -// <!ELEMENT Foo ((#PCDATA|a|b|c|)*)> -// -// So, all we have to do is to keep an array of the possible children and -// validate by just looking up each child being validated by looking it up -// in the list. -// -class MixedContentModel : public XMLContentModel -{ -public : - // ----------------------------------------------------------------------- - // Constructors and Destructor - // ----------------------------------------------------------------------- - MixedContentModel - ( - const bool dtd - , ContentSpecNode* const parentContentSpec - , const bool ordered = false - ); - - ~MixedContentModel(); - - - // ----------------------------------------------------------------------- - // Getter methods - // ----------------------------------------------------------------------- - bool hasDups() const; - - // ----------------------------------------------------------------------- - // Implementation of the ContentModel virtual interface - // ----------------------------------------------------------------------- - virtual int validateContent - ( - QName** const children - , const unsigned int childCount - , const unsigned int emptyNamespaceId - ) const; - - virtual int validateContentSpecial - ( - QName** const children - , const unsigned int childCount - , const unsigned int emptyNamespaceId - , GrammarResolver* const pGrammarResolver - , XMLStringPool* const pStringPool - ) const; - - virtual ContentLeafNameTypeVector* getContentLeafNameTypeVector() const ; - - virtual unsigned int getNextState(const unsigned int currentState, - const unsigned int elementIndex) const; - - virtual void checkUniqueParticleAttribution - ( - SchemaGrammar* const pGrammar - , GrammarResolver* const pGrammarResolver - , XMLStringPool* const pStringPool - , XMLValidator* const pValidator - , unsigned int* const pContentSpecOrgURI - ) ; - -private : - // ----------------------------------------------------------------------- - // Private helper methods - // ----------------------------------------------------------------------- - void buildChildList - ( - ContentSpecNode* const curNode - , ValueVectorOf<QName*>& toFill - , ValueVectorOf<ContentSpecNode::NodeTypes>& toType - ); - - // ----------------------------------------------------------------------- - // Unimplemented constructors and operators - // ----------------------------------------------------------------------- - MixedContentModel(); - MixedContentModel(const MixedContentModel&); - void operator=(const MixedContentModel&); - - - // ----------------------------------------------------------------------- - // Private data members - // - // fCount - // The count of possible children in the fChildren member. - // - // fChildren - // The list of possible children that we have to accept. This array - // is allocated as large as needed in the constructor. - // - // fChildTypes - // The type of the children to support ANY. - // - // fOrdered - // True if mixed content model is ordered. DTD mixed content models - // are <em>always</em> unordered. - // - // fDTD - // Boolean to allow DTDs to validate even with namespace support. - // - // ----------------------------------------------------------------------- - unsigned int fCount; - QName** fChildren; - ContentSpecNode::NodeTypes* fChildTypes; - bool fOrdered; - bool fDTD; - -}; - -inline ContentLeafNameTypeVector* MixedContentModel::getContentLeafNameTypeVector() const -{ - return 0; -} - -inline unsigned int -MixedContentModel::getNextState(const unsigned int currentState, - const unsigned int elementIndex) const { - - return XMLContentModel::gInvalidTrans; -} - -inline void MixedContentModel::checkUniqueParticleAttribution - ( - SchemaGrammar* const pGrammar - , GrammarResolver* const pGrammarResolver - , XMLStringPool* const pStringPool - , XMLValidator* const pValidator - , unsigned int* const pContentSpecOrgURI - ) -{ - // rename back - unsigned int i = 0; - for (i = 0; i < fCount; i++) { - unsigned int orgURIIndex = fChildren[i]->getURI(); - if (orgURIIndex != XMLContentModel::gEOCFakeId) - fChildren[i]->setURI(pContentSpecOrgURI[orgURIIndex]); - } - - // for mixed content model, it's only a sequence - // UPA checking is not necessary -} -#endif diff --git a/src/validators/common/SimpleContentModel.cpp b/src/validators/common/SimpleContentModel.cpp deleted file mode 100644 index 0f4a5a56e1b050b9e7ddeb84b674c7176e24401f..0000000000000000000000000000000000000000 --- a/src/validators/common/SimpleContentModel.cpp +++ /dev/null @@ -1,523 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999-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$ - * Revision 1.11 2001/11/28 16:46:20 tng - * Schema fix: Check for invalid URI index first. - * - * Revision 1.10 2001/11/21 14:30:13 knoaman - * Fix for UPA checking. - * - * Revision 1.9 2001/08/21 16:06:11 tng - * Schema: Unique Particle Attribution Constraint Checking. - * - * Revision 1.8 2001/05/11 13:27:19 tng - * Copyright update. - * - * Revision 1.7 2001/05/03 21:02:32 tng - * Schema: Add SubstitutionGroupComparator and update exception messages. By Pei Yong Zhang. - * - * Revision 1.6 2001/04/19 18:17:33 tng - * Schema: SchemaValidator update, and use QName in Content Model - * - * Revision 1.5 2001/03/21 21:56:29 tng - * Schema: Add Schema Grammar, Schema Validator, and split the DTDValidator into DTDValidator, DTDScanner, and DTDGrammar. - * - * Revision 1.4 2001/03/21 19:30:00 tng - * Schema: Content Model Updates, by Pei Yong Zhang. - * - * Revision 1.3 2001/02/27 14:48:57 tng - * Schema: Add CMAny and ContentLeafNameTypeVector, by Pei Yong Zhang - * - * Revision 1.2 2001/02/16 14:58:57 tng - * Schema: Update Makefile, configure files, project files, and include path in - * certain cpp files because of the move of the common Content Model files. By Pei Yong Zhang. - * - * Revision 1.1 2001/02/16 14:17:29 tng - * Schema: Move the common Content Model files that are shared by DTD - * and schema from 'DTD' folder to 'common' folder. By Pei Yong Zhang. - * - * Revision 1.4 2000/03/03 22:33:00 roddey - * Fixed a bug in SimpleContentModel that allowed an <a/> to be taken - * as valid for a content model of (a,b). - * - * Revision 1.3 2000/03/02 19:55:40 roddey - * This checkin includes many changes done while waiting for the - * 1.1.0 code to be finished. I can't list them all here, but a list is - * available elsewhere. - * - * Revision 1.2 2000/02/09 21:42:39 abagchi - * Copyright swatswat - * - * Revision 1.1.1.1 1999/11/09 01:03:46 twl - * Initial checkin - * - * Revision 1.2 1999/11/08 20:45:44 rahul - * Swat for adding in Product name and CVS comment log variable. - * - */ - - -// --------------------------------------------------------------------------- -// Includes -// --------------------------------------------------------------------------- -#include <util/RuntimeException.hpp> -#include <framework/XMLValidator.hpp> -#include <validators/common/SimpleContentModel.hpp> -#include <validators/schema/SubstitutionGroupComparator.hpp> -#include <validators/schema/XercesElementWildcard.hpp> - - -// --------------------------------------------------------------------------- -// SimpleContentModel: Implementation of the ContentModel virtual interface -// --------------------------------------------------------------------------- -// -// This method is called to validate our content. For this one, its just a -// pretty simple 'bull your way through it' test according to what kind of -// operation it is for. -// -int -SimpleContentModel::validateContent(QName** const children - , const unsigned int childCount - , const unsigned int emptyNamespaceId) const -{ - // - // According to the type of operation, we do the correct type of - // content check. - // - unsigned int index; - switch(fOp) - { - case ContentSpecNode::Leaf : - // - // There can only be one child and it has to be of the - // element type we stored. - // - if (!childCount) - return 0; - - // If the 0th child is not the right kind, report an error at 0 - if (fDTD) { - if (XMLString::compareString(children[0]->getRawName(), fFirstChild->getRawName())!=0) { - return 0; - } - } - else { - if ((children[0]->getURI() != fFirstChild->getURI()) || - (XMLString::compareString(children[0]->getLocalPart(), fFirstChild->getLocalPart())!=0)) { - return 0; - } - } - - if (childCount > 1) - return 1; - break; - - case ContentSpecNode::ZeroOrOne : - // - // If the child count is greater than one, then obviously - // bad. Otherwise, if its one, then the one child must be - // of the type we stored. - // - if (childCount == 1) { - if (fDTD) { - if (XMLString::compareString(children[0]->getRawName(), fFirstChild->getRawName())!=0) { - return 0; - } - } - else { - if ((children[0]->getURI() != fFirstChild->getURI()) || - (XMLString::compareString(children[0]->getLocalPart(), fFirstChild->getLocalPart())!=0)) { - return 0; - } - } - } - - - if (childCount > 1) - return 1; - break; - - case ContentSpecNode::ZeroOrMore : - // - // If the child count is zero, that's fine. If its more than - // zero, then make sure that all children are of the element - // type that we stored. - // - if (childCount > 0) - { - if (fDTD) { - for (index = 0; index < childCount; index++) { - if (XMLString::compareString(children[index]->getRawName(), fFirstChild->getRawName())!=0) { - return index; - } - } - } - else { - for (index = 0; index < childCount; index++) { - if ((children[index]->getURI() != fFirstChild->getURI()) || - (XMLString::compareString(children[index]->getLocalPart(), fFirstChild->getLocalPart())!=0)) { - return index; - } - } - } - } - break; - - case ContentSpecNode::OneOrMore : - // - // If the child count is zero, that's an error. If its more - // than zero, then make sure that all children are of the - // element type that we stored. - // - if (childCount == 0) - return 0; - - if (fDTD) { - for (index = 0; index < childCount; index++) { - if (XMLString::compareString(children[index]->getRawName(), fFirstChild->getRawName())!=0) { - return index; - } - } - } - else { - for (index = 0; index < childCount; index++) { - if ((children[index]->getURI() != fFirstChild->getURI()) || - (XMLString::compareString(children[index]->getLocalPart(), fFirstChild->getLocalPart())!=0)) { - return index; - } - } - } - break; - - case ContentSpecNode::Choice : - // - // There can only be one child, and it must be one of the - // two types we stored. - // - if (!childCount) - return 0; - - if (fDTD) { - if ((XMLString::compareString(children[0]->getRawName(), fFirstChild->getRawName())!=0) && - (XMLString::compareString(children[0]->getRawName(), fSecondChild->getRawName())!=0)) { - return 0; - } - } - else { - if (((children[0]->getURI() != fFirstChild->getURI()) || - (XMLString::compareString(children[0]->getLocalPart(), fFirstChild->getLocalPart())!=0)) && - ((children[0]->getURI() != fSecondChild->getURI()) || - (XMLString::compareString(children[0]->getLocalPart(), fSecondChild->getLocalPart())!=0))) { - return 0; - } - } - - if (childCount > 1) - return 1; - break; - - case ContentSpecNode::Sequence : - // - // There must be two children and they must be the two values - // we stored, in the stored order. So first check the obvious - // problem of an empty content, which would never be valid - // in this content mode. - // - if (!childCount) - return 0; - - if (childCount == 2) { - if (fDTD) { - if (XMLString::compareString(children[0]->getRawName(), fFirstChild->getRawName())!=0) { - return 0; - } - if (XMLString::compareString(children[1]->getRawName(), fSecondChild->getRawName())!=0) { - return 1; - } - } - else { - if ((children[0]->getURI() != fFirstChild->getURI()) || - (XMLString::compareString(children[0]->getLocalPart(), fFirstChild->getLocalPart())!=0)) { - return 0; - } - - if ((children[1]->getURI() != fSecondChild->getURI()) || - (XMLString::compareString(children[1]->getLocalPart(), fSecondChild->getLocalPart())!=0)) { - return 1; - } - } - } - else { - if (childCount > 2) { - return 2; - } - - return childCount; - } - break; - - default : - ThrowXML(RuntimeException, XMLExcepts::CM_UnknownCMSpecType); - break; - } - return -1; -} - -int SimpleContentModel::validateContentSpecial(QName** const children - , const unsigned int childCount - , const unsigned int emptyNamespaceId - , GrammarResolver* const pGrammarResolver - , XMLStringPool* const pStringPool) const -{ - - SubstitutionGroupComparator comparator(pGrammarResolver, pStringPool); - - // - // According to the type of operation, we do the correct type of - // content check. - // - unsigned int index; - switch(fOp) - { - case ContentSpecNode::Leaf : - // - // There can only be one child and it has to be of the - // element type we stored. - // - if (!childCount) - return 0; - - if ((children[0]->getURI() != fFirstChild->getURI()) || - (XMLString::compareString(children[0]->getLocalPart(), fFirstChild->getLocalPart())!=0)) - { - if (!comparator.isEquivalentTo(children[0], fFirstChild)) - return 0; - } - - if (childCount > 1) - return 1; - break; - - case ContentSpecNode::ZeroOrOne : - // - // If the child count is greater than one, then obviously - // bad. Otherwise, if its one, then the one child must be - // of the type we stored. - // - if ((childCount == 1) && - ((children[0]->getURI() != fFirstChild->getURI()) || - (XMLString::compareString(children[0]->getLocalPart(), fFirstChild->getLocalPart())!=0))) - { - if(!comparator.isEquivalentTo(children[0], fFirstChild)) - return 0; - } - - if (childCount > 1) - return 1; - break; - - case ContentSpecNode::ZeroOrMore : - // - // If the child count is zero, that's fine. If its more than - // zero, then make sure that all children are of the element - // type that we stored. - // - if (childCount > 0) - { - for (index = 0; index < childCount; index++) - { - if ((children[index]->getURI() != fFirstChild->getURI()) || - (XMLString::compareString(children[index]->getLocalPart(), fFirstChild->getLocalPart())!=0)) - { - if (!comparator.isEquivalentTo(children[index], fFirstChild)) - return index; - } - } - } - break; - - case ContentSpecNode::OneOrMore : - // - // If the child count is zero, that's an error. If its more - // than zero, then make sure that all children are of the - // element type that we stored. - // - if (childCount == 0) - return 0; - - for (index = 0; index < childCount; index++) - { - if ((children[index]->getURI() != fFirstChild->getURI()) || - (XMLString::compareString(children[index]->getLocalPart(), fFirstChild->getLocalPart())!=0)) - { - if (!comparator.isEquivalentTo(children[index], fFirstChild)) - return index; - } - } - break; - - case ContentSpecNode::Choice : - // - // There can only be one child, and it must be one of the - // two types we stored. - // - if (!childCount) - return 0; - - if (((children[0]->getURI() != fFirstChild->getURI()) || - (XMLString::compareString(children[0]->getLocalPart(), fFirstChild->getLocalPart())!=0)) && - ((children[0]->getURI() != fSecondChild->getURI()) || - (XMLString::compareString(children[0]->getLocalPart(), fSecondChild->getLocalPart())!=0))) - { - - if (!comparator.isEquivalentTo(children[0], fFirstChild) && - !comparator.isEquivalentTo(children[0], fSecondChild) ) - return 0; - } - - if (childCount > 1) - return 1; - break; - - case ContentSpecNode::Sequence : - // - // There must be two children and they must be the two values - // we stored, in the stored order. So first check the obvious - // problem of an empty content, which would never be valid - // in this content mode. - // - if (!childCount) - return 0; - - if (childCount == 2) - { - if ((children[0]->getURI() != fFirstChild->getURI()) || - (XMLString::compareString(children[0]->getLocalPart(), fFirstChild->getLocalPart())!=0)) - { - if(!comparator.isEquivalentTo(children[0], fFirstChild)) - return 0; - } - - if ((children[1]->getURI() != fSecondChild->getURI()) || - (XMLString::compareString(children[1]->getLocalPart(), fSecondChild->getLocalPart())!=0)) - { - if (!comparator.isEquivalentTo(children[1], fSecondChild)) - return 1; - } - } - else - { - if (childCount > 2) - { - return 2; - } - - return childCount; - } - break; - - default : - ThrowXML(RuntimeException, XMLExcepts::CM_UnknownCMSpecType); - break; - } - return -1; -} - -ContentLeafNameTypeVector* SimpleContentModel::getContentLeafNameTypeVector() const -{ - return 0; -} - -void SimpleContentModel::checkUniqueParticleAttribution - ( - SchemaGrammar* const pGrammar - , GrammarResolver* const pGrammarResolver - , XMLStringPool* const pStringPool - , XMLValidator* const pValidator - , unsigned int* const pContentSpecOrgURI - ) -{ - // rename back - unsigned int orgURIIndex = 0; - - orgURIIndex = fFirstChild->getURI(); - if (orgURIIndex != XMLContentModel::gEOCFakeId) - fFirstChild->setURI(pContentSpecOrgURI[orgURIIndex]); - - orgURIIndex = fSecondChild->getURI(); - if (orgURIIndex != XMLContentModel::gEOCFakeId) - fSecondChild->setURI(pContentSpecOrgURI[orgURIIndex]); - - // only possible violation is when it's a choice - if (fOp == ContentSpecNode::Choice) { - - SubstitutionGroupComparator comparator(pGrammarResolver, pStringPool); - - if (XercesElementWildcard::conflict(pGrammar, - ContentSpecNode::Leaf, - fFirstChild, - ContentSpecNode::Leaf, - fSecondChild, - &comparator)) - - pValidator->emitError(XMLValid::UniqueParticleAttributionFail, - fFirstChild->getRawName(), - fSecondChild->getRawName()); - } -} - diff --git a/src/validators/common/SimpleContentModel.hpp b/src/validators/common/SimpleContentModel.hpp deleted file mode 100644 index d72919aa540224a6d50561fcb8c4110538a75355..0000000000000000000000000000000000000000 --- a/src/validators/common/SimpleContentModel.hpp +++ /dev/null @@ -1,268 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999-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$ - * Revision 1.12 2001/11/21 14:30:13 knoaman - * Fix for UPA checking. - * - * Revision 1.11 2001/10/03 15:08:45 tng - * typo fix: remove the extra space which may confuse some compilers while constructing the qname. - * - * Revision 1.10 2001/08/21 16:06:11 tng - * Schema: Unique Particle Attribution Constraint Checking. - * - * Revision 1.9 2001/08/13 15:06:39 knoaman - * update <any> validation. - * - * Revision 1.8 2001/05/11 13:27:20 tng - * Copyright update. - * - * Revision 1.7 2001/05/03 21:02:33 tng - * Schema: Add SubstitutionGroupComparator and update exception messages. By Pei Yong Zhang. - * - * Revision 1.6 2001/04/19 18:17:34 tng - * Schema: SchemaValidator update, and use QName in Content Model - * - * Revision 1.5 2001/03/21 21:56:29 tng - * Schema: Add Schema Grammar, Schema Validator, and split the DTDValidator into DTDValidator, DTDScanner, and DTDGrammar. - * - * Revision 1.4 2001/03/21 19:30:02 tng - * Schema: Content Model Updates, by Pei Yong Zhang. - * - * Revision 1.3 2001/02/27 14:48:57 tng - * Schema: Add CMAny and ContentLeafNameTypeVector, by Pei Yong Zhang - * - * Revision 1.2 2001/02/16 14:58:57 tng - * Schema: Update Makefile, configure files, project files, and include path in - * certain cpp files because of the move of the common Content Model files. By Pei Yong Zhang. - * - * Revision 1.1 2001/02/16 14:17:29 tng - * Schema: Move the common Content Model files that are shared by DTD - * and schema from 'DTD' folder to 'common' folder. By Pei Yong Zhang. - * - * Revision 1.3 2000/02/24 20:16:49 abagchi - * Swat for removing Log from API docs - * - * Revision 1.2 2000/02/09 21:42:39 abagchi - * Copyright swat - * - * Revision 1.1.1.1 1999/11/09 01:03:48 twl - * Initial checkin - * - * Revision 1.2 1999/11/08 20:45:44 rahul - * Swat for adding in Product name and CVS comment log variable. - * - */ - - -#if !defined(SIMPLECONTENTMODEL_HPP) -#define SIMPLECONTENTMODEL_HPP - -#include <framework/XMLContentModel.hpp> -#include <validators/common/ContentSpecNode.hpp> - -// -// SimpleContentModel is a derivative of the abstract content model base -// class that handles a small set of simple content models that are just -// way overkill to give the DFA treatment. -// -// DESCRIPTION: -// -// This guy handles the following scenarios: -// -// a -// a? -// a* -// a+ -// a,b -// a|b -// -// These all involve a unary operation with one element type, or a binary -// operation with two elements. These are very simple and can be checked -// in a simple way without a DFA and without the overhead of setting up a -// DFA for such a simple check. -// -// NOTE: Pass the XMLElementDecl::fgPCDataElemId value to represent a -// PCData node. Pass XMLElementDecl::fgInvalidElemId for unused element -// -class SimpleContentModel : public XMLContentModel -{ -public : - // ----------------------------------------------------------------------- - // Constructors and Destructor - // ----------------------------------------------------------------------- - SimpleContentModel - ( - const bool dtd - , QName* const firstChild - , QName* const secondChild - , const ContentSpecNode::NodeTypes cmOp - ); - - ~SimpleContentModel(); - - - // ----------------------------------------------------------------------- - // Implementation of the ContentModel virtual interface - // ----------------------------------------------------------------------- - virtual int validateContent - ( - QName** const children - , const unsigned int childCount - , const unsigned int emptyNamespaceId - ) const; - - virtual int validateContentSpecial - ( - QName** const children - , const unsigned int childCount - , const unsigned int emptyNamespaceId - , GrammarResolver* const pGrammarResolver - , XMLStringPool* const pStringPool - ) const; - - virtual ContentLeafNameTypeVector *getContentLeafNameTypeVector() const; - - virtual unsigned int getNextState(const unsigned int currentState, - const unsigned int elementIndex) const; - - virtual void checkUniqueParticleAttribution - ( - SchemaGrammar* const pGrammar - , GrammarResolver* const pGrammarResolver - , XMLStringPool* const pStringPool - , XMLValidator* const pValidator - , unsigned int* const pContentSpecOrgURI - ) ; - - private : - // ----------------------------------------------------------------------- - // Unimplemented constructors and operators - // ----------------------------------------------------------------------- - SimpleContentModel(); - SimpleContentModel(const SimpleContentModel&); - void operator=(const SimpleContentModel&); - - - // ----------------------------------------------------------------------- - // Private data members - // - // fFirstChild - // fSecondChild - // The first (and optional second) child node. The - // operation code tells us whether the second child is used or not. - // - // fOp - // The operation that this object represents. Since this class only - // does simple contents, there is only ever a single operation - // involved (i.e. the children of the operation are always one or - // two leafs.) - // - // fDTD - // Boolean to allow DTDs to validate even with namespace support. */ - // - // ----------------------------------------------------------------------- - QName* fFirstChild; - QName* fSecondChild; - ContentSpecNode::NodeTypes fOp; - bool fDTD; -}; - - -// --------------------------------------------------------------------------- -// SimpleContentModel: Constructors and Destructor -// --------------------------------------------------------------------------- -inline -SimpleContentModel::SimpleContentModel( const bool dtd - , QName* const firstChild - , QName* const secondChild - , const ContentSpecNode::NodeTypes cmOp) : - - fFirstChild(0) - , fSecondChild(0) - , fOp(cmOp) - , fDTD(dtd) -{ - if (firstChild) - fFirstChild = new QName(firstChild); - else - fFirstChild = new QName(XMLUni::fgZeroLenString, XMLUni::fgZeroLenString, XMLElementDecl::fgInvalidElemId); - - if (secondChild) - fSecondChild = new QName(secondChild); - else - fSecondChild = new QName(XMLUni::fgZeroLenString, XMLUni::fgZeroLenString, XMLElementDecl::fgInvalidElemId); -} - -inline SimpleContentModel::~SimpleContentModel() -{ - delete fFirstChild; - delete fSecondChild; -} - - -// --------------------------------------------------------------------------- -// SimpleContentModel: Virtual methods -// --------------------------------------------------------------------------- -inline unsigned int -SimpleContentModel::getNextState(const unsigned int currentState, - const unsigned int elementIndex) const { - - return XMLContentModel::gInvalidTrans; -} - -#endif diff --git a/src/validators/datatype/AbstractNumericFacetValidator.cpp b/src/validators/datatype/AbstractNumericFacetValidator.cpp deleted file mode 100644 index a0a7fbbfe6621a3ad0a53f018069b8e567d0066c..0000000000000000000000000000000000000000 --- a/src/validators/datatype/AbstractNumericFacetValidator.cpp +++ /dev/null @@ -1,783 +0,0 @@ -/* - * 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.6 2001/12/13 16:48:29 peiyongz - * Avoid dangling pointer - * - * Revision 1.5 2001/12/10 22:13:21 peiyongz - * swap checking to avoid "dangling pointer" reported by BoundsChecker - * - * Revision 1.4 2001/11/12 20:37:57 peiyongz - * SchemaDateTimeException defined - * - * Revision 1.3 2001/10/16 16:29:34 tng - * Schema: Fix Typo - * - * Revision 1.2 2001/10/09 21:17:41 peiyongz - * . macro to simplify code - * .save get***() to temp vars. - * - * Revision 1.1 2001/10/01 16:13:56 peiyongz - * DTV Reorganization:new classes: AbstractNumericFactValidator/ AbstractNumericValidator - * - */ - -// --------------------------------------------------------------------------- -// Includes -// --------------------------------------------------------------------------- -#include <validators/datatype/AbstractNumericFacetValidator.hpp> -#include <validators/schema/SchemaSymbols.hpp> -#include <validators/datatype/InvalidDatatypeFacetException.hpp> -#include <util/NumberFormatException.hpp> - -const int AbstractNumericFacetValidator::INDETERMINATE = 2; - -#define REPORT_FACET_ERROR(val1, val2, except_code) \ - XMLCh* value1 = (val1)->toString(); \ - ArrayJanitor<XMLCh> jan1(value1); \ - XMLCh* value2 = (val2)->toString(); \ - ArrayJanitor<XMLCh> jan2(value2); \ - ThrowXML2(InvalidDatatypeFacetException \ - , except_code \ - , value2 \ - , value1); - - -#define FROM_BASE_VALUE_SPACE(val, facetFlag, except_code) \ - if ((thisFacetsDefined & facetFlag) != 0) \ -{ \ - XMLCh* value1 = (val)->toString(); \ - ArrayJanitor<XMLCh> jan(value1); \ - try \ -{ \ - numBase->checkContent(value1, false); \ -} \ - catch ( XMLException& ) \ -{ \ - ThrowXML1(InvalidDatatypeFacetException \ - , except_code \ - , value1); \ -} \ -} - - -// --------------------------------------------------------------------------- -// Constructors and Destructor -// --------------------------------------------------------------------------- -AbstractNumericFacetValidator::~AbstractNumericFacetValidator() -{ - if (!fMaxInclusiveInherited && fMaxInclusive) - delete fMaxInclusive; - - if (!fMaxExclusiveInherited && fMaxExclusive) - delete fMaxExclusive; - - if (!fMinInclusiveInherited && fMinInclusive) - delete fMinInclusive; - - if (!fMinExclusiveInherited && fMinExclusive) - delete fMinExclusive; - - //~RefVectorOf will delete all adopted elements - if (!fEnumerationInherited && fEnumeration) - delete fEnumeration; -} - -AbstractNumericFacetValidator::AbstractNumericFacetValidator( - DatatypeValidator* const baseValidator - , RefHashTableOf<KVStringPair>* const facets - , const int finalSet - , const ValidatorType type) -:DatatypeValidator(baseValidator, facets, finalSet, type) -, fMaxInclusiveInherited(false) -, fMaxExclusiveInherited(false) -, fMinInclusiveInherited(false) -, fMinExclusiveInherited(false) -, fEnumerationInherited(false) -, fMaxInclusive(0) -, fMaxExclusive(0) -, fMinInclusive(0) -, fMinExclusive(0) -, fEnumeration(0) -, fStrEnumeration(0) -{ - //do not invoke init() here !!! -} - -// -// P1. Enumeration -// -void AbstractNumericFacetValidator::init(RefVectorOf<XMLCh>* const enums) -{ - - fStrEnumeration = enums; // save the literal value - Janitor<RefVectorOf<XMLCh> > janStrEnum(fStrEnumeration); - - if (enums) - { - setFacetsDefined(DatatypeValidator::FACET_ENUMERATION); - } - - assignFacet(); - inspectFacet(); - inspectFacetBase(); - inheritFacet(); -} - -// -// Assign facets -// assign common facets -// assign additional facet -// -void AbstractNumericFacetValidator::assignFacet() -{ - - RefHashTableOf<KVStringPair>* facets = getFacets(); - - if (!facets) // no facets defined - return; - - 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 if (XMLString::compareString(key, SchemaSymbols::fgELT_MAXINCLUSIVE)==0) - { - try - { - setMaxInclusive(value); - } - catch (NumberFormatException) - { - ThrowXML1(InvalidDatatypeFacetException, XMLExcepts::FACET_Invalid_MaxIncl, value); - } - setFacetsDefined(DatatypeValidator::FACET_MAXINCLUSIVE); - } - else if (XMLString::compareString(key, SchemaSymbols::fgELT_MAXEXCLUSIVE)==0) - { - try - { - setMaxExclusive(value); - } - catch (NumberFormatException) - { - ThrowXML1(InvalidDatatypeFacetException, XMLExcepts::FACET_Invalid_MaxExcl, value); - } - setFacetsDefined(DatatypeValidator::FACET_MAXEXCLUSIVE); - } - else if (XMLString::compareString(key, SchemaSymbols::fgELT_MININCLUSIVE)==0) - { - try - { - setMinInclusive(value); - } - catch (NumberFormatException) - { - ThrowXML1(InvalidDatatypeFacetException, XMLExcepts::FACET_Invalid_MinIncl, value); - } - setFacetsDefined(DatatypeValidator::FACET_MININCLUSIVE); - } - else if (XMLString::compareString(key, SchemaSymbols::fgELT_MINEXCLUSIVE)==0) - { - try - { - setMinExclusive(value); - } - catch (NumberFormatException) - { - ThrowXML1(InvalidDatatypeFacetException, XMLExcepts::FACET_Invalid_MinExcl, value); - } - setFacetsDefined(DatatypeValidator::FACET_MINEXCLUSIVE); - } - else if (XMLString::compareString(key, SchemaSymbols::fgATT_FIXED)==0) - { - unsigned int val; - bool retStatus; - try - { - retStatus = XMLString::textToBin(value, val); - } - catch (RuntimeException) - { - ThrowXML(InvalidDatatypeFacetException, XMLExcepts::FACET_internalError_fixed); - } - - if (!retStatus) - { - ThrowXML(InvalidDatatypeFacetException, XMLExcepts::FACET_internalError_fixed); - } - - setFixed(val); - //no setFacetsDefined here - - } - else - { - assignAdditionalFacet(key, value); - } - - }//while - -}// end of assigneFacet() - -// -// Check facet among self -// check common facets -// check Additional Facet Constraint -// -void AbstractNumericFacetValidator::inspectFacet() -{ - - int thisFacetsDefined = getFacetsDefined(); - XMLNumber *thisMaxInclusive = getMaxInclusive(); - XMLNumber *thisMaxExclusive = getMaxExclusive(); - XMLNumber *thisMinInclusive = getMinInclusive(); - XMLNumber *thisMinExclusive = getMinExclusive(); - - if (!thisFacetsDefined) - return; - - // non co-existence checking - // check 4.3.8.c1 error: maxInclusive + maxExclusive - if (((thisFacetsDefined & DatatypeValidator::FACET_MAXEXCLUSIVE) != 0) && - ((thisFacetsDefined & DatatypeValidator::FACET_MAXINCLUSIVE) != 0) ) - ThrowXML(InvalidDatatypeFacetException, XMLExcepts::FACET_max_Incl_Excl); - - // non co-existence checking - // check 4.3.9.c1 error: minInclusive + minExclusive - if (((thisFacetsDefined & DatatypeValidator::FACET_MINEXCLUSIVE) != 0) && - ((thisFacetsDefined & DatatypeValidator::FACET_MININCLUSIVE) != 0) ) - ThrowXML(InvalidDatatypeFacetException, XMLExcepts::FACET_min_Incl_Excl); - - // - // minExclusive < minInclusive <= maxInclusive < maxExclusive - // - // check 4.3.7.c1 must: minInclusive <= maxInclusive - if (((thisFacetsDefined & DatatypeValidator::FACET_MAXINCLUSIVE) != 0) && - ((thisFacetsDefined & DatatypeValidator::FACET_MININCLUSIVE) != 0) ) - { - int result = compareValues(thisMinInclusive, thisMaxInclusive); - if ( result == 1 || result == INDETERMINATE ) - { - REPORT_FACET_ERROR(thisMinInclusive - , thisMaxInclusive - , XMLExcepts::FACET_maxIncl_minIncl) - } - } - - // check 4.3.8.c2 must: minExclusive <= maxExclusive - if ( ((thisFacetsDefined & DatatypeValidator::FACET_MAXEXCLUSIVE) != 0) && - ((thisFacetsDefined & DatatypeValidator::FACET_MINEXCLUSIVE) != 0) ) - { - int result = compareValues(getMinExclusive(), getMaxExclusive()); - if ( result == 1 || result == INDETERMINATE ) - { - REPORT_FACET_ERROR(thisMinExclusive - , thisMaxExclusive - , XMLExcepts::FACET_maxExcl_minExcl) - } - } - - // check 4.3.9.c2 must: minExclusive < maxInclusive - if ( ((thisFacetsDefined & DatatypeValidator::FACET_MAXINCLUSIVE) != 0) && - ((thisFacetsDefined & DatatypeValidator::FACET_MINEXCLUSIVE) != 0) ) - { - int result = compareValues(getMinExclusive(), getMaxInclusive()); - if ( result != -1 ) - { - REPORT_FACET_ERROR(thisMinExclusive - , thisMaxInclusive - , XMLExcepts::FACET_maxIncl_minExcl) - } - } - - // check 4.3.10.c1 must: minInclusive < maxExclusive - if ( ((thisFacetsDefined & DatatypeValidator::FACET_MAXEXCLUSIVE) != 0) && - ((thisFacetsDefined & DatatypeValidator::FACET_MININCLUSIVE) != 0) ) - { - int result = compareValues(getMinInclusive(), getMaxExclusive()); - if ( result != -1) - { - REPORT_FACET_ERROR(thisMinInclusive - , thisMaxExclusive - , XMLExcepts::FACET_maxExcl_minIncl) - } - } - - checkAdditionalFacetConstraints(); - -}// end of inspectFacet() - -// -// Check vs base -// check common facets -// check enumeration -// check Additional Facet Constraint -// -void AbstractNumericFacetValidator::inspectFacetBase() -{ - - AbstractNumericFacetValidator* numBase = (AbstractNumericFacetValidator*) getBaseValidator(); - int thisFacetsDefined = getFacetsDefined(); - - if ( (!thisFacetsDefined && !fEnumeration) || - !numBase ) - return; - - int baseFacetsDefined = numBase->getFacetsDefined(); - - XMLNumber *thisMaxInclusive = getMaxInclusive(); - XMLNumber *thisMaxExclusive = getMaxExclusive(); - XMLNumber *thisMinInclusive = getMinInclusive(); - XMLNumber *thisMinExclusive = getMinExclusive(); - - XMLNumber *baseMaxInclusive = numBase->getMaxInclusive(); - XMLNumber *baseMaxExclusive = numBase->getMaxExclusive(); - XMLNumber *baseMinInclusive = numBase->getMinInclusive(); - XMLNumber *baseMinExclusive = numBase->getMinExclusive(); - int baseFixed = numBase->getFixed(); - - // this - // minExclusive maxExclusive - // minInclusive maxInclusive - // - // base - // minExclusive maxExclusive - // minInclusive maxInclusive - // - - // check 4.3.7.c2 error: - // maxInclusive > base.maxInclusive && maxInclusive != base.maxInclusive if (base.fixed) - // maxInclusive >= base.maxExclusive - // maxInclusive < base.minInclusive - // maxInclusive <= base.minExclusive - - if ((thisFacetsDefined & DatatypeValidator::FACET_MAXINCLUSIVE) != 0) - { - if ((baseFacetsDefined & DatatypeValidator::FACET_MAXINCLUSIVE) != 0) - { - int result = compareValues(thisMaxInclusive, baseMaxInclusive); - - if (((baseFixed & DatatypeValidator::FACET_MAXINCLUSIVE) != 0) && - (result != 0 )) - { - REPORT_FACET_ERROR(baseMaxInclusive - , thisMaxInclusive - , XMLExcepts::FACET_maxIncl_base_fixed) - } - - if (result == 1 || result == INDETERMINATE) - { - REPORT_FACET_ERROR(baseMaxInclusive - , thisMaxInclusive - , XMLExcepts::FACET_maxIncl_base_maxIncl) - } - - } - - if ((baseFacetsDefined & DatatypeValidator::FACET_MAXEXCLUSIVE) != 0) - { - int result = compareValues(thisMaxInclusive, baseMaxExclusive); - if (result != -1 ) - { - REPORT_FACET_ERROR(baseMaxExclusive - , thisMaxInclusive - , XMLExcepts::FACET_maxIncl_base_maxExcl) - } - } - - - if ((baseFacetsDefined & DatatypeValidator::FACET_MININCLUSIVE) != 0) - { - int result = compareValues(thisMaxInclusive, baseMinInclusive); - if (result == -1 || result == INDETERMINATE) - { - REPORT_FACET_ERROR(baseMinInclusive - , thisMaxInclusive - , XMLExcepts::FACET_maxIncl_base_minIncl) - } - } - - if ((baseFacetsDefined & DatatypeValidator::FACET_MINEXCLUSIVE) != 0) - { - int result = compareValues(thisMaxInclusive, baseMinExclusive); - if (result != 1 ) - { - REPORT_FACET_ERROR(baseMinExclusive - , thisMaxInclusive - , XMLExcepts::FACET_maxIncl_base_minExcl) - } - } - - } - - // check 4.3.8.c3 error: - // maxExclusive > base.maxExclusive && maxExclusive != base.maxExclusive if (base.fixed) - // maxExclusive > base.maxInclusive - // maxExclusive <= base.minInclusive - // maxExclusive <= base.minExclusive - - if ((thisFacetsDefined & DatatypeValidator::FACET_MAXEXCLUSIVE) != 0) - { - if (( baseFacetsDefined & DatatypeValidator::FACET_MAXEXCLUSIVE) != 0) - { - int result = compareValues(thisMaxExclusive, baseMaxExclusive); - - if (((baseFixed & DatatypeValidator::FACET_MAXEXCLUSIVE) != 0) && - (result != 0 )) - { - REPORT_FACET_ERROR(baseMaxExclusive - , thisMaxExclusive - , XMLExcepts::FACET_maxExcl_base_fixed) - } - - if (result == 1 || result == INDETERMINATE) - { - REPORT_FACET_ERROR(baseMaxExclusive - , thisMaxExclusive - , XMLExcepts::FACET_maxExcl_base_maxExcl) - } - } - - if (( baseFacetsDefined & DatatypeValidator::FACET_MAXINCLUSIVE) != 0) - { - int result = compareValues(thisMaxExclusive, baseMaxInclusive); - if (result == 1 || result == INDETERMINATE) - { - REPORT_FACET_ERROR(baseMaxInclusive - , thisMaxExclusive - , XMLExcepts::FACET_maxExcl_base_maxIncl) - } - } - - if (( baseFacetsDefined & DatatypeValidator::FACET_MINEXCLUSIVE) != 0) - { - int result = compareValues(thisMaxExclusive, baseMinExclusive); - if (result != 1) - { - REPORT_FACET_ERROR(baseMinExclusive - , thisMaxExclusive - , XMLExcepts::FACET_maxExcl_base_minExcl) - } - } - - if (( baseFacetsDefined & DatatypeValidator::FACET_MININCLUSIVE) != 0) - { - int result = compareValues(thisMaxExclusive, baseMinInclusive); - if (result != 1) - { - REPORT_FACET_ERROR(baseMinInclusive - , thisMaxExclusive - , XMLExcepts::FACET_maxExcl_base_minExcl) - } - } - } - - // check 4.3.9.c3 error: - // minExclusive < base.minExclusive minExclusive != base.minExclusive if (base.fixed) - // minExclusive > base.maxInclusive ??? minExclusive >= base.maxInclusive - // minExclusive < base.minInclusive - // minExclusive >= base.maxExclusive - - if ((thisFacetsDefined & DatatypeValidator::FACET_MINEXCLUSIVE) != 0) - { - if (( baseFacetsDefined & DatatypeValidator::FACET_MINEXCLUSIVE) != 0) - { - int result = compareValues(thisMinExclusive, baseMinExclusive); - - if (((baseFixed & DatatypeValidator::FACET_MINEXCLUSIVE) != 0) && - (result != 0 )) - { - REPORT_FACET_ERROR(baseMinExclusive - , thisMinExclusive - , XMLExcepts::FACET_minExcl_base_fixed) - } - - if (result == -1 || result == INDETERMINATE) - { - REPORT_FACET_ERROR(baseMinExclusive - , thisMinExclusive - , XMLExcepts::FACET_minExcl_base_minExcl) - } - } - - if (( baseFacetsDefined & DatatypeValidator::FACET_MAXINCLUSIVE) != 0) - { - int result = compareValues(thisMinExclusive, baseMaxInclusive); - if (result == 1 || result == INDETERMINATE) - { - REPORT_FACET_ERROR(baseMaxInclusive - , thisMinExclusive - , XMLExcepts::FACET_minExcl_base_maxIncl) - } - } - - if (( baseFacetsDefined & DatatypeValidator::FACET_MININCLUSIVE) != 0) - { - int result = compareValues(thisMinExclusive, baseMinInclusive); - if (result == -1 || result == INDETERMINATE) - { - REPORT_FACET_ERROR(baseMinInclusive - , thisMinExclusive - , XMLExcepts::FACET_minExcl_base_minIncl) - } - } - - if (( baseFacetsDefined & DatatypeValidator::FACET_MAXEXCLUSIVE) != 0) - { - int result = compareValues(thisMinExclusive, baseMaxExclusive); - if (result != -1) - { - REPORT_FACET_ERROR(baseMaxExclusive - , thisMinExclusive - , XMLExcepts::FACET_minExcl_base_maxExcl) - } - } - - } - - // check 4.3.10.c2 error: - // minInclusive < base.minInclusive minInclusive != base.minInclusive if (base.fixed) - // minInclusive > base.maxInclusive - // minInclusive <= base.minExclusive - // minInclusive >= base.maxExclusive - - - if ((thisFacetsDefined & DatatypeValidator::FACET_MININCLUSIVE) != 0) - { - if ((baseFacetsDefined & DatatypeValidator::FACET_MININCLUSIVE) != 0) - { - int result = compareValues(thisMinInclusive, baseMinInclusive); - - if (((baseFixed & DatatypeValidator::FACET_MININCLUSIVE) != 0) && - (result != 0 )) - { - REPORT_FACET_ERROR(baseMinInclusive - , thisMinInclusive - , XMLExcepts::FACET_minIncl_base_fixed) - } - - if (result == -1 || result == INDETERMINATE) - { - REPORT_FACET_ERROR(baseMinInclusive - , thisMinInclusive - , XMLExcepts::FACET_minIncl_base_minIncl) - } - } - - if (( baseFacetsDefined & DatatypeValidator::FACET_MAXINCLUSIVE) != 0) - { - int result = compareValues(thisMinInclusive, baseMaxInclusive); - if (result == 1 || result == INDETERMINATE) - { - REPORT_FACET_ERROR(baseMaxInclusive - , thisMinInclusive - , XMLExcepts::FACET_minIncl_base_maxIncl) - } - } - - if (( baseFacetsDefined & DatatypeValidator::FACET_MINEXCLUSIVE) != 0) - { - int result = compareValues(thisMinInclusive, baseMinExclusive); - if (result != 1) - { - REPORT_FACET_ERROR(baseMinExclusive - , thisMinInclusive - , XMLExcepts::FACET_minIncl_base_minExcl) - } - } - - if (( baseFacetsDefined & DatatypeValidator::FACET_MAXEXCLUSIVE) != 0) - { - int result = compareValues(thisMinInclusive, baseMaxExclusive); - if (result != -1) - { - REPORT_FACET_ERROR(baseMaxExclusive - , thisMinInclusive - , XMLExcepts::FACET_minIncl_base_maxExcl) - } - } - - } - - checkAdditionalFacetConstraintsBase(); - - // check 4.3.5.c0 must: enumeration values from the value space of base - // - // In fact, the values in the enumeration shall go through validation - // of this class as well. - // this->checkContent(value, false); - // - if ( ((thisFacetsDefined & DatatypeValidator::FACET_ENUMERATION) != 0) && - ( fStrEnumeration )) - { - setEnumeration(); - } - - // - // maxInclusive, maxExclusive, minInclusive and minExclusive - // shall come from the base's value space as well - // - - FROM_BASE_VALUE_SPACE(thisMaxInclusive - , DatatypeValidator::FACET_MAXINCLUSIVE - , XMLExcepts::FACET_maxIncl_notFromBase) - - FROM_BASE_VALUE_SPACE(thisMaxExclusive - , DatatypeValidator::FACET_MAXEXCLUSIVE - , XMLExcepts::FACET_maxExcl_notFromBase) - - FROM_BASE_VALUE_SPACE(thisMinInclusive - , DatatypeValidator::FACET_MININCLUSIVE - , XMLExcepts::FACET_minIncl_notFromBase) - - FROM_BASE_VALUE_SPACE(thisMinExclusive - , DatatypeValidator::FACET_MINEXCLUSIVE - , XMLExcepts::FACET_minExcl_notFromBase) - -} //end of inspectFacetBase - -// -// Inherit facet from base -// a. inherit common facets -// b. inherit additional facet -// -void AbstractNumericFacetValidator::inheritFacet() -{ - - AbstractNumericFacetValidator* numBase = (AbstractNumericFacetValidator*) getBaseValidator(); - if (!numBase) - return; - - int thisFacetsDefined = getFacetsDefined(); - int baseFacetsDefined = numBase->getFacetsDefined(); - - // inherit enumeration - if ((( baseFacetsDefined & DatatypeValidator::FACET_ENUMERATION) != 0) && - (( thisFacetsDefined & DatatypeValidator::FACET_ENUMERATION) == 0)) - { - fEnumeration = numBase->fEnumeration; - fEnumerationInherited = true; - setFacetsDefined(DatatypeValidator::FACET_ENUMERATION); - } - - // inherit maxInclusive - if ((( baseFacetsDefined & DatatypeValidator::FACET_MAXINCLUSIVE) != 0) && - (( thisFacetsDefined & DatatypeValidator::FACET_MAXEXCLUSIVE) == 0) && - (( thisFacetsDefined & DatatypeValidator::FACET_MAXINCLUSIVE) == 0) ) - { - fMaxInclusive = numBase->getMaxInclusive(); - fMaxInclusiveInherited = true; - setFacetsDefined(DatatypeValidator::FACET_MAXINCLUSIVE); - } - - // inherit maxExclusive - if ((( baseFacetsDefined & DatatypeValidator::FACET_MAXEXCLUSIVE) != 0) && - (( thisFacetsDefined & DatatypeValidator::FACET_MAXEXCLUSIVE) == 0) && - (( thisFacetsDefined & DatatypeValidator::FACET_MAXINCLUSIVE) == 0) ) - { - fMaxExclusive = numBase->getMaxExclusive(); - fMaxExclusiveInherited = true; - setFacetsDefined(DatatypeValidator::FACET_MAXEXCLUSIVE); - } - - // inherit minExclusive - if ((( baseFacetsDefined & DatatypeValidator::FACET_MININCLUSIVE) != 0) && - (( thisFacetsDefined & DatatypeValidator::FACET_MINEXCLUSIVE) == 0) && - (( thisFacetsDefined & DatatypeValidator::FACET_MININCLUSIVE) == 0) ) - { - fMinInclusive = numBase->getMinInclusive(); - fMinInclusiveInherited = true; - setFacetsDefined(DatatypeValidator::FACET_MININCLUSIVE); - } - - // inherit minExclusive - if ((( baseFacetsDefined & DatatypeValidator::FACET_MINEXCLUSIVE) != 0) && - (( thisFacetsDefined & DatatypeValidator::FACET_MINEXCLUSIVE) == 0) && - (( thisFacetsDefined & DatatypeValidator::FACET_MININCLUSIVE) == 0) ) - { - fMinExclusive = numBase->getMinExclusive(); - fMinExclusiveInherited = true; - setFacetsDefined(DatatypeValidator::FACET_MINEXCLUSIVE); - } - - inheritAdditionalFacet(); - - // inherit "fixed" option - setFixed(getFixed() | numBase->getFixed()); - -} - -/** - * End of file AbstractNumericFacetValidator::cpp - */ diff --git a/src/validators/datatype/AbstractNumericFacetValidator.hpp b/src/validators/datatype/AbstractNumericFacetValidator.hpp deleted file mode 100644 index d8fb491a976472febedb66e44347b4189de0185e..0000000000000000000000000000000000000000 --- a/src/validators/datatype/AbstractNumericFacetValidator.hpp +++ /dev/null @@ -1,213 +0,0 @@ -/* - * 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.3 2001/11/22 20:23:20 peiyongz - * _declspec(dllimport) and inline warning C4273 - * - * Revision 1.2 2001/11/12 20:37:57 peiyongz - * SchemaDateTimeException defined - * - * Revision 1.1 2001/10/01 16:13:56 peiyongz - * DTV Reorganization:new classes: AbstractNumericFactValidator/ AbstractNumericValidator - * - */ - -#if !defined(ABSTRACT_NUMERIC_FACET_VALIDATOR_HPP) -#define ABSTRACT_NUMERIC_FACET_VALIDATOR_HPP - -#include <validators/datatype/DatatypeValidator.hpp> -#include <util/RefVectorOf.hpp> -#include <util/XMLNumber.hpp> - -class VALIDATORS_EXPORT AbstractNumericFacetValidator : public DatatypeValidator -{ -public: - - // ----------------------------------------------------------------------- - // Public ctor/dtor - // ----------------------------------------------------------------------- - /** @name Constructor. */ - //@{ - - virtual ~AbstractNumericFacetValidator(); - - //@} - -protected: - - AbstractNumericFacetValidator(DatatypeValidator* const baseValidator - , RefHashTableOf<KVStringPair>* const facets - , const int finalSet - , const ValidatorType type); - - void init(RefVectorOf<XMLCh>* const enums); - - // - // Abstract interface - // - virtual void assignAdditionalFacet(const XMLCh* const key - , const XMLCh* const value) = 0; - - virtual void inheritAdditionalFacet() = 0; - - virtual void checkAdditionalFacetConstraints() const = 0; - - virtual void checkAdditionalFacetConstraintsBase() const = 0; - - virtual int compareValues(const XMLNumber* const lValue - , const XMLNumber* const rValue) = 0; - - virtual void checkContent(const XMLCh* const content - , bool asBase) = 0; - -// ----------------------------------------------------------------------- -// Setter methods -// ----------------------------------------------------------------------- - - virtual void setMaxInclusive(const XMLCh* const) = 0; - - virtual void setMaxExclusive(const XMLCh* const) = 0; - - virtual void setMinInclusive(const XMLCh* const) = 0; - - virtual void setMinExclusive(const XMLCh* const) = 0; - - virtual void setEnumeration() = 0; - - static const int INDETERMINATE; - -// ----------------------------------------------------------------------- -// Getter methods -// ----------------------------------------------------------------------- - - inline XMLNumber* const getMaxInclusive() const; - - inline XMLNumber* const getMaxExclusive() const; - - inline XMLNumber* const getMinInclusive() const; - - inline XMLNumber* const getMinExclusive() const; - - inline RefVectorOf<XMLNumber>* getEnumeration() const; - - // ----------------------------------------------------------------------- - // Protected data members - // - // Allow access to derived class - // - // ----------------------------------------------------------------------- - bool fMaxInclusiveInherited; - bool fMaxExclusiveInherited; - bool fMinInclusiveInherited; - bool fMinExclusiveInherited; - bool fEnumerationInherited; - - XMLNumber* fMaxInclusive; - XMLNumber* fMaxExclusive; - XMLNumber* fMinInclusive; - XMLNumber* fMinExclusive; - - RefVectorOf<XMLNumber>* fEnumeration; // save the actual value - RefVectorOf<XMLCh>* fStrEnumeration; - -private: - - void assignFacet(); - - void inspectFacet(); - - void inspectFacetBase(); - - void inheritFacet(); - -}; - -// ----------------------------------------------------------------------- -// Getter methods -// ----------------------------------------------------------------------- - -inline XMLNumber* const AbstractNumericFacetValidator::getMaxInclusive() const -{ - return fMaxInclusive; -} - -inline XMLNumber* const AbstractNumericFacetValidator::getMaxExclusive() const -{ - return fMaxExclusive; -} - -inline XMLNumber* const AbstractNumericFacetValidator::getMinInclusive() const -{ - return fMinInclusive; -} - -inline XMLNumber* const AbstractNumericFacetValidator::getMinExclusive() const -{ - return fMinExclusive; -} - -inline RefVectorOf<XMLNumber>* AbstractNumericFacetValidator::getEnumeration() const -{ - return fEnumeration; -} - -/** - * End of file AbstractNumericFacetValidator.hpp - */ -#endif diff --git a/src/validators/datatype/AbstractNumericValidator.cpp b/src/validators/datatype/AbstractNumericValidator.cpp deleted file mode 100644 index 9839234b7fc28a26f00fa01b95fce4f70f913e00..0000000000000000000000000000000000000000 --- a/src/validators/datatype/AbstractNumericValidator.cpp +++ /dev/null @@ -1,171 +0,0 @@ -/* - * 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.2 2001/10/09 21:16:31 peiyongz - * . macro to simplify code - * - * Revision 1.1 2001/10/01 16:13:56 peiyongz - * DTV Reorganization:new classes: AbstractNumericFactValidator/ AbstractNumericValidator - * - */ - -// --------------------------------------------------------------------------- -// Includes -// --------------------------------------------------------------------------- -#include <validators/datatype/AbstractNumericValidator.hpp> -#include <validators/datatype/InvalidDatatypeValueException.hpp> - -#define REPORT_VALUE_ERROR(val1, val2, except_code) \ - XMLCh* value1 = (val1)->toString(); \ - ArrayJanitor<XMLCh> jan1(value1); \ - XMLCh* value2 = (val2)->toString(); \ - ArrayJanitor<XMLCh> jan2(value2); \ - ThrowXML2(InvalidDatatypeValueException \ - , except_code \ - , value1 \ - , value2); - -// --------------------------------------------------------------------------- -// Constructors and Destructor -// --------------------------------------------------------------------------- -AbstractNumericValidator::~AbstractNumericValidator() -{} - -AbstractNumericValidator::AbstractNumericValidator( - DatatypeValidator* const baseValidator - , RefHashTableOf<KVStringPair>* const facets - , const int finalSet - , const ValidatorType type) -:AbstractNumericFacetValidator(baseValidator, facets, finalSet, type) -{ - //do not invoke init() here !!! -} - -void AbstractNumericValidator::validate(const XMLCh* const content) -{ - checkContent(content, false); -} - -void AbstractNumericValidator::boundsCheck(const XMLNumber* const theData) -{ - int thisFacetsDefined = getFacetsDefined(); - int result; - - try - { - - // must be < MaxExclusive - if ( (thisFacetsDefined & DatatypeValidator::FACET_MAXEXCLUSIVE) != 0 ) - { - result = compareValues(theData, getMaxExclusive()); - if ( result != -1) - { - REPORT_VALUE_ERROR(theData - , getMaxExclusive() - , XMLExcepts::VALUE_exceed_maxExcl) - } - } - - // must be <= MaxInclusive - if ( (thisFacetsDefined & DatatypeValidator::FACET_MAXINCLUSIVE) != 0 ) - { - result = compareValues(theData, getMaxInclusive()); - if (result == 1) - { - REPORT_VALUE_ERROR(theData - , getMaxInclusive() - , XMLExcepts::VALUE_exceed_maxIncl) - } - } - - // must be >= MinInclusive - if ( (thisFacetsDefined & DatatypeValidator::FACET_MININCLUSIVE) != 0 ) - { - result = compareValues(theData, getMinInclusive()); - if (result == -1) - { - REPORT_VALUE_ERROR(theData - , getMinInclusive() - , XMLExcepts::VALUE_exceed_minIncl) - } - } - - // must be > MinExclusive - if ( (thisFacetsDefined & DatatypeValidator::FACET_MINEXCLUSIVE) != 0 ) - { - result = compareValues(theData, getMinExclusive()); - if (result != 1) - { - REPORT_VALUE_ERROR(theData - , getMinExclusive() - , XMLExcepts::VALUE_exceed_minExcl) - } - } - } - catch (XMLException &e) - { - ThrowXML1(InvalidDatatypeValueException, XMLExcepts::RethrowError, e.getMessage()); - } - -} - -/** - * End of file AbstractNumericValidator::cpp - */ - diff --git a/src/validators/datatype/AbstractNumericValidator.hpp b/src/validators/datatype/AbstractNumericValidator.hpp deleted file mode 100644 index a4cc736ff5ffeb0dc56112e3bb0c1b786adc9982..0000000000000000000000000000000000000000 --- a/src/validators/datatype/AbstractNumericValidator.hpp +++ /dev/null @@ -1,125 +0,0 @@ -/* - * 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.2 2001/11/22 20:23:20 peiyongz - * _declspec(dllimport) and inline warning C4273 - * - * Revision 1.1 2001/10/01 16:13:56 peiyongz - * DTV Reorganization:new classes: AbstractNumericFactValidator/ AbstractNumericValidator - * - */ - -#if !defined(ABSTRACT_NUMERIC_VALIDATOR_HPP) -#define ABSTRACT_NUMERIC_VALIDATOR_HPP - -#include <validators/datatype/AbstractNumericFacetValidator.hpp> -#include <util/RefVectorOf.hpp> -#include <util/XMLNumber.hpp> - -class VALIDATORS_EXPORT AbstractNumericValidator : public AbstractNumericFacetValidator -{ -public: - - // ----------------------------------------------------------------------- - // Public ctor/dtor - // ----------------------------------------------------------------------- - /** @name Constructor. */ - //@{ - - virtual ~AbstractNumericValidator(); - - //@} - - virtual void validate(const XMLCh* const content); - -protected: - - AbstractNumericValidator(DatatypeValidator* const baseValidator - , RefHashTableOf<KVStringPair>* const facets - , const int finalSet - , const ValidatorType type); - - inline void init(RefVectorOf<XMLCh>* const enums); - - // - // Abstract interface - // - virtual void checkContent(const XMLCh* const content - , bool asBase) = 0; - - void boundsCheck(const XMLNumber* const); - -private: - - // ----------------------------------------------------------------------- - // Private data members - // - // ----------------------------------------------------------------------- - -}; - -inline void AbstractNumericValidator::init(RefVectorOf<XMLCh>* const enums) -{ - AbstractNumericFacetValidator::init(enums); -} - -/** - * End of file AbstractNumericValidator.hpp - */ -#endif diff --git a/src/validators/datatype/AbstractStringValidator.cpp b/src/validators/datatype/AbstractStringValidator.cpp deleted file mode 100644 index 5ae2930e4aace076f264c460368a70c5d6fe4094..0000000000000000000000000000000000000000 --- a/src/validators/datatype/AbstractStringValidator.cpp +++ /dev/null @@ -1,655 +0,0 @@ -/* - * 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$ - * Revision 1.7 2001/12/13 16:48:29 peiyongz - * Avoid dangling pointer - * - * Revision 1.6 2001/10/15 20:57:27 tng - * Schema: we should propagate the exception thrown from checkContent. - * - * Revision 1.5 2001/10/09 21:00:54 peiyongz - * . init() take 1 arg, - * . make inspectFacetBase() virtual to allow ListDTV provide its own method, - * . reorganize init() into assignFacet(), inspectFacet(), inspectFacetBase() and - * inheritFacet() to improve mantainability. - * . macro to simplify code - * . save get***() to temp vars - * - * Revision 1.4 2001/09/24 15:30:16 peiyongz - * DTV Reorganization: init() to be invoked from derived class' ctor to allow - * correct resolution of virtual methods like assignAdditionalFacet(), - * inheritAdditionalFacet(), etc. - * - * Revision 1.3 2001/09/19 18:48:27 peiyongz - * DTV reorganization:getLength() added, move inline to class declaration to avoid inline - * function interdependency. - * - * Revision 1.2 2001/09/18 21:16:42 peiyongz - * DTV reorganization: temp vars to replace repeated invocation of getFacetsDefined() - * - * Revision 1.1 2001/09/18 14:45:04 peiyongz - * DTV reorganization - * - * - */ - -// --------------------------------------------------------------------------- -// Includes -// --------------------------------------------------------------------------- -#include <validators/datatype/AbstractStringValidator.hpp> -#include <validators/schema/SchemaSymbols.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]; - -#define REPORT_FACET_ERROR(val1, val2, except_code) \ - XMLString::binToText(val1, value1, BUF_LEN, 10); \ - XMLString::binToText(val2, value2, BUF_LEN, 10); \ - ThrowXML2(InvalidDatatypeFacetException \ - , except_code \ - , value1 \ - , value2); - -#define REPORT_VALUE_ERROR(data, val1, val2, except_code) \ - XMLString::binToText(val1, value1, BUF_LEN, 10); \ - XMLString::binToText(val2, value2, BUF_LEN, 10); \ - ThrowXML3(InvalidDatatypeValueException \ - , except_code \ - , data \ - , value1 \ - , value2); - -// --------------------------------------------------------------------------- -// Constructors and Destructor -// --------------------------------------------------------------------------- -AbstractStringValidator::~AbstractStringValidator() -{ - //~RefVectorOf will delete all adopted elements - if ( !fEnumerationInherited && fEnumeration) - { - delete fEnumeration; - fEnumeration = 0; - } -} - -AbstractStringValidator::AbstractStringValidator( - DatatypeValidator* const baseValidator - , RefHashTableOf<KVStringPair>* const facets - , const int finalSet - , const ValidatorType type) -:DatatypeValidator(baseValidator, facets, finalSet, type) -,fLength(0) -,fMaxLength(SchemaSymbols::fgINT_MAX_VALUE) -,fMinLength(0) -,fEnumerationInherited(false) -,fEnumeration(0) -{ - // init() is invoked from derived class's ctor instead of from - // here to allow correct resolution of virutal method, such as - // assigneAdditionalFacet(), inheritAdditionalFacet(). -} - -void AbstractStringValidator::init(RefVectorOf<XMLCh>* const enums) -{ - - if (enums) - setEnumeration(enums, false); - - assignFacet(); - inspectFacet(); - inspectFacetBase(); - inheritFacet(); - -} - -// -// Assign facets -// assign common facets -// assign additional facet -// -void AbstractStringValidator::assignFacet() -{ - - RefHashTableOf<KVStringPair>* facets = getFacets(); - - if (!facets) - return; - - 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_LENGTH)==0) - { - int val; - try - { - val = XMLString::parseInt(value); - } - catch (NumberFormatException nfe) - { - ThrowXML1(InvalidDatatypeFacetException, XMLExcepts::FACET_Invalid_Len, value); - } - - if ( val < 0 ) - ThrowXML1(InvalidDatatypeFacetException, XMLExcepts::FACET_NonNeg_Len, value); - - setLength(val); - setFacetsDefined(DatatypeValidator::FACET_LENGTH); - } - else if (XMLString::compareString(key, SchemaSymbols::fgELT_MINLENGTH)==0) - { - int val; - try - { - val = XMLString::parseInt(value); - } - catch (NumberFormatException nfe) - { - ThrowXML1(InvalidDatatypeFacetException, XMLExcepts::FACET_Invalid_minLen, value); - } - - if ( val < 0 ) - ThrowXML1(InvalidDatatypeFacetException, XMLExcepts::FACET_NonNeg_minLen, value); - - setMinLength(val); - setFacetsDefined(DatatypeValidator::FACET_MINLENGTH); - } - else if (XMLString::compareString(key, SchemaSymbols::fgELT_MAXLENGTH)==0) - { - int val; - try - { - val = XMLString::parseInt(value); - } - catch (NumberFormatException nfe) - { - ThrowXML1(InvalidDatatypeFacetException, XMLExcepts::FACET_Invalid_maxLen, value); - } - - if ( val < 0 ) - ThrowXML1(InvalidDatatypeFacetException, XMLExcepts::FACET_NonNeg_maxLen, value); - - setMaxLength(val); - setFacetsDefined(DatatypeValidator::FACET_MAXLENGTH); - } - else if (XMLString::compareString(key, SchemaSymbols::fgELT_PATTERN)==0) - { - setPattern(value); - if (getPattern()) - setFacetsDefined(DatatypeValidator::FACET_PATTERN); - // do not construct regex until needed - } - else if (XMLString::compareString(key, SchemaSymbols::fgATT_FIXED)==0) - { - unsigned int val; - bool retStatus; - try - { - retStatus = XMLString::textToBin(value, val); - } - catch (RuntimeException) - { - ThrowXML(InvalidDatatypeFacetException, XMLExcepts::FACET_internalError_fixed); - } - - if (!retStatus) - { - ThrowXML(InvalidDatatypeFacetException, XMLExcepts::FACET_internalError_fixed); - } - - setFixed(val); - //no setFacetsDefined here - } - // - // else if (XMLString::compareString(key, SchemaSymbols::fgELT_SPECIAL_TOKEN)==0) - // TODO - // - // Note: whitespace is taken care of by TraverseSchema. - // - else - { - assignAdditionalFacet(key, value); - } - }//while -}//end of assigneFacet() - -// -// Check facet among self -// check common facets -// check Additional Facet Constraint -// -void AbstractStringValidator::inspectFacet() -{ - - int thisFacetsDefined = getFacetsDefined(); - - if (!thisFacetsDefined) - return; - - // check 4.3.1.c1 error: length & (maxLength | minLength) - if ((thisFacetsDefined & DatatypeValidator::FACET_LENGTH) != 0) - { - if ((thisFacetsDefined & DatatypeValidator::FACET_MAXLENGTH) != 0) - ThrowXML(InvalidDatatypeFacetException, XMLExcepts::FACET_Len_maxLen); - else if (((thisFacetsDefined & DatatypeValidator::FACET_MINLENGTH) != 0)) - ThrowXML(InvalidDatatypeFacetException, XMLExcepts::FACET_Len_minLen); - } - - // check 4.3.2.c1 must: minLength <= maxLength - if ((thisFacetsDefined & (DatatypeValidator::FACET_MINLENGTH - |DatatypeValidator::FACET_MAXLENGTH)) != 0) - { - int thisMinLength = getMinLength(); - int thisMaxLength = getMaxLength(); - if ( thisMinLength > thisMaxLength ) - { - REPORT_FACET_ERROR(thisMaxLength - , thisMinLength - , XMLExcepts::FACET_maxLen_minLen) - } - } - -}// end of inspectFacet() - -// -// Check vs base -// check common facets -// check enumeration -// check Additional Facet Constraint -// -void AbstractStringValidator::inspectFacetBase() -{ - - AbstractStringValidator *pBaseValidator = (AbstractStringValidator*) getBaseValidator(); - int thisFacetsDefined = getFacetsDefined(); - - if ( (!thisFacetsDefined && !fEnumeration) || - (!pBaseValidator) ) - return; - - int baseFacetsDefined = pBaseValidator->getFacetsDefined(); - - int thisLength = getLength(); - int thisMinLength = getMinLength(); - int thisMaxLength = getMaxLength(); - - int baseLength = pBaseValidator->getLength(); - int baseMinLength = pBaseValidator->getMinLength(); - int baseMaxLength = pBaseValidator->getMaxLength(); - int baseFixed = pBaseValidator->getFixed(); - - /*** - check facets against base.facets - Note: later we need to check the "fix" option of the base type - and apply that to every individual facet. - ***/ - - /*** - Non coexistence of derived' length and base' (minLength | maxLength) - base' length and derived' (minLength | maxLength) - ***/ - - // check 4.3.1.c1 error: length & (base.maxLength | base.minLength) - if ((thisFacetsDefined & DatatypeValidator::FACET_LENGTH) !=0) - { - if ((baseFacetsDefined & DatatypeValidator::FACET_MAXLENGTH) !=0) - ThrowXML(InvalidDatatypeFacetException, XMLExcepts::FACET_Len_maxLen); - else if ((baseFacetsDefined & DatatypeValidator::FACET_MINLENGTH) !=0) - ThrowXML(InvalidDatatypeFacetException, XMLExcepts::FACET_Len_minLen); - } - - // check 4.3.1.c1 error: base.length & (maxLength | minLength) - if ((baseFacetsDefined & DatatypeValidator::FACET_LENGTH) !=0) - { - if ((thisFacetsDefined & DatatypeValidator::FACET_MAXLENGTH) !=0) - ThrowXML(InvalidDatatypeFacetException, XMLExcepts::FACET_Len_maxLen); - else if ((thisFacetsDefined & DatatypeValidator::FACET_MINLENGTH) !=0) - ThrowXML(InvalidDatatypeFacetException, XMLExcepts::FACET_Len_minLen); - } - - // check 4.3.1.c2 error: length != base.length - if (((thisFacetsDefined & DatatypeValidator::FACET_LENGTH) !=0) && - ((baseFacetsDefined & DatatypeValidator::FACET_LENGTH) !=0)) - { - if ( thisLength != baseLength ) - { - REPORT_FACET_ERROR(thisLength - , baseLength - , XMLExcepts::FACET_Len_baseLen) - } - } - - /*** - |--- derived ---| - base.minLength <= minLength <= maxLength <= base.maxLength - |------------------- base -------------------| - ***/ - - // check 4.3.2.c1 must: minLength <= base.maxLength - if (((thisFacetsDefined & DatatypeValidator::FACET_MINLENGTH ) != 0) && - ((baseFacetsDefined & DatatypeValidator::FACET_MAXLENGTH ) != 0)) - { - if ( thisMinLength > baseMaxLength ) - { - REPORT_FACET_ERROR(thisMinLength - , baseMaxLength - , XMLExcepts::FACET_minLen_basemaxLen) - } - } - - // check 4.3.2.c2 error: minLength < base.minLength - if (((thisFacetsDefined & DatatypeValidator::FACET_MINLENGTH) !=0) && - ((baseFacetsDefined & DatatypeValidator::FACET_MINLENGTH) != 0)) - { - if ((baseFixed & DatatypeValidator::FACET_MINLENGTH) !=0) - { - if ( thisMinLength != baseMinLength ) - { - REPORT_FACET_ERROR(thisMinLength - , baseMinLength - , XMLExcepts::FACET_minLen_base_fixed) - } - - } - else - { - if ( thisMinLength < baseMinLength ) - { - REPORT_FACET_ERROR(thisMinLength - , baseMinLength - , XMLExcepts::FACET_minLen_baseminLen) - } - } - } - - // check 4.3.2.c1 must: base.minLength <= maxLength - if (((baseFacetsDefined & DatatypeValidator::FACET_MINLENGTH) !=0) && - ((thisFacetsDefined & DatatypeValidator::FACET_MAXLENGTH) !=0)) - { - if ( baseMinLength > thisMaxLength ) - { - REPORT_FACET_ERROR(thisMaxLength - , baseMinLength - , XMLExcepts::FACET_maxLen_baseminLen) - } - } - - // check 4.3.3.c1 error: maxLength > base.maxLength - if (((thisFacetsDefined & DatatypeValidator::FACET_MAXLENGTH) !=0) && - ((baseFacetsDefined & DatatypeValidator::FACET_MAXLENGTH) !=0)) - { - if ((baseFixed & DatatypeValidator::FACET_MAXLENGTH) !=0) - { - if ( thisMaxLength != baseMaxLength ) - { - REPORT_FACET_ERROR(thisMaxLength - , baseMaxLength - , XMLExcepts::FACET_maxLen_base_fixed) - } - } - else - { - if ( thisMaxLength > baseMaxLength ) - { - REPORT_FACET_ERROR(thisMaxLength - , baseMaxLength - , XMLExcepts::FACET_maxLen_basemaxLen) - } - } - } - - // check 4.3.5.c0 must: enumeration values from the value space of base - if ( ((thisFacetsDefined & DatatypeValidator::FACET_ENUMERATION) != 0) && - (getEnumeration() !=0)) - { - int i = 0; - int enumLength = getEnumeration()->size(); - for ( ; i < enumLength; i++) - { - // ask parent do a complete check - pBaseValidator->checkContent(getEnumeration()->elementAt(i), false); - // enum shall pass this->checkContent() as well. - checkContent(getEnumeration()->elementAt(i), false); - } - } - - checkAdditionalFacetConstraints(); - -} //end of inspectFacetBase - -// -// Inherit facet from base -// a. inherit common facets -// b. inherit additional facet -// -void AbstractStringValidator::inheritFacet() -{ - /*** - P3. 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. - ***/ - - AbstractStringValidator *pBaseValidator = (AbstractStringValidator*) getBaseValidator(); - - if (!pBaseValidator) - return; - - int thisFacetsDefined = getFacetsDefined(); - int baseFacetsDefined = pBaseValidator->getFacetsDefined(); - - // inherit length - if (((baseFacetsDefined & DatatypeValidator::FACET_LENGTH) != 0) && - ((thisFacetsDefined & DatatypeValidator::FACET_LENGTH) == 0)) - { - setLength(pBaseValidator->getLength()); - setFacetsDefined(DatatypeValidator::FACET_LENGTH); - } - - // inherit minLength - if (((baseFacetsDefined & DatatypeValidator::FACET_MINLENGTH) !=0) && - ((thisFacetsDefined & DatatypeValidator::FACET_MINLENGTH) == 0)) - { - setMinLength(pBaseValidator->getMinLength()); - setFacetsDefined(DatatypeValidator::FACET_MINLENGTH); - } - - // inherit maxLength - if (((baseFacetsDefined & DatatypeValidator::FACET_MAXLENGTH) !=0) && - ((thisFacetsDefined & DatatypeValidator::FACET_MAXLENGTH) == 0)) - { - setMaxLength(pBaseValidator->getMaxLength()); - setFacetsDefined(DatatypeValidator::FACET_MAXLENGTH); - } - - // inherit enumeration - if (((baseFacetsDefined & DatatypeValidator::FACET_ENUMERATION) !=0) && - ((thisFacetsDefined & DatatypeValidator::FACET_ENUMERATION) == 0)) - { - setEnumeration(pBaseValidator->getEnumeration(), true); - } - - // we don't inherit pattern - - // inherit "fixed" option - setFixed(getFixed() | pBaseValidator->getFixed()); - - // inherit additional facet - inheritAdditionalFacet(); - -} // end of inheritance - - -// ----------------------------------------------------------------------- -// Compare methods -// ----------------------------------------------------------------------- -int AbstractStringValidator::compare(const XMLCh* const lValue - , const XMLCh* const rValue) -{ - return XMLString::compareString(lValue, rValue); -} - -void AbstractStringValidator::validate( const XMLCh* const content) -{ - checkContent(content, false); -} - -void AbstractStringValidator::checkContent( const XMLCh* const content, bool asBase) -{ - - //validate against base validator if any - AbstractStringValidator *pBaseValidator = (AbstractStringValidator*) this->getBaseValidator(); - if (pBaseValidator) - pBaseValidator->checkContent(content, true); - - int thisFacetsDefined = getFacetsDefined(); - - // we check pattern first - if ( (thisFacetsDefined & 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; - - checkValueSpace(content); - unsigned int length = getLength(content); - - if (((thisFacetsDefined & DatatypeValidator::FACET_MAXLENGTH) != 0) && - (length > getMaxLength())) - { - REPORT_VALUE_ERROR(content - , length - , getMaxLength() - , XMLExcepts::VALUE_GT_maxLen) - } - - if (((thisFacetsDefined & DatatypeValidator::FACET_MINLENGTH) != 0) && - (length < getMinLength())) - { - REPORT_VALUE_ERROR(content - , length - , getMinLength() - , XMLExcepts::VALUE_LT_minLen) - } - - if (((thisFacetsDefined & DatatypeValidator::FACET_LENGTH) != 0) && - (length != getLength())) - { - REPORT_VALUE_ERROR(content - , length - , getLength() - , XMLExcepts::VALUE_NE_Len) - } - - if ((thisFacetsDefined & DatatypeValidator::FACET_ENUMERATION) != 0 && - (getEnumeration() != 0)) - { - int i=0; - int enumLength = getEnumeration()->size(); - for ( ; i < enumLength; i++) - { - if (XMLString::compareString(content, getEnumeration()->elementAt(i))==0) - break; - } - - if (i == enumLength) - ThrowXML1(InvalidDatatypeValueException, XMLExcepts::VALUE_NotIn_Enumeration, content); - } - - checkAdditionalFacet(content); - -} - -/** - * End of file AbstractStringValidator.cpp - */ diff --git a/src/validators/datatype/AbstractStringValidator.hpp b/src/validators/datatype/AbstractStringValidator.hpp deleted file mode 100644 index 7d432ac9da05aebfd324b85273020f262f4b54f6..0000000000000000000000000000000000000000 --- a/src/validators/datatype/AbstractStringValidator.hpp +++ /dev/null @@ -1,280 +0,0 @@ -/* - * 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.9 2001/12/13 16:48:29 peiyongz - * Avoid dangling pointer - * - * Revision 1.8 2001/11/22 20:23:20 peiyongz - * _declspec(dllimport) and inline warning C4273 - * - * Revision 1.7 2001/11/15 16:08:15 peiyongz - * checkContent() made virtual to allow ListDTV participate in the building of - * its own (in AbstractStringValidator's init()) - * - * Revision 1.6 2001/10/11 19:32:12 peiyongz - * Allow derived to overwrite inheritFacet() - * - * Revision 1.5 2001/10/09 21:00:54 peiyongz - * . init() take 1 arg, - * . make inspectFacetBase() virtual to allow ListDTV provide its own method, - * . reorganize init() into assignFacet(), inspectFacet(), inspectFacetBase() and - * inheritFacet() to improve mantainability. - * . macro to simplify code - * . save get***() to temp vars - * - * Revision 1.4 2001/09/27 13:51:25 peiyongz - * DTV Reorganization: ctor/init created to be used by derived class - * - * Revision 1.3 2001/09/24 15:30:16 peiyongz - * DTV Reorganization: init() to be invoked from derived class' ctor to allow - * correct resolution of virtual methods like assignAdditionalFacet(), - * inheritAdditionalFacet(), etc. - * - * Revision 1.2 2001/09/19 18:48:27 peiyongz - * DTV reorganization:getLength() added, move inline to class declaration to avoid inline - * function interdependency. - * - * Revision 1.1 2001/09/18 14:45:04 peiyongz - * DTV reorganization - * - */ - -#if !defined(ABSTRACT_STRING_VALIDATOR_HPP) -#define ABSTRACT_STRING_VALIDATOR_HPP - -#include <validators/datatype/DatatypeValidator.hpp> - -class VALIDATORS_EXPORT AbstractStringValidator : public DatatypeValidator -{ -public: - - // ----------------------------------------------------------------------- - // Public ctor/dtor - // ----------------------------------------------------------------------- - /** @name Constructor. */ - //@{ - - virtual ~AbstractStringValidator(); - - //@} - - // ----------------------------------------------------------------------- - // Validation methods - // ----------------------------------------------------------------------- - /** @name Validation Function */ - //@{ - - /** - * validate that a string matches the boolean datatype - * @param content A string containing the content to be validated - * - * @exception throws InvalidDatatypeException if the content is - * is not valid. - */ - - virtual void validate(const XMLCh* const content); - - //@} - - // ----------------------------------------------------------------------- - // Compare methods - // ----------------------------------------------------------------------- - /** @name Compare Function */ - //@{ - - virtual int compare(const XMLCh* const, const XMLCh* const); - - //@} - -protected: - - AbstractStringValidator(DatatypeValidator* const baseValidator - , RefHashTableOf<KVStringPair>* const facets - , const int finalSet - , const ValidatorType type); - - void init(RefVectorOf<XMLCh>* const enums); - - // - // Abstract interface - // - virtual void assignAdditionalFacet(const XMLCh* const key - , const XMLCh* const value) = 0; - - virtual void inheritAdditionalFacet() = 0; - - virtual void checkAdditionalFacetConstraints() const = 0; - - virtual void checkAdditionalFacet(const XMLCh* const content) const = 0; - - virtual void checkValueSpace(const XMLCh* const content) = 0; - - virtual int getLength(const XMLCh* const content) const = 0; - - // - // to Allow ListDTV to overwrite - // - virtual void inspectFacetBase(); - - virtual void inheritFacet(); - - virtual void checkContent(const XMLCh* const content, bool asBase); - -// ----------------------------------------------------------------------- -// Getter methods -// ----------------------------------------------------------------------- - - inline unsigned int getLength() const; - - inline unsigned int getMaxLength() const; - - inline unsigned int getMinLength() const; - - inline RefVectorOf<XMLCh>* getEnumeration() const; - -// ----------------------------------------------------------------------- -// Setter methods -// ----------------------------------------------------------------------- - - inline void setLength(unsigned int); - - inline void setMaxLength(unsigned int); - - inline void setMinLength(unsigned int); - - inline void setEnumeration(RefVectorOf<XMLCh>*, bool); - -private: - - void assignFacet(); - - void inspectFacet(); - - // ----------------------------------------------------------------------- - // Private data members - // - // ----------------------------------------------------------------------- - unsigned int fLength; - unsigned int fMaxLength; - unsigned int fMinLength; - bool fEnumerationInherited; - RefVectorOf<XMLCh>* fEnumeration; -}; - -// ----------------------------------------------------------------------- -// Getter methods -// ----------------------------------------------------------------------- - -inline unsigned int AbstractStringValidator::getLength() const -{ - return fLength; -} - -inline unsigned int AbstractStringValidator::getMaxLength() const -{ - return fMaxLength; -} - -inline unsigned int AbstractStringValidator::getMinLength() const -{ - return fMinLength; -} - -inline RefVectorOf<XMLCh>* AbstractStringValidator:: getEnumeration() const -{ - return fEnumeration; -} - -// ----------------------------------------------------------------------- -// Setter methods -// ----------------------------------------------------------------------- - -inline void AbstractStringValidator::setLength(unsigned int newLength) -{ - fLength = newLength; -} - -inline void AbstractStringValidator::setMaxLength(unsigned int newMaxLength) -{ - fMaxLength = newMaxLength; -} - -inline void AbstractStringValidator::setMinLength(unsigned int newMinLength) -{ - fMinLength = newMinLength; -} - -inline void AbstractStringValidator::setEnumeration(RefVectorOf<XMLCh>* enums - , bool inherited) -{ - if (enums) - { - if ( !fEnumerationInherited && fEnumeration) - delete fEnumeration; - - fEnumeration = enums; - fEnumerationInherited = inherited; - setFacetsDefined(DatatypeValidator::FACET_ENUMERATION); - } -} - -/** - * End of file AbstractStringValidator.hpp - */ -#endif diff --git a/src/validators/datatype/AnySimpleTypeDatatypeValidator.cpp b/src/validators/datatype/AnySimpleTypeDatatypeValidator.cpp deleted file mode 100644 index 9d961a0aa1b173e148dcb82a9b7c9940cca3482f..0000000000000000000000000000000000000000 --- a/src/validators/datatype/AnySimpleTypeDatatypeValidator.cpp +++ /dev/null @@ -1,108 +0,0 @@ -/* - * 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$ - * Revision 1.1 2001/08/24 17:12:01 knoaman - * Add support for anySimpleType. - * Remove parameter 'baseValidator' from the virtual method 'newInstance'. - * - */ - - -// --------------------------------------------------------------------------- -// Includes -// --------------------------------------------------------------------------- -#include <validators/datatype/AnySimpleTypeDatatypeValidator.hpp> -#include <validators/schema/SchemaSymbols.hpp> -#include <util/RuntimeException.hpp> - - -// --------------------------------------------------------------------------- -// AnySimpleTypeDatatypeValidator: Constructors and Destructor -// --------------------------------------------------------------------------- -AnySimpleTypeDatatypeValidator::AnySimpleTypeDatatypeValidator() - : DatatypeValidator(0, 0, SchemaSymbols::RESTRICTION, DatatypeValidator::AnySimpleType) -{ - -} - -AnySimpleTypeDatatypeValidator::~AnySimpleTypeDatatypeValidator() -{ - -} - -// --------------------------------------------------------------------------- -// AnySimpleTypeDatatypeValidator: Instance methods -// --------------------------------------------------------------------------- -DatatypeValidator* -AnySimpleTypeDatatypeValidator::newInstance(RefHashTableOf<KVStringPair>* const facets, - RefVectorOf<XMLCh>* const enums, - const int finalSet) { - - // We own them, so we will delete them first - delete facets; - delete enums; - - ThrowXML(RuntimeException, XMLExcepts::DV_InvalidOperation); - - // to satisfy some compilers - return 0; -} -/** - * End of file AnySimpleTypeDatatypeValidator.cpp - */ - diff --git a/src/validators/datatype/AnySimpleTypeDatatypeValidator.hpp b/src/validators/datatype/AnySimpleTypeDatatypeValidator.hpp deleted file mode 100644 index 2f4d34c87103d42683771d9989c6e4c37f934cd4..0000000000000000000000000000000000000000 --- a/src/validators/datatype/AnySimpleTypeDatatypeValidator.hpp +++ /dev/null @@ -1,197 +0,0 @@ -/* - * 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$ - */ - -#if !defined(ANYSIMPLETYPEDATATYPEVALIDATOR_HPP) -#define ANYSIMPLETYPEDATATYPEVALIDATOR_HPP - -#include <validators/datatype/DatatypeValidator.hpp> - - -class VALIDATORS_EXPORT AnySimpleTypeDatatypeValidator : public DatatypeValidator -{ -public: - // ----------------------------------------------------------------------- - // Public Constructor - // ----------------------------------------------------------------------- - /** @name Constructor */ - //@{ - - AnySimpleTypeDatatypeValidator(); - - //@} - - // ----------------------------------------------------------------------- - // Public Destructor - // ----------------------------------------------------------------------- - /** @name Destructor. */ - //@{ - - virtual ~AnySimpleTypeDatatypeValidator(); - - //@} - - // ----------------------------------------------------------------------- - // Getter methods - // ----------------------------------------------------------------------- - /** @name Getter Functions */ - //@{ - - /** - * Returns default value (collapse) for whiteSpace facet. - * This function is overwritten in StringDatatypeValidator. - */ - short getWSFacet () const; - - //@} - - // ----------------------------------------------------------------------- - // Validation methods - // ----------------------------------------------------------------------- - /** @name Validation Function */ - //@{ - - /** - * Checks that the "content" string is valid datatype. - * If invalid, a Datatype validation exception is thrown. - * - * @param content A string containing the content to be validated - * - */ - void validate(const XMLCh* const content); - - /** - * Checks whether a given type can be used as a substitute - * - * @param toCheck A datatype validator of the type to be used as a - * substitute - * - */ - - bool isSubstitutableBy(const DatatypeValidator* const toCheck); - - //@} - - // ----------------------------------------------------------------------- - // Compare methods - // ----------------------------------------------------------------------- - /** @name Compare Function */ - //@{ - - /** - * Compares content in the Domain value vs. lexical value. - * - * @param value1 string to compare - * - * @param value2 string to compare - * - */ - int compare(const XMLCh* const value1, const XMLCh* const value2); - - //@} - - /** - * Returns an instance of the base datatype validator class - * Used by the DatatypeValidatorFactory. - */ - DatatypeValidator* newInstance(RefHashTableOf<KVStringPair>* const, - RefVectorOf<XMLCh>* const enums, - const int finalSet); -}; - - -// --------------------------------------------------------------------------- -// DatatypeValidator: Getters -// --------------------------------------------------------------------------- -inline short AnySimpleTypeDatatypeValidator::getWSFacet() const { - - return DatatypeValidator::PRESERVE; -} - - -// --------------------------------------------------------------------------- -// DatatypeValidators: Compare methods -// --------------------------------------------------------------------------- -inline int AnySimpleTypeDatatypeValidator::compare(const XMLCh* const lValue, - const XMLCh* const rValue) -{ - return -1; -} - -// --------------------------------------------------------------------------- -// DatatypeValidators: Validation methods -// --------------------------------------------------------------------------- -inline bool -AnySimpleTypeDatatypeValidator::isSubstitutableBy(const DatatypeValidator* const toCheck) -{ - return true; -} - -inline void -AnySimpleTypeDatatypeValidator::validate(const XMLCh* const content) -{ - return; -} - -#endif - -/** - * End of file AnySimpleTypeDatatypeValidator.hpp - */ - diff --git a/src/validators/datatype/AnyURIDatatypeValidator.cpp b/src/validators/datatype/AnyURIDatatypeValidator.cpp deleted file mode 100644 index f9a8b21cd11b4507704ef8cebc8adf9ac8f9ff30..0000000000000000000000000000000000000000 --- a/src/validators/datatype/AnyURIDatatypeValidator.cpp +++ /dev/null @@ -1,210 +0,0 @@ -/* - * 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.10 2001/10/10 14:18:26 peiyongz - * no message - * - * Revision 1.9 2001/10/09 20:53:58 peiyongz - * init(): take 1 arg. - * - * Revision 1.8 2001/10/02 18:59:29 peiyongz - * Invalid_Facet_Tag to display the tag name - * - * Revision 1.7 2001/09/24 15:33:15 peiyongz - * DTV Reorganization: virtual methods moved to *.cpp - * - * Revision 1.6 2001/09/19 18:49:17 peiyongz - * DTV reorganization: move inline to class declaration to avoid inline - * function interdependency. - * - * Revision 1.5 2001/09/18 20:38:03 peiyongz - * DTV reorganization: inherit from AbstractStringValidator. - * - * Revision 1.4 2001/08/21 18:42:53 peiyongz - * Bugzilla# 2816: cleanUp() declared with external linkage and called - * before defined as inline - * - * Revision 1.3 2001/08/14 22:11:56 peiyongz - * new exception message added - * - * Revision 1.2 2001/08/10 16:21:19 peiyongz - * use XMLUri instead of XMLURL - * - * Revision 1.1 2001/08/01 18:49:16 peiyongz - * AnyRUIDatatypeValidator - * - * - */ - -// --------------------------------------------------------------------------- -// Includes -// --------------------------------------------------------------------------- -#include <validators/datatype/AnyURIDatatypeValidator.hpp> -#include <validators/datatype/InvalidDatatypeFacetException.hpp> -#include <validators/datatype/InvalidDatatypeValueException.hpp> - -// -//http://www.template.com -// -static const XMLCh BASE_URI[] = -{ - chLatin_h, chLatin_t, chLatin_t, chLatin_p, - chColon, chForwardSlash, chForwardSlash, - chLatin_w, chLatin_w, chLatin_w, chPeriod, - chLatin_t, chLatin_e, chLatin_m, chLatin_p, chLatin_l, - chLatin_a, chLatin_t, chLatin_e, chPeriod, - chLatin_c, chLatin_o, chLatin_m, chNull -}; - -// --------------------------------------------------------------------------- -// Constructors and Destructor -// --------------------------------------------------------------------------- -AnyURIDatatypeValidator::AnyURIDatatypeValidator() -:AbstractStringValidator(0, 0, 0, DatatypeValidator::AnyURI) -,fTempURI(0) -{} - -AnyURIDatatypeValidator::~AnyURIDatatypeValidator() -{ - cleanUp(); -} - -AnyURIDatatypeValidator::AnyURIDatatypeValidator( - DatatypeValidator* const baseValidator - , RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet) -:AbstractStringValidator(baseValidator, facets, finalSet, DatatypeValidator::AnyURI) -,fTempURI(0) -{ - try - { - init(enums); - } - catch (...) - { - cleanUp(); - throw; - } -} - -DatatypeValidator* AnyURIDatatypeValidator::newInstance( - RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet) -{ - return (DatatypeValidator*) new AnyURIDatatypeValidator(this, facets, enums, finalSet); -} - -// --------------------------------------------------------------------------- -// Utilities -// --------------------------------------------------------------------------- - -void AnyURIDatatypeValidator::assignAdditionalFacet( const XMLCh* const key - , const XMLCh* const) -{ - ThrowXML1(InvalidDatatypeFacetException - , XMLExcepts::FACET_Invalid_Tag - , key); -} - -void AnyURIDatatypeValidator::inheritAdditionalFacet() -{} - -void AnyURIDatatypeValidator::checkAdditionalFacetConstraints() const -{} - -void AnyURIDatatypeValidator::checkAdditionalFacet(const XMLCh* const) const -{} - -int AnyURIDatatypeValidator::getLength(const XMLCh* const content) const -{ - return XMLString::stringLen(content); -} - -void AnyURIDatatypeValidator::checkValueSpace(const XMLCh* const content) -{ - - // check 3.2.17.c0 must: URI (rfc 2396/2723) - try - { - if (!fTempURI) - fTempURI = new XMLUri(BASE_URI); - - // Support for relative URLs - // According to Java 1.1: URLs may also be specified with a - // String and the URL object that it is related to. - // - if (XMLString::stringLen(content)) - { - XMLUri newURI(fTempURI, content ); - } - } - catch (...) - { - ThrowXML1(InvalidDatatypeValueException - , XMLExcepts::VALUE_URI_Malformed - , content); - } - -} - -/** - * End of file AnyURIDatatypeValidator.cpp - */ diff --git a/src/validators/datatype/AnyURIDatatypeValidator.hpp b/src/validators/datatype/AnyURIDatatypeValidator.hpp deleted file mode 100644 index 79f82741cc8f5cc232b5ca902ce1fb868e871efb..0000000000000000000000000000000000000000 --- a/src/validators/datatype/AnyURIDatatypeValidator.hpp +++ /dev/null @@ -1,168 +0,0 @@ -/* - * 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/>. - */ - -/* - * $Id$ - * $Log$ - * Revision 1.8 2001/11/22 20:23:20 peiyongz - * _declspec(dllimport) and inline warning C4273 - * - * Revision 1.7 2001/09/24 15:33:15 peiyongz - * DTV Reorganization: virtual methods moved to *.cpp - * - * Revision 1.6 2001/09/19 18:49:17 peiyongz - * DTV reorganization: move inline to class declaration to avoid inline - * function interdependency. - * - * Revision 1.5 2001/09/18 20:38:02 peiyongz - * DTV reorganization: inherit from AbstractStringValidator. - * - * Revision 1.4 2001/08/24 17:12:01 knoaman - * Add support for anySimpleType. - * Remove parameter 'baseValidator' from the virtual method 'newInstance'. - * - * Revision 1.3 2001/08/21 18:42:53 peiyongz - * Bugzilla# 2816: cleanUp() declared with external linkage and called - * before defined as inline - * - * Revision 1.2 2001/08/10 16:21:19 peiyongz - * use XMLUri instead of XMLURL - * - * Revision 1.1 2001/08/01 18:49:16 peiyongz - * AnyRUIDatatypeValidator - * - * - */ - -#if !defined(ANYURI_DATATYPEVALIDATOR_HPP) -#define ANYURI_DATATYPEVALIDATOR_HPP - -#include <validators/datatype/AbstractStringValidator.hpp> -#include <util/XMLUri.hpp> - -class VALIDATORS_EXPORT AnyURIDatatypeValidator : public AbstractStringValidator -{ -public: - - // ----------------------------------------------------------------------- - // Public ctor/dtor - // ----------------------------------------------------------------------- - /** @name Constructor. */ - //@{ - - AnyURIDatatypeValidator(); - - AnyURIDatatypeValidator(DatatypeValidator* const baseValidator - , RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet); - - virtual ~AnyURIDatatypeValidator(); - - //@} - - /** - * Returns an instance of the base datatype validator class - * Used by the DatatypeValidatorFactory. - */ - virtual DatatypeValidator* newInstance(RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet); - -protected: - - virtual void assignAdditionalFacet(const XMLCh* const key - , const XMLCh* const value); - - virtual void inheritAdditionalFacet(); - - virtual void checkAdditionalFacetConstraints() const; - - virtual void checkAdditionalFacet(const XMLCh* const content) const; - - virtual void checkValueSpace(const XMLCh* const content); - - virtual int getLength(const XMLCh* const content) const; - -private: - - inline void cleanUp(); - - // ----------------------------------------------------------------------- - // Private data members - // - // fTempURI - // to support relative URI, such as the urispec= "\sample" - // - // ----------------------------------------------------------------------- - - XMLUri *fTempURI; - -}; - -inline void AnyURIDatatypeValidator::cleanUp() -{ - if (fTempURI) - { - delete fTempURI; - fTempURI = 0; - } -} - -/** - * End of file AnyURIDatatypeValidator.hpp - */ -#endif diff --git a/src/validators/datatype/Base64BinaryDatatypeValidator.cpp b/src/validators/datatype/Base64BinaryDatatypeValidator.cpp deleted file mode 100644 index fc3f55606e06daefc8a2dc76c2874946beac3e9c..0000000000000000000000000000000000000000 --- a/src/validators/datatype/Base64BinaryDatatypeValidator.cpp +++ /dev/null @@ -1,171 +0,0 @@ -/* - * 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$ - * Revision 1.12 2001/10/09 20:47:26 peiyongz - * init(): take 1 arg - * - * Revision 1.11 2001/10/02 18:59:29 peiyongz - * Invalid_Facet_Tag to display the tag name - * - * Revision 1.10 2001/09/24 15:33:15 peiyongz - * DTV Reorganization: virtual methods moved to *.cpp - * - * Revision 1.9 2001/09/19 18:49:40 peiyongz - * DTV reorganization: inherit from AbstractStringVaildator - * - * Revision 1.8 2001/08/21 18:42:53 peiyongz - * Bugzilla# 2816: cleanUp() declared with external linkage and called - * before defined as inline - * - * Revision 1.7 2001/06/20 17:56:47 peiyongz - * support for "fixed" option on constrainning facets - * - * Revision 1.6 2001/05/29 19:49:31 tng - * Schema: Constraint Checking Fix in datatypeValidators. By Pei Yong Zhang. - * - * Revision 1.5 2001/05/28 21:11:17 tng - * Schema: Various DatatypeValidator fix. By Pei Yong Zhang - * - * Revision 1.4 2001/05/18 13:36:41 tng - * Schema: Catch RegularExpression exception and NumberFormatException - * - * Revision 1.3 2001/05/18 13:23:43 tng - * Schema: Exception messages in DatatypeValidator. By Pei Yong Zhang. - * - * Revision 1.2 2001/05/17 18:13:46 tng - * Schema Fix: issue error message when binary data is invalid. - * - * Revision 1.1 2001/05/16 15:24:40 tng - * Schema: Add Base64 and HexBin. By Pei Yong Zhang. - * - */ - -// --------------------------------------------------------------------------- -// Includes -// --------------------------------------------------------------------------- -#include <validators/datatype/Base64BinaryDatatypeValidator.hpp> -#include <validators/datatype/InvalidDatatypeFacetException.hpp> -#include <validators/datatype/InvalidDatatypeValueException.hpp> -#include <util/Base64.hpp> - -// --------------------------------------------------------------------------- -// Constructors and Destructor -// --------------------------------------------------------------------------- -Base64BinaryDatatypeValidator::Base64BinaryDatatypeValidator() -:AbstractStringValidator(0, 0, 0, DatatypeValidator::Base64Binary) -{} - -Base64BinaryDatatypeValidator::~Base64BinaryDatatypeValidator() -{} - -Base64BinaryDatatypeValidator::Base64BinaryDatatypeValidator( - DatatypeValidator* const baseValidator - , RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet) -:AbstractStringValidator(baseValidator, facets, finalSet, DatatypeValidator::Base64Binary) -{ - init(enums); -} - -DatatypeValidator* Base64BinaryDatatypeValidator::newInstance( - RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet) -{ - return (DatatypeValidator*) new Base64BinaryDatatypeValidator(this, facets, enums, finalSet); -} - -// --------------------------------------------------------------------------- -// Utilities -// --------------------------------------------------------------------------- -void Base64BinaryDatatypeValidator::assignAdditionalFacet( const XMLCh* const key - , const XMLCh* const) -{ - ThrowXML1(InvalidDatatypeFacetException - , XMLExcepts::FACET_Invalid_Tag - , key); -} - -void Base64BinaryDatatypeValidator::inheritAdditionalFacet() -{} - -void Base64BinaryDatatypeValidator::checkAdditionalFacetConstraints() const -{} - -void Base64BinaryDatatypeValidator::checkAdditionalFacet(const XMLCh* const) const -{} - -void Base64BinaryDatatypeValidator::checkValueSpace(const XMLCh* const content) -{ - if (getLength(content) <= 0) - { - ThrowXML1(InvalidDatatypeValueException - , XMLExcepts::VALUE_Not_Base64 - , content); - } -} - -int Base64BinaryDatatypeValidator::getLength(const XMLCh* const content) const -{ - return Base64::getDataLength(content); -} - -/** - * End of file Base64BinaryDatatypeValidator.cpp - */ diff --git a/src/validators/datatype/Base64BinaryDatatypeValidator.hpp b/src/validators/datatype/Base64BinaryDatatypeValidator.hpp deleted file mode 100644 index 641761f017cb11d068c4ec45da996bc9e28a6244..0000000000000000000000000000000000000000 --- a/src/validators/datatype/Base64BinaryDatatypeValidator.hpp +++ /dev/null @@ -1,130 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999-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/>. - */ - -/* - * $Id$ - * $Log$ - * Revision 1.6 2001/09/24 15:33:15 peiyongz - * DTV Reorganization: virtual methods moved to *.cpp - * - * Revision 1.5 2001/09/19 18:49:40 peiyongz - * DTV reorganization: inherit from AbstractStringVaildator - * - */ - -#if !defined(BASE64BINARY_DATATYPEVALIDATOR_HPP) -#define BASE64BINARY_DATATYPEVALIDATOR_HPP - -#include <validators/datatype/AbstractStringValidator.hpp> - -class VALIDATORS_EXPORT Base64BinaryDatatypeValidator : public AbstractStringValidator -{ -public: - - // ----------------------------------------------------------------------- - // Public ctor/dtor - // ----------------------------------------------------------------------- - /** @name Constructor. */ - //@{ - - Base64BinaryDatatypeValidator(); - - Base64BinaryDatatypeValidator(DatatypeValidator* const baseValidator - , RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet); - - virtual ~Base64BinaryDatatypeValidator(); - - //@} - - /** - * Returns an instance of the base datatype validator class - * Used by the DatatypeValidatorFactory. - */ - virtual DatatypeValidator* newInstance(RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet); - -protected: - - virtual void assignAdditionalFacet(const XMLCh* const key - , const XMLCh* const value); - - virtual void inheritAdditionalFacet(); - - virtual void checkAdditionalFacetConstraints() const; - - virtual void checkAdditionalFacet(const XMLCh* const content) const; - - virtual void checkValueSpace(const XMLCh* const content); - - virtual int getLength(const XMLCh* const content) const; - -private: - - // ----------------------------------------------------------------------- - // Private data members - // - // Nil - // ----------------------------------------------------------------------- - -}; - -/** - * End of file Base64BinaryDatatypeValidator.hpp - */ -#endif diff --git a/src/validators/datatype/BooleanDatatypeValidator.cpp b/src/validators/datatype/BooleanDatatypeValidator.cpp deleted file mode 100644 index 2dcb7654e618a38c5bb60c4909a3981840fcb099..0000000000000000000000000000000000000000 --- a/src/validators/datatype/BooleanDatatypeValidator.cpp +++ /dev/null @@ -1,225 +0,0 @@ -/* - * 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$ - * Revision 1.7 2001/10/02 18:59:29 peiyongz - * Invalid_Facet_Tag to display the tag name - * - * Revision 1.6 2001/06/22 16:26:01 peiyongz - * fix: redefinition of SIZE - * - * Revision 1.5 2001/05/29 19:49:33 tng - * Schema: Constraint Checking Fix in datatypeValidators. By Pei Yong Zhang. - * - * Revision 1.4 2001/05/28 21:11:17 tng - * Schema: Various DatatypeValidator fix. By Pei Yong Zhang - * - * Revision 1.3 2001/05/18 13:36:44 tng - * Schema: Catch RegularExpression exception and NumberFormatException - * - * Revision 1.2 2001/05/11 13:27:26 tng - * Copyright update. - * - * Revision 1.1 2001/05/09 18:43:35 tng - * Add StringDatatypeValidator and BooleanDatatypeValidator. By Pei Yong Zhang. - * - */ - -// --------------------------------------------------------------------------- -// Includes -// --------------------------------------------------------------------------- -#include <validators/datatype/BooleanDatatypeValidator.hpp> -#include <validators/schema/SchemaSymbols.hpp> -#include <validators/datatype/InvalidDatatypeFacetException.hpp> -#include <validators/datatype/InvalidDatatypeValueException.hpp> - -const int ARRAYSIZE = 4; -const XMLCh fgValueSpace[][32] = -{ - { chLatin_f, chLatin_a, chLatin_l, chLatin_s, chLatin_e, chNull }, - { chLatin_t, chLatin_r, chLatin_u, chLatin_e, chNull }, - { chDigit_0, chNull }, - { chDigit_1, chNull } -}; - -// --------------------------------------------------------------------------- -// Constructors and Destructor -// --------------------------------------------------------------------------- -BooleanDatatypeValidator::BooleanDatatypeValidator( - DatatypeValidator* const baseValidator - , RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet) -:DatatypeValidator(baseValidator, facets, finalSet, DatatypeValidator::Boolean) -{ - - // Set Facets if any defined - if ( facets ) - { - - // Boolean shall NOT have enumeration - if (enums) - ThrowXML1(InvalidDatatypeFacetException - , XMLExcepts::FACET_Invalid_Tag - , "enumeration"); - - 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); - setFacetsDefined(DatatypeValidator::FACET_PATTERN); - } - else - { - ThrowXML1(InvalidDatatypeFacetException - , XMLExcepts::FACET_Invalid_Tag - , key); - } - - } - - }// End of facet setting -} - -void BooleanDatatypeValidator::checkContent( const XMLCh* const content, bool asBase) -{ - - //validate against base validator if any - BooleanDatatypeValidator *pBaseValidator = (BooleanDatatypeValidator*) this->getBaseValidator(); - if (pBaseValidator !=0) - pBaseValidator->checkContent(content, true); - - // 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; - - int i = 0; - for ( ; i < ARRAYSIZE; i++ ) - { - if ( XMLString::compareString(content, fgValueSpace[i]) ==0 ) - break; - } - - if (i == ARRAYSIZE) - ThrowXML(InvalidDatatypeValueException, XMLExcepts::CM_UnaryOpHadBinType); - //Not valid boolean type - -} - -int BooleanDatatypeValidator::compare(const XMLCh* const lValue - , const XMLCh* const rValue) -{ - // need to check by bool semantics - // 1 == true - // 0 == false - - if (( XMLString::compareString(lValue, fgValueSpace[0]) ==0 ) || - ( XMLString::compareString(lValue, fgValueSpace[2]) ==0 ) ) - { - if (( XMLString::compareString(rValue, fgValueSpace[0]) ==0 ) || - ( XMLString::compareString(rValue, fgValueSpace[2]) ==0 ) ) - return 0; - } - else - if (( XMLString::compareString(lValue, fgValueSpace[1]) ==0 ) || - ( XMLString::compareString(lValue, fgValueSpace[3]) ==0 ) ) - { - if (( XMLString::compareString(rValue, fgValueSpace[1]) ==0 ) || - ( XMLString::compareString(rValue, fgValueSpace[3]) ==0 ) ) - return 0; - } - - return 1; -} - -/** - * End of file BooleanDatatypeValidator.cpp - */ - diff --git a/src/validators/datatype/BooleanDatatypeValidator.hpp b/src/validators/datatype/BooleanDatatypeValidator.hpp deleted file mode 100644 index c23dc5abe535b4dfec17168c512af6bb79c6f677..0000000000000000000000000000000000000000 --- a/src/validators/datatype/BooleanDatatypeValidator.hpp +++ /dev/null @@ -1,187 +0,0 @@ -/* - * 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$ - */ - -#if !defined(BOOLEAN_DATATYPEVALIDATOR_HPP) -#define BOOLEAN_DATATYPEVALIDATOR_HPP - -#include <validators/datatype/DatatypeValidator.hpp> - -class VALIDATORS_EXPORT BooleanDatatypeValidator : public DatatypeValidator -{ -public: - - // ----------------------------------------------------------------------- - // Public ctor/dtor - // ----------------------------------------------------------------------- - /** @name Constructor. */ - //@{ - - BooleanDatatypeValidator(); - - BooleanDatatypeValidator(DatatypeValidator* const baseValidator - , RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet); - - virtual ~BooleanDatatypeValidator(); - - //@} - - // ----------------------------------------------------------------------- - // 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(RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet); - -private: - - void checkContent(const XMLCh* const content, bool asBase); - - // ----------------------------------------------------------------------- - // Private data members - // - // ----------------------------------------------------------------------- - -}; - -// --------------------------------------------------------------------------- -// Constructors and Destructor -// --------------------------------------------------------------------------- -inline BooleanDatatypeValidator::BooleanDatatypeValidator() -:DatatypeValidator(0, 0, 0, DatatypeValidator::Boolean) -{ -} - -inline BooleanDatatypeValidator::~BooleanDatatypeValidator() -{ -} - -// ----------------------------------------------------------------------- -// Getter methods -// ----------------------------------------------------------------------- - - -// ----------------------------------------------------------------------- -// Compare methods -// ----------------------------------------------------------------------- - -inline DatatypeValidator* BooleanDatatypeValidator::newInstance( - RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet) -{ - return (DatatypeValidator*) new BooleanDatatypeValidator(this, facets, enums, finalSet); -} - -inline void BooleanDatatypeValidator::validate( const XMLCh* const content) -{ - checkContent(content, false); -} - -/** - * End of file BooleanDatatypeValidator.hpp - */ -#endif diff --git a/src/validators/datatype/DatatypeValidator.cpp b/src/validators/datatype/DatatypeValidator.cpp deleted file mode 100644 index 02517b0e1fc226e342a470e11d26fd4055a073aa..0000000000000000000000000000000000000000 --- a/src/validators/datatype/DatatypeValidator.cpp +++ /dev/null @@ -1,130 +0,0 @@ -/* - * 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$ - * Revision 1.7 2001/06/20 17:56:56 peiyongz - * support for "fixed" option on constrainning facets - * - * Revision 1.6 2001/05/11 21:51:09 knoaman - * Schema updates and fixes. - * - * Revision 1.5 2001/05/11 13:27:27 tng - * Copyright update. - * - * Revision 1.4 2001/05/09 18:43:38 tng - * Add StringDatatypeValidator and BooleanDatatypeValidator. By Pei Yong Zhang. - * - * Revision 1.3 2001/05/03 21:09:52 tng - * Schema: DatatypeValidator Update. By Pei Yong Zhang. - * - * Revision 1.2 2001/05/03 19:17:43 knoaman - * TraverseSchema Part II. - * - * Revision 1.1 2001/03/21 21:39:13 knoaman - * Schema symbols and Datatype validator part I - * - */ - - -// --------------------------------------------------------------------------- -// Includes -// --------------------------------------------------------------------------- -#include <validators/datatype/DatatypeValidator.hpp> -#include <validators/schema/SchemaSymbols.hpp> - -// --------------------------------------------------------------------------- -// DatatypeValidator: Constructors and Destructor -// --------------------------------------------------------------------------- -DatatypeValidator::DatatypeValidator(DatatypeValidator* const baseValidator, - RefHashTableOf<KVStringPair>* const facets, - const int finalSet, - const ValidatorType type) - : fFinalSet(finalSet) - , fFacetsDefined(0) - , fFixed(0) - , fType(type) - , fBaseValidator(baseValidator) - , fFacets(facets) - , fPattern(0) - , fRegex(0) -{ -} - -DatatypeValidator::~DatatypeValidator() -{ - cleanUp(); -} - -const XMLCh* DatatypeValidator::getWSstring(const short theType) const -{ - switch (theType) - { - case PRESERVE: - return SchemaSymbols::fgWS_PRESERVE; - case REPLACE: - return SchemaSymbols::fgWS_COLLAPSE; - case COLLAPSE: - return SchemaSymbols::fgWS_REPLACE; - default: - return SchemaSymbols::fgWS_PRESERVE; - } - -} -/** - * End of file DatatypeValidator.cpp - */ - diff --git a/src/validators/datatype/DatatypeValidator.hpp b/src/validators/datatype/DatatypeValidator.hpp deleted file mode 100644 index 1fbe416ece0e0472968aadfa451e1c91f9ddff33..0000000000000000000000000000000000000000 --- a/src/validators/datatype/DatatypeValidator.hpp +++ /dev/null @@ -1,494 +0,0 @@ -/* - * 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$ - */ - -#if !defined(DATATYPEVALIDATOR_HPP) -#define DATATYPEVALIDATOR_HPP - -#include <util/RefHashTableOf.hpp> -#include <util/KVStringPair.hpp> -#include <dom/DOMString.hpp> -#include <util/regx/RegularExpression.hpp> - -/** - * DataTypeValidator defines the interface that data type validators must - * obey. These validators can be supplied by the application writer and may - * be useful as standalone code as well as plugins to the validator - * architecture. - * - * Notice: - * The datatype validator will own the facets hashtable passed to it during - * construction, which means that the datatype validator will be responsible - * for the deletion. The facets hashtable will be created during parsing and - * passed to the appropriate datatype validator which in turn will delete it - * upon its destruction. - * - */ - - -class VALIDATORS_EXPORT DatatypeValidator -{ -public: - // ----------------------------------------------------------------------- - // Constant data - // ----------------------------------------------------------------------- - //facets - enum { - FACET_LENGTH = 1, - FACET_MINLENGTH = 1<<1, - FACET_MAXLENGTH = 1<<2, - FACET_PATTERN = 1<<3, - FACET_ENUMERATION = 1<<4, - FACET_MAXINCLUSIVE = 1<<5, - FACET_MAXEXCLUSIVE = 1<<6, - FACET_MININCLUSIVE = 1<<7, - FACET_MINEXCLUSIVE = 1<<8, - FACET_TOTALDIGITS = 1<<9, - FACET_FRACTIONDIGITS = 1<<10, - FACET_ENCODING = 1<<11, - FACET_DURATION = 1<<12, - FACET_PERIOD = 1<<13, - FACET_WHITESPACE = 1<<14 - }; - - //2.4.2.6 whiteSpace - Datatypes - enum { - PRESERVE = 0, - REPLACE = 1, - COLLAPSE = 2 - }; - - enum ValidatorType { - String, - AnyURI, - QName, - Name, - NCName, - Boolean, - Float, - Double, - Decimal, - HexBinary, - Base64Binary, - Duration, - DateTime, - Date, - Time, - MonthDay, - YearMonth, - Year, - Month, - Day, - ID, - IDREF, - ENTITY, - NOTATION, - List, - Union, - AnySimpleType - }; - - // ----------------------------------------------------------------------- - // Public Destructor - // ----------------------------------------------------------------------- - /** @name Destructor. */ - //@{ - - virtual ~DatatypeValidator(); - - //@} - - // ----------------------------------------------------------------------- - // Getter methods - // ----------------------------------------------------------------------- - /** @name Getter Functions */ - //@{ - - /** - * Returns the final values of the simpleType - */ - int getFinalSet() const; - - /** - * Returns the datatype facet if any is set. - */ - RefHashTableOf<KVStringPair>* getFacets() const; - - /** - * Returns default value (collapse) for whiteSpace facet. - * This function is overwritten in StringDatatypeValidator. - */ - virtual short getWSFacet () const; - - /** - * Returns the base datatype validator if set. - */ - DatatypeValidator* getBaseValidator() const; - - /** - * Returns the 'class' type of datatype validator - */ - ValidatorType getType() const; - - /** - * Returns whether the type is atomic or not - * - * To be redefined in List/Union validators - */ - virtual bool isAtomic() const; - - //@} - - // ----------------------------------------------------------------------- - // Validation methods - // ----------------------------------------------------------------------- - /** @name Validation Function */ - //@{ - - /** - * Checks that the "content" string is valid datatype. - * If invalid, a Datatype validation exception is thrown. - * - * @param content A string containing the content to be validated - * - */ - virtual void validate(const XMLCh* const content) = 0; - - /** - * Checks whether a given type can be used as a substitute - * - * @param toCheck A datatype validator of the type to be used as a - * substitute - * - * To be redefined in UnionDatatypeValidator - */ - - virtual bool isSubstitutableBy(const DatatypeValidator* const toCheck); - - //@} - - // ----------------------------------------------------------------------- - // Compare methods - // ----------------------------------------------------------------------- - /** @name Compare Function */ - //@{ - - /** - * Compares content in the Domain value vs. lexical value. - * - * e.g. If type is a float then 1.0 may be equivalent to 1 even though - * both are lexically different. - * - * @param value1 string to compare - * - * @param value2 string to compare - * - * We will provide a default behavior that should be redefined at the - * children level, if necessary (i.e. boolean case). - */ - virtual int compare(const XMLCh* const value1, const XMLCh* const value2); - - //@} - - /** - * Returns an instance of the base datatype validator class - * Used by the DatatypeValidatorFactory. - */ - virtual DatatypeValidator* newInstance(RefHashTableOf<KVStringPair>* const, - RefVectorOf<XMLCh>* const enums, - const int finalSet) = 0; - -protected: - // ----------------------------------------------------------------------- - // Protected Constructors - // ----------------------------------------------------------------------- - /** @name Constructors */ - //@{ - - /** - * - * @param baseValidator The base datatype validator for derived - * validators. Null if native validator. - * - * @param facets A hashtable of datatype facets (except enum). - * - * @param finalSet 'final' value of the simpleType - */ - - DatatypeValidator(DatatypeValidator* const baseValidator, - RefHashTableOf<KVStringPair>* const facets, - const int finalSet, - const ValidatorType type); - - //@} - - - friend class DatatypeValidatorFactory; - - /** - * facetDefined - */ - int getFacetsDefined() const; - void setFacetsDefined(int); - - /** - * fixed - */ - int getFixed() const; - void setFixed(int); - - - /** - * fPattern - */ - const XMLCh* getPattern() const; - void setPattern(const XMLCh* ); - - /** - * fRegex - */ - RegularExpression* getRegex() const; - void setRegex(RegularExpression* const); - - /** - * set fType - */ - void setType(ValidatorType); - - /** - * get WSString - */ - const XMLCh* getWSstring(const short WSType) const; - -private: - // ----------------------------------------------------------------------- - // CleanUp methods - // ----------------------------------------------------------------------- - void cleanUp(); - - // ----------------------------------------------------------------------- - // Private data members - // - // fFinalSet - // stores "final" values of simpleTypes - // - // fBaseValidator - // This is a pointer to a base datatype validator. If value is null, - // it means we have a native datatype validator not a derived one. - // - // fFacets - // This is a hashtable of dataype facets. - // - // fType - // Stores the class type of datatype validator - // - // fFacetsDefined - // Stores the constaiting facets flag - // - // fPattern - // the pointer to the String of the pattern. The actual data is - // in the Facets. - // - // fRegex - // pointer to the RegularExpress object - // - // - // fFixed - // if {fixed} is true, then types for which this type is the - // {base type definition} cannot specify a value for a specific - // facet. - // - // ----------------------------------------------------------------------- - - int fFinalSet; - int fFacetsDefined; - int fFixed; - ValidatorType fType; - DatatypeValidator* fBaseValidator; - RefHashTableOf<KVStringPair>* fFacets; - XMLCh* fPattern; - RegularExpression* fRegex; -}; - - -// --------------------------------------------------------------------------- -// DatatypeValidator: Getters -// --------------------------------------------------------------------------- -inline int DatatypeValidator::getFinalSet() const { - - return fFinalSet; -} - -inline RefHashTableOf<KVStringPair>* DatatypeValidator::getFacets() const { - - return fFacets; -} - -inline DatatypeValidator* DatatypeValidator::getBaseValidator() const { - - return fBaseValidator; -} - -inline short DatatypeValidator::getWSFacet() const { - - return COLLAPSE; -} - -inline DatatypeValidator::ValidatorType DatatypeValidator::getType() const -{ - return fType; -} - -inline void DatatypeValidator::setType(ValidatorType theType) -{ - fType = theType; -} - -// --------------------------------------------------------------------------- -// DatatypeValidator: CleanUp methods -// --------------------------------------------------------------------------- -inline void DatatypeValidator::cleanUp() { - - delete fFacets; - delete [] fPattern; - delete fRegex; -} - - -// --------------------------------------------------------------------------- -// DatatypeValidators: Compare methods -// --------------------------------------------------------------------------- -inline int DatatypeValidator::compare(const XMLCh* const lValue, - const XMLCh* const rValue) -{ - return XMLString::compareString(lValue, rValue); -} - -// --------------------------------------------------------------------------- -// DatatypeValidators: Validation methods -// --------------------------------------------------------------------------- -inline bool -DatatypeValidator::isSubstitutableBy(const DatatypeValidator* const toCheck) -{ - const DatatypeValidator* dv = toCheck; - - while (dv != 0) { - - if (dv == this) { - return true; - } - - dv = dv->getBaseValidator(); - } - - return false; -} - -inline int DatatypeValidator::getFacetsDefined() const -{ - return fFacetsDefined; -} - -inline void DatatypeValidator::setFacetsDefined(int facets) -{ - fFacetsDefined |= facets; -} - -inline int DatatypeValidator::getFixed() const -{ - return fFixed; -} - -inline void DatatypeValidator::setFixed(int fixed) -{ - fFixed |= fixed; -} - -inline const XMLCh* DatatypeValidator::getPattern() const -{ - return fPattern; -} - -inline void DatatypeValidator::setPattern(const XMLCh* pattern) -{ - delete [] fPattern; - fPattern = XMLString::replicate(pattern); -} - -inline RegularExpression* DatatypeValidator::getRegex() const -{ - return fRegex; -} - -inline void DatatypeValidator::setRegex(RegularExpression* const regex) -{ - fRegex = regex; -} - -inline bool DatatypeValidator::isAtomic() const { - - return true; -} - -#endif - -/** - * End of file DatatypeValidator.hpp - */ - diff --git a/src/validators/datatype/DatatypeValidatorFactory.cpp b/src/validators/datatype/DatatypeValidatorFactory.cpp deleted file mode 100644 index d0d453bb25df132093377770eaf7fd62321083a7..0000000000000000000000000000000000000000 --- a/src/validators/datatype/DatatypeValidatorFactory.cpp +++ /dev/null @@ -1,793 +0,0 @@ -/* - * 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$ - * Revision 1.26 2001/11/07 19:18:52 peiyongz - * DateTime Port - * - * Revision 1.25 2001/10/25 15:06:49 tng - * Thread safe the static instance. - * - * Revision 1.24 2001/10/23 23:14:22 peiyongz - * [Bug#880] patch to PlatformUtils:init()/term() and related. from Mark Weaver - * - * Revision 1.23 2001/09/25 16:00:03 peiyongz - * DTV Reorganization: Create native NameDTV and NCNameDTV - * - * Revision 1.22 2001/08/24 17:12:01 knoaman - * Add support for anySimpleType. - * Remove parameter 'baseValidator' from the virtual method 'newInstance'. - * - * Revision 1.21 2001/08/01 18:49:16 peiyongz - * AnyRUIDatatypeValidator - * - * Revision 1.20 2001/07/26 20:48:02 peiyongz - * FloatDatatypeValidator - * - * Revision 1.19 2001/07/24 21:23:39 tng - * Schema: Use DatatypeValidator for ID/IDREF/ENTITY/ENTITIES/NOTATION. - * - * Revision 1.18 2001/07/24 13:59:03 peiyongz - * DoubleDTV - * - * Revision 1.17 2001/07/19 17:46:42 tng - * Enable those derived dataype like nonPositiveinteger, negativeInteger ... etc. - * - * Revision 1.16 2001/07/13 14:10:33 peiyongz - * UnionDTV - * - * Revision 1.15 2001/07/11 21:37:18 peiyongz - * ListDatatypeDTV - * - * Revision 1.14 2001/07/06 20:21:58 peiyongz - * QNameDTV & ENTITYDTV enabled - * - * Revision 1.13 2001/07/05 20:15:25 peiyongz - * NOTATIONDatatypeValidator - * - * Revision 1.12 2001/07/04 20:16:31 peiyongz - * IDREFDatatypeValidator - * - * Revision 1.11 2001/07/04 14:38:24 peiyongz - * IDDatatypeValidator: created - * DatatypeValidatorFactory: IDDTV enabled - * XMLString:isValidName(): to validate Name (XML [4][5]) - * - * Revision 1.10 2001/05/28 21:11:17 tng - * Schema: Various DatatypeValidator fix. By Pei Yong Zhang - * - * Revision 1.9 2001/05/18 16:51:37 knoaman - * Added circular check for complexType + more error messages. - * - * Revision 1.8 2001/05/17 18:11:11 knoaman - * More constraint and attribute checking. - * - * Revision 1.7 2001/05/16 15:24:42 tng - * Schema: Add Base64 and HexBin. By Pei Yong Zhang. - * - * Revision 1.6 2001/05/15 21:59:19 knoaman - * TraverseSchema: add attribute checking + some fixes + more error messages. - * More attribute cheking to come. - * - * Revision 1.5 2001/05/11 21:51:13 knoaman - * Schema updates and fixes. - * - * Revision 1.4 2001/05/11 13:27:28 tng - * Copyright update. - * - * Revision 1.3 2001/05/09 18:43:40 tng - * Add StringDatatypeValidator and BooleanDatatypeValidator. By Pei Yong Zhang. - * - * Revision 1.2 2001/05/03 19:17:47 knoaman - * TraverseSchema Part II. - * - * Revision 1.1 2001/03/21 21:39:14 knoaman - * Schema symbols and Datatype validator part I - * - */ - - -// --------------------------------------------------------------------------- -// Includes -// --------------------------------------------------------------------------- -#include <validators/datatype/DatatypeValidatorFactory.hpp> -#include <validators/schema/SchemaSymbols.hpp> -#include <util/XMLUniDefs.hpp> -#include <util/Janitor.hpp> -#include <validators/datatype/StringDatatypeValidator.hpp> -#include <validators/datatype/BooleanDatatypeValidator.hpp> -#include <validators/datatype/DecimalDatatypeValidator.hpp> -#include <validators/datatype/HexBinaryDatatypeValidator.hpp> -#include <validators/datatype/Base64BinaryDatatypeValidator.hpp> -#include <validators/datatype/IDDatatypeValidator.hpp> -#include <validators/datatype/IDREFDatatypeValidator.hpp> -#include <validators/datatype/NOTATIONDatatypeValidator.hpp> -#include <validators/datatype/ENTITYDatatypeValidator.hpp> -#include <validators/datatype/QNameDatatypeValidator.hpp> -#include <validators/datatype/NameDatatypeValidator.hpp> -#include <validators/datatype/NCNameDatatypeValidator.hpp> -#include <validators/datatype/ListDatatypeValidator.hpp> -#include <validators/datatype/UnionDatatypeValidator.hpp> -#include <validators/datatype/DoubleDatatypeValidator.hpp> -#include <validators/datatype/FloatDatatypeValidator.hpp> -#include <validators/datatype/AnyURIDatatypeValidator.hpp> -#include <validators/datatype/AnySimpleTypeDatatypeValidator.hpp> -#include <validators/datatype/DateTimeDatatypeValidator.hpp> -#include <validators/datatype/DateDatatypeValidator.hpp> -#include <validators/datatype/TimeDatatypeValidator.hpp> -#include <validators/datatype/DayDatatypeValidator.hpp> -#include <validators/datatype/MonthDatatypeValidator.hpp> -#include <validators/datatype/MonthDayDatatypeValidator.hpp> -#include <validators/datatype/YearDatatypeValidator.hpp> -#include <validators/datatype/YearMonthDatatypeValidator.hpp> -#include <validators/datatype/DurationDatatypeValidator.hpp> -#include <util/PlatformUtils.hpp> -#include <util/XMLRegisterCleanup.hpp> - -// --------------------------------------------------------------------------- -// DatatypeValidatorFactory: Local const data -// --------------------------------------------------------------------------- -const XMLCh fgTokPattern[] = -{ - chBackSlash, chLatin_c, chPlus, chNull -}; - -//"([a-zA-Z]{2}|[iI]-[a-zA-Z]+|[xX]-[a-zA-Z]+)(-[a-zA-Z]+)*" -const XMLCh fgLangPattern[] = -{ - chOpenParen, chOpenSquare, chLatin_a, chDash, chLatin_z, chLatin_A, chDash, - chLatin_Z, chCloseSquare, chOpenCurly, chDigit_2, chCloseCurly, chPipe, - chOpenSquare, chLatin_i, chLatin_I, chCloseSquare, chDash, chOpenSquare, - chLatin_a, chDash, chLatin_z, chLatin_A, chDash, chLatin_Z, chCloseSquare, - chPlus, chPipe, chOpenSquare, chLatin_x, chLatin_X, chCloseSquare, chDash, - chOpenSquare, chLatin_a, chDash, chLatin_z, chLatin_A, chDash, chLatin_Z, - chCloseSquare, chPlus, chCloseParen, chOpenParen, chDash, chOpenSquare, - chLatin_a, chDash, chLatin_z, chLatin_A, chDash, chLatin_Z, chCloseSquare, - chPlus, chCloseParen, chAsterisk, chNull -}; - -//"\\i\\c*" -const XMLCh fgNamePattern[] = -{ - chBackSlash, chLatin_i, chBackSlash, chLatin_c, chAsterisk, chNull -}; - -//"[\\i-[:]][\\c-[:]]*" -const XMLCh fgNCNamePattern[] = -{ - chOpenSquare, chBackSlash, chLatin_i, chDash, chOpenSquare, chColon, chCloseSquare, - chCloseSquare, chOpenSquare, chBackSlash, chLatin_c, chDash, chOpenSquare, - chColon, chCloseSquare, chCloseSquare, chAsterisk, chNull -}; - -const XMLCh fgValueZero[] = -{ - chDigit_0, chNull -}; - -const XMLCh fgNegOne[] = -{ - chDash, chDigit_1, chNull -}; - -const XMLCh fgValueOne[] = -{ - chDigit_1, chNull -}; - -//"9223372036854775807" -const XMLCh fgLongMaxInc[] = -{ - chDigit_9, chDigit_2, chDigit_2, chDigit_3, chDigit_3, chDigit_7, chDigit_2, - chDigit_0, chDigit_3, chDigit_6, chDigit_8, chDigit_5, chDigit_4, chDigit_7, - chDigit_7, chDigit_5, chDigit_8, chDigit_0, chDigit_7, chNull -}; - -//"-9223372036854775808" -const XMLCh fgLongMinInc[] = -{ - chDash, chDigit_9, chDigit_2, chDigit_2, chDigit_3, chDigit_3, chDigit_7, - chDigit_2, chDigit_0, chDigit_3, chDigit_6, chDigit_8, chDigit_5, chDigit_4, - chDigit_7, chDigit_7, chDigit_5, chDigit_8, chDigit_0, chDigit_8, chNull -}; - -const XMLCh fgIntMaxInc[] = -{ - chDigit_2, chDigit_1, chDigit_4, chDigit_7, chDigit_4, chDigit_8, - chDigit_3, chDigit_6, chDigit_4, chDigit_7, chNull -}; - -const XMLCh fgIntMinInc[] = -{ - chDash, chDigit_2, chDigit_1, chDigit_4, chDigit_7, chDigit_4, - chDigit_8, chDigit_3, chDigit_6, chDigit_4, chDigit_8, chNull -}; - -const XMLCh fgShortMaxInc[] = -{ - chDigit_3, chDigit_2, chDigit_7, chDigit_6, chDigit_7, chNull -}; - -const XMLCh fgShortMinInc[] = -{ - chDash, chDigit_3, chDigit_2, chDigit_7, chDigit_6, chDigit_8, chNull -}; - -const XMLCh fgByteMaxInc[] = -{ - chDigit_1, chDigit_2, chDigit_7, chNull -}; - -const XMLCh fgByteMinInc[] = -{ - chDash, chDigit_1, chDigit_2, chDigit_8, chNull -}; - -const XMLCh fgULongMaxInc[] = -{ - chDigit_1, chDigit_8, chDigit_4, chDigit_4, chDigit_6, chDigit_7, chDigit_4, - chDigit_4, chDigit_0, chDigit_7, chDigit_3, chDigit_7, chDigit_0, chDigit_9, - chDigit_5, chDigit_5, chDigit_1, chDigit_6, chDigit_1, chDigit_5, chNull -}; - -const XMLCh fgUIntMaxInc[] = -{ - chDigit_4, chDigit_2, chDigit_9, chDigit_4, chDigit_9, chDigit_6, - chDigit_7, chDigit_2, chDigit_9, chDigit_5, chNull -}; - -const XMLCh fgUShortMaxInc[] = -{ - chDigit_6, chDigit_5, chDigit_5, chDigit_3, chDigit_5, chNull -}; - -const XMLCh fgUByteMaxInc[] = -{ - chDigit_2, chDigit_5, chDigit_5, chNull -}; - -const XMLCh fgP0Y[] = -{ - chLatin_P, chDigit_0, chLatin_Y, chNull -}; - -const XMLCh fgP1Y[] = -{ - chLatin_P, chDigit_1, chLatin_Y, chNull -}; - -const XMLCh fgP100Y[] = -{ - chLatin_P, chDigit_1, chDigit_0, chDigit_0, chLatin_Y, chNull -}; - -const XMLCh fgPT24H[] = -{ - chLatin_P, chLatin_T, chDigit_2, chDigit_4, chLatin_H, chNull -}; - -const XMLCh fgP1M[] = -{ - chLatin_P, chDigit_1, chLatin_M, chNull -}; - - -// --------------------------------------------------------------------------- -// DatatypeValidatorFactory: Static member data -// --------------------------------------------------------------------------- -RefHashTableOf<DatatypeValidator>* DatatypeValidatorFactory::fBuiltInRegistry = 0; -int DatatypeValidatorFactory::fRegistryExpanded = 0; - -// --------------------------------------------------------------------------- -// DatatypeValidatorFactory: Constructors and Destructor -// --------------------------------------------------------------------------- -DatatypeValidatorFactory::DatatypeValidatorFactory() - : fUserDefinedRegistry(0) -{ -} - -DatatypeValidatorFactory::~DatatypeValidatorFactory() -{ - cleanUp(); -} - - -// --------------------------------------------------------------------------- -// DatatypeValidatorFactory: Reset methods -// --------------------------------------------------------------------------- -void DatatypeValidatorFactory::resetRegistry() { - - if (fUserDefinedRegistry != 0) { - fUserDefinedRegistry->removeAll(); - } - -} - - -// ----------------------------------------------------------------------- -// Notification that lazy data has been deleted -// ----------------------------------------------------------------------- -void DatatypeValidatorFactory::reinitRegistry() { - delete fBuiltInRegistry; - fBuiltInRegistry = 0; - fRegistryExpanded = 0; -} - -// --------------------------------------------------------------------------- -// DatatypeValidatorFactory: Registry initialization methods -// --------------------------------------------------------------------------- -void DatatypeValidatorFactory::initializeDTDRegistry() -{ - if (fRegistryExpanded) - return; - - static XMLRegisterCleanup builtInRegistryCleanup; - - if (fBuiltInRegistry == 0) { - RefHashTableOf<DatatypeValidator>* t = new RefHashTableOf<DatatypeValidator>(109); - if (XMLPlatformUtils::compareAndSwap((void **)&fBuiltInRegistry, t, 0) != 0) - { - delete t; - } - else - { - builtInRegistryCleanup.registerCleanup(reinitRegistry); - } - - } - - fBuiltInRegistry->put((void*) SchemaSymbols::fgDT_STRING, - new StringDatatypeValidator()); - fBuiltInRegistry->put((void*) XMLUni::fgIDString, - new IDDatatypeValidator()); - fBuiltInRegistry->put((void*) XMLUni::fgIDRefString, - new IDREFDatatypeValidator()); - fBuiltInRegistry->put((void*) XMLUni::fgEntityString, - new ENTITYDatatypeValidator()); - fBuiltInRegistry->put((void*) XMLUni::fgNotationString, - new NOTATIONDatatypeValidator()); - - - // Create 'IDREFS' datatype validator - createDatatypeValidator(XMLUni::fgIDRefsString, - getDatatypeValidator(XMLUni::fgIDRefString), 0, 0, true, 0, false); - - // Create 'ENTITIES' datatype validator - createDatatypeValidator(XMLUni::fgEntitiesString, - getDatatypeValidator(XMLUni::fgEntityString), 0, 0, true, 0, false); - - RefHashTableOf<KVStringPair>* facets = new RefHashTableOf<KVStringPair>(2); - - facets->put((void*) SchemaSymbols::fgELT_PATTERN , - new KVStringPair(SchemaSymbols::fgELT_PATTERN,fgTokPattern)); - facets->put((void*) SchemaSymbols::fgELT_WHITESPACE, - new KVStringPair(SchemaSymbols::fgELT_WHITESPACE, SchemaSymbols::fgWS_COLLAPSE)); - - // Create 'NMTOKEN' datatype validator - createDatatypeValidator(XMLUni::fgNmTokenString, - getDatatypeValidator(SchemaSymbols::fgDT_STRING),facets, 0, false, 0, false); - - // Create 'NMTOKENS' datatype validator - createDatatypeValidator(XMLUni::fgNmTokensString, - getDatatypeValidator(XMLUni::fgNmTokenString), 0, 0, true, 0, false); - - fRegistryExpanded = 1; -} - - -void DatatypeValidatorFactory::expandRegistryToFullSchemaSet() -{ - if (fRegistryExpanded == 2) - return; - - // Initialize common Schema/DTD Datatype validator set if not initialized - if (fBuiltInRegistry == 0 - || fBuiltInRegistry->get(SchemaSymbols::fgDT_STRING) == 0) { - initializeDTDRegistry(); - } - - fBuiltInRegistry->put((void*) SchemaSymbols::fgDT_ANYSIMPLETYPE, - new AnySimpleTypeDatatypeValidator()); - fBuiltInRegistry->put((void*) SchemaSymbols::fgDT_BOOLEAN, - new BooleanDatatypeValidator()); - fBuiltInRegistry->put((void*) SchemaSymbols::fgDT_DECIMAL, - new DecimalDatatypeValidator()); - fBuiltInRegistry->put((void*) SchemaSymbols::fgDT_HEXBINARY, - new HexBinaryDatatypeValidator()); - fBuiltInRegistry->put((void*) SchemaSymbols::fgDT_BASE64BINARY, - new Base64BinaryDatatypeValidator()); - fBuiltInRegistry->put((void*) SchemaSymbols::fgDT_DOUBLE, - new DoubleDatatypeValidator()); - fBuiltInRegistry->put((void*) SchemaSymbols::fgDT_FLOAT, - new FloatDatatypeValidator()); - fBuiltInRegistry->put((void*) SchemaSymbols::fgDT_ANYURI, - new AnyURIDatatypeValidator()); - fBuiltInRegistry->put((void*) SchemaSymbols::fgDT_QNAME, - new QNameDatatypeValidator()); - fBuiltInRegistry->put((void*) SchemaSymbols::fgDT_NAME, - new NameDatatypeValidator()); - fBuiltInRegistry->put((void*) SchemaSymbols::fgDT_NCNAME, - new NCNameDatatypeValidator()); - - fBuiltInRegistry->put((void*) SchemaSymbols::fgDT_DATETIME, - new DateTimeDatatypeValidator()); - fBuiltInRegistry->put((void*) SchemaSymbols::fgDT_DATE, - new DateDatatypeValidator()); - fBuiltInRegistry->put((void*) SchemaSymbols::fgDT_TIME, - new TimeDatatypeValidator()); - fBuiltInRegistry->put((void*) SchemaSymbols::fgDT_DAY, - new DayDatatypeValidator()); - fBuiltInRegistry->put((void*) SchemaSymbols::fgDT_MONTH, - new MonthDatatypeValidator()); - fBuiltInRegistry->put((void*) SchemaSymbols::fgDT_MONTHDAY, - new MonthDayDatatypeValidator()); - fBuiltInRegistry->put((void*) SchemaSymbols::fgDT_YEAR, - new YearDatatypeValidator()); - fBuiltInRegistry->put((void*) SchemaSymbols::fgDT_YEARMONTH, - new YearMonthDatatypeValidator()); - fBuiltInRegistry->put((void*) SchemaSymbols::fgDT_DURATION, - new DurationDatatypeValidator()); - - // REVISIT - // We are creating a lot of Hashtables for the facets of the different - // validators. It's better to have some kind of a memory pool and ask - // the pool to give us a new instance of the hashtable. - - // Create 'normalizedString' datatype validator - RefHashTableOf<KVStringPair>* facets = new RefHashTableOf<KVStringPair>(3); - - facets->put((void*) SchemaSymbols::fgELT_WHITESPACE, - new KVStringPair(SchemaSymbols::fgELT_WHITESPACE, SchemaSymbols::fgWS_REPLACE)); - - createDatatypeValidator(SchemaSymbols::fgDT_NORMALIZEDSTRING, - getDatatypeValidator(SchemaSymbols::fgDT_STRING), - facets, 0, false, 0, false); - - // Create 'token' datatype validator - facets = new RefHashTableOf<KVStringPair>(3); - - facets->put((void*) SchemaSymbols::fgELT_WHITESPACE, - new KVStringPair(SchemaSymbols::fgELT_WHITESPACE, SchemaSymbols::fgWS_COLLAPSE)); - - createDatatypeValidator(SchemaSymbols::fgDT_TOKEN, - getDatatypeValidator(SchemaSymbols::fgDT_NORMALIZEDSTRING), - facets, 0, false, 0, false); - - // Create 'language' datatype validator - facets = new RefHashTableOf<KVStringPair>(3); - - facets->put((void*) SchemaSymbols::fgELT_PATTERN, - new KVStringPair(SchemaSymbols::fgELT_PATTERN, fgLangPattern)); - - createDatatypeValidator(SchemaSymbols::fgDT_LANGUAGE, - getDatatypeValidator(SchemaSymbols::fgDT_TOKEN), - facets, 0, false, 0, false); - - // Create 'Name' datatype validator - /*** - facets = new RefHashTableOf<KVStringPair>(3); - - facets->put((void*) SchemaSymbols::fgELT_PATTERN, - new KVStringPair(SchemaSymbols::fgELT_PATTERN, fgNamePattern)); - - createDatatypeValidator(SchemaSymbols::fgDT_NAME, - getDatatypeValidator(SchemaSymbols::fgDT_TOKEN), - facets, 0, false, 0, false); - - // Create a 'NCName' datatype validator - facets = new RefHashTableOf<KVStringPair>(3); - - facets->put((void*) SchemaSymbols::fgELT_PATTERN, - new KVStringPair(SchemaSymbols::fgELT_PATTERN, fgNCNamePattern)); - - createDatatypeValidator(SchemaSymbols::fgDT_NCNAME, - getDatatypeValidator(SchemaSymbols::fgDT_TOKEN), - facets, 0, false, 0, false); - ***/ - - // Create 'integer' datatype validator - facets = new RefHashTableOf<KVStringPair>(3); - - facets->put((void*) SchemaSymbols::fgELT_FRACTIONDIGITS, - new KVStringPair(SchemaSymbols::fgELT_FRACTIONDIGITS, fgValueZero)); - - createDatatypeValidator(SchemaSymbols::fgDT_INTEGER, - getDatatypeValidator(SchemaSymbols::fgDT_DECIMAL), - facets, 0, false, 0, false); - - // Create 'nonPositiveInteger' datatype validator - facets = new RefHashTableOf<KVStringPair>(2); - - facets->put((void*) SchemaSymbols::fgELT_MAXINCLUSIVE, - new KVStringPair(SchemaSymbols::fgELT_MAXINCLUSIVE, fgValueZero)); - - createDatatypeValidator(SchemaSymbols::fgDT_NONPOSITIVEINTEGER, - getDatatypeValidator(SchemaSymbols::fgDT_INTEGER), - facets, 0, false, 0, false); - - // Create 'negativeInteger' datatype validator - facets = new RefHashTableOf<KVStringPair>(2); - - facets->put((void*) SchemaSymbols::fgELT_MAXINCLUSIVE, - new KVStringPair(SchemaSymbols::fgELT_MAXINCLUSIVE,fgNegOne)); - - createDatatypeValidator(SchemaSymbols::fgDT_NEGATIVEINTEGER, - getDatatypeValidator(SchemaSymbols::fgDT_NONPOSITIVEINTEGER), - facets, 0, false, 0, false); - - // Create 'long' datatype validator - facets = new RefHashTableOf<KVStringPair>(2); - - facets->put((void*) SchemaSymbols::fgELT_MAXINCLUSIVE, - new KVStringPair(SchemaSymbols::fgELT_MAXINCLUSIVE,fgLongMaxInc)); - facets->put((void*) SchemaSymbols::fgELT_MININCLUSIVE, - new KVStringPair(SchemaSymbols::fgELT_MININCLUSIVE,fgLongMinInc)); - - createDatatypeValidator(SchemaSymbols::fgDT_LONG, - getDatatypeValidator(SchemaSymbols::fgDT_INTEGER), - facets, 0, false, 0, false); - - // Create 'int' datatype validator - facets = new RefHashTableOf<KVStringPair>(2); - - facets->put((void*) SchemaSymbols::fgELT_MAXINCLUSIVE, - new KVStringPair(SchemaSymbols::fgELT_MAXINCLUSIVE, fgIntMaxInc)); - facets->put((void*) SchemaSymbols::fgELT_MININCLUSIVE, - new KVStringPair(SchemaSymbols::fgELT_MININCLUSIVE, fgIntMinInc)); - - createDatatypeValidator(SchemaSymbols::fgDT_INT, - getDatatypeValidator(SchemaSymbols::fgDT_LONG), - facets, 0, false, 0, false); - - // Create 'short' datatype validator - facets = new RefHashTableOf<KVStringPair>(2); - - facets->put((void*) SchemaSymbols::fgELT_MAXINCLUSIVE, - new KVStringPair(SchemaSymbols::fgELT_MAXINCLUSIVE, fgShortMaxInc)); - facets->put((void*) SchemaSymbols::fgELT_MININCLUSIVE, - new KVStringPair(SchemaSymbols::fgELT_MININCLUSIVE, fgShortMinInc)); - - createDatatypeValidator(SchemaSymbols::fgDT_SHORT, - getDatatypeValidator(SchemaSymbols::fgDT_INT), - facets, 0, false, 0 ,false); - - // Create 'byte' datatype validator - facets = new RefHashTableOf<KVStringPair>(2); - - facets->put((void*) SchemaSymbols::fgELT_MAXINCLUSIVE, - new KVStringPair(SchemaSymbols::fgELT_MAXINCLUSIVE, fgByteMaxInc)); - facets->put((void*) SchemaSymbols::fgELT_MININCLUSIVE, - new KVStringPair(SchemaSymbols::fgELT_MININCLUSIVE, fgByteMinInc)); - - createDatatypeValidator(SchemaSymbols::fgDT_BYTE, - getDatatypeValidator(SchemaSymbols::fgDT_SHORT), - facets, 0, false, 0, false); - - // Create 'nonNegativeInteger' datatype validator - facets = new RefHashTableOf<KVStringPair>(2); - - facets->put((void*) SchemaSymbols::fgELT_MININCLUSIVE, - new KVStringPair(SchemaSymbols::fgELT_MININCLUSIVE, fgValueZero)); - - createDatatypeValidator(SchemaSymbols::fgDT_NONNEGATIVEINTEGER, - getDatatypeValidator(SchemaSymbols::fgDT_INTEGER), - facets, 0, false, 0, false); - - // Create 'unsignedLong' datatype validator - facets = new RefHashTableOf<KVStringPair>(2); - - facets->put((void*) SchemaSymbols::fgELT_MAXINCLUSIVE, - new KVStringPair(SchemaSymbols::fgELT_MAXINCLUSIVE, fgULongMaxInc)); - - createDatatypeValidator(SchemaSymbols::fgDT_ULONG, - getDatatypeValidator(SchemaSymbols::fgDT_NONNEGATIVEINTEGER), - facets, 0, false, 0, false); - - // Create 'unsignedInt' datatype validator - facets = new RefHashTableOf<KVStringPair>(2); - - facets->put((void*) SchemaSymbols::fgELT_MAXINCLUSIVE, - new KVStringPair(SchemaSymbols::fgELT_MAXINCLUSIVE, fgUIntMaxInc)); - - createDatatypeValidator(SchemaSymbols::fgDT_UINT, - getDatatypeValidator(SchemaSymbols::fgDT_ULONG), - facets, 0, false, 0, false); - - // Create 'unsignedShort' datatypeValidator - facets = new RefHashTableOf<KVStringPair>(2); - - facets->put((void*) SchemaSymbols::fgELT_MAXINCLUSIVE, - new KVStringPair(SchemaSymbols::fgELT_MAXINCLUSIVE, fgUShortMaxInc)); - - createDatatypeValidator(SchemaSymbols::fgDT_USHORT, - getDatatypeValidator(SchemaSymbols::fgDT_UINT), - facets, 0, false, 0, false); - - // Create 'unsignedByte' datatype validator - facets = new RefHashTableOf<KVStringPair>(2); - - facets->put((void*) SchemaSymbols::fgELT_MAXINCLUSIVE, - new KVStringPair(SchemaSymbols::fgELT_MAXINCLUSIVE, fgUByteMaxInc)); - - createDatatypeValidator(SchemaSymbols::fgDT_UBYTE, - getDatatypeValidator(SchemaSymbols::fgDT_USHORT), - facets, 0, false, 0, false); - - // Create 'positiveInteger' datatype validator - facets = new RefHashTableOf<KVStringPair>(2); - - facets->put((void*) SchemaSymbols::fgELT_MININCLUSIVE, - new KVStringPair(SchemaSymbols::fgELT_MININCLUSIVE, fgValueOne)); - - createDatatypeValidator(SchemaSymbols::fgDT_POSITIVEINTEGER, - getDatatypeValidator(SchemaSymbols::fgDT_NONNEGATIVEINTEGER), - facets, 0, false, 0, false); - - // REVISIT - Add the remaining datatype validators - // Create 'dateTime' datatype validator - - // Create 'date' datatype validator - - // Create 'gMonthDay' datatype validator - - // Create 'gYearMonth' datatype validator - - // Create 'gYear' datatype validator - - // Create 'gMonth' datatype validator - - fRegistryExpanded = 2; -} - -// --------------------------------------------------------------------------- -// DatatypeValidatorFactory: factory methods -// --------------------------------------------------------------------------- -DatatypeValidator* -DatatypeValidatorFactory::createDatatypeValidator(const XMLCh* const typeName, - DatatypeValidator* const baseValidator, - RefHashTableOf<KVStringPair>* const facets, - RefVectorOf<XMLCh>* const enums, - const bool derivedByList, - const int finalSet, - const bool userDefined) -{ - if (baseValidator == 0) { - - if (facets) { - Janitor<KVStringPairHashTable> janFacets(facets); - } - - if (enums) { - Janitor<XMLChRefVector> janEnums(enums); - } - - return 0; - } - - DatatypeValidator* datatypeValidator = 0; - - if (derivedByList) { - datatypeValidator = new ListDatatypeValidator(baseValidator, facets, enums, finalSet); - } - else { - - if ((baseValidator->getType() != DatatypeValidator::String) && facets) { - - KVStringPair* value = facets->get(SchemaSymbols::fgELT_WHITESPACE); - - if (value != 0) { - facets->removeKey(SchemaSymbols::fgELT_WHITESPACE); - } - } - - datatypeValidator = baseValidator->newInstance(facets, enums, finalSet); - } - - if (datatypeValidator != 0) { - - if (userDefined) { - - if (!fUserDefinedRegistry) { - fUserDefinedRegistry = new RefHashTableOf<DatatypeValidator>(29); - } - - fUserDefinedRegistry->put((void *)typeName, datatypeValidator); - } - else { - fBuiltInRegistry->put((void *)typeName, datatypeValidator); - } - } - - return datatypeValidator; -} - - -DatatypeValidator* -DatatypeValidatorFactory::createDatatypeValidator(const XMLCh* const typeName, - RefVectorOf<DatatypeValidator>* const validators, - const int finalSet, - const bool userDefined) -{ - if (validators == 0) - return 0; - - DatatypeValidator* datatypeValidator = 0; - - datatypeValidator = new UnionDatatypeValidator(validators, finalSet); - - if (datatypeValidator != 0) { - - if (userDefined) { - - if (!fUserDefinedRegistry) { - fUserDefinedRegistry = new RefHashTableOf<DatatypeValidator>(29); - } - - fUserDefinedRegistry->put((void *)typeName, datatypeValidator); - } - else { - fBuiltInRegistry->put((void *)typeName, datatypeValidator); - } - } - - return datatypeValidator; -} - -/** - * End of file DatatypeValidatorFactory.cpp - */ - diff --git a/src/validators/datatype/DatatypeValidatorFactory.hpp b/src/validators/datatype/DatatypeValidatorFactory.hpp deleted file mode 100644 index 7827435473aa1634836eae8a06edff19e74f33dc..0000000000000000000000000000000000000000 --- a/src/validators/datatype/DatatypeValidatorFactory.hpp +++ /dev/null @@ -1,284 +0,0 @@ -/* - * 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$ - */ - -#if !defined(DATATYPEVALIDATORFACTORY_HPP) -#define DATATYPEVALIDATORFACTORY_HPP - -/** - * This class implements a factory of Datatype Validators. Internally the - * DatatypeValidators are kept in a registry. - * There is one instance of DatatypeValidatorFactory per Parser. - * There is one datatype Registry per instance of DatatypeValidatorFactory, - * such registry is first allocated with the number DatatypeValidators needed. - * e.g. - * If Parser finds an XML document with a DTD, a registry of DTD validators (only - * 9 validators) get initialized in the registry. - * The initialization process consist of instantiating the Datatype and - * facets and registering the Datatype into registry table. - * This implementation uses a Hahtable as a registry. The datatype validators created - * by the factory will be deleted by the registry. - * - * As the Parser parses an instance document it knows if validation needs - * to be checked. If no validation is necesary we should not instantiate a - * DatatypeValidatorFactory. - * If validation is needed, we need to instantiate a DatatypeValidatorFactory. - */ - -// --------------------------------------------------------------------------- -// Includes -// --------------------------------------------------------------------------- -#include <validators/datatype/DatatypeValidator.hpp> -#include <util/RefVectorOf.hpp> - -// --------------------------------------------------------------------------- -// DatatypeValidatorFactory: Local declaration -// --------------------------------------------------------------------------- -typedef RefHashTableOf<KVStringPair> KVStringPairHashTable; -typedef RefHashTableOf<DatatypeValidator> DVHashTable; -typedef RefVectorOf<XMLCh> XMLChRefVector; - - -class VALIDATORS_EXPORT DatatypeValidatorFactory -{ -public: - - // ----------------------------------------------------------------------- - // Public Constructors and Destructor - // ----------------------------------------------------------------------- - /** @name Constructors */ - //@{ - - DatatypeValidatorFactory(); - - //@} - - /** @name Destructor. */ - //@{ - - ~DatatypeValidatorFactory(); - - //@} - - // ----------------------------------------------------------------------- - // Getter methods - // ----------------------------------------------------------------------- - /** @name Getter Functions */ - //@{ - - /** - * Returns the datatype validator - * - * @param dvType Datatype validator name/type - */ - DatatypeValidator* getDatatypeValidator(const XMLCh* const dvType) const; - - //@} - - // ----------------------------------------------------------------------- - // Registry Initialization methods - // ----------------------------------------------------------------------- - /** @name Registry Initialization Functions */ - //@{ - - /** - * Initializes registry with primitive and derived Simple types. - * - * This method does not clear the registry to clear the registry you - * have to call resetRegistry. - * - * The net effect of this method is to start with a the smallest set of - * datatypes needed by the validator. - * - * If we start with DTD's, then we initialize the table to only - * the 9 validators needed by DTD Validation. - */ - void initializeDTDRegistry(); - - /** - * Initializes registry with primitive and derived Simple types. - * - * This method does not clear the registry to clear the registry you - * have to call resetRegistry. - * - * The net effect of this method is to start with a the smallest set of - * datatypes needed by the validator. - * - * If we start with Schema's then we initialize to to full set of - * validators. - */ - void expandRegistryToFullSchemaSet(); - - //@} - - // ----------------------------------------------------------------------- - // Validator Factory methods - // ----------------------------------------------------------------------- - /** @name Validator Factory Functions */ - //@{ - - /** - * Creates a new datatype validator of type baseValidator's class and - * adds it to the registry - * - * @param typeName Datatype validator name - * - * @param baseValidator Base datatype validator - * - * @param facets datatype facets if any - * - * @param enums vector of values for enum facet - * - * @param derivedByList Indicates whether the datatype is derived by - * list or not - * - * @param finalSet 'final' values of the simpleType - */ - DatatypeValidator* createDatatypeValidator(const XMLCh* const, - DatatypeValidator* const, - RefHashTableOf<KVStringPair>* const, - RefVectorOf<XMLCh>* const enums, - const bool, - const int = 0, - const bool = true); - - /** - * Creates a new datatype validator of type UnionDatatypeValidator and - * adds it to the registry - * - * @param typeName Datatype validator name - * - * @param validators Vector of datatype validators - * - */ - DatatypeValidator* createDatatypeValidator(const XMLCh* const, - RefVectorOf<DatatypeValidator>* const, - const int finalSet, - const bool = true); - - //@} - - /** - * Reset datatype validator registry - */ - void resetRegistry(); - - // ----------------------------------------------------------------------- - // Notification that lazy data has been deleted - // ----------------------------------------------------------------------- - static void reinitRegistry(); - -private: - // ----------------------------------------------------------------------- - // CleanUp methods - // ----------------------------------------------------------------------- - void cleanUp(); - - // ----------------------------------------------------------------------- - // Private data members - // - // fRegistryExpanded - // Indicated whether we have expanded the registry or not. - // - // fUserDefinedRegistry - // This is a hashtable of user defined dataype validators. - // - // fBuiltInRegistry - // This is a hashtable of built-in primitive datatype validators. - // ----------------------------------------------------------------------- - RefHashTableOf<DatatypeValidator>* fUserDefinedRegistry; - static int fRegistryExpanded; - static RefHashTableOf<DatatypeValidator>* fBuiltInRegistry; -}; - - -// --------------------------------------------------------------------------- -// DatatypeValidatorFactory: Getters -// --------------------------------------------------------------------------- -inline DatatypeValidator* -DatatypeValidatorFactory::getDatatypeValidator(const XMLCh* const dvType) const -{ - if (dvType) { - - if (fBuiltInRegistry && fBuiltInRegistry->containsKey(dvType)) { - return fBuiltInRegistry->get(dvType); - } - - if (fUserDefinedRegistry && fUserDefinedRegistry->containsKey(dvType)) { - return fUserDefinedRegistry->get(dvType); - } - } - - return 0; -} - -// --------------------------------------------------------------------------- -// DatatypeValidator: CleanUp methods -// --------------------------------------------------------------------------- -inline void DatatypeValidatorFactory::cleanUp() { - - delete fUserDefinedRegistry; -} - -#endif - -/** - * End of file DatatypeValidatorFactory.hpp - */ - diff --git a/src/validators/datatype/DateDatatypeValidator.cpp b/src/validators/datatype/DateDatatypeValidator.cpp deleted file mode 100644 index 86d876efd53ea77eab79e7949f7770337ff13a9f..0000000000000000000000000000000000000000 --- a/src/validators/datatype/DateDatatypeValidator.cpp +++ /dev/null @@ -1,127 +0,0 @@ -/* - * 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.3 2001/11/15 17:09:23 peiyongz - * catch(...) only. (the invoker need to cath XMLException to display proper message) - * - * Revision 1.2 2001/11/14 22:02:25 peiyongz - * rethrow exception with original error message. - * - * Revision 1.1 2001/11/07 19:18:52 peiyongz - * DateTime Port - * - */ - -// --------------------------------------------------------------------------- -// Includes -// --------------------------------------------------------------------------- -#include <validators/datatype/DateDatatypeValidator.hpp> - -// --------------------------------------------------------------------------- -// Constructors and Destructor -// --------------------------------------------------------------------------- -DateDatatypeValidator::DateDatatypeValidator() -:DateTimeValidator(0, 0, 0, DatatypeValidator::Date) -{} - -DateDatatypeValidator::DateDatatypeValidator( - DatatypeValidator* const baseValidator - , RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet) -:DateTimeValidator(baseValidator, facets, finalSet, DatatypeValidator::Date) -{ - init(enums); -} - -DateDatatypeValidator::~DateDatatypeValidator() -{} - -DatatypeValidator* DateDatatypeValidator::newInstance( - RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet) -{ - return (DatatypeValidator*) new DateDatatypeValidator(this, facets, enums, finalSet); -} - -// -// caller need to release the date created here -// -XMLDateTime* DateDatatypeValidator::parse(const XMLCh* const content) -{ - XMLDateTime *pRetDate = new XMLDateTime(content); - - try - { - pRetDate->parseDate(); - } - catch (...) - { - delete pRetDate; - throw; - } - - return pRetDate; -} - -/** - * End of file DateDatatypeValidator::cpp - */ - diff --git a/src/validators/datatype/DateDatatypeValidator.hpp b/src/validators/datatype/DateDatatypeValidator.hpp deleted file mode 100644 index 21cd96c0d3f44b6641310131e73d26f16832b7bd..0000000000000000000000000000000000000000 --- a/src/validators/datatype/DateDatatypeValidator.hpp +++ /dev/null @@ -1,112 +0,0 @@ -/* - * 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/11/07 19:18:52 peiyongz - * DateTime Port - * - */ - -#if !defined(DATE_DATATYPE_VALIDATOR_HPP) -#define DATE_DATATYPE_VALIDATOR_HPP - -#include <validators/datatype/DateTimeValidator.hpp> - -class VALIDATORS_EXPORT DateDatatypeValidator : public DateTimeValidator -{ -public: - - // ----------------------------------------------------------------------- - // Public ctor/dtor - // ----------------------------------------------------------------------- - /** @name Constructor. */ - //@{ - - DateDatatypeValidator(); - - DateDatatypeValidator(DatatypeValidator* const baseValidator - , RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet); - - ~DateDatatypeValidator(); - - - //@} - - /** - * Returns an instance of the base datatype validator class - * Used by the DatatypeValidatorFactory. - */ - virtual DatatypeValidator* newInstance(RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet); - -protected: - - // ----------------------------------------------------------------------- - // implementation of (DateTimeValidator's) virtual interface - // ----------------------------------------------------------------------- - virtual XMLDateTime* parse(const XMLCh* const); -}; - -/** - * End of file DateDatatypeValidator.hpp - */ -#endif - diff --git a/src/validators/datatype/DateTimeDatatypeValidator.cpp b/src/validators/datatype/DateTimeDatatypeValidator.cpp deleted file mode 100644 index a898bc7dce0a026519ad1dcc1398e3cffbade413..0000000000000000000000000000000000000000 --- a/src/validators/datatype/DateTimeDatatypeValidator.cpp +++ /dev/null @@ -1,127 +0,0 @@ -/* - * 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.3 2001/11/15 17:09:23 peiyongz - * catch(...) only. (the invoker need to cath XMLException to display proper message) - * - * Revision 1.2 2001/11/14 22:02:25 peiyongz - * rethrow exception with original error message. - * - * Revision 1.1 2001/11/07 19:18:52 peiyongz - * DateTime Port - * - */ - -// --------------------------------------------------------------------------- -// Includes -// --------------------------------------------------------------------------- -#include <validators/datatype/DateTimeDatatypeValidator.hpp> - -// --------------------------------------------------------------------------- -// Constructors and Destructor -// --------------------------------------------------------------------------- -DateTimeDatatypeValidator::DateTimeDatatypeValidator() -:DateTimeValidator(0, 0, 0, DatatypeValidator::DateTime) -{} - -DateTimeDatatypeValidator::DateTimeDatatypeValidator( - DatatypeValidator* const baseValidator - , RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet) -:DateTimeValidator(baseValidator, facets, finalSet, DatatypeValidator::DateTime) -{ - init(enums); -} - -DateTimeDatatypeValidator::~DateTimeDatatypeValidator() -{} - -DatatypeValidator* DateTimeDatatypeValidator::newInstance( - RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet) -{ - return (DatatypeValidator*) new DateTimeDatatypeValidator(this, facets, enums, finalSet); -} - -// -// caller need to release the date created here -// -XMLDateTime* DateTimeDatatypeValidator::parse(const XMLCh* const content) -{ - XMLDateTime *pRetDate = new XMLDateTime(content); - - try - { - pRetDate->parseDateTime(); - } - catch (...) - { - delete pRetDate; - throw; - } - - return pRetDate; -} - -/** - * End of file DateTimeDatatypeValidator::cpp - */ - diff --git a/src/validators/datatype/DateTimeDatatypeValidator.hpp b/src/validators/datatype/DateTimeDatatypeValidator.hpp deleted file mode 100644 index d8295ffd423f8783965ddbfd95bb1ffbbe0be49f..0000000000000000000000000000000000000000 --- a/src/validators/datatype/DateTimeDatatypeValidator.hpp +++ /dev/null @@ -1,112 +0,0 @@ -/* - * 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/11/07 19:18:52 peiyongz - * DateTime Port - * - */ - -#if !defined(DATETIME_DATATYPE_VALIDATOR_HPP) -#define DATETIME_DATATYPE_VALIDATOR_HPP - -#include <validators/datatype/DateTimeValidator.hpp> - -class VALIDATORS_EXPORT DateTimeDatatypeValidator : public DateTimeValidator -{ -public: - - // ----------------------------------------------------------------------- - // Public ctor/dtor - // ----------------------------------------------------------------------- - /** @name Constructor. */ - //@{ - - DateTimeDatatypeValidator(); - - DateTimeDatatypeValidator(DatatypeValidator* const baseValidator - , RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet); - - ~DateTimeDatatypeValidator(); - - - //@} - - /** - * Returns an instance of the base datatype validator class - * Used by the DatatypeValidatorFactory. - */ - virtual DatatypeValidator* newInstance(RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet); - -protected: - - // ----------------------------------------------------------------------- - // implementation of (DateTimeValidator's) virtual interface - // ----------------------------------------------------------------------- - virtual XMLDateTime* parse(const XMLCh* const); -}; - -/** - * End of file DateTimeDatatypeValidator.hpp - */ -#endif - diff --git a/src/validators/datatype/DateTimeValidator.cpp b/src/validators/datatype/DateTimeValidator.cpp deleted file mode 100644 index 896f9f64248a94c54986d9c10cbdb183d497836f..0000000000000000000000000000000000000000 --- a/src/validators/datatype/DateTimeValidator.cpp +++ /dev/null @@ -1,351 +0,0 @@ -/* - * 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.2 2001/11/12 20:37:57 peiyongz - * SchemaDateTimeException defined - * - * Revision 1.1 2001/11/07 19:18:52 peiyongz - * DateTime Port - * - */ - -// --------------------------------------------------------------------------- -// Includes -// --------------------------------------------------------------------------- -#include <validators/datatype/DateTimeValidator.hpp> -#include <validators/datatype/InvalidDatatypeFacetException.hpp> -#include <validators/datatype/InvalidDatatypeValueException.hpp> -#include <validators/schema/SchemaSymbols.hpp> - -static const int BUF_LEN = 64; -static XMLCh value1[BUF_LEN+1]; -static XMLCh value2[BUF_LEN+1]; - -// --------------------------------------------------------------------------- -// Macro -// --------------------------------------------------------------------------- -#define REPORT_VALUE_ERROR(val1, val2, except_code) \ - XMLCh* value1 = (val1)->toString(); \ - ArrayJanitor<XMLCh> jan1(value1); \ - XMLCh* value2 = (val2)->toString(); \ - ArrayJanitor<XMLCh> jan2(value2); \ - ThrowXML2(InvalidDatatypeValueException \ - , except_code \ - , value1 \ - , value2); - -// --------------------------------------------------------------------------- -// Constructors and Destructor -// --------------------------------------------------------------------------- -DateTimeValidator::~DateTimeValidator() -{} - -DateTimeValidator::DateTimeValidator( - DatatypeValidator* const baseValidator - , RefHashTableOf<KVStringPair>* const facets - , const int finalSet - , const ValidatorType type) -:AbstractNumericFacetValidator(baseValidator, facets, finalSet, type) -{ - //do not invoke init() here !!! -} - -void DateTimeValidator::validate(const XMLCh* const content) -{ - checkContent(content, false); -} - -int DateTimeValidator::compare(const XMLCh* const value1 - , const XMLCh* const value2) -{ - try - { - XMLDateTime *pDate1 = parse(value1); - Janitor<XMLDateTime> jName1(pDate1); - XMLDateTime *pDate2 = parse(value2); - Janitor<XMLDateTime> jName2(pDate2); - int result = compareDates(pDate1, pDate2, true); - return (result==INDETERMINATE)? -1 : result; - } - catch (...) // RuntimeException e - { - return -1; // revisit after implement compareDates() - } - -} - -void DateTimeValidator::assignAdditionalFacet( const XMLCh* const key - , const XMLCh* const) -{ - ThrowXML1(InvalidDatatypeFacetException - , XMLExcepts::FACET_Invalid_Tag - , key); -} - -void DateTimeValidator::inheritAdditionalFacet() -{} - -void DateTimeValidator::checkAdditionalFacetConstraints() const -{} - -void DateTimeValidator::checkAdditionalFacetConstraintsBase() const -{} - -void DateTimeValidator::checkContent(const XMLCh* const content - , bool asBase) -{ - - //validate against base validator if any - DateTimeValidator *pBaseValidator = (DateTimeValidator*) this->getBaseValidator(); - if (pBaseValidator) - pBaseValidator->checkContent(content, true); - - int thisFacetsDefined = getFacetsDefined(); - - // we check pattern first - if ( (thisFacetsDefined & 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; - - try - { - // the derived classes' parse() method constructs an - // XMLDateTime object anc invokes appropriate XMLDateTime's - // parser to parse the content. - XMLDateTime *theDate = parse(content); - Janitor<XMLDateTime> jname(theDate); - - int result; - - // must be < MaxExclusive - if ( (thisFacetsDefined & DatatypeValidator::FACET_MAXEXCLUSIVE) != 0 ) - { - result = compareValues(theDate, getMaxExclusive()); - if ( result != XMLDateTime::LESS_THAN ) - { - REPORT_VALUE_ERROR(theDate - , getMaxExclusive() - , XMLExcepts::VALUE_exceed_maxExcl) - } - } - - // must be <= MaxInclusive - if ( (thisFacetsDefined & DatatypeValidator::FACET_MAXINCLUSIVE) != 0 ) - { - result = compareValues(theDate, getMaxInclusive()); - if ( result == XMLDateTime::GREATER_THAN || result == XMLDateTime::INDETERMINATE ) - { - REPORT_VALUE_ERROR(theDate - , getMaxInclusive() - , XMLExcepts::VALUE_exceed_maxIncl) - } - } - - // must be >= MinInclusive - if ( (thisFacetsDefined & DatatypeValidator::FACET_MININCLUSIVE) != 0 ) - { - result = compareValues(theDate, getMinInclusive()); - if (result == XMLDateTime::LESS_THAN || result == XMLDateTime::INDETERMINATE ) - { - REPORT_VALUE_ERROR(theDate - , getMinInclusive() - , XMLExcepts::VALUE_exceed_minIncl) - } - } - - // must be > MinExclusive - if ( (thisFacetsDefined & DatatypeValidator::FACET_MINEXCLUSIVE) != 0 ) - { - result = compareValues(theDate, getMinExclusive()); - if (result != XMLDateTime::GREATER_THAN) - { - REPORT_VALUE_ERROR(theDate - , getMinExclusive() - , XMLExcepts::VALUE_exceed_minExcl) - } - } - - if ((thisFacetsDefined & DatatypeValidator::FACET_ENUMERATION) != 0 && - (getEnumeration() != 0)) - { - int i=0; - int enumLength = getEnumeration()->size(); - for ( ; i < enumLength; i++) - { - if (compareValues(theDate, getEnumeration()->elementAt(i)) == XMLDateTime::EQUAL) - break; - } - - if (i == enumLength) - ThrowXML1(InvalidDatatypeValueException, XMLExcepts::VALUE_NotIn_Enumeration, content); - } - } - catch (...) - { - ThrowXML1(InvalidDatatypeValueException, XMLExcepts::VALUE_NotIn_Enumeration, content); - // new error message needed here - //("Value '"+content+ "' is not legal value for current datatype. " +e.getMessage() ); - } - -} - -// -// Comparision methods -// -int DateTimeValidator::compareValues(const XMLNumber* const lValue - , const XMLNumber* const rValue) -{ - return compareDates((XMLDateTime*) lValue, (XMLDateTime*) rValue, true); -} - -/** - * Compare algorithm described in dateDime (3.2.7). - * Duration datatype overwrites this method - * - * @param date1 normalized date representation of the first value - * @param date2 normalized date representation of the second value - * @param strict - * @return less, greater, less_equal, greater_equal, equal - */ -int DateTimeValidator::compareDates(const XMLDateTime* const date1 - , const XMLDateTime* const date2 - , bool strict) -{ - return XMLDateTime::compare(date1, date2); -} - -// -// In fact, the proper way of the following set*() shall be -// { -// if (fMaxInclusive) -// delete fMaxInclusive; -// -// fMaxInclusive = parse(value); -// -// } -// -// But we know this function is invoked once and only once -// since there is no duplicated facet passed in, therefore -// fMaxInclusive is alwasy zero before, so for the -// sake of performance, we do not do the checking/delete. -// - -void DateTimeValidator::setMaxInclusive(const XMLCh* const value) -{ - fMaxInclusive = parse(value); -} - -void DateTimeValidator::setMaxExclusive(const XMLCh* const value) -{ - fMaxExclusive = parse(value); -} - -void DateTimeValidator::setMinInclusive(const XMLCh* const value) -{ - fMinInclusive = parse(value); -} - -void DateTimeValidator::setMinExclusive(const XMLCh* const value) -{ - fMinExclusive = parse(value); -} - -void DateTimeValidator::setEnumeration() -{ -// to do: do we need to check against base value space??? - - if (!fStrEnumeration) - return; - - int enumLength = fStrEnumeration->size(); - fEnumeration = new RefVectorOf<XMLNumber>(enumLength, true); - fEnumerationInherited = false; - - for ( int i = 0; i < enumLength; i++) - fEnumeration->insertElementAt(parse(fStrEnumeration->elementAt(i)), i); - -} - -/** - * End of file DateTimeValidator::cpp - */ - diff --git a/src/validators/datatype/DateTimeValidator.hpp b/src/validators/datatype/DateTimeValidator.hpp deleted file mode 100644 index 02c906473d39a11170d27fd70f9e6ab1e7e53553..0000000000000000000000000000000000000000 --- a/src/validators/datatype/DateTimeValidator.hpp +++ /dev/null @@ -1,152 +0,0 @@ -/* - * 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.2 2001/11/12 20:37:57 peiyongz - * SchemaDateTimeException defined - * - * Revision 1.1 2001/11/07 19:18:52 peiyongz - * DateTime Port - * - */ - -#if !defined(DATETIME_VALIDATOR_HPP) -#define DATETIME_VALIDATOR_HPP - -#include <validators/datatype/AbstractNumericFacetValidator.hpp> -#include <util/XMLDateTime.hpp> - -class VALIDATORS_EXPORT DateTimeValidator : public AbstractNumericFacetValidator -{ -public: - - // ----------------------------------------------------------------------- - // Public dtor - // ----------------------------------------------------------------------- - /** @name Constructor. */ - //@{ - - virtual ~DateTimeValidator(); - - //@} - - virtual void validate(const XMLCh* const content); - - virtual int compare(const XMLCh* const value1 - , const XMLCh* const value2); - -protected: - - // ----------------------------------------------------------------------- - // ctor used by derived class - // ----------------------------------------------------------------------- - DateTimeValidator(DatatypeValidator* const baseValidator - , RefHashTableOf<KVStringPair>* const facets - , const int finalSet - , const ValidatorType type); - - // - // Abstract interface - // - - virtual void assignAdditionalFacet(const XMLCh* const key - , const XMLCh* const value); - - virtual void inheritAdditionalFacet(); - - virtual void checkAdditionalFacetConstraints() const; - - virtual void checkAdditionalFacetConstraintsBase() const; - - virtual int compareValues(const XMLNumber* const lValue - , const XMLNumber* const rValue); - - virtual void checkContent(const XMLCh* const content - , bool asBase); - - - virtual void setMaxInclusive(const XMLCh* const); - - virtual void setMaxExclusive(const XMLCh* const); - - virtual void setMinInclusive(const XMLCh* const); - - virtual void setMinExclusive(const XMLCh* const); - - virtual void setEnumeration(); - -protected: - - // ----------------------------------------------------------------------- - // helper interface: to be implemented/overwritten by derived class - // ----------------------------------------------------------------------- - virtual XMLDateTime* parse(const XMLCh* const) = 0; - - // to be overwritten by duration - virtual int compareDates(const XMLDateTime* const lValue - , const XMLDateTime* const rValue - , bool strict); - -}; - -/** - * End of file DateTimeValidator.hpp - */ - -#endif - diff --git a/src/validators/datatype/DayDatatypeValidator.cpp b/src/validators/datatype/DayDatatypeValidator.cpp deleted file mode 100644 index 79089bce14aee2f35e4f45dc80e928096a4e23c9..0000000000000000000000000000000000000000 --- a/src/validators/datatype/DayDatatypeValidator.cpp +++ /dev/null @@ -1,127 +0,0 @@ -/* - * 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.3 2001/11/15 17:09:23 peiyongz - * catch(...) only. (the invoker need to cath XMLException to display proper message) - * - * Revision 1.2 2001/11/14 22:02:25 peiyongz - * rethrow exception with original error message. - * - * Revision 1.1 2001/11/07 19:18:52 peiyongz - * DateTime Port - * - */ - -// --------------------------------------------------------------------------- -// Includes -// --------------------------------------------------------------------------- -#include <validators/datatype/DayDatatypeValidator.hpp> - -// --------------------------------------------------------------------------- -// Constructors and Destructor -// --------------------------------------------------------------------------- -DayDatatypeValidator::DayDatatypeValidator() -:DateTimeValidator(0, 0, 0, DatatypeValidator::Day) -{} - -DayDatatypeValidator::DayDatatypeValidator( - DatatypeValidator* const baseValidator - , RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet) -:DateTimeValidator(baseValidator, facets, finalSet, DatatypeValidator::Day) -{ - init(enums); -} - -DayDatatypeValidator::~DayDatatypeValidator() -{} - -DatatypeValidator* DayDatatypeValidator::newInstance( - RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet) -{ - return (DatatypeValidator*) new DayDatatypeValidator(this, facets, enums, finalSet); -} - -// -// caller need to release the date created here -// -XMLDateTime* DayDatatypeValidator::parse(const XMLCh* const content) -{ - XMLDateTime *pRetDate = new XMLDateTime(content); - - try - { - pRetDate->parseDay(); - } - catch (...) - { - delete pRetDate; - throw; - } - - return pRetDate; -} - -/** - * End of file DayDatatypeValidator::cpp - */ - diff --git a/src/validators/datatype/DayDatatypeValidator.hpp b/src/validators/datatype/DayDatatypeValidator.hpp deleted file mode 100644 index 6c67dc4cb7d31d8e9b9b7342e765ae5a06b65f41..0000000000000000000000000000000000000000 --- a/src/validators/datatype/DayDatatypeValidator.hpp +++ /dev/null @@ -1,111 +0,0 @@ -/* - * 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/11/07 19:18:52 peiyongz - * DateTime Port - * - */ - -#if !defined(DAY_DATATYPE_VALIDATOR_HPP) -#define DAY_DATATYPE_VALIDATOR_HPP - -#include <validators/datatype/DateTimeValidator.hpp> - -class VALIDATORS_EXPORT DayDatatypeValidator : public DateTimeValidator -{ -public: - - // ----------------------------------------------------------------------- - // Public ctor/dtor - // ----------------------------------------------------------------------- - /** @name Constructor. */ - //@{ - - DayDatatypeValidator(); - - DayDatatypeValidator(DatatypeValidator* const baseValidator - , RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet); - - ~DayDatatypeValidator(); - - //@} - - /** - * Returns an instance of the base datatype validator class - * Used by the DatatypeValidatorFactory. - */ - virtual DatatypeValidator* newInstance(RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet); - -protected: - - // ----------------------------------------------------------------------- - // implementation of (DateTimeValidator's) virtual interface - // ----------------------------------------------------------------------- - virtual XMLDateTime* parse(const XMLCh* const); -}; - -/** - * End of file DayDatatypeValidator.hpp - */ -#endif - diff --git a/src/validators/datatype/DecimalDatatypeValidator.cpp b/src/validators/datatype/DecimalDatatypeValidator.cpp deleted file mode 100644 index 3343b5e4e70f6ff1eb083e1b7c25b8bded4584a5..0000000000000000000000000000000000000000 --- a/src/validators/datatype/DecimalDatatypeValidator.cpp +++ /dev/null @@ -1,546 +0,0 @@ -/* - * 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$ - * Revision 1.19 2001/10/09 20:53:22 peiyongz - * Optimization: save get***() to temp var - * - * Revision 1.18 2001/10/02 18:59:29 peiyongz - * Invalid_Facet_Tag to display the tag name - * - * Revision 1.17 2001/10/01 21:04:40 peiyongz - * DTV Reorganization:fix to memory leak in compare() method. - * - * Revision 1.16 2001/10/01 16:16:38 peiyongz - * DTV Reorganization:derived from AbstractNumericValidator - * - * Revision 1.15 2001/09/20 13:11:42 knoaman - * Regx + misc. fixes - * - * Revision 1.14 2001/08/22 18:28:01 peiyongz - * Memory leak: delete the bufffer allocated by ::toString() - * - * Revision 1.13 2001/08/21 18:42:53 peiyongz - * Bugzilla# 2816: cleanUp() declared with external linkage and called - * before defined as inline - * - * Revision 1.12 2001/08/15 18:08:44 peiyongz - * Fix to potential leakage in strEnumeration - * - * Revision 1.11 2001/07/17 21:30:12 peiyongz - * bug fix: numBase->getMinInclusive()->toString() - * - * Revision 1.10 2001/06/20 17:56:32 peiyongz - * support for "fixed" option on constrainning facets - * - * Revision 1.8 2001/05/29 19:49:34 tng - * Schema: Constraint Checking Fix in datatypeValidators. By Pei Yong Zhang. - * - * Revision 1.7 2001/05/28 21:11:18 tng - * Schema: Various DatatypeValidator fix. By Pei Yong Zhang - * - * Revision 1.6 2001/05/18 20:18:02 tng - * Schema: More exception messages in XMLBigDecimal/XMLBigInteger/DecimalDatatypeValidator. By Pei Yong Zhang. - * - * Revision 1.5 2001/05/18 13:36:45 tng - * Schema: Catch RegularExpression exception and NumberFormatException - * - * Revision 1.4 2001/05/18 13:23:46 tng - * Schema: Exception messages in DatatypeValidator. By Pei Yong Zhang. - * - * Revision 1.3 2001/05/11 17:17:23 tng - * Schema: DatatypeValidator fixes. By Pei Yong Zhang. - * - * Revision 1.2 2001/05/11 13:27:28 tng - * Copyright update. - * - * Revision 1.1 2001/05/10 20:51:29 tng - * Schema: Add DecimalDatatypeValidator and XMLBigDecimal, XMLBigInteger. By Pei Yong Zhang. - * - */ - -// --------------------------------------------------------------------------- -// Includes -// --------------------------------------------------------------------------- -#include <validators/datatype/DecimalDatatypeValidator.hpp> -#include <validators/schema/SchemaSymbols.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 -// --------------------------------------------------------------------------- -DecimalDatatypeValidator::DecimalDatatypeValidator() -:AbstractNumericValidator(0, 0, 0, DatatypeValidator::Decimal) -, fTotalDigits(0) -, fFractionDigits(0) -{} - -DecimalDatatypeValidator::DecimalDatatypeValidator( - DatatypeValidator* const baseValidator - , RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet) -:AbstractNumericValidator(baseValidator, facets, finalSet, DatatypeValidator::Decimal) -, fTotalDigits(0) -, fFractionDigits(0) -{ - init(enums); -} - -DecimalDatatypeValidator::~DecimalDatatypeValidator() -{} - -// ----------------------------------------------------------------------- -// Compare methods -// ----------------------------------------------------------------------- -int DecimalDatatypeValidator::compare(const XMLCh* const lValue - , const XMLCh* const rValue) -{ - XMLBigDecimal * lObj = new XMLBigDecimal(lValue); - Janitor<XMLBigDecimal> jname1(lObj); - XMLBigDecimal * rObj = new XMLBigDecimal(rValue); - Janitor<XMLBigDecimal> jname2(rObj); - - return compareValues(lObj, rObj); -} - -DatatypeValidator* DecimalDatatypeValidator::newInstance( - RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet) -{ - return (DatatypeValidator*) new DecimalDatatypeValidator(this, facets, enums, finalSet); -} - -// ----------------------------------------------------------------------- -// ctor provided to be used by derived classes -// ----------------------------------------------------------------------- -DecimalDatatypeValidator::DecimalDatatypeValidator(DatatypeValidator* const baseValidator - , RefHashTableOf<KVStringPair>* const facets - , const int finalSet - , const ValidatorType type) -:AbstractNumericValidator(baseValidator, facets, finalSet, type) -, fTotalDigits(0) -, fFractionDigits(0) -{ - //do not invoke init here !!! -} - -void DecimalDatatypeValidator::assignAdditionalFacet(const XMLCh* const key - , const XMLCh* const value) -{ - if (XMLString::compareString(key, SchemaSymbols::fgELT_TOTALDIGITS)==0) - { - int val; - try - { - val = XMLString::parseInt(value); - } - catch (NumberFormatException) - { - ThrowXML1(InvalidDatatypeFacetException, XMLExcepts::FACET_Invalid_TotalDigit, value); - } - - // check 4.3.11.c0 must: totalDigits > 0 - if ( val <= 0 ) - ThrowXML1(InvalidDatatypeFacetException, XMLExcepts::FACET_NonNeg_TotalDigit, value); - - setTotalDigits(val); - setFacetsDefined(DatatypeValidator::FACET_TOTALDIGITS); - } - else if (XMLString::compareString(key, SchemaSymbols::fgELT_FRACTIONDIGITS)==0) - { - int val; - try - { - val = XMLString::parseInt(value); - } - catch (NumberFormatException) - { - ThrowXML1(InvalidDatatypeFacetException, XMLExcepts::FACET_Invalid_FractDigit, value); - } - - // check 4.3.12.c0 must: fractionDigits > 0 - if ( val < 0 ) - ThrowXML1(InvalidDatatypeFacetException, XMLExcepts::FACET_NonNeg_FractDigit, value); - - setFractionDigits(val); - setFacetsDefined(DatatypeValidator::FACET_FRACTIONDIGITS); - } - else - { - ThrowXML1(InvalidDatatypeFacetException - , XMLExcepts::FACET_Invalid_Tag - , key); - } -} - -void DecimalDatatypeValidator::inheritAdditionalFacet() -{ - - DecimalDatatypeValidator *numBase = (DecimalDatatypeValidator*) getBaseValidator(); - - if (!numBase) - return; - - int thisFacetsDefined = getFacetsDefined(); - int baseFacetsDefined = numBase->getFacetsDefined(); - - // inherit totalDigits - if ((( baseFacetsDefined & DatatypeValidator::FACET_TOTALDIGITS) != 0) && - (( thisFacetsDefined & DatatypeValidator::FACET_TOTALDIGITS) == 0) ) - { - setTotalDigits(numBase->fTotalDigits); - setFacetsDefined(DatatypeValidator::FACET_TOTALDIGITS); - } - - // inherit fractionDigits - if ((( baseFacetsDefined & DatatypeValidator::FACET_FRACTIONDIGITS) != 0) && - (( thisFacetsDefined & DatatypeValidator::FACET_FRACTIONDIGITS) == 0) ) - { - setFractionDigits(numBase->fFractionDigits); - setFacetsDefined(DatatypeValidator::FACET_FRACTIONDIGITS); - } -} - -void DecimalDatatypeValidator::checkAdditionalFacetConstraints() const -{ - int thisFacetsDefined = getFacetsDefined(); - - // check 4.3.12.c1 must: fractionDigits <= totalDigits - if ( ((thisFacetsDefined & DatatypeValidator::FACET_FRACTIONDIGITS) != 0) && - ((thisFacetsDefined & DatatypeValidator::FACET_TOTALDIGITS) != 0) ) - { - if ( fFractionDigits > fTotalDigits ) - { - XMLString::binToText(getFractionDigits(), value1, BUF_LEN, 10); - XMLString::binToText(getTotalDigits(), value2, BUF_LEN, 10); - ThrowXML2(InvalidDatatypeFacetException - , XMLExcepts::FACET_TotDigit_FractDigit - , value2 - , value1); - } - } - -} - -void DecimalDatatypeValidator::checkAdditionalFacetConstraintsBase() const -{ - - DecimalDatatypeValidator *numBase = (DecimalDatatypeValidator*) getBaseValidator(); - - if (!numBase) - return; - - int thisFacetsDefined = getFacetsDefined(); - int baseFacetsDefined = numBase->getFacetsDefined(); - - // check 4.3.11.c1 error: totalDigits > base.totalDigits - // totalDigits != base.totalDigits if (base.fixed) - if (( thisFacetsDefined & DatatypeValidator::FACET_TOTALDIGITS) != 0) - { - if ( (( baseFacetsDefined & DatatypeValidator::FACET_TOTALDIGITS) != 0) && - ( fTotalDigits > numBase->fTotalDigits )) - { - XMLString::binToText(fTotalDigits, value1, BUF_LEN, 10); - XMLString::binToText(numBase->fTotalDigits, value2, BUF_LEN, 10); - ThrowXML2(InvalidDatatypeFacetException - , XMLExcepts::FACET_totalDigit_base_totalDigit - , value1 - , value2); - } - - if ( (( baseFacetsDefined & DatatypeValidator::FACET_TOTALDIGITS) != 0) && - (( numBase->getFixed() & DatatypeValidator::FACET_TOTALDIGITS) != 0) && - ( fTotalDigits != numBase->fTotalDigits )) - { - XMLString::binToText(fTotalDigits, value1, BUF_LEN, 10); - XMLString::binToText(numBase->fTotalDigits, value2, BUF_LEN, 10); - ThrowXML2(InvalidDatatypeFacetException - , XMLExcepts::FACET_totalDigit_base_fixed - , value1 - , value2); - } - } - - if (( thisFacetsDefined & DatatypeValidator::FACET_FRACTIONDIGITS) != 0) - { - // check question error: fractionDigits > base.fractionDigits ??? - if ( (( baseFacetsDefined & DatatypeValidator::FACET_FRACTIONDIGITS) != 0) && - ( fFractionDigits > numBase->fFractionDigits )) - { - XMLString::binToText(fFractionDigits, value1, BUF_LEN, 10); - XMLString::binToText(numBase->fFractionDigits, value2, BUF_LEN, 10); - ThrowXML2(InvalidDatatypeFacetException - , XMLExcepts::FACET_fractDigit_base_fractDigit - , value1 - , value2); - } - - // check question error: fractionDigits > base.totalDigits ??? - if ( (( baseFacetsDefined & DatatypeValidator::FACET_TOTALDIGITS) != 0) && - ( fFractionDigits > numBase->fTotalDigits )) - { - XMLString::binToText(fFractionDigits, value1, BUF_LEN, 10); - XMLString::binToText(numBase->fTotalDigits, value2, BUF_LEN, 10); - ThrowXML2(InvalidDatatypeFacetException - , XMLExcepts::FACET_fractDigit_base_totalDigit - , value1 - , value2); - } - - // fractionDigits != base.fractionDigits if (base.fixed) - if ( (( baseFacetsDefined & DatatypeValidator::FACET_FRACTIONDIGITS) != 0) && - (( numBase->getFixed() & DatatypeValidator::FACET_FRACTIONDIGITS) != 0) && - ( fFractionDigits != numBase->fFractionDigits )) - { - XMLString::binToText(fFractionDigits, value1, BUF_LEN, 10); - XMLString::binToText(numBase->fFractionDigits, value2, BUF_LEN, 10); - ThrowXML2(InvalidDatatypeFacetException - , XMLExcepts::FACET_fractDigit_base_fixed - , value1 - , value2); - } - } - -} - -int DecimalDatatypeValidator::compareValues(const XMLNumber* const lValue - , const XMLNumber* const rValue) -{ - return XMLBigDecimal::compareValues((XMLBigDecimal*) lValue, (XMLBigDecimal*) rValue); -} - -void DecimalDatatypeValidator::setMaxInclusive(const XMLCh* const value) -{ - fMaxInclusive = new XMLBigDecimal(value); -} - -void DecimalDatatypeValidator::setMaxExclusive(const XMLCh* const value) -{ - fMaxExclusive = new XMLBigDecimal(value); -} - -void DecimalDatatypeValidator::setMinInclusive(const XMLCh* const value) -{ - fMinInclusive = new XMLBigDecimal(value); -} - -void DecimalDatatypeValidator::setMinExclusive(const XMLCh* const value) -{ - fMinExclusive = new XMLBigDecimal(value); -} - -void DecimalDatatypeValidator::setEnumeration() -{ - // check 4.3.5.c0 must: enumeration values from the value space of base - // - // 1. shall be from base value space - // 2. shall be from current value space as well ( shall go through boundsCheck() ) - // - if (!fStrEnumeration) - return; - - int i = 0; - int enumLength = fStrEnumeration->size(); - - DecimalDatatypeValidator *numBase = (DecimalDatatypeValidator*) getBaseValidator(); - if (numBase) - { - try - { - for ( i = 0; i < enumLength; i++) - { - numBase->checkContent(fStrEnumeration->elementAt(i), false); - } - } - catch (XMLException&) - { - ThrowXML1(InvalidDatatypeFacetException - , XMLExcepts::FACET_enum_base - , fStrEnumeration->elementAt(i)); - } - } - - // We put the this->checkContent in a separate loop - // to not block original message with in that method. - // - for ( i = 0; i < enumLength; i++) - { - checkContent(fStrEnumeration->elementAt(i), false); - } - - fEnumeration = new RefVectorOf<XMLNumber>(enumLength, true); - fEnumerationInherited = false; - - for ( i = 0; i < enumLength; i++) - { - fEnumeration->insertElementAt(new XMLBigDecimal(fStrEnumeration->elementAt(i)), i); - } - -} - -// ----------------------------------------------------------------------- -// Abstract interface from AbstractNumericValidator -// ----------------------------------------------------------------------- -void DecimalDatatypeValidator::checkContent( const XMLCh* const content, bool asBase) -{ - - //validate against base validator if any - DecimalDatatypeValidator *pBase = (DecimalDatatypeValidator*) this->getBaseValidator(); - if (pBase) - pBase->checkContent(content, true); - - int thisFacetsDefined = getFacetsDefined(); - - // we check pattern first - if ( (thisFacetsDefined & 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; - - try { - XMLBigDecimal theValue(content); - XMLBigDecimal *theData = &theValue; - - if (getEnumeration()) - { - int i=0; - int enumLength = getEnumeration()->size(); - for ( ; i < enumLength; i++) - { - if (compareValues(theData, (XMLBigDecimal*) getEnumeration()->elementAt(i)) ==0 ) - break; - } - - if (i == enumLength) - ThrowXML1(InvalidDatatypeValueException, XMLExcepts::VALUE_NotIn_Enumeration, content); - } - - boundsCheck(theData); - - if ( (thisFacetsDefined & DatatypeValidator::FACET_FRACTIONDIGITS) != 0 ) - { - if ( theData->getScale() > fFractionDigits ) - { - XMLCh* value = theData->toString(); - ArrayJanitor<XMLCh> jan(value); - XMLString::binToText(theData->getScale(), value1, BUF_LEN, 10); - XMLString::binToText(fFractionDigits, value2, BUF_LEN, 10); - ThrowXML3(InvalidDatatypeFacetException - , XMLExcepts::VALUE_exceed_fractDigit - , value - , value1 - , value2); - } - } - - if ( (thisFacetsDefined & DatatypeValidator::FACET_TOTALDIGITS) != 0 ) - { - if ( theData->getTotalDigit() > fTotalDigits ) - { - XMLCh* value = theData->toString(); - ArrayJanitor<XMLCh> jan(value); - XMLString::binToText(theData->getTotalDigit(), value1, BUF_LEN, 10); - XMLString::binToText(fTotalDigits, value2, BUF_LEN, 10); - ThrowXML3(InvalidDatatypeFacetException - , XMLExcepts::VALUE_exceed_totalDigit - , value - , value1 - , value2); - } - } - - } - catch (XMLException &e) - { - ThrowXML1(InvalidDatatypeFacetException, XMLExcepts::RethrowError, e.getMessage()); - } - -} - -/** - * End of file DecimalDatatypeValidator::cpp - */ diff --git a/src/validators/datatype/DecimalDatatypeValidator.hpp b/src/validators/datatype/DecimalDatatypeValidator.hpp deleted file mode 100644 index 40460dff811c10ac67812b6978fbedaca4f26a46..0000000000000000000000000000000000000000 --- a/src/validators/datatype/DecimalDatatypeValidator.hpp +++ /dev/null @@ -1,227 +0,0 @@ -/* - * 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.10 2001/11/22 20:23:20 peiyongz - * _declspec(dllimport) and inline warning C4273 - * - * Revision 1.9 2001/10/09 20:52:43 peiyongz - * init():removed - * - * Revision 1.8 2001/10/01 21:04:40 peiyongz - * DTV Reorganization:fix to memory leak in compare() method. - * - * Revision 1.7 2001/10/01 16:16:38 peiyongz - * DTV Reorganization:derived from AbstractNumericValidator - * - */ - -#if !defined(DECIMAL_DATATYPEVALIDATOR_HPP) -#define DECIMAL_DATATYPEVALIDATOR_HPP - -#include <validators/datatype/AbstractNumericValidator.hpp> -#include <util/RefVectorOf.hpp> -#include <util/XMLBigDecimal.hpp> - -class VALIDATORS_EXPORT DecimalDatatypeValidator : public AbstractNumericValidator -{ -public: - - // ----------------------------------------------------------------------- - // Public ctor/dtor - // ----------------------------------------------------------------------- - /** @name Constructor. */ - //@{ - - DecimalDatatypeValidator(); - - DecimalDatatypeValidator(DatatypeValidator* const baseValidator - , RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet); - - virtual ~DecimalDatatypeValidator(); - - //@} - - // ----------------------------------------------------------------------- - // Compare methods - // ----------------------------------------------------------------------- - /** @name Compare Function */ - //@{ - - /** - * Compare two boolean data types - * - * @param content1 - * @param content2 - * @return - */ - virtual int compare(const XMLCh* const, const XMLCh* const); - - //@} - - /** - * Returns an instance of the base datatype validator class - * Used by the DatatypeValidatorFactory. - */ - virtual DatatypeValidator* newInstance(RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet); - -protected: - -// ----------------------------------------------------------------------- -// ctor provided to be used by derived classes -// ----------------------------------------------------------------------- - DecimalDatatypeValidator(DatatypeValidator* const baseValidator - , RefHashTableOf<KVStringPair>* const facets - , const int finalSet - , const ValidatorType type); - -// ----------------------------------------------------------------------- -// Abstract interface from AbstractNumericFacetValidator -// ----------------------------------------------------------------------- - - virtual void assignAdditionalFacet(const XMLCh* const key - , const XMLCh* const value); - - virtual void inheritAdditionalFacet(); - - virtual void checkAdditionalFacetConstraints() const; - - virtual void checkAdditionalFacetConstraintsBase() const; - - virtual int compareValues(const XMLNumber* const lValue - , const XMLNumber* const rValue); - - virtual void setMaxInclusive(const XMLCh* const); - - virtual void setMaxExclusive(const XMLCh* const); - - virtual void setMinInclusive(const XMLCh* const); - - virtual void setMinExclusive(const XMLCh* const); - - virtual void setEnumeration(); - -// ----------------------------------------------------------------------- -// Abstract interface from AbstractNumericValidator -// ----------------------------------------------------------------------- - - virtual void checkContent( const XMLCh* const content, bool asBase); - -private: - -// ----------------------------------------------------------------------- -// Getter methods -// ----------------------------------------------------------------------- - - inline unsigned int getTotalDigits() const; - - inline unsigned int getFractionDigits() const; - -// ----------------------------------------------------------------------- -// Setter methods -// ----------------------------------------------------------------------- - - inline void setTotalDigits(unsigned int); - - inline void setFractionDigits(unsigned int); - - // ----------------------------------------------------------------------- - // Private data members - // - // ----------------------------------------------------------------------- - unsigned int fTotalDigits; - unsigned int fFractionDigits; - -}; - -// ----------------------------------------------------------------------- -// Getter methods -// ----------------------------------------------------------------------- - -inline unsigned int DecimalDatatypeValidator::getTotalDigits() const -{ - return fTotalDigits; -} - -inline unsigned int DecimalDatatypeValidator::getFractionDigits() const -{ - return fFractionDigits; -} - -// ----------------------------------------------------------------------- -// Setter methods -// ----------------------------------------------------------------------- - -inline void DecimalDatatypeValidator::setTotalDigits(unsigned int newTotalDigits) -{ - fTotalDigits = newTotalDigits; -} - -inline void DecimalDatatypeValidator::setFractionDigits(unsigned int newFractionDigits) -{ - fFractionDigits = newFractionDigits; -} - -/** - * End of file DecimalDatatypeValidator.hpp - */ -#endif diff --git a/src/validators/datatype/DoubleDatatypeValidator.cpp b/src/validators/datatype/DoubleDatatypeValidator.cpp deleted file mode 100644 index 3415d6adb3751723483727ad2ba01b9bbd73d6f8..0000000000000000000000000000000000000000 --- a/src/validators/datatype/DoubleDatatypeValidator.cpp +++ /dev/null @@ -1,305 +0,0 @@ -/* - * 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.6 2001/10/02 18:59:29 peiyongz - * Invalid_Facet_Tag to display the tag name - * - * Revision 1.5 2001/10/01 21:03:55 peiyongz - * DTV Reorganization:derived from AbstractNumericValidator - * - * Revision 1.4 2001/09/20 13:11:42 knoaman - * Regx + misc. fixes - * - * Revision 1.3 2001/08/21 18:42:53 peiyongz - * Bugzilla# 2816: cleanUp() declared with external linkage and called - * before defined as inline - * - * Revision 1.2 2001/08/15 18:08:44 peiyongz - * Fix to potential leakage in strEnumeration - * - * Revision 1.1 2001/07/24 13:59:03 peiyongz - * DoubleDTV - * - */ - -// --------------------------------------------------------------------------- -// Includes -// --------------------------------------------------------------------------- -#include <validators/datatype/DoubleDatatypeValidator.hpp> -#include <validators/schema/SchemaSymbols.hpp> -#include <validators/datatype/InvalidDatatypeFacetException.hpp> -#include <validators/datatype/InvalidDatatypeValueException.hpp> - -// --------------------------------------------------------------------------- -// Constructors and Destructor -// --------------------------------------------------------------------------- -DoubleDatatypeValidator::DoubleDatatypeValidator() -:AbstractNumericValidator(0, 0, 0, DatatypeValidator::Double) -{} - -DoubleDatatypeValidator::DoubleDatatypeValidator( - DatatypeValidator* const baseValidator - , RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet) -:AbstractNumericValidator(baseValidator, facets, finalSet, DatatypeValidator::Double) -{ - init(enums); -} - -DoubleDatatypeValidator::~DoubleDatatypeValidator() -{} - -// ----------------------------------------------------------------------- -// Compare methods -// ----------------------------------------------------------------------- -int DoubleDatatypeValidator::compare(const XMLCh* const lValue - , const XMLCh* const rValue) -{ - XMLDouble * lObj = new XMLDouble(lValue); - Janitor<XMLDouble> jname1(lObj); - XMLDouble * rObj = new XMLDouble(rValue); - Janitor<XMLDouble> jname2(rObj); - - return compareValues(lObj, rObj); -} - -DatatypeValidator* DoubleDatatypeValidator::newInstance( - RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet) -{ - return (DatatypeValidator*) new DoubleDatatypeValidator(this, facets, enums, finalSet); -} - -// ----------------------------------------------------------------------- -// ctor provided to be used by derived classes -// ----------------------------------------------------------------------- -DoubleDatatypeValidator::DoubleDatatypeValidator(DatatypeValidator* const baseValidator - , RefHashTableOf<KVStringPair>* const facets - , const int finalSet - , const ValidatorType type) -:AbstractNumericValidator(baseValidator, facets, finalSet, type) -{ - //do not invoke init here !!! -} - -void DoubleDatatypeValidator::assignAdditionalFacet(const XMLCh* const key - , const XMLCh* const) -{ - ThrowXML1(InvalidDatatypeFacetException - , XMLExcepts::FACET_Invalid_Tag - , key); -} - -void DoubleDatatypeValidator::inheritAdditionalFacet() -{} - -void DoubleDatatypeValidator::checkAdditionalFacetConstraints() const -{} - -void DoubleDatatypeValidator::checkAdditionalFacetConstraintsBase() const -{} - -int DoubleDatatypeValidator::compareValues(const XMLNumber* const lValue - , const XMLNumber* const rValue) -{ - return XMLDouble::compareValues((XMLDouble*) lValue, (XMLDouble*) rValue); -} - -void DoubleDatatypeValidator::setMaxInclusive(const XMLCh* const value) -{ - fMaxInclusive = new XMLDouble(value); -} - -void DoubleDatatypeValidator::setMaxExclusive(const XMLCh* const value) -{ - fMaxExclusive = new XMLDouble(value); -} - -void DoubleDatatypeValidator::setMinInclusive(const XMLCh* const value) -{ - fMinInclusive = new XMLDouble(value); -} - -void DoubleDatatypeValidator::setMinExclusive(const XMLCh* const value) -{ - fMinExclusive = new XMLDouble(value); -} - -void DoubleDatatypeValidator::setEnumeration() -{ - // check 4.3.5.c0 must: enumeration values from the value space of base - // - // 1. shall be from base value space - // 2. shall be from current value space as well ( shall go through boundsCheck() ) - // - if (!fStrEnumeration) - return; - - int i = 0; - int enumLength = fStrEnumeration->size(); - - DoubleDatatypeValidator *numBase = (DoubleDatatypeValidator*) getBaseValidator(); - if (numBase) - { - try - { - for ( i = 0; i < enumLength; i++) - { - numBase->checkContent(fStrEnumeration->elementAt(i), false); - } - } - catch (XMLException&) - { - ThrowXML1(InvalidDatatypeFacetException - , XMLExcepts::FACET_enum_base - , fStrEnumeration->elementAt(i)); - - } - } - - // We put the this->checkContent in a separate loop - // to not block original message with in that method. - // - for ( i = 0; i < enumLength; i++) - { - checkContent(fStrEnumeration->elementAt(i), false); - } - - fEnumeration = new RefVectorOf<XMLNumber>(enumLength, true); - fEnumerationInherited = false; - - for ( i = 0; i < enumLength; i++) - { - fEnumeration->insertElementAt(new XMLDouble(fStrEnumeration->elementAt(i)), i); - } -} - -// ----------------------------------------------------------------------- -// Abstract interface from AbstractNumericValidator -// ----------------------------------------------------------------------- - -void DoubleDatatypeValidator::checkContent( const XMLCh* const content, bool asBase) -{ - - //validate against base validator if any - DoubleDatatypeValidator *pBase = (DoubleDatatypeValidator*) this->getBaseValidator(); - if (pBase) - pBase->checkContent(content, true); - - // 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; - - try { - XMLDouble theValue(content); - XMLDouble *theData = &theValue; - - if (getEnumeration()) - { - int i=0; - int enumLength = getEnumeration()->size(); - for ( ; i < enumLength; i++) - { - if (compareValues(theData, (XMLDouble*) getEnumeration()->elementAt(i)) ==0 ) - break; - } - - if (i == enumLength) - ThrowXML1(InvalidDatatypeValueException, XMLExcepts::VALUE_NotIn_Enumeration, content); - } - - boundsCheck(theData); - - } - catch (XMLException &e) - { - ThrowXML1(InvalidDatatypeFacetException, XMLExcepts::RethrowError, e.getMessage()); - } - -} - -/** - * End of file DoubleDatatypeValidator::cpp - */ diff --git a/src/validators/datatype/DoubleDatatypeValidator.hpp b/src/validators/datatype/DoubleDatatypeValidator.hpp deleted file mode 100644 index 52fa04769c2e410ad0e70dd45a8acc3dd90d2251..0000000000000000000000000000000000000000 --- a/src/validators/datatype/DoubleDatatypeValidator.hpp +++ /dev/null @@ -1,179 +0,0 @@ -/* - * 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.5 2001/10/09 20:52:43 peiyongz - * init():removed - * - * Revision 1.4 2001/10/01 21:03:55 peiyongz - * DTV Reorganization:derived from AbstractNumericValidator - * - * Revision 1.3 2001/08/24 17:12:01 knoaman - * Add support for anySimpleType. - * Remove parameter 'baseValidator' from the virtual method 'newInstance'. - * - * Revision 1.2 2001/08/21 18:42:53 peiyongz - * Bugzilla# 2816: cleanUp() declared with external linkage and called - * before defined as inline - * - * Revision 1.1 2001/07/24 13:59:03 peiyongz - * DoubleDTV - * - */ - -#if !defined(DOUBLE_DATATYPEVALIDATOR_HPP) -#define DOUBLE_DATATYPEVALIDATOR_HPP - -#include <validators/datatype/AbstractNumericValidator.hpp> -#include <util/RefVectorOf.hpp> -#include <util/XMLDouble.hpp> - -class VALIDATORS_EXPORT DoubleDatatypeValidator : public AbstractNumericValidator -{ -public: - - // ----------------------------------------------------------------------- - // Public ctor/dtor - // ----------------------------------------------------------------------- - /** @name Constructor. */ - //@{ - - DoubleDatatypeValidator(); - - DoubleDatatypeValidator(DatatypeValidator* const baseValidator - , RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet); - - virtual ~DoubleDatatypeValidator(); - - //@} - - // ----------------------------------------------------------------------- - // Compare methods - // ----------------------------------------------------------------------- - /** @name Compare Function */ - //@{ - - /** - * Compare two boolean data types - * - * @param content1 - * @param content2 - * @return - */ - virtual int compare(const XMLCh* const, const XMLCh* const); - - //@} - - /** - * Returns an instance of the base datatype validator class - * Used by the DatatypeValidatorFactory. - */ - virtual DatatypeValidator* newInstance(RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet); - -protected: - -// ----------------------------------------------------------------------- -// ctor provided to be used by derived classes -// ----------------------------------------------------------------------- - DoubleDatatypeValidator(DatatypeValidator* const baseValidator - , RefHashTableOf<KVStringPair>* const facets - , const int finalSet - , const ValidatorType type); - -// ----------------------------------------------------------------------- -// Abstract interface from AbstractNumericFacetValidator -// ----------------------------------------------------------------------- - - virtual void assignAdditionalFacet(const XMLCh* const key - , const XMLCh* const value); - - virtual void inheritAdditionalFacet(); - - virtual void checkAdditionalFacetConstraints() const; - - virtual void checkAdditionalFacetConstraintsBase() const; - - virtual int compareValues(const XMLNumber* const lValue - , const XMLNumber* const rValue); - - virtual void setMaxInclusive(const XMLCh* const); - - virtual void setMaxExclusive(const XMLCh* const); - - virtual void setMinInclusive(const XMLCh* const); - - virtual void setMinExclusive(const XMLCh* const); - - virtual void setEnumeration(); - -// ----------------------------------------------------------------------- -// Abstract interface from AbstractNumericValidator -// ----------------------------------------------------------------------- - - virtual void checkContent( const XMLCh* const content, bool asBase); - -}; - -/** - * End of file DoubleDatatypeValidator.hpp - */ -#endif diff --git a/src/validators/datatype/DurationDatatypeValidator.cpp b/src/validators/datatype/DurationDatatypeValidator.cpp deleted file mode 100644 index 91364d83c288bf9840611742e38516de8ac26d5e..0000000000000000000000000000000000000000 --- a/src/validators/datatype/DurationDatatypeValidator.cpp +++ /dev/null @@ -1,134 +0,0 @@ -/* - * 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.3 2001/11/15 17:09:23 peiyongz - * catch(...) only. (the invoker need to cath XMLException to display proper message) - * - * Revision 1.2 2001/11/14 22:02:25 peiyongz - * rethrow exception with original error message. - * - * Revision 1.1 2001/11/07 19:18:52 peiyongz - * DateTime Port - * - */ - -// --------------------------------------------------------------------------- -// Includes -// --------------------------------------------------------------------------- -#include <validators/datatype/DurationDatatypeValidator.hpp> - -// --------------------------------------------------------------------------- -// Constructors and Destructor -// --------------------------------------------------------------------------- -DurationDatatypeValidator::DurationDatatypeValidator() -:DateTimeValidator(0, 0, 0, DatatypeValidator::Duration) -{} - -DurationDatatypeValidator::DurationDatatypeValidator( - DatatypeValidator* const baseValidator - , RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet) -:DateTimeValidator(baseValidator, facets, finalSet, DatatypeValidator::Duration) -{ - init(enums); -} - -DurationDatatypeValidator::~DurationDatatypeValidator() -{} - -DatatypeValidator* DurationDatatypeValidator::newInstance( - RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet) -{ - return (DatatypeValidator*) new DurationDatatypeValidator(this, facets, enums, finalSet); -} - -// -// caller need to release the date created here -// -XMLDateTime* DurationDatatypeValidator::parse(const XMLCh* const content) -{ - XMLDateTime *pRetDate = new XMLDateTime(content); - - try - { - pRetDate->parseDuration(); - } - catch (...) - { - delete pRetDate; - throw; - } - - return pRetDate; -} - -int DurationDatatypeValidator::compareDates(const XMLDateTime* const date1 - , const XMLDateTime* const date2 - , bool strict) -{ - return XMLDateTime::compare(date1, date2, strict); -} - -/** - * End of file DurationDatatypeValidator::cpp - */ - diff --git a/src/validators/datatype/DurationDatatypeValidator.hpp b/src/validators/datatype/DurationDatatypeValidator.hpp deleted file mode 100644 index 9f6d716918cf84c75ae86ac0f111b17c81e16d74..0000000000000000000000000000000000000000 --- a/src/validators/datatype/DurationDatatypeValidator.hpp +++ /dev/null @@ -1,117 +0,0 @@ -/* - * 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/11/07 19:18:52 peiyongz - * DateTime Port - * - */ - -#if !defined(DURATION_DATATYPE_VALIDATOR_HPP) -#define DURATION_DATATYPE_VALIDATOR_HPP - -#include <validators/datatype/DateTimeValidator.hpp> - -class VALIDATORS_EXPORT DurationDatatypeValidator : public DateTimeValidator -{ -public: - - // ----------------------------------------------------------------------- - // Public ctor/dtor - // ----------------------------------------------------------------------- - /** @name Constructor. */ - //@{ - - DurationDatatypeValidator(); - - DurationDatatypeValidator(DatatypeValidator* const baseValidator - , RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet); - - ~DurationDatatypeValidator(); - - - //@} - - /** - * Returns an instance of the base datatype validator class - * Used by the DatatypeValidatorFactory. - */ - virtual DatatypeValidator* newInstance(RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet); - -protected: - - // ----------------------------------------------------------------------- - // implementation of (DateTimeValidator's) virtual interface - // ----------------------------------------------------------------------- - virtual XMLDateTime* parse(const XMLCh* const); - - virtual int compareDates(const XMLDateTime* const - , const XMLDateTime* const - , bool ); - -}; - -/** - * End of file DurationDatatypeValidator.hpp - */ -#endif - diff --git a/src/validators/datatype/ENTITYDatatypeValidator.cpp b/src/validators/datatype/ENTITYDatatypeValidator.cpp deleted file mode 100644 index 758fdbc6fcf1acc9113141814d09864119044c8b..0000000000000000000000000000000000000000 --- a/src/validators/datatype/ENTITYDatatypeValidator.cpp +++ /dev/null @@ -1,173 +0,0 @@ -/* - * 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/>. - */ - -/* - * $Id$ - * $Log$ - * Revision 1.7 2001/11/13 13:21:59 tng - * Schema fix: Entities should be unparsed. - * - * Revision 1.6 2001/10/09 20:50:27 peiyongz - * init(): take 1 arg - * - * Revision 1.5 2001/09/27 13:51:25 peiyongz - * DTV Reorganization: ctor/init created to be used by derived class - * - * Revision 1.4 2001/09/24 21:39:29 peiyongz - * DTV Reorganization: checkValueSpace() - * - * Revision 1.3 2001/08/14 22:11:56 peiyongz - * new exception message added - * - * Revision 1.2 2001/07/24 21:23:39 tng - * Schema: Use DatatypeValidator for ID/IDREF/ENTITY/ENTITIES/NOTATION. - * - * Revision 1.1 2001/07/06 20:19:52 peiyongz - * ENTITYDTV - * - */ - -// --------------------------------------------------------------------------- -// Includes -// --------------------------------------------------------------------------- -#include <validators/datatype/ENTITYDatatypeValidator.hpp> -#include <validators/datatype/InvalidDatatypeValueException.hpp> -#include <framework/XMLEntityDecl.hpp> - -// --------------------------------------------------------------------------- -// Constructors and Destructor -// --------------------------------------------------------------------------- -ENTITYDatatypeValidator::ENTITYDatatypeValidator() -:StringDatatypeValidator(0, 0, 0, DatatypeValidator::ENTITY) -,fEntityDeclPool(0) -{} - -ENTITYDatatypeValidator::ENTITYDatatypeValidator( - DatatypeValidator* const baseValidator - , RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet) -:StringDatatypeValidator(baseValidator, facets, finalSet, DatatypeValidator::ENTITY) -,fEntityDeclPool(0) -{ - init(enums); -} - -ENTITYDatatypeValidator::~ENTITYDatatypeValidator() -{} - -DatatypeValidator* ENTITYDatatypeValidator::newInstance( - RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet) -{ - return (DatatypeValidator*) new ENTITYDatatypeValidator(this, facets, enums, finalSet); -} - -// ----------------------------------------------------------------------- -// Compare methods -// ----------------------------------------------------------------------- -int ENTITYDatatypeValidator::compare(const XMLCh* const lValue - , const XMLCh* const rValue) -{ - return ( XMLString::compareString(lValue, rValue)==0 ? 0 : -1); -} - -void ENTITYDatatypeValidator::validate(const XMLCh* const content) -{ - // use StringDatatypeValidator (which in turn, invoke - // the baseValidator) to validate content against - // facets if any. - // - StringDatatypeValidator::validate(content); - - // - // parse the entity iff an EntityDeclPool is provided - // - if (fEntityDeclPool) - { - DTDEntityDecl* decl = fEntityDeclPool->getByKey(content); - - if (!decl || - (!decl->isUnparsed()) ) - { - ThrowXML1(InvalidDatatypeValueException - , XMLExcepts::VALUE_ENTITY_Invalid - , content); - } - - } - - return; -} - -void ENTITYDatatypeValidator::checkValueSpace(const XMLCh* const content) -{ - // - // 3.3.11 check must: "NCName" - // - if ( !XMLString::isValidNCName(content)) - { - ThrowXML1(InvalidDatatypeValueException - , XMLExcepts::VALUE_Invalid_NCName - , content); - } - -} - - /** - * End of file ENTITYDatatypeValidator.cpp - */ diff --git a/src/validators/datatype/ENTITYDatatypeValidator.hpp b/src/validators/datatype/ENTITYDatatypeValidator.hpp deleted file mode 100644 index 688a2c42798e7a2ef5ac08227d4a706585bdcfa2..0000000000000000000000000000000000000000 --- a/src/validators/datatype/ENTITYDatatypeValidator.hpp +++ /dev/null @@ -1,200 +0,0 @@ -/* - * 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/>. - */ - -/* - * $Id$ - * $Log$ - * Revision 1.7 2001/11/22 20:23:20 peiyongz - * _declspec(dllimport) and inline warning C4273 - * - * Revision 1.6 2001/10/09 20:50:27 peiyongz - * init(): take 1 arg - * - * Revision 1.5 2001/09/27 13:51:25 peiyongz - * DTV Reorganization: ctor/init created to be used by derived class - * - * Revision 1.4 2001/09/24 21:39:29 peiyongz - * DTV Reorganization: checkValueSpace() - * - * Revision 1.3 2001/08/24 17:12:01 knoaman - * Add support for anySimpleType. - * Remove parameter 'baseValidator' from the virtual method 'newInstance'. - * - * Revision 1.2 2001/07/24 21:23:40 tng - * Schema: Use DatatypeValidator for ID/IDREF/ENTITY/ENTITIES/NOTATION. - * - * Revision 1.1 2001/07/06 20:19:52 peiyongz - * ENTITYDTV - * - */ - -#if !defined(ENTITY_DATATYPEVALIDATOR_HPP) -#define ENTITY_DATATYPEVALIDATOR_HPP - -#include <validators/datatype/StringDatatypeValidator.hpp> -#include <internal/XMLScanner.hpp> - -class VALIDATORS_EXPORT ENTITYDatatypeValidator : public StringDatatypeValidator -{ -public: - - // ----------------------------------------------------------------------- - // Public ctor/dtor - // ----------------------------------------------------------------------- - /** @name Constructor. */ - //@{ - - ENTITYDatatypeValidator(); - - ENTITYDatatypeValidator(DatatypeValidator* const baseValidator - , RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet); - - virtual ~ENTITYDatatypeValidator(); - - //@} - - // ----------------------------------------------------------------------- - // Validation methods - // ----------------------------------------------------------------------- - /** @name Validation Function */ - //@{ - - /** - * validate that a string matches the boolean datatype - * @param content A string containing the content to be validated - * - * @exception throws InvalidDatatypeException if the content is - * is not valid. - */ - - virtual void validate(const XMLCh* const content); - - //@} - - // ----------------------------------------------------------------------- - // Compare methods - // ----------------------------------------------------------------------- - /** @name Compare Function */ - //@{ - - /** - * Compare two boolean data types - * - * @param content1 - * @param content2 - * @return - */ - virtual int compare(const XMLCh* const, const XMLCh* const); - - //@} - - /** - * Returns an instance of the base datatype validator class - * Used by the DatatypeValidatorFactory. - */ - virtual DatatypeValidator* newInstance(RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet); - -// ----------------------------------------------------------------------- -// Setter methods -// ----------------------------------------------------------------------- - /** @name Setter Functions */ - //@{ - - inline void setEntityDeclPool(NameIdPool<DTDEntityDecl>* const entityDeclPool); - - //@} - -protected: - - // - // ctor provided to be used by derived classes - // - ENTITYDatatypeValidator(DatatypeValidator* const baseValidator - , RefHashTableOf<KVStringPair>* const facets - , const int finalSet - , const ValidatorType type); - - virtual void checkValueSpace(const XMLCh* const content); - -private: - - // ----------------------------------------------------------------------- - // Private data members - // - // fEntityDeclPool - // we do NOT own it. - // - // ----------------------------------------------------------------------- - - NameIdPool<DTDEntityDecl>* fEntityDeclPool; -}; - -// ----------------------------------------------------------------------- -// Setter methods -// ----------------------------------------------------------------------- -inline void ENTITYDatatypeValidator::setEntityDeclPool(NameIdPool<DTDEntityDecl>* const entityDeclPool) -{ - fEntityDeclPool = entityDeclPool; -} - -/** - * End of file ENTITYDatatypeValidator.hpp - */ -#endif diff --git a/src/validators/datatype/FloatDatatypeValidator.cpp b/src/validators/datatype/FloatDatatypeValidator.cpp deleted file mode 100644 index a88fc31e5216827a3388b028efea44f81e606b09..0000000000000000000000000000000000000000 --- a/src/validators/datatype/FloatDatatypeValidator.cpp +++ /dev/null @@ -1,304 +0,0 @@ -/* - * 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.6 2001/10/02 18:59:29 peiyongz - * Invalid_Facet_Tag to display the tag name - * - * Revision 1.5 2001/10/01 21:03:55 peiyongz - * DTV Reorganization:derived from AbstractNumericValidator - * - * Revision 1.4 2001/09/20 13:11:42 knoaman - * Regx + misc. fixes - * - * Revision 1.3 2001/08/21 18:42:53 peiyongz - * Bugzilla# 2816: cleanUp() declared with external linkage and called - * before defined as inline - * - * Revision 1.2 2001/08/15 18:08:44 peiyongz - * Fix to potential leakage in strEnumeration - * - * Revision 1.1 2001/07/26 20:42:16 peiyongz - * FloatDatatypeValidator - * - * - */ - -// --------------------------------------------------------------------------- -// Includes -// --------------------------------------------------------------------------- -#include <validators/datatype/FloatDatatypeValidator.hpp> -#include <validators/schema/SchemaSymbols.hpp> -#include <validators/datatype/InvalidDatatypeFacetException.hpp> -#include <validators/datatype/InvalidDatatypeValueException.hpp> - -// --------------------------------------------------------------------------- -// Constructors and Destructor -// --------------------------------------------------------------------------- -FloatDatatypeValidator::FloatDatatypeValidator() -:AbstractNumericValidator(0, 0, 0, DatatypeValidator::Float) -{} - -FloatDatatypeValidator::FloatDatatypeValidator( - DatatypeValidator* const baseValidator - , RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet) -:AbstractNumericValidator(baseValidator, facets, finalSet, DatatypeValidator::Float) -{ - init(enums); -} - -FloatDatatypeValidator::~FloatDatatypeValidator() -{} - -// ----------------------------------------------------------------------- -// Compare methods -// ----------------------------------------------------------------------- -int FloatDatatypeValidator::compare(const XMLCh* const lValue - , const XMLCh* const rValue) -{ - XMLFloat * lObj = new XMLFloat(lValue); - Janitor<XMLFloat> jname1(lObj); - XMLFloat * rObj = new XMLFloat(rValue); - Janitor<XMLFloat> jname2(rObj); - - return compareValues(lObj, rObj); -} - -DatatypeValidator* FloatDatatypeValidator::newInstance( - RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet) -{ - return (DatatypeValidator*) new FloatDatatypeValidator(this, facets, enums, finalSet); -} - -// ----------------------------------------------------------------------- -// ctor provided to be used by derived classes -// ----------------------------------------------------------------------- -FloatDatatypeValidator::FloatDatatypeValidator(DatatypeValidator* const baseValidator - , RefHashTableOf<KVStringPair>* const facets - , const int finalSet - , const ValidatorType type) -:AbstractNumericValidator(baseValidator, facets, finalSet, type) -{ - //do not invoke init here !!! -} - -void FloatDatatypeValidator::assignAdditionalFacet(const XMLCh* const key - , const XMLCh* const) -{ - ThrowXML1(InvalidDatatypeFacetException - , XMLExcepts::FACET_Invalid_Tag - , key); -} - -void FloatDatatypeValidator::inheritAdditionalFacet() -{} - -void FloatDatatypeValidator::checkAdditionalFacetConstraints() const -{} - -void FloatDatatypeValidator::checkAdditionalFacetConstraintsBase() const -{} - -int FloatDatatypeValidator::compareValues(const XMLNumber* const lValue - , const XMLNumber* const rValue) -{ - return XMLFloat::compareValues((XMLFloat*) lValue, (XMLFloat*) rValue); -} - -void FloatDatatypeValidator::setMaxInclusive(const XMLCh* const value) -{ - fMaxInclusive = new XMLFloat(value); -} - -void FloatDatatypeValidator::setMaxExclusive(const XMLCh* const value) -{ - fMaxExclusive = new XMLFloat(value); -} - -void FloatDatatypeValidator::setMinInclusive(const XMLCh* const value) -{ - fMinInclusive = new XMLFloat(value); -} - -void FloatDatatypeValidator::setMinExclusive(const XMLCh* const value) -{ - fMinExclusive = new XMLFloat(value); -} - -void FloatDatatypeValidator::setEnumeration() -{ - // check 4.3.5.c0 must: enumeration values from the value space of base - // - // 1. shall be from base value space - // 2. shall be from current value space as well ( shall go through boundsCheck() ) - // - if (!fStrEnumeration) - return; - - int i = 0; - int enumLength = fStrEnumeration->size(); - - FloatDatatypeValidator *numBase = (FloatDatatypeValidator*) getBaseValidator(); - if (numBase) - { - try - { - for ( i = 0; i < enumLength; i++) - { - numBase->checkContent(fStrEnumeration->elementAt(i), false); - } - } - catch (XMLException&) - { - ThrowXML1(InvalidDatatypeFacetException - , XMLExcepts::FACET_enum_base - , fStrEnumeration->elementAt(i)); - - } - } - - // We put the this->checkContent in a separate loop - // to not block original message with in that method. - // - for ( i = 0; i < enumLength; i++) - { - checkContent(fStrEnumeration->elementAt(i), false); - } - - fEnumeration = new RefVectorOf<XMLNumber>(enumLength, true); - fEnumerationInherited = false; - - for ( i = 0; i < enumLength; i++) - { - fEnumeration->insertElementAt(new XMLFloat(fStrEnumeration->elementAt(i)), i); - } -} - -// ----------------------------------------------------------------------- -// Abstract interface from AbstractNumericValidator -// ----------------------------------------------------------------------- -void FloatDatatypeValidator::checkContent( const XMLCh* const content, bool asBase) -{ - - //validate against base validator if any - FloatDatatypeValidator *pBase = (FloatDatatypeValidator*) this->getBaseValidator(); - if (pBase) - pBase->checkContent(content, true); - - // 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; - - try { - XMLFloat theValue(content); - XMLFloat *theData = &theValue; - - if (getEnumeration() != 0) - { - int i=0; - int enumLength = getEnumeration()->size(); - for ( ; i < enumLength; i++) - { - if (compareValues(theData, (XMLFloat*) getEnumeration()->elementAt(i))==0) - break; - } - - if (i == enumLength) - ThrowXML1(InvalidDatatypeValueException, XMLExcepts::VALUE_NotIn_Enumeration, content); - } - - boundsCheck(theData); - } - catch (XMLException &e) - { - ThrowXML1(InvalidDatatypeFacetException, XMLExcepts::RethrowError, e.getMessage()); - } - -} - -/** - * End of file FloatDatatypeValidator::cpp - */ diff --git a/src/validators/datatype/FloatDatatypeValidator.hpp b/src/validators/datatype/FloatDatatypeValidator.hpp deleted file mode 100644 index 9ba7a8d5177fa6beda43db3a90073ab45033b7c3..0000000000000000000000000000000000000000 --- a/src/validators/datatype/FloatDatatypeValidator.hpp +++ /dev/null @@ -1,180 +0,0 @@ -/* - * 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.5 2001/10/09 20:52:43 peiyongz - * init():removed - * - * Revision 1.4 2001/10/01 21:03:55 peiyongz - * DTV Reorganization:derived from AbstractNumericValidator - * - * Revision 1.3 2001/08/24 17:12:01 knoaman - * Add support for anySimpleType. - * Remove parameter 'baseValidator' from the virtual method 'newInstance'. - * - * Revision 1.2 2001/08/21 18:42:53 peiyongz - * Bugzilla# 2816: cleanUp() declared with external linkage and called - * before defined as inline - * - * Revision 1.1 2001/07/26 20:42:16 peiyongz - * FloatDatatypeValidator - * - * - */ - -#if !defined(FLOAT_DATATYPEVALIDATOR_HPP) -#define FLOAT_DATATYPEVALIDATOR_HPP - -#include <validators/datatype/AbstractNumericValidator.hpp> -#include <util/RefVectorOf.hpp> -#include <util/XMLFloat.hpp> - -class VALIDATORS_EXPORT FloatDatatypeValidator : public AbstractNumericValidator -{ -public: - - // ----------------------------------------------------------------------- - // Public ctor/dtor - // ----------------------------------------------------------------------- - /** @name Constructor. */ - //@{ - - FloatDatatypeValidator(); - - FloatDatatypeValidator(DatatypeValidator* const baseValidator - , RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet); - - virtual ~FloatDatatypeValidator(); - - //@} - - // ----------------------------------------------------------------------- - // Compare methods - // ----------------------------------------------------------------------- - /** @name Compare Function */ - //@{ - - /** - * Compare two boolean data types - * - * @param content1 - * @param content2 - * @return - */ - virtual int compare(const XMLCh* const, const XMLCh* const); - - //@} - - /** - * Returns an instance of the base datatype validator class - * Used by the DatatypeValidatorFactory. - */ - virtual DatatypeValidator* newInstance(RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet); - -protected: - -// ----------------------------------------------------------------------- -// ctor provided to be used by derived classes -// ----------------------------------------------------------------------- - FloatDatatypeValidator(DatatypeValidator* const baseValidator - , RefHashTableOf<KVStringPair>* const facets - , const int finalSet - , const ValidatorType type); - -// ----------------------------------------------------------------------- -// Abstract interface from AbstractNumericFacetValidator -// ----------------------------------------------------------------------- - - virtual void assignAdditionalFacet(const XMLCh* const key - , const XMLCh* const value); - - virtual void inheritAdditionalFacet(); - - virtual void checkAdditionalFacetConstraints() const; - - virtual void checkAdditionalFacetConstraintsBase() const; - - virtual int compareValues(const XMLNumber* const lValue - , const XMLNumber* const rValue); - - virtual void setMaxInclusive(const XMLCh* const); - - virtual void setMaxExclusive(const XMLCh* const); - - virtual void setMinInclusive(const XMLCh* const); - - virtual void setMinExclusive(const XMLCh* const); - - virtual void setEnumeration(); - -// ----------------------------------------------------------------------- -// Abstract interface from AbstractNumericValidator -// ----------------------------------------------------------------------- - - virtual void checkContent( const XMLCh* const content, bool asBase); - -}; - -/** - * End of file FloatDatatypeValidator.hpp - */ -#endif diff --git a/src/validators/datatype/HexBinaryDatatypeValidator.cpp b/src/validators/datatype/HexBinaryDatatypeValidator.cpp deleted file mode 100644 index 8d5701e44c2f679b6c9367fb9048f231fe2c8e32..0000000000000000000000000000000000000000 --- a/src/validators/datatype/HexBinaryDatatypeValidator.cpp +++ /dev/null @@ -1,171 +0,0 @@ -/* - * 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$ - * Revision 1.12 2001/10/09 20:47:45 peiyongz - * init(): take 1 arg - * - * Revision 1.11 2001/10/02 18:59:29 peiyongz - * Invalid_Facet_Tag to display the tag name - * - * Revision 1.10 2001/09/24 15:33:15 peiyongz - * DTV Reorganization: virtual methods moved to *.cpp - * - * Revision 1.9 2001/09/19 20:35:23 peiyongz - * DTV reorganization: inherit from AbstractStringVaildator - * - * Revision 1.8 2001/08/21 18:42:53 peiyongz - * Bugzilla# 2816: cleanUp() declared with external linkage and called - * before defined as inline - * - * Revision 1.7 2001/06/20 17:56:21 peiyongz - * support for "fixed" option on constrainning facets - * - * Revision 1.6 2001/05/29 19:49:35 tng - * Schema: Constraint Checking Fix in datatypeValidators. By Pei Yong Zhang. - * - * Revision 1.5 2001/05/28 21:11:18 tng - * Schema: Various DatatypeValidator fix. By Pei Yong Zhang - * - * Revision 1.4 2001/05/18 13:36:47 tng - * Schema: Catch RegularExpression exception and NumberFormatException - * - * Revision 1.3 2001/05/18 13:23:49 tng - * Schema: Exception messages in DatatypeValidator. By Pei Yong Zhang. - * - * Revision 1.2 2001/05/17 18:13:47 tng - * Schema Fix: issue error message when binary data is invalid. - * - * Revision 1.1 2001/05/16 15:24:43 tng - * Schema: Add Base64 and HexBin. By Pei Yong Zhang. - * - */ - -// --------------------------------------------------------------------------- -// Includes -// --------------------------------------------------------------------------- -#include <validators/datatype/HexBinaryDatatypeValidator.hpp> -#include <validators/datatype/InvalidDatatypeFacetException.hpp> -#include <validators/datatype/InvalidDatatypeValueException.hpp> -#include <util/HexBin.hpp> - -// --------------------------------------------------------------------------- -// Constructors and Destructor -// --------------------------------------------------------------------------- -HexBinaryDatatypeValidator::HexBinaryDatatypeValidator() -:AbstractStringValidator(0, 0, 0, DatatypeValidator::HexBinary) -{} - -HexBinaryDatatypeValidator::~HexBinaryDatatypeValidator() -{} - -HexBinaryDatatypeValidator::HexBinaryDatatypeValidator( - DatatypeValidator* const baseValidator - , RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet) -:AbstractStringValidator(baseValidator, facets, finalSet, DatatypeValidator::HexBinary) -{ - init(enums); -} - -DatatypeValidator* HexBinaryDatatypeValidator::newInstance( - RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet) -{ - return (DatatypeValidator*) new HexBinaryDatatypeValidator(this, facets, enums, finalSet); -} - -// --------------------------------------------------------------------------- -// Utilities -// --------------------------------------------------------------------------- -void HexBinaryDatatypeValidator::assignAdditionalFacet( const XMLCh* const key - , const XMLCh* const) -{ - ThrowXML1(InvalidDatatypeFacetException - , XMLExcepts::FACET_Invalid_Tag - , key); -} - -void HexBinaryDatatypeValidator::inheritAdditionalFacet() -{} - -void HexBinaryDatatypeValidator::checkAdditionalFacetConstraints() const -{} - -void HexBinaryDatatypeValidator::checkAdditionalFacet(const XMLCh* const) const -{} - -void HexBinaryDatatypeValidator::checkValueSpace(const XMLCh* const content) -{ - if (getLength(content) <= 0) - { - ThrowXML1(InvalidDatatypeValueException - , XMLExcepts::VALUE_Not_HexBin - , content); - } -} - -int HexBinaryDatatypeValidator::getLength(const XMLCh* const content) const -{ - return HexBin::getDataLength(content); -} - -/** - * End of file HexBinaryDatatypeValidator.cpp - */ diff --git a/src/validators/datatype/HexBinaryDatatypeValidator.hpp b/src/validators/datatype/HexBinaryDatatypeValidator.hpp deleted file mode 100644 index 959afe3368b57118b47bb120299af1e529ada4d2..0000000000000000000000000000000000000000 --- a/src/validators/datatype/HexBinaryDatatypeValidator.hpp +++ /dev/null @@ -1,130 +0,0 @@ -/* - * 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.6 2001/09/24 15:33:15 peiyongz - * DTV Reorganization: virtual methods moved to *.cpp - * - * Revision 1.5 2001/09/19 20:35:23 peiyongz - * DTV reorganization: inherit from AbstractStringVaildator - * - */ - -#if !defined(HEXBINARY_DATATYPEVALIDATOR_HPP) -#define HEXBINARY_DATATYPEVALIDATOR_HPP - -#include <validators/datatype/AbstractStringValidator.hpp> - -class VALIDATORS_EXPORT HexBinaryDatatypeValidator : public AbstractStringValidator -{ -public: - - // ----------------------------------------------------------------------- - // Public ctor/dtor - // ----------------------------------------------------------------------- - /** @name Constructor. */ - //@{ - - HexBinaryDatatypeValidator(); - - HexBinaryDatatypeValidator(DatatypeValidator* const baseValidator - , RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet); - - virtual ~HexBinaryDatatypeValidator(); - - //@} - - /** - * Returns an instance of the base datatype validator class - * Used by the DatatypeValidatorFactory. - */ - virtual DatatypeValidator* newInstance(RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet); - - -protected: - - virtual void assignAdditionalFacet(const XMLCh* const key - , const XMLCh* const value); - - virtual void inheritAdditionalFacet(); - - virtual void checkAdditionalFacetConstraints() const; - - virtual void checkAdditionalFacet(const XMLCh* const content) const; - - virtual void checkValueSpace(const XMLCh* const content); - - virtual int getLength(const XMLCh* const content) const; - -private: - - // ----------------------------------------------------------------------- - // Private data members - // - // Nil. - // ----------------------------------------------------------------------- -}; - -/** - * End of file HexBinaryDatatypeValidator.hpp - */ -#endif diff --git a/src/validators/datatype/IDDatatypeValidator.cpp b/src/validators/datatype/IDDatatypeValidator.cpp deleted file mode 100644 index 3638658fde922e77b9be99f828a7e80f67e96010..0000000000000000000000000000000000000000 --- a/src/validators/datatype/IDDatatypeValidator.cpp +++ /dev/null @@ -1,182 +0,0 @@ -/* - * 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.6 2001/10/09 20:50:02 peiyongz - * init(): take 1 arg - * - * Revision 1.5 2001/09/27 13:51:25 peiyongz - * DTV Reorganization: ctor/init created to be used by derived class - * - * Revision 1.4 2001/09/25 14:23:42 peiyongz - * DTV Reorganization: checkValueSpace() - * - * Revision 1.3 2001/08/14 22:11:56 peiyongz - * new exception message added - * - * Revision 1.2 2001/07/24 21:23:40 tng - * Schema: Use DatatypeValidator for ID/IDREF/ENTITY/ENTITIES/NOTATION. - * - * Revision 1.1 2001/07/04 14:38:25 peiyongz - * IDDatatypeValidator: created - * DatatypeValidatorFactory: IDDTV enabled - * XMLString:isValidName(): to validate Name (XML [4][5]) - * - */ - -// --------------------------------------------------------------------------- -// Includes -// --------------------------------------------------------------------------- -#include <validators/datatype/IDDatatypeValidator.hpp> -#include <validators/datatype/InvalidDatatypeValueException.hpp> - -// --------------------------------------------------------------------------- -// Constructors and Destructor -// --------------------------------------------------------------------------- -IDDatatypeValidator::IDDatatypeValidator() -:StringDatatypeValidator(0, 0, 0, DatatypeValidator::ID) -,fIDRefList(0) -{} - -IDDatatypeValidator::IDDatatypeValidator( - DatatypeValidator* const baseValidator - , RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet) -:StringDatatypeValidator(baseValidator, facets, finalSet, DatatypeValidator::ID) -,fIDRefList(0) -{ - init(enums); -} - -IDDatatypeValidator::~IDDatatypeValidator() -{} - -DatatypeValidator* IDDatatypeValidator::newInstance( - RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet) -{ - return (DatatypeValidator*) new IDDatatypeValidator(this, facets, enums, finalSet); -} - -IDDatatypeValidator::IDDatatypeValidator( - DatatypeValidator* const baseValidator - , RefHashTableOf<KVStringPair>* const facets - , const int finalSet - , const ValidatorType type) -:StringDatatypeValidator(baseValidator, facets, finalSet, type) -,fIDRefList(0) -{ - // do not invoke init() here!!! -} - -void IDDatatypeValidator::validate(const XMLCh* const content) -{ - // use StringDatatypeValidator (which in turn, invoke - // the baseValidator) to validate content against - // facets if any. - // - StringDatatypeValidator::validate(content); - - // storing IDs to the global ID table - if (fIDRefList) - addId(content); -} - -void IDDatatypeValidator::addId(const XMLCh * const content) -{ - XMLRefInfo* find = fIDRefList->get(content); - if (find) - { - if (find->getDeclared()) - { - ThrowXML1(InvalidDatatypeValueException - , XMLExcepts::VALUE_ID_Not_Unique - , content); - } - } - else - { - find = new XMLRefInfo(content); - fIDRefList->put((void*)find->getRefName(), find); - } - - // - // Mark it declared - // - find->setDeclared(true); -} - -void IDDatatypeValidator::checkValueSpace(const XMLCh* const content) -{ - // - // 3.3.8 check must: "NCName" - // - if ( !XMLString::isValidNCName(content)) - { - ThrowXML1(InvalidDatatypeValueException - , XMLExcepts::VALUE_Invalid_NCName - , content); - } - -} - -/** - * End of file IDDatatypeValidator.cpp - */ diff --git a/src/validators/datatype/IDDatatypeValidator.hpp b/src/validators/datatype/IDDatatypeValidator.hpp deleted file mode 100644 index 3983ec30b997b40a54ad562329c986471a9d2b59..0000000000000000000000000000000000000000 --- a/src/validators/datatype/IDDatatypeValidator.hpp +++ /dev/null @@ -1,179 +0,0 @@ -/* - * 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.8 2001/11/22 20:23:20 peiyongz - * _declspec(dllimport) and inline warning C4273 - * - * Revision 1.7 2001/10/09 20:50:02 peiyongz - * init(): take 1 arg - * - * Revision 1.6 2001/09/27 13:51:25 peiyongz - * DTV Reorganization: ctor/init created to be used by derived class - * - * Revision 1.5 2001/09/25 14:23:42 peiyongz - * DTV Reorganization: checkValueSpace() - * - * Revision 1.4 2001/08/24 17:12:01 knoaman - * Add support for anySimpleType. - * Remove parameter 'baseValidator' from the virtual method 'newInstance'. - * - * Revision 1.3 2001/07/25 17:58:08 tng - * Fix compilation errors. - * - * Revision 1.2 2001/07/24 21:23:40 tng - * Schema: Use DatatypeValidator for ID/IDREF/ENTITY/ENTITIES/NOTATION. - * - * Revision 1.1 2001/07/04 14:38:25 peiyongz - * IDDatatypeValidator: created - * DatatypeValidatorFactory: IDDTV enabled - * XMLString:isValidName(): to validate Name (XML [4][5]) - * - */ - -#if !defined(ID_DATATYPEVALIDATOR_HPP) -#define ID_DATATYPEVALIDATOR_HPP - -#include <validators/datatype/StringDatatypeValidator.hpp> -#include <validators/schema/SchemaSymbols.hpp> -#include <framework/XMLRefInfo.hpp> - -class VALIDATORS_EXPORT IDDatatypeValidator : public StringDatatypeValidator -{ -public: - - // ----------------------------------------------------------------------- - // Public ctor/dtor - // ----------------------------------------------------------------------- - /** @name Constructor. */ - //@{ - - IDDatatypeValidator(); - - IDDatatypeValidator(DatatypeValidator* const baseValidator - , RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet); - - virtual ~IDDatatypeValidator(); - - //@} - - // ----------------------------------------------------------------------- - // Validation methods - // ----------------------------------------------------------------------- - /** @name Validation Function */ - //@{ - - /** - * validate that a string matches the boolean datatype - * @param content A string containing the content to be validated - * - * @exception throws InvalidDatatypeException if the content is - * is not valid. - */ - - virtual void validate(const XMLCh* const content); - - /** - * Returns an instance of the base datatype validator class - * Used by the DatatypeValidatorFactory. - */ - virtual DatatypeValidator* newInstance(RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet); - - //@} - - inline void setIDRefList(RefHashTableOf<XMLRefInfo>* fIDRefList); - -protected: - - // - // ctor provided to be used by derived classes - // - IDDatatypeValidator(DatatypeValidator* const baseValidator - , RefHashTableOf<KVStringPair>* const facets - , const int finalSet - , const ValidatorType type); - - virtual void checkValueSpace(const XMLCh* const content); - -private: - - void addId(const XMLCh* const); - - // ----------------------------------------------------------------------- - // Private data members - // - // fIDRefList - // we do not own it. - // - // ----------------------------------------------------------------------- - RefHashTableOf<XMLRefInfo>* fIDRefList; -}; - -inline void IDDatatypeValidator::setIDRefList(RefHashTableOf<XMLRefInfo>* newIDRefList) -{ - fIDRefList = newIDRefList; -} - -/** - * End of file IDDatatypeValidator.hpp - */ -#endif diff --git a/src/validators/datatype/IDREFDatatypeValidator.cpp b/src/validators/datatype/IDREFDatatypeValidator.cpp deleted file mode 100644 index e638d8216781ae82c65913f7723ba236276e95ff..0000000000000000000000000000000000000000 --- a/src/validators/datatype/IDREFDatatypeValidator.cpp +++ /dev/null @@ -1,176 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999-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/>. - */ - -/* - * $Id$ - * $Log$ - * Revision 1.6 2001/10/09 20:49:38 peiyongz - * init(): take 1 arg - * - * Revision 1.5 2001/09/27 13:51:25 peiyongz - * DTV Reorganization: ctor/init created to be used by derived class - * - * Revision 1.4 2001/09/25 14:23:42 peiyongz - * DTV Reorganization: checkValueSpace() - * - * Revision 1.3 2001/08/14 22:11:56 peiyongz - * new exception message added - * - * Revision 1.2 2001/07/24 21:23:40 tng - * Schema: Use DatatypeValidator for ID/IDREF/ENTITY/ENTITIES/NOTATION. - * - * Revision 1.1 2001/07/04 20:16:59 peiyongz - * IDREFDatatypeValidator - * - */ - -// --------------------------------------------------------------------------- -// Includes -// --------------------------------------------------------------------------- -#include <validators/datatype/IDREFDatatypeValidator.hpp> -#include <validators/datatype/InvalidDatatypeValueException.hpp> - -// --------------------------------------------------------------------------- -// Constructors and Destructor -// --------------------------------------------------------------------------- -IDREFDatatypeValidator::IDREFDatatypeValidator() -:StringDatatypeValidator(0, 0, 0, DatatypeValidator::IDREF) -,fIDRefList(0) -{} - -IDREFDatatypeValidator::IDREFDatatypeValidator( - DatatypeValidator* const baseValidator - , RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet) -:StringDatatypeValidator(baseValidator, facets, finalSet, DatatypeValidator::IDREF) -,fIDRefList(0) -{ - init(enums); -} - -IDREFDatatypeValidator::~IDREFDatatypeValidator() -{} - -DatatypeValidator* IDREFDatatypeValidator::newInstance( - RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet) -{ - return (DatatypeValidator*) new IDREFDatatypeValidator(this, facets, enums, finalSet); -} - -IDREFDatatypeValidator::IDREFDatatypeValidator( - DatatypeValidator* const baseValidator - , RefHashTableOf<KVStringPair>* const facets - , const int finalSet - , const ValidatorType type) -:StringDatatypeValidator(baseValidator, facets, finalSet, type) -,fIDRefList(0) -{ - // do not invoke init() here!!! -} - -void IDREFDatatypeValidator::validate(const XMLCh* const content) -{ - // use StringDatatypeValidator (which in turn, invoke - // the baseValidator) to validate content against - // facets if any. - // - StringDatatypeValidator::validate(content); - - // this is different from java, since we always add, while - // in java, it is done as told. REVISIT. - // - if (fIDRefList) - addIdRef(content); -} - -// -// Add an IDREF to the fIDRefList -// -void IDREFDatatypeValidator::addIdRef(const XMLCh* const content) -{ - XMLRefInfo* find = fIDRefList->get(content); - if (!find) - { - find = new XMLRefInfo(content); - fIDRefList->put((void*)find->getRefName(), find); - } - - // - // Mark it used - // - find->setUsed(true); -} - -void IDREFDatatypeValidator::checkValueSpace(const XMLCh* const content) -{ - // - // 3.3.9 check must: "NCName" - // - if ( !XMLString::isValidNCName(content)) - { - ThrowXML1(InvalidDatatypeValueException - , XMLExcepts::VALUE_Invalid_NCName - , content); - } - -} - -/** - * End of file IDREFDatatypeValidator.cpp - */ diff --git a/src/validators/datatype/IDREFDatatypeValidator.hpp b/src/validators/datatype/IDREFDatatypeValidator.hpp deleted file mode 100644 index 703918d109945724caa1c5d7fdc1474bc79523c3..0000000000000000000000000000000000000000 --- a/src/validators/datatype/IDREFDatatypeValidator.hpp +++ /dev/null @@ -1,180 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999-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/>. - */ - -/* - * $Id$ - * $Log$ - * Revision 1.8 2001/11/22 20:23:20 peiyongz - * _declspec(dllimport) and inline warning C4273 - * - * Revision 1.7 2001/10/09 20:49:38 peiyongz - * init(): take 1 arg - * - * Revision 1.6 2001/09/27 13:51:25 peiyongz - * DTV Reorganization: ctor/init created to be used by derived class - * - * Revision 1.5 2001/09/25 14:23:42 peiyongz - * DTV Reorganization: checkValueSpace() - * - * Revision 1.4 2001/08/24 17:12:01 knoaman - * Add support for anySimpleType. - * Remove parameter 'baseValidator' from the virtual method 'newInstance'. - * - * Revision 1.3 2001/07/25 17:58:08 tng - * Fix compilation errors. - * - * Revision 1.2 2001/07/24 21:23:40 tng - * Schema: Use DatatypeValidator for ID/IDREF/ENTITY/ENTITIES/NOTATION. - * - * Revision 1.1 2001/07/04 20:16:59 peiyongz - * IDREFDatatypeValidator - * - */ - -#if !defined(IDREF_DATATYPEVALIDATOR_HPP) -#define IDREF_DATATYPEVALIDATOR_HPP - -#include <validators/datatype/StringDatatypeValidator.hpp> -#include <framework/XMLRefInfo.hpp> - -class VALIDATORS_EXPORT IDREFDatatypeValidator : public StringDatatypeValidator -{ -public: - - // ----------------------------------------------------------------------- - // Public ctor/dtor - // ----------------------------------------------------------------------- - /** @name Constructor. */ - //@{ - - IDREFDatatypeValidator(); - - IDREFDatatypeValidator(DatatypeValidator* const baseValidator - , RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet); - - virtual ~IDREFDatatypeValidator(); - - //@} - - // ----------------------------------------------------------------------- - // Validation methods - // ----------------------------------------------------------------------- - /** @name Validation Function */ - //@{ - - /** - * validate that a string matches the boolean datatype - * @param content A string containing the content to be validated - * - * @exception throws InvalidDatatypeException if the content is - * is not valid. - */ - - virtual void validate(const XMLCh* const content); - - //@} - - /** - * Returns an instance of the base datatype validator class - * Used by the DatatypeValidatorFactory. - */ - virtual DatatypeValidator* newInstance(RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet); - - inline void setIDRefList(RefHashTableOf<XMLRefInfo>* fIDRefList); - -protected: - - // - // ctor provided to be used by derived classes - // - IDREFDatatypeValidator(DatatypeValidator* const baseValidator - , RefHashTableOf<KVStringPair>* const facets - , const int finalSet - , const ValidatorType type); - - virtual void checkValueSpace(const XMLCh* const content); - -private: - - void addIdRef(const XMLCh* const content); - - // ----------------------------------------------------------------------- - // Private data members - // - // fIDRefList - // we do not own it. - // - // ----------------------------------------------------------------------- - RefHashTableOf<XMLRefInfo>* fIDRefList; - -}; - -// ----------------------------------------------------------------------- -// Validation methods -// ----------------------------------------------------------------------- -inline void IDREFDatatypeValidator::setIDRefList(RefHashTableOf<XMLRefInfo>* newIDRefList) -{ - fIDRefList = newIDRefList; -} - -/** - * End of file IDREFDatatypeValidator.hpp - */ -#endif diff --git a/src/validators/datatype/InvalidDatatypeFacetException.hpp b/src/validators/datatype/InvalidDatatypeFacetException.hpp deleted file mode 100644 index e665c96b59eb929298246ccd3f86690831f58336..0000000000000000000000000000000000000000 --- a/src/validators/datatype/InvalidDatatypeFacetException.hpp +++ /dev/null @@ -1,71 +0,0 @@ -/* - * 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$ - */ - - -#if !defined(INVALIDDATATYPEFACETEXCEPTION_HPP) -#define INVALIDDATATYPEFACETEXCEPTION_HPP - -#include <util/XercesDefs.hpp> -#include <util/XMLException.hpp> - - -MakeXMLException(InvalidDatatypeFacetException, XMLUTIL_EXPORT) - -#endif diff --git a/src/validators/datatype/InvalidDatatypeValueException.hpp b/src/validators/datatype/InvalidDatatypeValueException.hpp deleted file mode 100644 index 2206573e55c86388a557893884847d805f8b307c..0000000000000000000000000000000000000000 --- a/src/validators/datatype/InvalidDatatypeValueException.hpp +++ /dev/null @@ -1,71 +0,0 @@ -/* - * 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$ - */ - - -#if !defined(INVALIDDATATYPEVALUEEXCEPTION_HPP) -#define INVALIDDATATYPEVALUEEXCEPTION_HPP - -#include <util/XercesDefs.hpp> -#include <util/XMLException.hpp> - - -MakeXMLException(InvalidDatatypeValueException, XMLUTIL_EXPORT) - -#endif diff --git a/src/validators/datatype/ListDatatypeValidator.cpp b/src/validators/datatype/ListDatatypeValidator.cpp deleted file mode 100644 index b1cc76b71eb9c07b1920ba805f1aa06f2bbff00e..0000000000000000000000000000000000000000 --- a/src/validators/datatype/ListDatatypeValidator.cpp +++ /dev/null @@ -1,446 +0,0 @@ -/* - * 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.8 2001/10/11 19:32:27 peiyongz - * To overwrite inheritFacet() - * - * Revision 1.7 2001/10/09 20:56:21 peiyongz - * inherit from AbstractStringValidator instead of DatatypeValidator to reuse - * the code. - * - * Revision 1.6 2001/10/02 18:59:29 peiyongz - * Invalid_Facet_Tag to display the tag name - * - * Revision 1.5 2001/09/20 13:11:42 knoaman - * Regx + misc. fixes - * - * Revision 1.4 2001/08/29 19:03:40 peiyongz - * Bugzilla# 2816:on AIX 4.2, xlC 3 r ev.1, Compilation error on inline method - * - * Revision 1.3 2001/08/21 18:42:53 peiyongz - * Bugzilla# 2816: cleanUp() declared with external linkage and called - * before defined as inline - * - * Revision 1.2 2001/08/14 22:11:56 peiyongz - * new exception message added - * - * Revision 1.1 2001/07/11 21:37:17 peiyongz - * ListDatatypeDTV - * - * - */ - -// --------------------------------------------------------------------------- -// Includes -// --------------------------------------------------------------------------- -#include <validators/datatype/ListDatatypeValidator.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 -// --------------------------------------------------------------------------- -ListDatatypeValidator::ListDatatypeValidator() -:AbstractStringValidator(0, 0, 0, DatatypeValidator::List) -,fContent(0) -{} - -ListDatatypeValidator::ListDatatypeValidator( - DatatypeValidator* const baseValidator - , RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet) -:AbstractStringValidator(baseValidator, facets, finalSet, DatatypeValidator::List) -,fContent(0) -{ - // - // baseValidator shall either - // an atomic DTV which servers as itemType, or - // another ListDTV from which, this ListDTV is derived by restriction. - // - // In either case, it shall be not null - // - if (!baseValidator) - ThrowXML(InvalidDatatypeFacetException, XMLExcepts::FACET_List_Null_baseValidator); - - init(enums); -} - -ListDatatypeValidator::~ListDatatypeValidator() -{} - -DatatypeValidator* ListDatatypeValidator::newInstance( - RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet) -{ - return (DatatypeValidator*) new ListDatatypeValidator(this, facets, enums, finalSet); -} - - -int ListDatatypeValidator::compare(const XMLCh* const lValue - , const XMLCh* const rValue) -{ - DatatypeValidator* theItemTypeDTV = getItemTypeDTV(); - RefVectorOf<XMLCh>* lVector = XMLString::tokenizeString(lValue); - Janitor<RefVectorOf<XMLCh> > janl(lVector); - RefVectorOf<XMLCh>* rVector = XMLString::tokenizeString(rValue); - Janitor<RefVectorOf<XMLCh> > janr(rVector); - - int lNumberOfTokens = lVector->size(); - int rNumberOfTokens = rVector->size(); - - if (lNumberOfTokens < rNumberOfTokens) - return -1; - else if (lNumberOfTokens > rNumberOfTokens) - return 1; - else - { //compare each token - for ( int i = 0; i < lNumberOfTokens; i++) - { - int returnValue = theItemTypeDTV->compare(lVector->elementAt(i), rVector->elementAt(i)); - if (returnValue != 0) - return returnValue; //REVISIT: does it make sense to return -1 or +1..? - } - return 0; - } - -} - -bool ListDatatypeValidator::isAtomic() const { - return false; -} - -void ListDatatypeValidator::validate( const XMLCh* const content) -{ - setContent(content); - RefVectorOf<XMLCh>* tokenVector = XMLString::tokenizeString(content); - Janitor<RefVectorOf<XMLCh> > janName(tokenVector); - checkContent(tokenVector, false); -} - -void ListDatatypeValidator::checkContent( const XMLCh* const content, bool asBase) -{ - setContent(content); - RefVectorOf<XMLCh>* tokenVector = XMLString::tokenizeString(content); - Janitor<RefVectorOf<XMLCh> > janName(tokenVector); - checkContent(tokenVector, asBase); -} - -// -// here content is a list of items -// -void ListDatatypeValidator::checkContent( RefVectorOf<XMLCh>* tokenVector, bool asBase) -{ - DatatypeValidator* bv = getBaseValidator(); - - if (bv->getType() == DatatypeValidator::List) - ((ListDatatypeValidator*)bv)->checkContent(tokenVector, true); - else - { // the ultimate itemType DTV - for (unsigned int i = 0; i < tokenVector->size(); i++) - bv->validate(tokenVector->elementAt(i)); - } - - int thisFacetsDefined = getFacetsDefined(); - - // we check pattern first - if ( (thisFacetsDefined & 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()); - } - } - - //check each and every item in the list - for (unsigned int i = 0; i < tokenVector->size(); i++) - { - if (getRegex()->matches(tokenVector->elementAt(i)) ==false) - { - ThrowXML2(InvalidDatatypeValueException - , XMLExcepts::VALUE_NotMatch_Pattern - , tokenVector->elementAt(i) - , 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; - - unsigned int tokenNumber = tokenVector->size(); - - if (((thisFacetsDefined & DatatypeValidator::FACET_MAXLENGTH) != 0) && - (tokenNumber > getMaxLength())) - { - XMLString::binToText(tokenNumber, value1, BUF_LEN, 10); - XMLString::binToText(getMaxLength(), value2, BUF_LEN, 10); - - ThrowXML3(InvalidDatatypeValueException - , XMLExcepts::VALUE_GT_maxLen - , getContent() - , value1 - , value2); - } - - if (((thisFacetsDefined & DatatypeValidator::FACET_MINLENGTH) != 0) && - (tokenNumber < getMinLength())) - { - XMLString::binToText(tokenNumber, value1, BUF_LEN, 10); - XMLString::binToText(getMinLength(), value2, BUF_LEN, 10); - - ThrowXML3(InvalidDatatypeValueException - , XMLExcepts::VALUE_LT_minLen - , getContent() - , value1 - , value2); - } - - if (((thisFacetsDefined & DatatypeValidator::FACET_LENGTH) != 0) && - (tokenNumber != AbstractStringValidator::getLength())) - { - XMLString::binToText(tokenNumber, value1, BUF_LEN, 10); - XMLString::binToText(AbstractStringValidator::getLength(), value2, BUF_LEN, 10); - - ThrowXML3(InvalidDatatypeValueException - , XMLExcepts::VALUE_NE_Len - , getContent() - , value1 - , value2); - } - - if ((thisFacetsDefined & DatatypeValidator::FACET_ENUMERATION) != 0 && - (getEnumeration() != 0)) - { - int i; - int enumLength = getEnumeration()->size(); - - for ( i = 0; i < enumLength; i++) - { - //optimization: we do a lexical comparision first - // this may be faster for string and its derived - if (XMLString::compareString(getEnumeration()->elementAt(i), getContent()) == 0) - break; // a match found - - // do a value space check - // this is needed for decimal (and probably other types - // such as datetime related) - // eg. - // tokenVector = "1 2 3.0 4" vs enumeration = "1 2 3 4.0" - // - if (valueSpaceCheck(tokenVector, getEnumeration()->elementAt(i))) - break; - } - - if (i == enumLength) - ThrowXML1(InvalidDatatypeValueException, XMLExcepts::VALUE_NotIn_Enumeration, getContent()); - - } // enumeration - -} - -bool ListDatatypeValidator::valueSpaceCheck(RefVectorOf<XMLCh>* tokenVector - , const XMLCh* const enumStr) const -{ - DatatypeValidator* theItemTypeDTV = getItemTypeDTV(); - RefVectorOf<XMLCh>* enumVector = XMLString::tokenizeString(enumStr); - Janitor<RefVectorOf<XMLCh> > janName(enumVector); - - if (tokenVector->size() != enumVector->size()) - return false; - - for ( unsigned int j = 0; j < tokenVector->size(); j++ ) - { - if (theItemTypeDTV->compare(tokenVector->elementAt(j), enumVector->elementAt(j)) != 0) - return false; - } - - return true; -} - -DatatypeValidator* ListDatatypeValidator::getItemTypeDTV() const -{ - DatatypeValidator* bdv = this->getBaseValidator(); - - while (bdv->getType() == DatatypeValidator::List) - bdv = bdv->getBaseValidator(); - - return bdv; -} - -// --------------------------------------------------------------------------- -// Utilities -// --------------------------------------------------------------------------- -void ListDatatypeValidator::assignAdditionalFacet( const XMLCh* const key - , const XMLCh* const) -{ - ThrowXML1(InvalidDatatypeFacetException - , XMLExcepts::FACET_Invalid_Tag - , key); -} - -void ListDatatypeValidator::inheritAdditionalFacet() -{} - -void ListDatatypeValidator::checkAdditionalFacetConstraints() const -{} - -void ListDatatypeValidator::checkAdditionalFacet(const XMLCh* const) const -{} - -void ListDatatypeValidator::checkValueSpace(const XMLCh* const content) -{} - -int ListDatatypeValidator::getLength(const XMLCh* const content) const -{ - RefVectorOf<XMLCh>* tokenVector = XMLString::tokenizeString(content); - Janitor<RefVectorOf<XMLCh> > janName(tokenVector); - - return tokenVector->size(); -} - -void ListDatatypeValidator::inspectFacetBase() -{ - - // - // we are pretty sure baseValidator is not null - // - - if (getBaseValidator()->getType() == DatatypeValidator::List) - { - AbstractStringValidator::inspectFacetBase(); - } - else - { - // the first level ListDTV - // check 4.3.5.c0 must: enumeration values from the value space of base - if ( ((getFacetsDefined() & DatatypeValidator::FACET_ENUMERATION) != 0) && - (getEnumeration() !=0) ) - { - int i; - int enumLength = getEnumeration()->size(); - try - { - for ( i = 0; i < enumLength; i++) - { - // ask the itemType for a complete check - RefVectorOf<XMLCh>* tempList = XMLString::tokenizeString(getEnumeration()->elementAt(i)); - int tokenNumber = tempList->size(); - - try - { - for ( int j = 0; j < tokenNumber; j++) - getBaseValidator()->validate(tempList->elementAt(j)); - } - catch (...) - { - delete tempList; - throw; - } - - delete tempList; - - // enum shall pass this->checkContent() as well. - checkContent(getEnumeration()->elementAt(i), false); - } - } - - catch ( XMLException& ) - { - ThrowXML1(InvalidDatatypeFacetException - , XMLExcepts::FACET_enum_base - , getEnumeration()->elementAt(i)); - } - - } - - } - -}// End of inspectFacetBase() - -void ListDatatypeValidator::inheritFacet() -{ - - //iff the base validator is List, then we inherit - // - if (getBaseValidator()->getType() == DatatypeValidator::List) - { - AbstractStringValidator::inheritFacet(); - } - -} - -/** - * End of file ListDatatypeValidator.cpp - */ diff --git a/src/validators/datatype/ListDatatypeValidator.hpp b/src/validators/datatype/ListDatatypeValidator.hpp deleted file mode 100644 index d938ac7f6374d55c1f79541e3d9b367204332229..0000000000000000000000000000000000000000 --- a/src/validators/datatype/ListDatatypeValidator.hpp +++ /dev/null @@ -1,252 +0,0 @@ -/* - * 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.11 2001/11/22 20:23:20 peiyongz - * _declspec(dllimport) and inline warning C4273 - * - * Revision 1.10 2001/11/15 16:08:15 peiyongz - * checkContent() made virtual to allow ListDTV participate in the building of - * its own (in AbstractStringValidator's init()) - * - * Revision 1.9 2001/10/11 19:32:27 peiyongz - * To overwrite inheritFacet() - * - * Revision 1.8 2001/10/09 20:56:21 peiyongz - * inherit from AbstractStringValidator instead of DatatypeValidator to reuse - * the code. - * - * Revision 1.7 2001/08/29 19:03:40 peiyongz - * Bugzilla# 2816:on AIX 4.2, xlC 3 r ev.1, Compilation error on inline method - * - * Revision 1.6 2001/08/24 17:12:01 knoaman - * Add support for anySimpleType. - * Remove parameter 'baseValidator' from the virtual method 'newInstance'. - * - * Revision 1.5 2001/08/21 20:05:41 peiyongz - * put back changes introduced in 1.3 - * - * Revision 1.3 2001/08/16 14:41:38 knoaman - * implementation of virtual methods. - * - * Revision 1.2 2001/07/24 21:23:40 tng - * Schema: Use DatatypeValidator for ID/IDREF/ENTITY/ENTITIES/NOTATION. - * - * Revision 1.1 2001/07/11 21:37:17 peiyongz - * ListDatatypeDTV - * - */ - -#if !defined(LIST_DATATYPEVALIDATOR_HPP) -#define LIST_DATATYPEVALIDATOR_HPP - -#include <validators/datatype/AbstractStringValidator.hpp> -#include <validators/schema/SchemaSymbols.hpp> - -class VALIDATORS_EXPORT ListDatatypeValidator : public AbstractStringValidator -{ -public: - - // ----------------------------------------------------------------------- - // Public ctor/dtor - // ----------------------------------------------------------------------- - /** @name Constructor. */ - //@{ - - ListDatatypeValidator(); - - ListDatatypeValidator(DatatypeValidator* const baseValidator - , RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet); - - virtual ~ListDatatypeValidator(); - - //@} - - /** @name Getter Functions */ - //@{ - /** - * Returns whether the type is atomic or not - */ - virtual bool isAtomic() const; - //@} - - // ----------------------------------------------------------------------- - // Validation methods - // ----------------------------------------------------------------------- - /** @name Validation Function */ - //@{ - - /** - * validate that a string matches the boolean datatype - * @param content A string containing the content to be validated - * - * @exception throws InvalidDatatypeException if the content is - * is not valid. - */ - - 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. - */ - virtual DatatypeValidator* newInstance(RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet); - - DatatypeValidator* getItemTypeDTV() const; - -protected: - - // - // ctor provided to be used by derived classes: No - // - - virtual void assignAdditionalFacet(const XMLCh* const key - , const XMLCh* const value); - - virtual void inheritAdditionalFacet(); - - virtual void checkAdditionalFacetConstraints() const; - - virtual void checkAdditionalFacet(const XMLCh* const content) const; - - virtual void checkValueSpace(const XMLCh* const content); - - virtual int getLength(const XMLCh* const content) const; - - // - // Overwrite AbstractStringValidator's - // - virtual void inspectFacetBase(); - - virtual void inheritFacet(); - - void checkContent(const XMLCh* const content, bool asBase); - -private: - - void checkContent(RefVectorOf<XMLCh>* tokenVector, bool asBase); - - bool valueSpaceCheck(RefVectorOf<XMLCh>* tokenVector - , const XMLCh* const enumStr) const; - -// ----------------------------------------------------------------------- -// Getter methods -// ----------------------------------------------------------------------- - - inline const XMLCh* const getContent() const; - -// ----------------------------------------------------------------------- -// Setter methods -// ----------------------------------------------------------------------- - - inline void setContent(const XMLCh* const content); - - // ----------------------------------------------------------------------- - // Private data members - // - // fContent - // temporary var referenceing the content to be validated, - // for error reporting purpose. - // - // ----------------------------------------------------------------------- - const XMLCh* fContent; -}; - -// ----------------------------------------------------------------------- -// Getter methods -// ----------------------------------------------------------------------- -inline const XMLCh* const ListDatatypeValidator::getContent() const -{ - return fContent; -} - -// ----------------------------------------------------------------------- -// Setter methods -// ----------------------------------------------------------------------- -inline void ListDatatypeValidator::setContent(const XMLCh* const content) -{ - fContent = content; -} - -/** - * End of file ListDatatypeValidator.hpp - */ -#endif diff --git a/src/validators/datatype/Makefile.in b/src/validators/datatype/Makefile.in deleted file mode 100644 index 99e9ecae755e5558473b5a5cff7030863dc46751..0000000000000000000000000000000000000000 --- a/src/validators/datatype/Makefile.in +++ /dev/null @@ -1,248 +0,0 @@ -# -# 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$ -# Revision 1.22 2001/11/07 19:18:52 peiyongz -# DateTime Port -# -# Revision 1.21 2001/10/01 16:14:22 peiyongz -# DTV Reorganization:new classes: AbstractNumericFactValidator/ AbstractNumericValidator -# -# Revision 1.20 2001/09/25 16:08:26 peiyongz -# DTV Reorganization: Create native NameDTV and NCNameDTV -# -# Revision 1.19 2001/09/18 16:00:54 peiyongz -# DTV reorganization: AbstractStringValidator -# -# Revision 1.18 2001/08/24 17:12:01 knoaman -# Add support for anySimpleType. -# Remove parameter 'baseValidator' from the virtual method 'newInstance'. -# -# Revision 1.17 2001/08/01 18:49:16 peiyongz -# AnyRUIDatatypeValidator -# -# Revision 1.16 2001/07/26 20:40:56 peiyongz -# FloatDatatypeValidator -# -# Revision 1.15 2001/07/24 13:59:03 peiyongz -# DoubleDTV -# -# Revision 1.14 2001/07/13 14:10:37 peiyongz -# UnionDTV -# -# Revision 1.13 2001/07/11 21:37:15 peiyongz -# ListDatatypeDTV -# -# Revision 1.12 2001/07/06 20:21:46 peiyongz -# QNameDTV & ENTITYDTV enabled -# -# Revision 1.11 2001/07/06 17:12:11 tng -# Automatic build of single-threaded library. By Martin Kalen. -# -# Revision 1.10 2001/07/05 20:15:26 peiyongz -# NOTATIONDatatypeValidator -# -# Revision 1.9 2001/07/04 20:16:31 peiyongz -# IDREFDatatypeValidator -# -# Revision 1.8 2001/07/04 15:22:55 peiyongz -# IDDatatypeValidator -# -# Revision 1.7 2001/06/27 17:09:52 tng -# [Bug 1147] Headers install in wrong directory. By Murray Cumming. -# -# Revision 1.6 2001/05/16 15:24:44 tng -# Schema: Add Base64 and HexBin. By Pei Yong Zhang. -# -# Revision 1.5 2001/05/11 13:27:29 tng -# Copyright update. -# -# Revision 1.4 2001/05/10 20:51:31 tng -# Schema: Add DecimalDatatypeValidator and XMLBigDecimal, XMLBigInteger. By Pei Yong Zhang. -# -# Revision 1.3 2001/05/09 18:43:41 tng -# Add StringDatatypeValidator and BooleanDatatypeValidator. By Pei Yong Zhang. -# -# Revision 1.2 2001/03/21 21:39:15 knoaman -# Schema symbols and Datatype validator part I -# -# Revision 1.1 2001/02/15 18:41:50 tng -# Schema: Exception Handling added by Pei Yong Zhang. Add NumberFormatException, ParseException, -# InvalidDatatypeFacetException, and InvalidDatatypeValueException. The associated -# Makefile.in and configure.in are updated. -# -# - -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 = datatype - -VALIDATORS_DATATYPE_CPP_PUBHEADERS = \ - InvalidDatatypeFacetException.hpp \ - InvalidDatatypeValueException.hpp \ - DatatypeValidator.hpp \ - DatatypeValidatorFactory.hpp \ - Base64BinaryDatatypeValidator.hpp \ - BooleanDatatypeValidator.hpp \ - DecimalDatatypeValidator.hpp \ - HexBinaryDatatypeValidator.hpp \ - StringDatatypeValidator.hpp \ - IDDatatypeValidator.hpp \ - NOTATIONDatatypeValidator.hpp \ - ENTITYDatatypeValidator.hpp \ - QNameDatatypeValidator.hpp \ - NameDatatypeValidator.hpp \ - NCNameDatatypeValidator.hpp \ - ListDatatypeValidator.hpp \ - UnionDatatypeValidator.hpp \ - DoubleDatatypeValidator.hpp \ - FloatDatatypeValidator.hpp \ - AnyURIDatatypeValidator.hpp \ - IDREFDatatypeValidator.hpp \ - AnySimpleTypeDatatypeValidator.hpp \ - AbstractNumericFacetValidator.hpp \ - AbstractNumericValidator.hpp \ - AbstractStringValidator.hpp \ - DateTimeValidator.hpp \ - DateTimeDatatypeValidator.hpp \ - DateDatatypeValidator.hpp \ - TimeDatatypeValidator.hpp \ - DayDatatypeValidator.hpp \ - MonthDatatypeValidator.hpp \ - MonthDayDatatypeValidator.hpp \ - YearDatatypeValidator.hpp \ - YearMonthDatatypeValidator.hpp \ - DurationDatatypeValidator.hpp - -VALIDATORS_DATATYPE_CPP_PRIVHEADERS = - -VALIDATORS_DATATYPE_C_FILES = - -VALIDATORS_DATATYPE_CPP_OBJECTS = \ - DatatypeValidator.$(TO) \ - DatatypeValidatorFactory.$(TO) \ - Base64BinaryDatatypeValidator.$(TO) \ - BooleanDatatypeValidator.$(TO) \ - DecimalDatatypeValidator.$(TO) \ - HexBinaryDatatypeValidator.$(TO) \ - StringDatatypeValidator.$(TO) \ - IDDatatypeValidator.$(TO) \ - NOTATIONDatatypeValidator.$(TO) \ - ENTITYDatatypeValidator.$(TO) \ - QNameDatatypeValidator.$(TO) \ - NameDatatypeValidator.$(TO) \ - NCNameDatatypeValidator.$(TO) \ - ListDatatypeValidator.$(TO) \ - UnionDatatypeValidator.$(TO) \ - DoubleDatatypeValidator.$(TO) \ - FloatDatatypeValidator.$(TO) \ - AnyURIDatatypeValidator.$(TO) \ - IDREFDatatypeValidator.$(TO) \ - AnySimpleTypeDatatypeValidator.$(TO) \ - AbstractNumericFacetValidator.$(TO) \ - AbstractNumericValidator.$(TO) \ - AbstractStringValidator.$(TO) \ - DateTimeValidator.$(TO) \ - DateTimeDatatypeValidator.$(TO) \ - DateDatatypeValidator.$(TO) \ - TimeDatatypeValidator.$(TO) \ - DayDatatypeValidator.$(TO) \ - MonthDatatypeValidator.$(TO) \ - MonthDayDatatypeValidator.$(TO) \ - YearDatatypeValidator.$(TO) \ - YearMonthDatatypeValidator.$(TO) \ - DurationDatatypeValidator.$(TO) - -all:: includes $(VALIDATORS_DATATYPE_CPP_OBJECTS) - -includes:: pubheaders $(VALIDATORS_DATATYPE_C_FILES) - -pubheaders:: - -mkdir -p $(XML_INC_DIR)/$(MODULE)/$(SUBMODULE) - $(CP) $(VALIDATORS_DATATYPE_CPP_PUBHEADERS) $(VALIDATORS_DATATYPE_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_DATATYPE_CPP_OBJECTS)) - -distclean:: clean - $(RM) Makefile $(DEPFILE) - @echo "Removing all $(MODULE)/$(SUBMODULE) header files ..." - $(RM2) $(addprefix $(XML_INC_DIR)/$(MODULE)/$(SUBMODULE)/,$(VALIDATORS_DATATYPE_CPP_PUBHEADERS)) - -install:: - -mkdir -p $(PREFIX_INCLUDE)/$(MODULE)/$(SUBMODULE) - $(CP) $(VALIDATORS_DATATYPE_CPP_PUBHEADERS) $(VALIDATORS_DATATYPE_C_FILES) $(PREFIX_INCLUDE)/$(MODULE)/$(SUBMODULE) diff --git a/src/validators/datatype/MonthDatatypeValidator.cpp b/src/validators/datatype/MonthDatatypeValidator.cpp deleted file mode 100644 index 7ca25d7beef7bd4a9c349c65bf3f884d132df52f..0000000000000000000000000000000000000000 --- a/src/validators/datatype/MonthDatatypeValidator.cpp +++ /dev/null @@ -1,127 +0,0 @@ -/* - * 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.3 2001/11/15 17:09:23 peiyongz - * catch(...) only. (the invoker need to cath XMLException to display proper message) - * - * Revision 1.2 2001/11/14 22:02:25 peiyongz - * rethrow exception with original error message. - * - * Revision 1.1 2001/11/07 19:18:52 peiyongz - * DateTime Port - * - */ - -// --------------------------------------------------------------------------- -// Includes -// --------------------------------------------------------------------------- -#include <validators/datatype/MonthDatatypeValidator.hpp> - -// --------------------------------------------------------------------------- -// Constructors and Destructor -// --------------------------------------------------------------------------- -MonthDatatypeValidator::MonthDatatypeValidator() -:DateTimeValidator(0, 0, 0, DatatypeValidator::Month) -{} - -MonthDatatypeValidator::MonthDatatypeValidator( - DatatypeValidator* const baseValidator - , RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet) -:DateTimeValidator(baseValidator, facets, finalSet, DatatypeValidator::Month) -{ - init(enums); -} - -MonthDatatypeValidator::~MonthDatatypeValidator() -{} - -DatatypeValidator* MonthDatatypeValidator::newInstance( - RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet) -{ - return (DatatypeValidator*) new MonthDatatypeValidator(this, facets, enums, finalSet); -} - -// -// caller need to release the date created here -// -XMLDateTime* MonthDatatypeValidator::parse(const XMLCh* const content) -{ - XMLDateTime *pRetDate = new XMLDateTime(content); - - try - { - pRetDate->parseMonth(); - } - catch (...) - { - delete pRetDate; - throw; - } - - return pRetDate; -} - -/** - * End of file MonthDatatypeValidator::cpp - */ - diff --git a/src/validators/datatype/MonthDatatypeValidator.hpp b/src/validators/datatype/MonthDatatypeValidator.hpp deleted file mode 100644 index b635e6f15eb23d8ca1be4523bddaa222e851f530..0000000000000000000000000000000000000000 --- a/src/validators/datatype/MonthDatatypeValidator.hpp +++ /dev/null @@ -1,112 +0,0 @@ -/* - * 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/11/07 19:18:52 peiyongz - * DateTime Port - * - */ - -#if !defined(MONTH_DATATYPE_VALIDATOR_HPP) -#define MONTH_DATATYPE_VALIDATOR_HPP - -#include <validators/datatype/DateTimeValidator.hpp> - -class VALIDATORS_EXPORT MonthDatatypeValidator : public DateTimeValidator -{ -public: - - // ----------------------------------------------------------------------- - // Public ctor/dtor - // ----------------------------------------------------------------------- - /** @name Constructor. */ - //@{ - - MonthDatatypeValidator(); - - MonthDatatypeValidator(DatatypeValidator* const baseValidator - , RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet); - - ~MonthDatatypeValidator(); - - - //@} - - /** - * Returns an instance of the base datatype validator class - * Used by the DatatypeValidatorFactory. - */ - virtual DatatypeValidator* newInstance(RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet); - -protected: - - // ----------------------------------------------------------------------- - // implementation of (DateTimeValidator's) virtual interface - // ----------------------------------------------------------------------- - virtual XMLDateTime* parse(const XMLCh* const); -}; - -/** - * End of file MonthDatatypeValidator.hpp - */ -#endif - diff --git a/src/validators/datatype/MonthDayDatatypeValidator.cpp b/src/validators/datatype/MonthDayDatatypeValidator.cpp deleted file mode 100644 index a74d6b13c89659096938e08c2de5240f64579cbc..0000000000000000000000000000000000000000 --- a/src/validators/datatype/MonthDayDatatypeValidator.cpp +++ /dev/null @@ -1,127 +0,0 @@ -/* - * 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.3 2001/11/15 17:09:23 peiyongz - * catch(...) only. (the invoker need to cath XMLException to display proper message) - * - * Revision 1.2 2001/11/14 22:02:25 peiyongz - * rethrow exception with original error message. - * - * Revision 1.1 2001/11/07 19:18:52 peiyongz - * DateTime Port - * - */ - -// --------------------------------------------------------------------------- -// Includes -// --------------------------------------------------------------------------- -#include <validators/datatype/MonthDayDatatypeValidator.hpp> - -// --------------------------------------------------------------------------- -// Constructors and Destructor -// --------------------------------------------------------------------------- -MonthDayDatatypeValidator::MonthDayDatatypeValidator() -:DateTimeValidator(0, 0, 0, DatatypeValidator::MonthDay) -{} - -MonthDayDatatypeValidator::MonthDayDatatypeValidator( - DatatypeValidator* const baseValidator - , RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet) -:DateTimeValidator(baseValidator, facets, finalSet, DatatypeValidator::MonthDay) -{ - init(enums); -} - -MonthDayDatatypeValidator::~MonthDayDatatypeValidator() -{} - -DatatypeValidator* MonthDayDatatypeValidator::newInstance( - RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet) -{ - return (DatatypeValidator*) new MonthDayDatatypeValidator(this, facets, enums, finalSet); -} - -// -// caller need to release the date created here -// -XMLDateTime* MonthDayDatatypeValidator::parse(const XMLCh* const content) -{ - XMLDateTime *pRetDate = new XMLDateTime(content); - - try - { - pRetDate->parseMonthDay(); - } - catch (...) - { - delete pRetDate; - throw; - } - - return pRetDate; -} - -/** - * End of file MonthDayDatatypeValidator::cpp - */ - diff --git a/src/validators/datatype/MonthDayDatatypeValidator.hpp b/src/validators/datatype/MonthDayDatatypeValidator.hpp deleted file mode 100644 index fc43428dca885d5b8f60b821a036af25dfdeba0f..0000000000000000000000000000000000000000 --- a/src/validators/datatype/MonthDayDatatypeValidator.hpp +++ /dev/null @@ -1,112 +0,0 @@ -/* - * 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/11/07 19:18:52 peiyongz - * DateTime Port - * - */ - -#if !defined(MONTHDAY_DATATYPE_VALIDATOR_HPP) -#define MONTHDAY_DATATYPE_VALIDATOR_HPP - -#include <validators/datatype/DateTimeValidator.hpp> - -class VALIDATORS_EXPORT MonthDayDatatypeValidator : public DateTimeValidator -{ -public: - - // ----------------------------------------------------------------------- - // Public ctor/dtor - // ----------------------------------------------------------------------- - /** @name Constructor. */ - //@{ - - MonthDayDatatypeValidator(); - - MonthDayDatatypeValidator(DatatypeValidator* const baseValidator - , RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet); - - ~MonthDayDatatypeValidator(); - - - //@} - - /** - * Returns an instance of the base datatype validator class - * Used by the DatatypeValidatorFactory. - */ - virtual DatatypeValidator* newInstance(RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet); - -protected: - - // ----------------------------------------------------------------------- - // implementation of (DateTimeValidator's) virtual interface - // ----------------------------------------------------------------------- - virtual XMLDateTime* parse(const XMLCh* const); -}; - -/** - * End of file MonthDayDatatypeValidator.hpp - */ -#endif - diff --git a/src/validators/datatype/NCNameDatatypeValidator.cpp b/src/validators/datatype/NCNameDatatypeValidator.cpp deleted file mode 100644 index 11f49bda26b698fa4f64d675ebdb0b31f37dec45..0000000000000000000000000000000000000000 --- a/src/validators/datatype/NCNameDatatypeValidator.cpp +++ /dev/null @@ -1,151 +0,0 @@ -/* - * 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/>. - */ - -/* - * $Id$ - * $Log$ - * Revision 1.3 2001/10/09 20:49:09 peiyongz - * init(): take 1 arg - * - * Revision 1.2 2001/09/27 13:51:25 peiyongz - * DTV Reorganization: ctor/init created to be used by derived class - * - * Revision 1.1 2001/09/25 15:58:45 peiyongz - * DTV Reorganization: new class - * - */ - -// --------------------------------------------------------------------------- -// Includes -// --------------------------------------------------------------------------- -#include <validators/datatype/NCNameDatatypeValidator.hpp> -#include <validators/datatype/InvalidDatatypeValueException.hpp> - -// --------------------------------------------------------------------------- -// Constructors and Destructor -// --------------------------------------------------------------------------- -NCNameDatatypeValidator::NCNameDatatypeValidator() -:StringDatatypeValidator(0, 0, 0, DatatypeValidator::NCName) -{} - -NCNameDatatypeValidator::~NCNameDatatypeValidator() -{} - -NCNameDatatypeValidator::NCNameDatatypeValidator( - DatatypeValidator* const baseValidator - , RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet) -:StringDatatypeValidator(baseValidator, facets, finalSet, DatatypeValidator::NCName) -{ - init(enums); -} - -DatatypeValidator* NCNameDatatypeValidator::newInstance( - RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet) -{ - return (DatatypeValidator*) new NCNameDatatypeValidator(this, facets, enums, finalSet); -} - -NCNameDatatypeValidator::NCNameDatatypeValidator( - DatatypeValidator* const baseValidator - , RefHashTableOf<KVStringPair>* const facets - , const int finalSet - , const ValidatorType type) -:StringDatatypeValidator(baseValidator, facets, finalSet, type) -{ - // do not invoke init() here!!! -} - -// ----------------------------------------------------------------------- -// Compare methods -// ----------------------------------------------------------------------- -int NCNameDatatypeValidator::compare(const XMLCh* const lValue - , const XMLCh* const rValue) -{ - return ( XMLString::compareString(lValue, rValue)==0 ? 0 : -1); -} - -void NCNameDatatypeValidator::validate(const XMLCh* const content) -{ - // use StringDatatypeValidator (which in turn, invoke - // the baseValidator) to validate content against - // facets if any. - // - StringDatatypeValidator::validate(content); - - return; -} - -void NCNameDatatypeValidator::checkValueSpace(const XMLCh* const content) -{ - // - // 3.3.7 check must: "NCName" - // - if ( !XMLString::isValidNCName(content)) - { - ThrowXML1(InvalidDatatypeValueException - , XMLExcepts::VALUE_Invalid_NCName - , content); - } - -} - - /** - * End of file NCNameDatatypeValidator.cpp - */ diff --git a/src/validators/datatype/NCNameDatatypeValidator.hpp b/src/validators/datatype/NCNameDatatypeValidator.hpp deleted file mode 100644 index 87d7d5ccf6872810018668007e854f615c960bac..0000000000000000000000000000000000000000 --- a/src/validators/datatype/NCNameDatatypeValidator.hpp +++ /dev/null @@ -1,165 +0,0 @@ -/* - * 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/>. - */ - -/* - * $Id$ - * $Log$ - * Revision 1.3 2001/10/09 20:49:09 peiyongz - * init(): take 1 arg - * - * Revision 1.2 2001/09/27 13:51:25 peiyongz - * DTV Reorganization: ctor/init created to be used by derived class - * - * Revision 1.1 2001/09/25 15:58:45 peiyongz - * DTV Reorganization: new class - * - */ - -#if !defined(NCNAME_DATATYPEVALIDATOR_HPP) -#define NCNAME_DATATYPEVALIDATOR_HPP - -#include <validators/datatype/StringDatatypeValidator.hpp> - -class VALIDATORS_EXPORT NCNameDatatypeValidator : public StringDatatypeValidator -{ -public: - - // ----------------------------------------------------------------------- - // Public ctor/dtor - // ----------------------------------------------------------------------- - /** @name Constructor. */ - //@{ - - NCNameDatatypeValidator(); - - NCNameDatatypeValidator(DatatypeValidator* const baseValidator - , RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet); - - virtual ~NCNameDatatypeValidator(); - - //@} - - // ----------------------------------------------------------------------- - // Validation methods - // ----------------------------------------------------------------------- - /** @name Validation Function */ - //@{ - - /** - * validate that a string matches the boolean datatype - * @param content A string containing the content to be validated - * - * @exception throws InvalidDatatypeException if the content is - * is not valid. - */ - - virtual void validate(const XMLCh* const content); - - //@} - - // ----------------------------------------------------------------------- - // Compare methods - // ----------------------------------------------------------------------- - /** @name Compare Function */ - //@{ - - /** - * Compare two boolean data types - * - * @param content1 - * @param content2 - * @return - */ - virtual int compare(const XMLCh* const, const XMLCh* const); - - //@} - - /** - * Returns an instance of the base datatype validator class - * Used by the DatatypeValidatorFactory. - */ - virtual DatatypeValidator* newInstance(RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet); - -protected: - - // - // ctor provided to be used by derived classes - // - NCNameDatatypeValidator(DatatypeValidator* const baseValidator - , RefHashTableOf<KVStringPair>* const facets - , const int finalSet - , const ValidatorType type); - - virtual void checkValueSpace(const XMLCh* const content); - -private: - - // ----------------------------------------------------------------------- - // Private data members - // - // - // ----------------------------------------------------------------------- - -}; - -/** - * End of file NCNameDatatypeValidator.hpp - */ -#endif diff --git a/src/validators/datatype/NOTATIONDatatypeValidator.cpp b/src/validators/datatype/NOTATIONDatatypeValidator.cpp deleted file mode 100644 index 14dac92ea8fe27a2c020af0d3094baf116454d86..0000000000000000000000000000000000000000 --- a/src/validators/datatype/NOTATIONDatatypeValidator.cpp +++ /dev/null @@ -1,203 +0,0 @@ -/* - * 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.10 2001/10/10 15:11:21 peiyongz - * extract/validate URI iff present - * - * Revision 1.9 2001/10/10 14:17:50 peiyongz - * <URI>:<LocalPart> where <URI> can be optional. - * - * Revision 1.8 2001/10/09 20:46:19 peiyongz - * NOTATION: checkContent(): <URI>:<localPart> - * - * Revision 1.7 2001/10/02 18:59:29 peiyongz - * Invalid_Facet_Tag to display the tag name - * - * Revision 1.6 2001/09/24 15:33:15 peiyongz - * DTV Reorganization: virtual methods moved to *.cpp - * - * Revision 1.5 2001/09/20 15:14:47 peiyongz - * DTV reorganization: inherit from AbstractStringVaildator - * - * Revision 1.3 2001/08/21 18:42:53 peiyongz - * Bugzilla# 2816: cleanUp() declared with external linkage and called - * before defined as inline - * - * Revision 1.2 2001/08/14 22:11:56 peiyongz - * new exception message added - * - * Revision 1.1 2001/07/05 20:15:27 peiyongz - * NOTATIONDatatypeValidator - * - */ - -// --------------------------------------------------------------------------- -// Includes -// --------------------------------------------------------------------------- -#include <validators/datatype/NOTATIONDatatypeValidator.hpp> -#include <util/XMLUri.hpp> -#include <validators/datatype/InvalidDatatypeFacetException.hpp> -#include <validators/datatype/InvalidDatatypeValueException.hpp> - -// --------------------------------------------------------------------------- -// Constructors and Destructor -// --------------------------------------------------------------------------- -NOTATIONDatatypeValidator::NOTATIONDatatypeValidator() -:AbstractStringValidator(0, 0, 0, DatatypeValidator::NOTATION) -{} - -NOTATIONDatatypeValidator::~NOTATIONDatatypeValidator() -{} - -NOTATIONDatatypeValidator::NOTATIONDatatypeValidator( - DatatypeValidator* const baseValidator - , RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet) -:AbstractStringValidator(baseValidator, facets, finalSet, DatatypeValidator::NOTATION) -{ - init(enums); -} - -DatatypeValidator* NOTATIONDatatypeValidator::newInstance( - RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet) -{ - return (DatatypeValidator*) new NOTATIONDatatypeValidator(this, facets, enums, finalSet); -} - -// --------------------------------------------------------------------------- -// Utilities -// --------------------------------------------------------------------------- -void NOTATIONDatatypeValidator::assignAdditionalFacet( const XMLCh* const key - , const XMLCh* const) -{ - ThrowXML1(InvalidDatatypeFacetException - , XMLExcepts::FACET_Invalid_Tag - , key); -} - -void NOTATIONDatatypeValidator::inheritAdditionalFacet() -{} - -void NOTATIONDatatypeValidator::checkAdditionalFacetConstraints() const -{} - -void NOTATIONDatatypeValidator::checkAdditionalFacet(const XMLCh* const) const -{} - -void NOTATIONDatatypeValidator::checkValueSpace(const XMLCh* const content) -{ - // - // NOTATATION: <URI>:<localPart> - // where URI is optional - // ':' and localPart must be present - // - int contentLength = XMLString::stringLen(content); - int colonPosition = XMLString::lastIndexOf(content, chColon); - - if ((colonPosition == -1) || // no ':' - (colonPosition == contentLength - 1) ) // <URI>':' - ThrowXML1(InvalidDatatypeValueException - , XMLExcepts::VALUE_NOTATION_Invalid - , content); - - if (colonPosition > 0) - { - // Extract URI - XMLCh* uriPart = new XMLCh[colonPosition + 1]; - ArrayJanitor<XMLCh> jan1(uriPart); - XMLString::subString(uriPart, content, 0, colonPosition); - - try - { - // no relative uri support here - XMLUri newURI(uriPart); - } - catch (...) - { - ThrowXML1(InvalidDatatypeValueException - , XMLExcepts::VALUE_NOTATION_Invalid - , content); - } - } - - // Extract localpart - XMLCh* localPart = new XMLCh[contentLength - colonPosition]; - ArrayJanitor<XMLCh> jan2(localPart); - XMLString::subString(localPart, content, colonPosition + 1, contentLength); - - if ( !XMLString::isValidNCName(localPart)) - { - ThrowXML1(InvalidDatatypeValueException - , XMLExcepts::VALUE_NOTATION_Invalid - , content); - } - -} - -int NOTATIONDatatypeValidator::getLength(const XMLCh* const content) const -{ - return XMLString::stringLen(content); -} - -/** - * End of file NOTATIONDatatypeValidator.cpp - */ diff --git a/src/validators/datatype/NOTATIONDatatypeValidator.hpp b/src/validators/datatype/NOTATIONDatatypeValidator.hpp deleted file mode 100644 index fca699b79416d3f92ef922da084efc404a25c2e7..0000000000000000000000000000000000000000 --- a/src/validators/datatype/NOTATIONDatatypeValidator.hpp +++ /dev/null @@ -1,141 +0,0 @@ -/* - * 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/>. - */ - -/* - * $Id$ - * $Log$ - * Revision 1.5 2001/09/24 15:33:15 peiyongz - * DTV Reorganization: virtual methods moved to *.cpp - * - * Revision 1.4 2001/09/20 15:14:47 peiyongz - * DTV reorganization: inherit from AbstractStringVaildator - * - * Revision 1.3 2001/08/24 17:12:01 knoaman - * Add support for anySimpleType. - * Remove parameter 'baseValidator' from the virtual method 'newInstance'. - * - * Revision 1.2 2001/08/21 18:42:53 peiyongz - * Bugzilla# 2816: cleanUp() declared with external linkage and called - * before defined as inline - * - * Revision 1.1 2001/07/05 20:15:27 peiyongz - * NOTATIONDatatypeValidator - * - */ - -#if !defined(NOTATION_DATATYPEVALIDATOR_HPP) -#define NOTATION_DATATYPEVALIDATOR_HPP - -#include <validators/datatype/AbstractStringValidator.hpp> - -class VALIDATORS_EXPORT NOTATIONDatatypeValidator : public AbstractStringValidator -{ -public: - - // ----------------------------------------------------------------------- - // Public ctor/dtor - // ----------------------------------------------------------------------- - /** @name Constructor. */ - //@{ - - NOTATIONDatatypeValidator(); - - NOTATIONDatatypeValidator(DatatypeValidator* const baseValidator - , RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet); - - virtual ~NOTATIONDatatypeValidator(); - - //@} - - /** - * Returns an instance of the base datatype validator class - * Used by the DatatypeValidatorFactory. - */ - virtual DatatypeValidator* newInstance(RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet); - -protected: - - virtual void assignAdditionalFacet(const XMLCh* const key - , const XMLCh* const value); - - virtual void inheritAdditionalFacet(); - - virtual void checkAdditionalFacetConstraints() const; - - virtual void checkAdditionalFacet(const XMLCh* const content) const; - - virtual void checkValueSpace(const XMLCh* const content); - - virtual int getLength(const XMLCh* const content) const; - -private: - - // ----------------------------------------------------------------------- - // Private data members - // - // Nil - // ----------------------------------------------------------------------- - -}; - -/** - * End of file NOTATIONDatatypeValidator.hpp - */ -#endif diff --git a/src/validators/datatype/NameDatatypeValidator.cpp b/src/validators/datatype/NameDatatypeValidator.cpp deleted file mode 100644 index 6b22edbc2cbffa04503669ae5e236d843aadc797..0000000000000000000000000000000000000000 --- a/src/validators/datatype/NameDatatypeValidator.cpp +++ /dev/null @@ -1,153 +0,0 @@ -/* - * 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/>. - */ - -/* - * $Id$ - * $Log$ - * Revision 1.4 2001/10/09 20:48:39 peiyongz - * init(): take 1 arg - * - * Revision 1.3 2001/10/02 18:59:59 peiyongz - * Invalid_Name to replace Invalid_NCName. - * - * Revision 1.2 2001/09/27 13:51:25 peiyongz - * DTV Reorganization: ctor/init created to be used by derived class - * - * Revision 1.1 2001/09/25 15:58:45 peiyongz - * DTV Reorganization: new class - * - */ - -// --------------------------------------------------------------------------- -// Includes -// --------------------------------------------------------------------------- -#include <validators/datatype/NameDatatypeValidator.hpp> -#include <validators/datatype/InvalidDatatypeValueException.hpp> - -// --------------------------------------------------------------------------- -// Constructors and Destructor -// --------------------------------------------------------------------------- -NameDatatypeValidator::NameDatatypeValidator() -:StringDatatypeValidator(0, 0, 0, DatatypeValidator::Name) -{} - -NameDatatypeValidator::~NameDatatypeValidator() -{} - -NameDatatypeValidator::NameDatatypeValidator( - DatatypeValidator* const baseValidator - , RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet) -:StringDatatypeValidator(baseValidator, facets, finalSet, DatatypeValidator::Name) -{ - init(enums); -} - -DatatypeValidator* NameDatatypeValidator::newInstance( - RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet) -{ - return (DatatypeValidator*) new NameDatatypeValidator(this, facets, enums, finalSet); -} - -NameDatatypeValidator::NameDatatypeValidator( - DatatypeValidator* const baseValidator - , RefHashTableOf<KVStringPair>* const facets - , const int finalSet - , const ValidatorType type) -:StringDatatypeValidator(baseValidator, facets, finalSet, type) -{ - // do not invoke init() here!!! -} -// ----------------------------------------------------------------------- -// Compare methods -// ----------------------------------------------------------------------- -int NameDatatypeValidator::compare(const XMLCh* const lValue - , const XMLCh* const rValue) -{ - return ( XMLString::compareString(lValue, rValue)==0 ? 0 : -1); -} - -void NameDatatypeValidator::validate(const XMLCh* const content) -{ - // use StringDatatypeValidator (which in turn, invoke - // the baseValidator) to validate content against - // facets if any. - // - StringDatatypeValidator::validate(content); - - return; -} - -void NameDatatypeValidator::checkValueSpace(const XMLCh* const content) -{ - // - // 3.3.6 check must: "Name" - // - if ( !XMLString::isValidName(content)) - { - ThrowXML1(InvalidDatatypeValueException - , XMLExcepts::VALUE_Invalid_Name - , content); - } - -} - - /** - * End of file NameDatatypeValidator.cpp - */ diff --git a/src/validators/datatype/NameDatatypeValidator.hpp b/src/validators/datatype/NameDatatypeValidator.hpp deleted file mode 100644 index 81aa2d361afe26d07fdd718d19fe7457daa5e9e4..0000000000000000000000000000000000000000 --- a/src/validators/datatype/NameDatatypeValidator.hpp +++ /dev/null @@ -1,165 +0,0 @@ -/* - * 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/>. - */ - -/* - * $Id$ - * $Log$ - * Revision 1.3 2001/10/09 20:48:39 peiyongz - * init(): take 1 arg - * - * Revision 1.2 2001/09/27 13:51:25 peiyongz - * DTV Reorganization: ctor/init created to be used by derived class - * - * Revision 1.1 2001/09/25 15:58:45 peiyongz - * DTV Reorganization: new class - * - */ - -#if !defined(NAME_DATATYPEVALIDATOR_HPP) -#define NAME_DATATYPEVALIDATOR_HPP - -#include <validators/datatype/StringDatatypeValidator.hpp> - -class VALIDATORS_EXPORT NameDatatypeValidator : public StringDatatypeValidator -{ -public: - - // ----------------------------------------------------------------------- - // Public ctor/dtor - // ----------------------------------------------------------------------- - /** @name Constructor. */ - //@{ - - NameDatatypeValidator(); - - NameDatatypeValidator(DatatypeValidator* const baseValidator - , RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet); - - virtual ~NameDatatypeValidator(); - - //@} - - // ----------------------------------------------------------------------- - // Validation methods - // ----------------------------------------------------------------------- - /** @name Validation Function */ - //@{ - - /** - * validate that a string matches the boolean datatype - * @param content A string containing the content to be validated - * - * @exception throws InvalidDatatypeException if the content is - * is not valid. - */ - - virtual void validate(const XMLCh* const content); - - //@} - - // ----------------------------------------------------------------------- - // Compare methods - // ----------------------------------------------------------------------- - /** @name Compare Function */ - //@{ - - /** - * Compare two boolean data types - * - * @param content1 - * @param content2 - * @return - */ - virtual int compare(const XMLCh* const, const XMLCh* const); - - //@} - - /** - * Returns an instance of the base datatype validator class - * Used by the DatatypeValidatorFactory. - */ - virtual DatatypeValidator* newInstance(RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet); - -protected: - - // - // ctor provided to be used by derived classes - // - NameDatatypeValidator(DatatypeValidator* const baseValidator - , RefHashTableOf<KVStringPair>* const facets - , const int finalSet - , const ValidatorType type); - - virtual void checkValueSpace(const XMLCh* const content); - -private: - - // ----------------------------------------------------------------------- - // Private data members - // - // - // ----------------------------------------------------------------------- - -}; - -/** - * End of file NameDatatypeValidator.hpp - */ -#endif diff --git a/src/validators/datatype/QNameDatatypeValidator.cpp b/src/validators/datatype/QNameDatatypeValidator.cpp deleted file mode 100644 index bb4d3cdda431d0bcb5618107b972f0b38d1de6f4..0000000000000000000000000000000000000000 --- a/src/validators/datatype/QNameDatatypeValidator.cpp +++ /dev/null @@ -1,162 +0,0 @@ -/* - * 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.9 2001/10/09 20:47:05 peiyongz - * init(): take 1 arg - * - * Revision 1.8 2001/10/02 18:59:29 peiyongz - * Invalid_Facet_Tag to display the tag name - * - * Revision 1.7 2001/09/24 15:33:15 peiyongz - * DTV Reorganization: virtual methods moved to *.cpp - * - * Revision 1.6 2001/09/20 15:36:49 peiyongz - * DTV reorganization: inherit from AbstractStringVaildator - * - * Revision 1.4 2001/09/06 21:34:48 peiyongz - * Fix:improper loop in enumeration checking - * - * Revision 1.3 2001/08/21 18:42:53 peiyongz - * Bugzilla# 2816: cleanUp() declared with external linkage and called - * before defined as inline - * - * Revision 1.2 2001/08/14 22:11:56 peiyongz - * new exception message added - * - * Revision 1.1 2001/07/06 20:20:14 peiyongz - * QNameDTV - * - */ - -// --------------------------------------------------------------------------- -// Includes -// --------------------------------------------------------------------------- -#include <validators/datatype/QNameDatatypeValidator.hpp> -#include <validators/datatype/InvalidDatatypeFacetException.hpp> -#include <validators/datatype/InvalidDatatypeValueException.hpp> - -// --------------------------------------------------------------------------- -// Constructors and Destructor -// --------------------------------------------------------------------------- -QNameDatatypeValidator::QNameDatatypeValidator() -:AbstractStringValidator(0, 0, 0, DatatypeValidator::QName) -{} - -QNameDatatypeValidator::~QNameDatatypeValidator() -{} - -QNameDatatypeValidator::QNameDatatypeValidator( - DatatypeValidator* const baseValidator - , RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet) -:AbstractStringValidator(baseValidator, facets, finalSet, DatatypeValidator::QName) -{ - init(enums); -} - -DatatypeValidator* QNameDatatypeValidator::newInstance( - RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet) -{ - return (DatatypeValidator*) new QNameDatatypeValidator(this, facets, enums, finalSet); -} - -// --------------------------------------------------------------------------- -// Utilities -// --------------------------------------------------------------------------- -void QNameDatatypeValidator::assignAdditionalFacet( const XMLCh* const key - , const XMLCh* const) -{ - ThrowXML1(InvalidDatatypeFacetException - , XMLExcepts::FACET_Invalid_Tag - , key); -} - -void QNameDatatypeValidator::inheritAdditionalFacet() -{} - -void QNameDatatypeValidator::checkAdditionalFacetConstraints() const -{} - -void QNameDatatypeValidator::checkAdditionalFacet(const XMLCh* const) const -{} - -void QNameDatatypeValidator::checkValueSpace(const XMLCh* const content) -{ - // - // check 3.2.18.c0 must: QName - // - if ( !XMLString::isValidQName(content)) - { - ThrowXML1(InvalidDatatypeValueException - , XMLExcepts::VALUE_QName_Invalid - , content); - } -} - -int QNameDatatypeValidator::getLength(const XMLCh* const content) const -{ - return XMLString::stringLen(content); -} - -/** - * End of file QNameDatatypeValidator.cpp - */ diff --git a/src/validators/datatype/QNameDatatypeValidator.hpp b/src/validators/datatype/QNameDatatypeValidator.hpp deleted file mode 100644 index d2b1696fb371dd8c4983975436a0af0b152ba8f2..0000000000000000000000000000000000000000 --- a/src/validators/datatype/QNameDatatypeValidator.hpp +++ /dev/null @@ -1,141 +0,0 @@ -/* - * 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/>. - */ - -/* - * $Id$ - * $Log$ - * Revision 1.5 2001/09/24 15:33:15 peiyongz - * DTV Reorganization: virtual methods moved to *.cpp - * - * Revision 1.4 2001/09/20 15:36:49 peiyongz - * DTV reorganization: inherit from AbstractStringVaildator - * - * Revision 1.3 2001/08/24 17:12:01 knoaman - * Add support for anySimpleType. - * Remove parameter 'baseValidator' from the virtual method 'newInstance'. - * - * Revision 1.2 2001/08/21 18:42:53 peiyongz - * Bugzilla# 2816: cleanUp() declared with external linkage and called - * before defined as inline - * - * Revision 1.1 2001/07/06 20:20:15 peiyongz - * QNameDTV - * - */ - -#if !defined(QNAME_DATATYPEVALIDATOR_HPP) -#define QNAME_DATATYPEVALIDATOR_HPP - -#include <validators/datatype/AbstractStringValidator.hpp> - -class VALIDATORS_EXPORT QNameDatatypeValidator : public AbstractStringValidator -{ -public: - - // ----------------------------------------------------------------------- - // Public ctor/dtor - // ----------------------------------------------------------------------- - /** @name Constructor. */ - //@{ - - QNameDatatypeValidator(); - - QNameDatatypeValidator(DatatypeValidator* const baseValidator - , RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet); - - virtual ~QNameDatatypeValidator(); - - //@} - - /** - * Returns an instance of the base datatype validator class - * Used by the DatatypeValidatorFactory. - */ - virtual DatatypeValidator* newInstance(RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet); -protected: - - virtual void assignAdditionalFacet(const XMLCh* const key - , const XMLCh* const value); - - virtual void inheritAdditionalFacet(); - - virtual void checkAdditionalFacetConstraints() const; - - virtual void checkAdditionalFacet(const XMLCh* const content) const; - - virtual void checkValueSpace(const XMLCh* const content); - - virtual int getLength(const XMLCh* const content) const; - -private: - - // ----------------------------------------------------------------------- - // Private data members - // - // Nil - // ----------------------------------------------------------------------- - -}; - -/** - * End of file QNameDatatypeValidator.hpp - */ - -#endif diff --git a/src/validators/datatype/StringDatatypeValidator.cpp b/src/validators/datatype/StringDatatypeValidator.cpp deleted file mode 100644 index eb17729121325cfff5d9eb703d6c576e8f07b925..0000000000000000000000000000000000000000 --- a/src/validators/datatype/StringDatatypeValidator.cpp +++ /dev/null @@ -1,280 +0,0 @@ -/* - * 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$ - * Revision 1.17 2001/10/09 20:54:35 peiyongz - * init(): take 1 arg. - * - * Revision 1.16 2001/09/27 13:51:25 peiyongz - * DTV Reorganization: ctor/init created to be used by derived class - * - * Revision 1.15 2001/09/25 15:58:14 peiyongz - * Check baseValidator in assignAdditinoalFacet() and inheritAdditionalFacet() - * - * Revision 1.14 2001/09/24 15:31:13 peiyongz - * DTV Reorganization: inherit from AbstractStringValidator - * - * Revision 1.12 2001/08/21 18:42:53 peiyongz - * Bugzilla# 2816: cleanUp() declared with external linkage and called - * before defined as inline - * - * Revision 1.11 2001/06/20 17:56:09 peiyongz - * support for "fixed" option on constrainning facets - * - * Revision 1.10 2001/05/29 19:49:36 tng - * Schema: Constraint Checking Fix in datatypeValidators. By Pei Yong Zhang. - * - * Revision 1.9 2001/05/28 21:11:18 tng - * Schema: Various DatatypeValidator fix. By Pei Yong Zhang - * - * Revision 1.8 2001/05/23 16:05:11 tng - * Schema: NormalizedString fix. By Pei Yong Zhang. - * - * Revision 1.7 2001/05/23 15:45:25 tng - * Schema: NormalizedString fix. By Pei Yong Zhang. - * - * Revision 1.6 2001/05/18 13:36:48 tng - * Schema: Catch RegularExpression exception and NumberFormatException - * - * Revision 1.5 2001/05/18 13:23:51 tng - * Schema: Exception messages in DatatypeValidator. By Pei Yong Zhang. - * - * Revision 1.4 2001/05/16 14:33:40 tng - * Schema Constraint checking fix. - * - * Revision 1.3 2001/05/11 17:17:28 tng - * Schema: DatatypeValidator fixes. By Pei Yong Zhang. - * - * Revision 1.2 2001/05/11 13:27:29 tng - * Copyright update. - * - * Revision 1.1 2001/05/09 18:43:42 tng - * Add StringDatatypeValidator and BooleanDatatypeValidator. By Pei Yong Zhang. - * - */ - -// --------------------------------------------------------------------------- -// Includes -// --------------------------------------------------------------------------- -#include <validators/datatype/StringDatatypeValidator.hpp> -#include <validators/schema/SchemaSymbols.hpp> -#include <validators/datatype/InvalidDatatypeFacetException.hpp> -#include <validators/datatype/InvalidDatatypeValueException.hpp> - -static const int BUF_LEN = 64; -static XMLCh value1[BUF_LEN+1]; -static XMLCh value2[BUF_LEN+1]; - -// --------------------------------------------------------------------------- -// Constructors and Destructor -// --------------------------------------------------------------------------- -StringDatatypeValidator::StringDatatypeValidator() -:AbstractStringValidator(0, 0, 0, DatatypeValidator::String) -,fWhiteSpace(DatatypeValidator::PRESERVE) -{} - -StringDatatypeValidator::StringDatatypeValidator( - DatatypeValidator* const baseValidator - , RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet) -:AbstractStringValidator(baseValidator, facets, finalSet, DatatypeValidator::String) -,fWhiteSpace(DatatypeValidator::PRESERVE) -{ - init(enums); -} - -StringDatatypeValidator::~StringDatatypeValidator() -{} - -DatatypeValidator* StringDatatypeValidator::newInstance( - RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet) -{ - return (DatatypeValidator*) new StringDatatypeValidator(this, facets, enums, finalSet); -} - -StringDatatypeValidator::StringDatatypeValidator( - DatatypeValidator* const baseValidator - , RefHashTableOf<KVStringPair>* const facets - , const int finalSet - , const ValidatorType type) -:AbstractStringValidator(baseValidator, facets, finalSet, type) -,fWhiteSpace(DatatypeValidator::PRESERVE) -{ - // do not invoke init() here!!! -} - -short StringDatatypeValidator::getWSFacet() const -{ - return fWhiteSpace; -} - -// --------------------------------------------------------------------------- -// Utilities -// --------------------------------------------------------------------------- -void StringDatatypeValidator::assignAdditionalFacet(const XMLCh* const key - , const XMLCh* const value) -{ - if (XMLString::compareString(key, SchemaSymbols::fgELT_WHITESPACE)==0) - { - // whiteSpace = preserve | replace | collapse - if (XMLString::compareString(value, SchemaSymbols::fgWS_PRESERVE) == 0) - setWhiteSpace(DatatypeValidator::PRESERVE); - else if (XMLString::compareString(value, SchemaSymbols::fgWS_REPLACE) == 0) - setWhiteSpace(DatatypeValidator::REPLACE); - else if (XMLString::compareString(value, SchemaSymbols::fgWS_COLLAPSE) == 0) - setWhiteSpace(DatatypeValidator::COLLAPSE); - else - ThrowXML1(InvalidDatatypeFacetException, XMLExcepts::FACET_Invalid_WS, value); - //("whiteSpace value '" + ws + "' must be one of 'preserve', 'replace', 'collapse'."); - - setFacetsDefined(DatatypeValidator::FACET_WHITESPACE); - } - else - { - ThrowXML1(InvalidDatatypeFacetException - , XMLExcepts::FACET_Invalid_Tag - , key); - } -} - -void StringDatatypeValidator::inheritAdditionalFacet() -{ - StringDatatypeValidator *pBaseValidator = (StringDatatypeValidator*) getBaseValidator(); - - if (!pBaseValidator) - return; - - // inherit whitespace - if (((pBaseValidator->getFacetsDefined() & DatatypeValidator::FACET_WHITESPACE) !=0) && - ((getFacetsDefined() & DatatypeValidator::FACET_WHITESPACE) == 0)) - { - setWhiteSpace(getBaseValidator()->getWSFacet()); - setFacetsDefined(DatatypeValidator::FACET_WHITESPACE); - } -} - -void StringDatatypeValidator::checkAdditionalFacetConstraints() const -{ - - StringDatatypeValidator *pBaseValidator = (StringDatatypeValidator*) getBaseValidator(); - - if (!pBaseValidator) - return; - - short thisWSFacet = getWSFacet(); - short baseWSFacet = pBaseValidator->getWSFacet(); - - // check 4.3.6.c1 error: whitespace - if (((getFacetsDefined() & DatatypeValidator::FACET_WHITESPACE) != 0) && - ((pBaseValidator->getFacetsDefined() & DatatypeValidator::FACET_WHITESPACE) != 0 )) - { - if ((baseWSFacet == DatatypeValidator::COLLAPSE) && - ((thisWSFacet == DatatypeValidator::PRESERVE) || - (thisWSFacet == DatatypeValidator::REPLACE))) - ThrowXML(InvalidDatatypeFacetException, XMLExcepts::FACET_WS_collapse); - - if ((baseWSFacet == DatatypeValidator::REPLACE) && - (thisWSFacet == DatatypeValidator::PRESERVE)) - ThrowXML(InvalidDatatypeFacetException, XMLExcepts::FACET_WS_replace); - - if (((pBaseValidator->getFixed() & DatatypeValidator::FACET_WHITESPACE) !=0) && - ( thisWSFacet != baseWSFacet)) - { - ThrowXML2(InvalidDatatypeFacetException - , XMLExcepts::FACET_whitespace_base_fixed - , getWSstring(thisWSFacet) - , getWSstring(baseWSFacet)); - } - } - -} - -void StringDatatypeValidator::checkAdditionalFacet(const XMLCh* const content) const -{ - // - // check WhiteSpace - // - if ((getFacetsDefined() & DatatypeValidator::FACET_WHITESPACE) != 0 ) - { - if ( getWSFacet() == DatatypeValidator::REPLACE ) - { - if (!XMLString::isWSReplaced(content)) - ThrowXML1(InvalidDatatypeValueException, XMLExcepts::VALUE_WS_replaced, content); - } - else if ( getWSFacet() == DatatypeValidator::COLLAPSE ) - { - if (!XMLString::isWSCollapsed(content)) - ThrowXML1(InvalidDatatypeValueException, XMLExcepts::VALUE_WS_collapsed, content); - } - - } -} - -void StringDatatypeValidator::checkValueSpace(const XMLCh* const content) -{} - -int StringDatatypeValidator::getLength(const XMLCh* const content) const -{ - return XMLString::stringLen(content); -} - -/** - * End of file StringDatatypeValidator.cpp - */ diff --git a/src/validators/datatype/StringDatatypeValidator.hpp b/src/validators/datatype/StringDatatypeValidator.hpp deleted file mode 100644 index 9e21690ff4035052512a90b12078cb9f7362803e..0000000000000000000000000000000000000000 --- a/src/validators/datatype/StringDatatypeValidator.hpp +++ /dev/null @@ -1,167 +0,0 @@ -/* - * 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.10 2001/11/22 20:23:20 peiyongz - * _declspec(dllimport) and inline warning C4273 - * - * Revision 1.9 2001/10/09 20:54:48 peiyongz - * init(): removed - * - * Revision 1.8 2001/09/27 13:51:25 peiyongz - * DTV Reorganization: ctor/init created to be used by derived class - * - * Revision 1.7 2001/09/24 21:39:12 peiyongz - * DTV Reorganization: - * - * Revision 1.6 2001/09/24 15:31:13 peiyongz - * DTV Reorganization: inherit from AbstractStringValidator - * - */ - -#if !defined(STRING_DATATYPEVALIDATOR_HPP) -#define STRING_DATATYPEVALIDATOR_HPP - -#include <validators/datatype/AbstractStringValidator.hpp> - -class VALIDATORS_EXPORT StringDatatypeValidator : public AbstractStringValidator -{ -public: - - // ----------------------------------------------------------------------- - // Public ctor/dtor - // ----------------------------------------------------------------------- - /** @name Constructor. */ - //@{ - - StringDatatypeValidator(); - - StringDatatypeValidator(DatatypeValidator* const baseValidator - , RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet); - - virtual ~StringDatatypeValidator(); - - //@} - - // ----------------------------------------------------------------------- - // Getter methods - // ----------------------------------------------------------------------- - /** @name Getter Functions */ - //@{ - - virtual short getWSFacet() const; - - //@} - - /** - * Returns an instance of the base datatype validator class - * Used by the DatatypeValidatorFactory. - */ - virtual DatatypeValidator* newInstance(RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet); - -protected: - - // - // ctor provided to be used by derived classes - // - StringDatatypeValidator(DatatypeValidator* const baseValidator - , RefHashTableOf<KVStringPair>* const facets - , const int finalSet - , const ValidatorType type); - - virtual void assignAdditionalFacet(const XMLCh* const key - , const XMLCh* const value); - - virtual void inheritAdditionalFacet(); - - virtual void checkAdditionalFacetConstraints() const; - - virtual void checkAdditionalFacet(const XMLCh* const content) const; - - virtual void checkValueSpace(const XMLCh* const content); - - virtual int getLength(const XMLCh* const content) const; - -private: - - inline void setWhiteSpace(short); - - // ----------------------------------------------------------------------- - // Private data members - // - // ----------------------------------------------------------------------- - short fWhiteSpace; //DatatypeValidator::PRESERVE - -}; - -// ----------------------------------------------------------------------- -// Getter methods -// ----------------------------------------------------------------------- -inline void StringDatatypeValidator::setWhiteSpace(short newValue) -{ - fWhiteSpace = newValue; -} - -/** - * End of file StringDatatypeValidator.hpp - */ -#endif diff --git a/src/validators/datatype/TimeDatatypeValidator.cpp b/src/validators/datatype/TimeDatatypeValidator.cpp deleted file mode 100644 index a4aec15fbb5813604a03390bb853ccd8219498c6..0000000000000000000000000000000000000000 --- a/src/validators/datatype/TimeDatatypeValidator.cpp +++ /dev/null @@ -1,127 +0,0 @@ -/* - * 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.3 2001/11/15 17:09:23 peiyongz - * catch(...) only. (the invoker need to cath XMLException to display proper message) - * - * Revision 1.2 2001/11/14 22:02:25 peiyongz - * rethrow exception with original error message. - * - * Revision 1.1 2001/11/07 19:18:52 peiyongz - * DateTime Port - * - */ - -// --------------------------------------------------------------------------- -// Includes -// --------------------------------------------------------------------------- -#include <validators/datatype/TimeDatatypeValidator.hpp> - -// --------------------------------------------------------------------------- -// Constructors and Destructor -// --------------------------------------------------------------------------- -TimeDatatypeValidator::TimeDatatypeValidator() -:DateTimeValidator(0, 0, 0, DatatypeValidator::Time) -{} - -TimeDatatypeValidator::TimeDatatypeValidator( - DatatypeValidator* const baseValidator - , RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet) -:DateTimeValidator(baseValidator, facets, finalSet, DatatypeValidator::Time) -{ - init(enums); -} - -TimeDatatypeValidator::~TimeDatatypeValidator() -{} - -DatatypeValidator* TimeDatatypeValidator::newInstance( - RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet) -{ - return (DatatypeValidator*) new TimeDatatypeValidator(this, facets, enums, finalSet); -} - -// -// caller need to release the date created here -// -XMLDateTime* TimeDatatypeValidator::parse(const XMLCh* const content) -{ - XMLDateTime *pRetDate = new XMLDateTime(content); - - try - { - pRetDate->parseTime(); - } - catch (...) - { - delete pRetDate; - throw; - } - - return pRetDate; -} - -/** - * End of file TimeDatatypeValidator::cpp - */ - diff --git a/src/validators/datatype/TimeDatatypeValidator.hpp b/src/validators/datatype/TimeDatatypeValidator.hpp deleted file mode 100644 index 8299ac59bbada940e2b22ed0301b6904de3037b0..0000000000000000000000000000000000000000 --- a/src/validators/datatype/TimeDatatypeValidator.hpp +++ /dev/null @@ -1,113 +0,0 @@ -/* - * 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/11/07 19:18:52 peiyongz - * DateTime Port - * - */ - -#if !defined(TIME_DATATYPE_VALIDATOR_HPP) -#define TIME_DATATYPE_VALIDATOR_HPP - -#include <validators/datatype/DateTimeValidator.hpp> -#include <util/RefVectorOf.hpp> - -class VALIDATORS_EXPORT TimeDatatypeValidator : public DateTimeValidator -{ -public: - - // ----------------------------------------------------------------------- - // Public ctor/dtor - // ----------------------------------------------------------------------- - /** @name Constructor. */ - //@{ - - TimeDatatypeValidator(); - - TimeDatatypeValidator(DatatypeValidator* const baseValidator - , RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet); - - ~TimeDatatypeValidator(); - - - //@} - - /** - * Returns an instance of the base datatype validator class - * Used by the DatatypeValidatorFactory. - */ - virtual DatatypeValidator* newInstance(RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet); - -protected: - - // ----------------------------------------------------------------------- - // implementation of (DateTimeValidator's) virtual interface - // ----------------------------------------------------------------------- - virtual XMLDateTime* parse(const XMLCh* const); -}; - -/** - * End of file TimeDatatypeValidator.hpp - */ -#endif - diff --git a/src/validators/datatype/UnionDatatypeValidator.cpp b/src/validators/datatype/UnionDatatypeValidator.cpp deleted file mode 100644 index d592c90673ef123a6f5a99392fd31fa92204cb9b..0000000000000000000000000000000000000000 --- a/src/validators/datatype/UnionDatatypeValidator.cpp +++ /dev/null @@ -1,387 +0,0 @@ -/* - * 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.5 2001/10/02 18:59:29 peiyongz - * Invalid_Facet_Tag to display the tag name - * - * Revision 1.4 2001/09/20 13:11:42 knoaman - * Regx + misc. fixes - * - * Revision 1.3 2001/08/21 18:42:54 peiyongz - * Bugzilla# 2816: cleanUp() declared with external linkage and called - * before defined as inline - * - * Revision 1.2 2001/08/14 22:11:56 peiyongz - * new exception message added - * - * 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() -:DatatypeValidator(0, 0, 0, DatatypeValidator::Union) -,fEnumerationInherited(false) -,fEnumeration(0) -,fMemberTypeValidators(0) -{} - -UnionDatatypeValidator::~UnionDatatypeValidator() -{ - cleanUp(); -} - -UnionDatatypeValidator::UnionDatatypeValidator( - RefVectorOf<DatatypeValidator>* const memberTypeValidators - , const int finalSet) -:DatatypeValidator(0, 0, finalSet, DatatypeValidator::Union) -,fEnumerationInherited(false) -,fEnumeration(0) -,fMemberTypeValidators(0) -{ - if ( !memberTypeValidators ) - { - ThrowXML(InvalidDatatypeFacetException - , XMLExcepts::FACET_Union_Null_memberTypeValidators); - } - - // 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) - { - ThrowXML(InvalidDatatypeFacetException - , XMLExcepts::FACET_Union_Null_baseValidator); - } - - if (baseValidator->getType() != DatatypeValidator::Union) - { - XMLString::binToText(baseValidator->getType(), value1, BUF_LEN, 10); - ThrowXML1(InvalidDatatypeFacetException - , XMLExcepts::FACET_Union_invalid_baseValidatorType - , value1); - } - - try - { - init(baseValidator, facets, enums); - } - catch (...) - { - 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 - { - ThrowXML1(InvalidDatatypeFacetException - , XMLExcepts::FACET_Invalid_Tag - , key); - } - }//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_no_match_memberType - , 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 deleted file mode 100644 index f037523fa4e5c8e1639d259b4a0640faa1b6861e..0000000000000000000000000000000000000000 --- a/src/validators/datatype/UnionDatatypeValidator.hpp +++ /dev/null @@ -1,326 +0,0 @@ -/* - * 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.9 2001/12/13 16:48:29 peiyongz - * Avoid dangling pointer - * - * Revision 1.8 2001/09/05 20:49:10 knoaman - * Fix for complexTypes with mixed content model. - * - * Revision 1.7 2001/08/31 16:53:41 knoaman - * Misc. fixes. - * - * Revision 1.6 2001/08/24 17:12:01 knoaman - * Add support for anySimpleType. - * Remove parameter 'baseValidator' from the virtual method 'newInstance'. - * - * Revision 1.5 2001/08/21 20:05:41 peiyongz - * put back changes introduced in 1.3 - * - * Revision 1.3 2001/08/16 14:41:38 knoaman - * implementation of virtual methods. - * - * Revision 1.2 2001/07/24 21:23:40 tng - * Schema: Use DatatypeValidator for ID/IDREF/ENTITY/ENTITIES/NOTATION. - * - * 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 */ - //@{ - /** - * Returns whether the type is atomic or not - */ - virtual bool isAtomic() const; - - //@} - - // ----------------------------------------------------------------------- - // Validation methods - // ----------------------------------------------------------------------- - /** @name Validation Function */ - //@{ - - /** - * validate that a string matches the boolean datatype - * @param content A string containing the content to be validated - * - * @exception throws InvalidDatatypeException if the content is - * is not valid. - */ - - void validate(const XMLCh* const content); - - /** - * Checks whether a given type can be used as a substitute - * - * @param toCheck A datatype validator of the type to be used as a - * substitute - * - * To be redefined in UnionDatatypeValidator - */ - - virtual bool isSubstitutableBy(const DatatypeValidator* const toCheck); - - //@} - - // ----------------------------------------------------------------------- - // Compare methods - // ----------------------------------------------------------------------- - /** @name Compare Function */ - //@{ - - /** - * Compare two boolean data types - * - * @param content1 - * @param content2 - * @return - */ - int compare(const XMLCh* const, const XMLCh* const); - - //@} - - /** - * Returns an instance of the base datatype validator class - * Used by the DatatypeValidatorFactory. - */ - DatatypeValidator* newInstance(RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet); - - RefVectorOf<DatatypeValidator>* getMemberTypeValidators() const; - -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); - - - // ----------------------------------------------------------------------- - // Private data members - // - // fEnumeration - // we own it. - // - // fMemberTypeValidators - // we own it. - // - // ----------------------------------------------------------------------- - bool fEnumerationInherited; - RefVectorOf<XMLCh>* fEnumeration; - RefVectorOf<DatatypeValidator>* fMemberTypeValidators; -}; - -inline DatatypeValidator* UnionDatatypeValidator::newInstance( - RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet) -{ - return (DatatypeValidator*) new UnionDatatypeValidator(this, 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 ( !fEnumerationInherited && fEnumeration) - 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 ( !fEnumerationInherited && fEnumeration) - 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; -} - -inline bool UnionDatatypeValidator::isAtomic() const { - - - RefVectorOf<DatatypeValidator>* memberDVs = getMemberTypeValidators(); - - if (!memberDVs) { - return false; - } - - unsigned int memberSize = memberDVs->size(); - - for (unsigned int i=0; i < memberSize; i++) { - if (!memberDVs->elementAt(i)->isAtomic()) { - return false; - } - } - - return true; -} - -inline bool UnionDatatypeValidator::isSubstitutableBy(const DatatypeValidator* const toCheck) { - - if (toCheck == this) { - return true; - } - - unsigned int memberSize = fMemberTypeValidators->size(); - - for (unsigned int i=0; i < memberSize; i++) { - if (fMemberTypeValidators->elementAt(i)->isSubstitutableBy(toCheck)) { - return true; - } - } - - return false; -} - -/** - * End of file UnionDatatypeValidator.hpp - */ -#endif diff --git a/src/validators/datatype/YearDatatypeValidator.cpp b/src/validators/datatype/YearDatatypeValidator.cpp deleted file mode 100644 index c6f753cc7ce0069231a7711bbb7b22e788a1a642..0000000000000000000000000000000000000000 --- a/src/validators/datatype/YearDatatypeValidator.cpp +++ /dev/null @@ -1,127 +0,0 @@ -/* - * 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.3 2001/11/15 17:09:23 peiyongz - * catch(...) only. (the invoker need to cath XMLException to display proper message) - * - * Revision 1.2 2001/11/14 22:02:25 peiyongz - * rethrow exception with original error message. - * - * Revision 1.1 2001/11/07 19:18:52 peiyongz - * DateTime Port - * - */ - -// --------------------------------------------------------------------------- -// Includes -// --------------------------------------------------------------------------- -#include <validators/datatype/YearDatatypeValidator.hpp> - -// --------------------------------------------------------------------------- -// Constructors and Destructor -// --------------------------------------------------------------------------- -YearDatatypeValidator::YearDatatypeValidator() -:DateTimeValidator(0, 0, 0, DatatypeValidator::Year) -{} - -YearDatatypeValidator::YearDatatypeValidator( - DatatypeValidator* const baseValidator - , RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet) -:DateTimeValidator(baseValidator, facets, finalSet, DatatypeValidator::Year) -{ - init(enums); -} - -YearDatatypeValidator::~YearDatatypeValidator() -{} - -DatatypeValidator* YearDatatypeValidator::newInstance( - RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet) -{ - return (DatatypeValidator*) new YearDatatypeValidator(this, facets, enums, finalSet); -} - -// -// caller need to release the date created here -// -XMLDateTime* YearDatatypeValidator::parse(const XMLCh* const content) -{ - XMLDateTime *pRetDate = new XMLDateTime(content); - - try - { - pRetDate->parseYear(); - } - catch (...) - { - delete pRetDate; - throw; - } - - return pRetDate; -} - -/** - * End of file YearDatatypeValidator::cpp - */ - diff --git a/src/validators/datatype/YearDatatypeValidator.hpp b/src/validators/datatype/YearDatatypeValidator.hpp deleted file mode 100644 index fef0f3caa5f551ba9f1e4b6f083e5b745ca068de..0000000000000000000000000000000000000000 --- a/src/validators/datatype/YearDatatypeValidator.hpp +++ /dev/null @@ -1,112 +0,0 @@ -/* - * 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/11/07 19:18:52 peiyongz - * DateTime Port - * - */ - -#if !defined(YEAR_DATATYPE_VALIDATOR_HPP) -#define YEAR_DATATYPE_VALIDATOR_HPP - -#include <validators/datatype/DateTimeValidator.hpp> - -class VALIDATORS_EXPORT YearDatatypeValidator : public DateTimeValidator -{ -public: - - // ----------------------------------------------------------------------- - // Public ctor/dtor - // ----------------------------------------------------------------------- - /** @name Constructor. */ - //@{ - - YearDatatypeValidator(); - - YearDatatypeValidator(DatatypeValidator* const baseValidator - , RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet); - - ~YearDatatypeValidator(); - - - //@} - - /** - * Returns an instance of the base datatype validator class - * Used by the DatatypeValidatorFactory. - */ - virtual DatatypeValidator* newInstance(RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet); - -protected: - - // ----------------------------------------------------------------------- - // implementation of (DateTimeValidator's) virtual interface - // ----------------------------------------------------------------------- - virtual XMLDateTime* parse(const XMLCh* const); -}; - -/** - * End of file YearDatatypeValidator.hpp - */ -#endif - diff --git a/src/validators/datatype/YearMonthDatatypeValidator.cpp b/src/validators/datatype/YearMonthDatatypeValidator.cpp deleted file mode 100644 index ef9ced512242876207a8b503f3742cf8c23f8a55..0000000000000000000000000000000000000000 --- a/src/validators/datatype/YearMonthDatatypeValidator.cpp +++ /dev/null @@ -1,127 +0,0 @@ -/* - * 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.3 2001/11/15 17:09:23 peiyongz - * catch(...) only. (the invoker need to cath XMLException to display proper message) - * - * Revision 1.2 2001/11/14 22:02:25 peiyongz - * rethrow exception with original error message. - * - * Revision 1.1 2001/11/07 19:18:52 peiyongz - * DateTime Port - * - */ - -// --------------------------------------------------------------------------- -// Includes -// --------------------------------------------------------------------------- -#include <validators/datatype/YearMonthDatatypeValidator.hpp> - -// --------------------------------------------------------------------------- -// Constructors and Destructor -// --------------------------------------------------------------------------- -YearMonthDatatypeValidator::YearMonthDatatypeValidator() -:DateTimeValidator(0, 0, 0, DatatypeValidator::YearMonth) -{} - -YearMonthDatatypeValidator::YearMonthDatatypeValidator( - DatatypeValidator* const baseValidator - , RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet) -:DateTimeValidator(baseValidator, facets, finalSet, DatatypeValidator::YearMonth) -{ - init(enums); -} - -YearMonthDatatypeValidator::~YearMonthDatatypeValidator() -{} - -DatatypeValidator* YearMonthDatatypeValidator::newInstance( - RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet) -{ - return (DatatypeValidator*) new YearMonthDatatypeValidator(this, facets, enums, finalSet); -} - -// -// caller need to release the date created here -// -XMLDateTime* YearMonthDatatypeValidator::parse(const XMLCh* const content) -{ - XMLDateTime *pRetDate = new XMLDateTime(content); - - try - { - pRetDate->parseYearMonth(); - } - catch (...) - { - delete pRetDate; - throw; - } - - return pRetDate; -} - -/** - * End of file YearMonthDatatypeValidator::cpp - */ - diff --git a/src/validators/datatype/YearMonthDatatypeValidator.hpp b/src/validators/datatype/YearMonthDatatypeValidator.hpp deleted file mode 100644 index c6746857faf1dd035c7b7856a0d3245726cf2023..0000000000000000000000000000000000000000 --- a/src/validators/datatype/YearMonthDatatypeValidator.hpp +++ /dev/null @@ -1,112 +0,0 @@ -/* - * 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/11/07 19:18:52 peiyongz - * DateTime Port - * - */ - -#if !defined(YEARMONTH_DATATYPE_VALIDATOR_HPP) -#define YEARMONTH_DATATYPE_VALIDATOR_HPP - -#include <validators/datatype/DateTimeValidator.hpp> - -class VALIDATORS_EXPORT YearMonthDatatypeValidator : public DateTimeValidator -{ -public: - - // ----------------------------------------------------------------------- - // Public ctor/dtor - // ----------------------------------------------------------------------- - /** @name Constructor. */ - //@{ - - YearMonthDatatypeValidator(); - - YearMonthDatatypeValidator(DatatypeValidator* const baseValidator - , RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet); - - ~YearMonthDatatypeValidator(); - - - //@} - - /** - * Returns an instance of the base datatype validator class - * Used by the DatatypeValidatorFactory. - */ - virtual DatatypeValidator* newInstance(RefHashTableOf<KVStringPair>* const facets - , RefVectorOf<XMLCh>* const enums - , const int finalSet); - -protected: - - // ----------------------------------------------------------------------- - // implementation of (DateTimeValidator's) virtual interface - // ----------------------------------------------------------------------- - virtual XMLDateTime* parse(const XMLCh* const); -}; - -/** - * End of file YearMonthDatatypeValidator.hpp - */ -#endif - diff --git a/src/validators/schema/ComplexTypeInfo.cpp b/src/validators/schema/ComplexTypeInfo.cpp deleted file mode 100644 index 38e9f7c74e5a3a179b6477e72fff54583a8ad7fa..0000000000000000000000000000000000000000 --- a/src/validators/schema/ComplexTypeInfo.cpp +++ /dev/null @@ -1,733 +0,0 @@ -/* - * 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$ - * Revision 1.27 2002/01/15 19:09:16 knoaman - * Fix for bug 5807. - * - * Revision 1.26 2002/01/02 15:20:22 tng - * Schema Fix: should not store a temp value as the key in the element pool and the attribute pool. - * - * Revision 1.25 2001/12/17 21:38:59 tng - * Fix dangling pointer. - * - * Revision 1.24 2001/11/21 14:30:13 knoaman - * Fix for UPA checking. - * - * Revision 1.23 2001/11/15 17:10:19 knoaman - * Particle derivation checking support. - * - * Revision 1.22 2001/11/07 21:50:28 tng - * Fix comment log that lead to error. - * - * Revision 1.21 2001/11/07 21:12:15 tng - * Performance: Create QName in ContentSpecNode only if it is a leaf/Any/PCDataNode. - * - * Revision 1.20 2001/10/12 18:08:57 tng - * make sure the second node exists before calling getType - * - * Revision 1.19 2001/10/04 15:08:56 knoaman - * Add support for circular import. - * - * Revision 1.18 2001/09/05 20:49:11 knoaman - * Fix for complexTypes with mixed content model. - * - * Revision 1.17 2001/08/29 21:27:07 knoaman - * no message - * - * Revision 1.16 2001/08/28 20:43:52 knoaman - * Fix for content spec node adoption. - * - * Revision 1.15 2001/08/27 23:04:02 knoaman - * Handle deletion of spec node tree created during UPA checking. - * - * Revision 1.14 2001/08/27 20:48:45 knoaman - * Make the UPA rename before the content model expansion. - * - * Revision 1.13 2001/08/27 20:14:42 knoaman - * Validate attributes in <all>, <redefine>, <group> and <attributeGroup> declarations. - * Misc. fixes. - * - * Revision 1.12 2001/08/24 12:48:48 tng - * Schema: AllContentModel - * - * Revision 1.11 2001/08/23 11:54:26 tng - * Add newline at the end and various typo fixes. - * - * Revision 1.10 2001/08/21 18:14:55 knoaman - * Defer creation of spec node. - * - * Revision 1.9 2001/08/21 16:06:11 tng - * Schema: Unique Particle Attribution Constraint Checking. - * - * Revision 1.8 2001/08/09 15:23:16 knoaman - * add support for <anyAttribute> declaration. - * - * Revision 1.7 2001/07/24 18:33:46 knoaman - * Added support for <group> + extra constraint checking for complexType - * - * Revision 1.6 2001/06/05 13:59:53 knoaman - * Fixes to include and import. - * - * Revision 1.5 2001/05/11 13:27:32 tng - * Copyright update. - * - * Revision 1.4 2001/05/10 17:49:40 tng - * Schema: SchemaValidator fixes - * - * Revision 1.3 2001/05/10 16:33:12 knoaman - * Traverse Schema Part III + error messages. - * - * Revision 1.2 2001/05/03 20:34:41 tng - * Schema: SchemaValidator update - * - * Revision 1.1 2001/04/19 17:43:14 knoaman - * More schema implementation classes. - * - */ - -// --------------------------------------------------------------------------- -// Includes -// --------------------------------------------------------------------------- -#include <framework/XMLBuffer.hpp> -#include <validators/schema/ComplexTypeInfo.hpp> -#include <validators/schema/SchemaAttDefList.hpp> -#include <validators/common/AllContentModel.hpp> -#include <validators/common/ContentSpecNode.hpp> -#include <validators/common/DFAContentModel.hpp> -#include <validators/common/MixedContentModel.hpp> -#include <validators/common/SimpleContentModel.hpp> - -// --------------------------------------------------------------------------- -// ComplexTypeInfo: Constructors and Destructor -// --------------------------------------------------------------------------- -ComplexTypeInfo::ComplexTypeInfo() - : fAbstract(false) - , fAdoptContentSpec(true) - , fAttWithTypeId(false) - , fPreprocessed(false) - , fDerivedBy(0) - , fBlockSet(0) - , fFinalSet(0) - , fScopeDefined(Grammar::TOP_LEVEL_SCOPE) - , fElementId(XMLElementDecl::fgInvalidElemId) - , fContentType(SchemaElementDecl::Empty) - , fRecursingTypeIndex(-1) - , fTypeName(0) - , fBaseDatatypeValidator(0) - , fDatatypeValidator(0) - , fBaseComplexTypeInfo(0) - , fContentSpec(0) - , fAttWildCard(0) - , fAttDefs(0) - , fAttList(0) - , fElements(0) - , fContentModel(0) - , fFormattedModel(0) - , fContentSpecOrgURI(0) - , fUniqueURI(0) - , fContentSpecOrgURISize(16) - , fSpecNodesToDelete(0) -{ - -} - - -ComplexTypeInfo::~ComplexTypeInfo() -{ - delete [] fTypeName; - - if (fAdoptContentSpec) { - delete fContentSpec; - } - - delete fAttWildCard; - delete fAttDefs; - delete fAttList; - delete fElements; - delete fSpecNodesToDelete; - - delete fContentModel; - delete [] fFormattedModel; - delete [] fContentSpecOrgURI; -} - -// --------------------------------------------------------------------------- -// ComplexTypeInfo: Setter methods -// --------------------------------------------------------------------------- -void ComplexTypeInfo::addAttDef(SchemaAttDef* const toAdd) { - - // Fault in the att list if required - if (!fAttDefs) - faultInAttDefList(); - - // Tell this guy the element id of its parent (us) - toAdd->setElemId(getElementId()); - - fAttDefs->put((void*)(toAdd->getAttName()->getLocalPart()), - toAdd->getAttName()->getURI(), toAdd); -} - -void ComplexTypeInfo::setContentSpec(ContentSpecNode* const toAdopt) { - - if (fContentSpec && fAdoptContentSpec) { - delete fContentSpec; - } - - fContentSpec = toAdopt; -} - -// --------------------------------------------------------------------------- -// ComplexTypeInfo: Getter methods -// --------------------------------------------------------------------------- -XMLAttDefList& ComplexTypeInfo::getAttDefList() const -{ - if (!fAttList) - { - // If the att def list is not made yet, then fault it in too - if (!fAttDefs) - faultInAttDefList(); - - ((ComplexTypeInfo*)this)->fAttList = new SchemaAttDefList(fAttDefs); - } - - // Reset it before we return it - fAttList->Reset(); - return *fAttList; -} - -const XMLCh* -ComplexTypeInfo::getFormattedContentModel() const -{ - // - // If its not already built, then call the protected virtual method - // to allow the derived class to build it (since only it knows.) - // Otherwise, just return the previously formatted methods. - // - // Since we are faulting this in, within a const getter, we have to - // cast off the const-ness. - // - if (!fFormattedModel) - ((ComplexTypeInfo*)this)->fFormattedModel = formatContentModel(); - - return fFormattedModel; -} - -// --------------------------------------------------------------------------- -// ComplexTypeInfo: Helper methods -// --------------------------------------------------------------------------- -XMLAttDef* ComplexTypeInfo::findAttr(const XMLCh* const qName - , const unsigned int uriId - , const XMLCh* const baseName - , const XMLCh* const prefix - , const XMLElementDecl::LookupOpts options - , bool& wasAdded) const -{ - SchemaAttDef* retVal = 0; - - // If no att list faulted in yet, then it cannot exist - if (fAttDefs) - retVal = fAttDefs->get(baseName, uriId); - - // Fault it in if not found and ask to add it - if (!retVal && (options == XMLElementDecl::AddIfNotFound)) - { - // Fault in the list itself if not already - if (!fAttDefs) - faultInAttDefList(); - - // And add a default attribute for this name - retVal = new SchemaAttDef(prefix, baseName, uriId); - retVal->setElemId(getElementId()); - fAttDefs->put((void*)retVal->getAttName()->getLocalPart(), uriId, retVal); - - wasAdded = true; - } - else - { - wasAdded = false; - } - return retVal; -} - -bool ComplexTypeInfo::resetDefs() { - - // If the collection hasn't been faulted in, then no att defs - if (!fAttDefs) - return false; - - // - // Ok, run through them and clear the 'provided' flag on each of them. - // This lets the scanner use them to track which has been provided and - // which have not. - // - RefHash2KeysTableOfEnumerator<SchemaAttDef> enumDefs(fAttDefs); - while (enumDefs.hasMoreElements()) - enumDefs.nextElement().setProvided(false); - - return true; -} - - -void ComplexTypeInfo::checkUniqueParticleAttribution (SchemaGrammar* const pGrammar, - GrammarResolver* const pGrammarResolver, - XMLStringPool* const pStringPool, - XMLValidator* const pValidator) -{ - if (fContentSpec) { - ContentSpecNode* specNode = new ContentSpecNode(*fContentSpec); - XMLContentModel* cm = makeContentModel(true, specNode); - - if (cm) { - cm->checkUniqueParticleAttribution(pGrammar, pGrammarResolver, pStringPool, pValidator, fContentSpecOrgURI); - delete cm; - } - - fSpecNodesToDelete->removeAllElements(); - } -} - -// --------------------------------------------------------------------------- -// ComplexTypeInfo: Private Helper methods -// --------------------------------------------------------------------------- -void ComplexTypeInfo::faultInAttDefList() const -{ - // Use a hash modulus of 29 and tell it owns its elements - ((ComplexTypeInfo*)this)->fAttDefs = - new RefHash2KeysTableOf<SchemaAttDef>(29, true); -} - -XMLCh* ComplexTypeInfo::formatContentModel() const -{ - XMLCh* newValue = 0; - if (fContentType == SchemaElementDecl::Any) - { - newValue = XMLString::replicate(XMLUni::fgAnyString); - } - else if (fContentType == SchemaElementDecl::Empty) - { - newValue = XMLString::replicate(XMLUni::fgEmptyString); - } - else - { - // - // Use a temp XML buffer to format into. Content models could be - // pretty long, but very few will be longer than one K. The buffer - // will expand to handle the more pathological ones. - // - const ContentSpecNode* specNode = fContentSpec; - - if (specNode) { - XMLBuffer bufFmt; - - - specNode->formatSpec(bufFmt); - newValue = XMLString::replicate(bufFmt.getRawBuffer()); - } - } - return newValue; -} - -XMLContentModel* ComplexTypeInfo::makeContentModel(const bool checkUPA, ContentSpecNode* const specNode) -{ - if ((specNode || fContentSpec) && !fSpecNodesToDelete) { - fSpecNodesToDelete = new RefVectorOf<ContentSpecNode>(8); - } - - // expand the content spec first - ContentSpecNode* aSpecNode = specNode; - if (aSpecNode) { - - fContentSpecOrgURI = new unsigned int[fContentSpecOrgURISize]; - aSpecNode = convertContentSpecTree(aSpecNode, checkUPA); - fSpecNodesToDelete->addElement(aSpecNode); - } - else { - aSpecNode = convertContentSpecTree(fContentSpec, checkUPA); - if (aSpecNode != fContentSpec) { - if (!fAdoptContentSpec && (aSpecNode == fContentSpec->getFirst())) - fAdoptContentSpec = false; - else - fAdoptContentSpec = true; - - fContentSpec = aSpecNode; - } - } - - - XMLContentModel* cmRet = 0; - if (fContentType == SchemaElementDecl::Simple) { - // just return nothing - } - else if (fContentType == SchemaElementDecl::Mixed_Simple) - { - // - // Just create a mixel content model object. This type of - // content model is optimized for mixed content validation. - // - cmRet = new MixedContentModel(false, aSpecNode); - } - else if (fContentType == SchemaElementDecl::Mixed_Complex) { - - cmRet = createChildModel(aSpecNode, true); - } - else if (fContentType == SchemaElementDecl::Children) - { - // - // This method will create an optimal model for the complexity - // of the element's defined model. If its simple, it will create - // a SimpleContentModel object. If its a simple list, it will - // create a SimpleListContentModel object. If its complex, it - // will create a DFAContentModel object. - // - cmRet = createChildModel(aSpecNode, false); - } - else - { - ThrowXML(RuntimeException, XMLExcepts::CM_MustBeMixedOrChildren); - } - - return cmRet; -} - - - -// --------------------------------------------------------------------------- -// SchemaElementDecl: Private helper methods -// --------------------------------------------------------------------------- -XMLContentModel* ComplexTypeInfo::createChildModel(ContentSpecNode* specNode, const bool isMixed) -{ - if(!specNode) - ThrowXML(RuntimeException, XMLExcepts::CM_UnknownCMSpecType); - - ContentSpecNode::NodeTypes specType = specNode->getType(); - // - // Do a sanity check that the node is does not have a PCDATA id. Since, - // if it was, it should have already gotten taken by the Mixed model. - // - if (specNode->getElement()) { - if (specNode->getElement()->getURI() == XMLElementDecl::fgPCDataElemId) - ThrowXML(RuntimeException, XMLExcepts::CM_NoPCDATAHere); - } - - // - // According to the type of node, we will create the correct type of - // content model. - // - if (((specType & 0x0f) == ContentSpecNode::Any) || - ((specType & 0x0f) == ContentSpecNode::Any_Other) || - ((specType & 0x0f) == ContentSpecNode::Any_NS)) { - // let fall through to build a DFAContentModel - } - else if (isMixed) - { - if (specType == ContentSpecNode::All) { - // All the nodes under an ALL must be additional ALL nodes and - // ELEMENTs (or ELEMENTs under ZERO_OR_ONE nodes.) - // We collapse the ELEMENTs into a single vector. - return new AllContentModel(specNode, true); - } - else if (specType == ContentSpecNode::ZeroOrOne) { - // An ALL node can appear under a ZERO_OR_ONE node. - if (specNode->getFirst()->getType() == ContentSpecNode::All) { - return new AllContentModel(specNode->getFirst(), true); - } - } - - // otherwise, let fall through to build a DFAContentModel - } - else if (specType == ContentSpecNode::Leaf) - { - // Create a simple content model - return new SimpleContentModel - ( - false - , specNode->getElement() - , 0 - , ContentSpecNode::Leaf - ); - } - else if ((specType == ContentSpecNode::Choice) - || (specType == ContentSpecNode::Sequence)) - { - // - // Lets see if both of the children are leafs. If so, then it has to - // be a simple content model - // - if ((specNode->getFirst()->getType() == ContentSpecNode::Leaf) - && (specNode->getSecond()) - && (specNode->getSecond()->getType() == ContentSpecNode::Leaf)) - { - return new SimpleContentModel - ( - false - , specNode->getFirst()->getElement() - , specNode->getSecond()->getElement() - , specType - ); - } - } - else if ((specType == ContentSpecNode::OneOrMore) - || (specType == ContentSpecNode::ZeroOrMore) - || (specType == ContentSpecNode::ZeroOrOne)) - { - // - // Its a repetition, so see if its one child is a leaf. If so its a - // repetition of a single element, so we can do a simple content - // model for that. - // - if (specNode->getFirst()->getType() == ContentSpecNode::Leaf) - { - return new SimpleContentModel - ( - false - , specNode->getFirst()->getElement() - , 0 - , specType - ); - } - else if (specNode->getFirst()->getType() == ContentSpecNode::All) - return new AllContentModel(specNode->getFirst(), false); - - } - else if (specType == ContentSpecNode::All) - return new AllContentModel(specNode, false); - - else - { - ThrowXML(RuntimeException, XMLExcepts::CM_UnknownCMSpecType); - } - - // Its not any simple type of content, so create a DFA based content model - return new DFAContentModel(false, specNode, isMixed); -} - -ContentSpecNode* -ComplexTypeInfo::convertContentSpecTree(ContentSpecNode* const curNode, - const bool checkUPA) { - - if (!curNode) - return 0; - - const ContentSpecNode::NodeTypes curType = curNode->getType(); - - // When checking Unique Particle Attribution, rename leaf elements - if (checkUPA) { - if (curNode->getElement()) { - fContentSpecOrgURI[fUniqueURI] = curNode->getElement()->getURI(); - curNode->getElement()->setURI(fUniqueURI); - fUniqueURI++; - } - if (fUniqueURI == fContentSpecOrgURISize) - resizeContentSpecOrgURI(); - } - - // Get the spec type of the passed node - int minOccurs = curNode->getMinOccurs(); - int maxOccurs = curNode->getMaxOccurs(); - ContentSpecNode* retNode = curNode; - - if ((curType & 0x0f) == ContentSpecNode::Any - || (curType & 0x0f) == ContentSpecNode::Any_Other - || (curType & 0x0f) == ContentSpecNode::Any_NS - || curType == ContentSpecNode::Leaf) - { - retNode = expandContentModel(curNode, minOccurs, maxOccurs); - } - else if ((curType == ContentSpecNode::Choice) - || (curType == ContentSpecNode::All) - || (curType == ContentSpecNode::Sequence)) - { - ContentSpecNode* childNode = curNode->getFirst(); - ContentSpecNode* leftNode = convertContentSpecTree(childNode, checkUPA); - ContentSpecNode* rightNode = curNode->getSecond(); - - if (!rightNode) { - - retNode = expandContentModel(leftNode, minOccurs, maxOccurs); - curNode->setAdoptFirst(false); - delete curNode; - return retNode; - } - - if (leftNode != childNode) { - - curNode->setAdoptFirst(false); - curNode->setFirst(leftNode); - curNode->setAdoptFirst(true); - } - - childNode = rightNode; - rightNode = convertContentSpecTree(childNode, checkUPA); - - if (rightNode != childNode) { - - curNode->setAdoptSecond(false); - curNode->setSecond(rightNode); - curNode->setAdoptSecond(true); - } - - retNode = expandContentModel(curNode, minOccurs, maxOccurs); - } - - return retNode; -} - -ContentSpecNode* ComplexTypeInfo::expandContentModel(ContentSpecNode* const specNode, - const int minOccurs, - const int maxOccurs) -{ - if (!specNode) { - return 0; - } - - ContentSpecNode* saveNode = specNode; - ContentSpecNode* retNode = specNode; - - if (minOccurs == 1 && maxOccurs == 1) { - } - else if (minOccurs == 0 && maxOccurs == 1) { - - retNode = new ContentSpecNode(ContentSpecNode::ZeroOrOne, retNode, 0); - } - else if (minOccurs == 0 && maxOccurs == -1) { - retNode = new ContentSpecNode(ContentSpecNode::ZeroOrMore, retNode, 0); - } - else if (minOccurs == 1 && maxOccurs == -1) { - retNode = new ContentSpecNode(ContentSpecNode::OneOrMore, retNode, 0); - } - else if (maxOccurs == -1) { - - retNode = new ContentSpecNode(ContentSpecNode::OneOrMore, retNode, 0); - - for (int i=0; i < (int)(minOccurs-1); i++) { - retNode = new ContentSpecNode(ContentSpecNode::Sequence, - saveNode, retNode, false); - } - } - else { - - if (minOccurs == 0) { - - ContentSpecNode* optional = - new ContentSpecNode(ContentSpecNode::ZeroOrOne, saveNode, 0); - - retNode = optional; - - for (int i=0; i < (int)(maxOccurs-minOccurs-1); i++) { - retNode = new ContentSpecNode(ContentSpecNode::Sequence, - retNode, optional, true, false); - } - } - else { - - if (minOccurs > 1) { - - retNode = new ContentSpecNode(ContentSpecNode::Sequence, - retNode, saveNode, true, false); - - for (int i=1; i < (int)(minOccurs-1); i++) { - retNode = new ContentSpecNode(ContentSpecNode::Sequence, - retNode, saveNode, true, false); - } - } - - int counter = maxOccurs-minOccurs; - - if (counter > 0) { - - ContentSpecNode* optional = new ContentSpecNode(ContentSpecNode::ZeroOrOne, saveNode, 0, false); - - retNode = new ContentSpecNode(ContentSpecNode::Sequence, retNode, optional); - - for (int j=1; j < counter; j++) { - - retNode = new ContentSpecNode(ContentSpecNode::Sequence, - retNode, optional, true, false); - } - } - } - } - - return retNode; -} - -void ComplexTypeInfo::resizeContentSpecOrgURI() { - - unsigned int newSize = fContentSpecOrgURISize * 2; - unsigned int* newContentSpecOrgURI = new unsigned int[newSize]; - - // Copy the existing values - unsigned int index = 0; - for (; index < fContentSpecOrgURISize; index++) - newContentSpecOrgURI[index] = fContentSpecOrgURI[index]; - - for (; index < newSize; index++) - newContentSpecOrgURI[index] = 0; - - // Delete the old array and udpate our members - delete [] fContentSpecOrgURI; - fContentSpecOrgURI = newContentSpecOrgURI; - fContentSpecOrgURISize = newSize; -} - - -/** - * End of file ComplexTypeInfo.cpp - */ - - diff --git a/src/validators/schema/ComplexTypeInfo.hpp b/src/validators/schema/ComplexTypeInfo.hpp deleted file mode 100644 index f1bb4ea215f3283c85e52dd796cc7d61ddc28414..0000000000000000000000000000000000000000 --- a/src/validators/schema/ComplexTypeInfo.hpp +++ /dev/null @@ -1,526 +0,0 @@ -/* - * 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$ - */ - -#if !defined(COMPLEXTYPEINFO_HPP) -#define COMPLEXTYPEINFO_HPP - - -/** - * The class act as a place holder to store complex type information. - * - * The class is intended for internal use. - */ - -// --------------------------------------------------------------------------- -// Includes -// --------------------------------------------------------------------------- -#include <util/XMLString.hpp> -#include <util/RefHash2KeysTableOf.hpp> -#include <util/RefVectorOf.hpp> -#include <util/Janitor.hpp> -#include <framework/XMLElementDecl.hpp> -#include <framework/XMLContentModel.hpp> -#include <validators/schema/SchemaAttDef.hpp> - - -// --------------------------------------------------------------------------- -// Forward Declarations -// --------------------------------------------------------------------------- -class DatatypeValidator; -class ContentSpecNode; -class SchemaAttDefList; -class SchemaElementDecl; - - -class VALIDATORS_EXPORT ComplexTypeInfo -{ -public: - // ----------------------------------------------------------------------- - // Public Constructors/Destructor - // ----------------------------------------------------------------------- - ComplexTypeInfo(); - ~ComplexTypeInfo(); - - // ----------------------------------------------------------------------- - // Getter methods - // ----------------------------------------------------------------------- - bool getAbstract() const; - bool getAdoptContentSpec() const; - bool containsAttWithTypeId() const; - bool getPreprocessed() const; - int getDerivedBy() const; - int getBlockSet() const; - int getFinalSet() const; - int getScopeDefined() const; - unsigned int getElementId() const; - int getContentType() const; - unsigned int elementCount() const; - XMLCh* getTypeName() const; - DatatypeValidator* getBaseDatatypeValidator() const; - DatatypeValidator* getDatatypeValidator() const; - ComplexTypeInfo* getBaseComplexTypeInfo() const; - ContentSpecNode* getContentSpec() const; - const SchemaAttDef* getAttWildCard() const; - SchemaAttDef* getAttWildCard(); - const SchemaAttDef* getAttDef(const XMLCh* const baseName, - const int uriId) const; - SchemaAttDef* getAttDef(const XMLCh* const baseName, - const int uriId); - XMLAttDefList& getAttDefList() const; - const SchemaElementDecl* elementAt(const unsigned int index) const; - SchemaElementDecl* elementAt(const unsigned int index); - XMLContentModel* getContentModel(const bool checkUPA = false); - const XMLCh* getFormattedContentModel () const; - int getRecursingTypeIndex() const; - - // ----------------------------------------------------------------------- - // Setter methods - // ----------------------------------------------------------------------- - void setAbstract(const bool isAbstract); - void setAdoptContentSpec(const bool toAdopt); - void setAttWithTypeId(const bool value); - void setPreprocessed(const bool aValue = true); - void setDerivedBy(const int derivedBy); - void setBlockSet(const int blockSet); - void setFinalSet(const int finalSet); - void setScopeDefined(const int scopeDefined); - void setElementId(const unsigned int elemId); - void setTypeName(const XMLCh* const typeName); - void setContentType(const int contentType); - void setBaseDatatypeValidator(DatatypeValidator* const baseValidator); - void setDatatypeValidator(DatatypeValidator* const validator); - void setBaseComplexTypeInfo(ComplexTypeInfo* const typeInfo); - void setContentSpec(ContentSpecNode* const toAdopt); - void setAttWildCard(SchemaAttDef* const toAdopt); - void addAttDef(SchemaAttDef* const toAdd); - void addElement(SchemaElementDecl* const toAdd); - void setContentModel(XMLContentModel* const newModelToAdopt); - void setRecursingTypeIndex(const int anIndex); - - // ----------------------------------------------------------------------- - // Helper methods - // ----------------------------------------------------------------------- - bool hasAttDefs() const; - bool contains(const XMLCh* const attName); - XMLAttDef* findAttr - ( - const XMLCh* const qName - , const unsigned int uriId - , const XMLCh* const baseName - , const XMLCh* const prefix - , const XMLElementDecl::LookupOpts options - , bool& wasAdded - ) const; - bool resetDefs(); - void checkUniqueParticleAttribution - ( - SchemaGrammar* const pGrammar - , GrammarResolver* const pGrammarResolver - , XMLStringPool* const pStringPool - , XMLValidator* const pValidator - ) ; - -private: - // ----------------------------------------------------------------------- - // Unimplemented contstructors and operators - // ----------------------------------------------------------------------- - ComplexTypeInfo(const ComplexTypeInfo& elemInfo); - ComplexTypeInfo& operator= (const ComplexTypeInfo& other); - - // ----------------------------------------------------------------------- - // Private helper methods - // ----------------------------------------------------------------------- - void faultInAttDefList() const; - XMLContentModel* createChildModel(ContentSpecNode* specNode, const bool isMixed); - XMLContentModel* makeContentModel(const bool checkUPA = false, ContentSpecNode* const specNode = 0); - XMLCh* formatContentModel () const ; - ContentSpecNode* expandContentModel(ContentSpecNode* const curNode, const int minOccurs, const int maxOccurs); - ContentSpecNode* convertContentSpecTree(ContentSpecNode* const curNode, const bool checkUPA = false); - void resizeContentSpecOrgURI(); - - // ----------------------------------------------------------------------- - // Private data members - // ----------------------------------------------------------------------- - bool fAbstract; - bool fAdoptContentSpec; - bool fAttWithTypeId; - bool fPreprocessed; - int fDerivedBy; - int fBlockSet; - int fFinalSet; - int fScopeDefined; - unsigned int fElementId; - int fContentType; - int fRecursingTypeIndex; - XMLCh* fTypeName; - DatatypeValidator* fBaseDatatypeValidator; - DatatypeValidator* fDatatypeValidator; - ComplexTypeInfo* fBaseComplexTypeInfo; - ContentSpecNode* fContentSpec; - SchemaAttDef* fAttWildCard; - RefHash2KeysTableOf<SchemaAttDef>* fAttDefs; - SchemaAttDefList* fAttList; - RefVectorOf<SchemaElementDecl>* fElements; - XMLContentModel* fContentModel; - XMLCh* fFormattedModel; - unsigned int* fContentSpecOrgURI; - unsigned int fUniqueURI; - unsigned int fContentSpecOrgURISize; - RefVectorOf<ContentSpecNode>* fSpecNodesToDelete; -}; - -// --------------------------------------------------------------------------- -// ComplexTypeInfo: Getter methods -// --------------------------------------------------------------------------- -inline bool ComplexTypeInfo::getAbstract() const { - - return fAbstract; -} - -inline bool ComplexTypeInfo::getAdoptContentSpec() const { - - return fAdoptContentSpec; -} - -inline bool ComplexTypeInfo::containsAttWithTypeId() const { - - return fAttWithTypeId; -} - -inline bool ComplexTypeInfo::getPreprocessed() const { - - return fPreprocessed; -} - -inline int ComplexTypeInfo::getDerivedBy() const { - - return fDerivedBy; -} - -inline int ComplexTypeInfo::getBlockSet() const { - - return fBlockSet; -} - -inline int ComplexTypeInfo::getFinalSet() const { - - return fFinalSet; -} - -inline int ComplexTypeInfo::getScopeDefined() const { - - return fScopeDefined; -} - -inline unsigned int ComplexTypeInfo::getElementId() const { - - return fElementId; -} - -inline int ComplexTypeInfo::getContentType() const { - - return fContentType; -} - -inline unsigned int ComplexTypeInfo::elementCount() const { - - if (fElements) { - return fElements->size(); - } - - return 0; -} - -inline XMLCh* ComplexTypeInfo::getTypeName() const { - - return fTypeName; -} - -inline DatatypeValidator* ComplexTypeInfo::getBaseDatatypeValidator() const { - - return fBaseDatatypeValidator; -} - -inline DatatypeValidator* ComplexTypeInfo::getDatatypeValidator() const { - - return fDatatypeValidator; -} - -inline ComplexTypeInfo* ComplexTypeInfo::getBaseComplexTypeInfo() const { - - return fBaseComplexTypeInfo; -} - -inline ContentSpecNode* ComplexTypeInfo::getContentSpec() const { - - return fContentSpec; -} - -inline const SchemaAttDef* ComplexTypeInfo::getAttWildCard() const { - - return fAttWildCard; -} - -inline SchemaAttDef* ComplexTypeInfo::getAttWildCard() { - - return fAttWildCard; -} - -inline const SchemaAttDef* ComplexTypeInfo::getAttDef(const XMLCh* const baseName, - const int uriId) const { - - // If no list, then return a null - if (!fAttDefs) - return 0; - - return fAttDefs->get(baseName, uriId); -} - -inline SchemaAttDef* ComplexTypeInfo::getAttDef(const XMLCh* const baseName, - const int uriId) -{ - // If no list, then return a null - if (!fAttDefs) - return 0; - - return fAttDefs->get(baseName, uriId); -} - -inline SchemaElementDecl* -ComplexTypeInfo::elementAt(const unsigned int index) { - - if (!fElements) { - return 0; // REVISIT - need to throw an exception - } - - return fElements->elementAt(index); -} - -inline const SchemaElementDecl* -ComplexTypeInfo::elementAt(const unsigned int index) const { - - if (!fElements) { - return 0; // REVISIT - need to throw an exception - } - - return fElements->elementAt(index); -} - -inline XMLContentModel* ComplexTypeInfo::getContentModel(const bool checkUPA) -{ - if (!fContentModel) - fContentModel = makeContentModel(checkUPA); - - return fContentModel; -} - -inline int ComplexTypeInfo::getRecursingTypeIndex() const { - - return fRecursingTypeIndex; -} - -// --------------------------------------------------------------------------- -// ComplexTypeInfo: Setter methods -// --------------------------------------------------------------------------- -inline void ComplexTypeInfo::setAbstract(const bool isAbstract) { - - fAbstract = isAbstract; -} - -inline void ComplexTypeInfo::setAdoptContentSpec(const bool toAdopt) { - - fAdoptContentSpec = toAdopt; -} - -inline void ComplexTypeInfo::setAttWithTypeId(const bool value) { - - fAttWithTypeId = value; -} - -inline void ComplexTypeInfo::setPreprocessed(const bool aValue) { - - fPreprocessed = aValue; -} - -inline void ComplexTypeInfo::setDerivedBy(const int derivedBy) { - - fDerivedBy = derivedBy; -} - -inline void ComplexTypeInfo::setBlockSet(const int blockSet) { - - fBlockSet = blockSet; -} - -inline void ComplexTypeInfo::setFinalSet(const int finalSet) { - - fFinalSet = finalSet; -} - -inline void ComplexTypeInfo::setScopeDefined(const int scopeDefined) { - - fScopeDefined = scopeDefined; -} - -inline void ComplexTypeInfo::setElementId(const unsigned int elemId) { - - fElementId = elemId; -} - -inline void -ComplexTypeInfo::setContentType(const int contentType) { - - fContentType = contentType; -} - -inline void ComplexTypeInfo::setTypeName(const XMLCh* const typeName) { - - if (fTypeName != 0) { - delete [] fTypeName; - } - - fTypeName = XMLString::replicate(typeName); -} - -inline void -ComplexTypeInfo::setBaseDatatypeValidator(DatatypeValidator* const validator) { - - fBaseDatatypeValidator = validator; -} - -inline void -ComplexTypeInfo::setDatatypeValidator(DatatypeValidator* const validator) { - - fDatatypeValidator = validator; -} - -inline void -ComplexTypeInfo::setBaseComplexTypeInfo(ComplexTypeInfo* const typeInfo) { - - fBaseComplexTypeInfo = typeInfo; -} - -inline void ComplexTypeInfo::addElement(SchemaElementDecl* const elem) { - - if (!fElements) { - fElements = new RefVectorOf<SchemaElementDecl>(8, false); - } - - fElements->addElement(elem); -} - -inline void ComplexTypeInfo::setAttWildCard(SchemaAttDef* const toAdopt) { - - if (fAttWildCard) { - delete fAttWildCard; - } - - fAttWildCard = toAdopt; -} - -inline void -ComplexTypeInfo::setContentModel(XMLContentModel* const newModelToAdopt) -{ - delete fContentModel; - fContentModel = newModelToAdopt; -} - -inline void ComplexTypeInfo::setRecursingTypeIndex(const int anIndex) { - - fRecursingTypeIndex = anIndex; -} - -// --------------------------------------------------------------------------- -// ComplexTypeInfo: Helper methods -// --------------------------------------------------------------------------- -inline bool ComplexTypeInfo::hasAttDefs() const -{ - // If the collection hasn't been faulted in, then no att defs - if (!fAttDefs) - return false; - - return !fAttDefs->isEmpty(); -} - -inline bool ComplexTypeInfo::contains(const XMLCh* const attName) { - - if (!fAttDefs) { - return false; - } - - RefHash2KeysTableOfEnumerator<SchemaAttDef> enumDefs(fAttDefs); - - while (enumDefs.hasMoreElements()) { - - if (XMLString::compareString(attName, - enumDefs.nextElement().getAttName()->getLocalPart()) == 0) { - return true; - } - } - - return false; -} - -#endif - -/** - * End of file ComplexTypeInfo.hpp - */ - diff --git a/src/validators/schema/GeneralAttributeCheck.cpp b/src/validators/schema/GeneralAttributeCheck.cpp deleted file mode 100644 index d298dfbf219a5f1e9b4ead4ee8e56c993ad19903..0000000000000000000000000000000000000000 --- a/src/validators/schema/GeneralAttributeCheck.cpp +++ /dev/null @@ -1,1120 +0,0 @@ -/* - * 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$ - * Revision 1.16 2002/01/02 19:50:34 knoaman - * Fix for error message when checking for attributes with a namespace prefix. - * - * Revision 1.15 2001/12/13 18:08:39 knoaman - * Fix for bug 5410. - * - * Revision 1.14 2001/11/19 18:26:31 knoaman - * no message - * - * Revision 1.13 2001/11/19 17:37:55 knoaman - * Use the instance of ID datatye validator directly. - * - * Revision 1.12 2001/11/16 15:03:37 knoaman - * Design change: GeneralAttributeCheck is not longer a singleton class. - * - * Revision 1.11 2001/11/02 14:13:45 knoaman - * Add support for identity constraints. - * - * Revision 1.10 2001/10/25 15:07:46 tng - * Thread safe the static instance. - * - * Revision 1.9 2001/10/23 23:14:55 peiyongz - * [Bug#880] patch to PlatformUtils:init()/term() and related. from Mark Weaver - * - * Revision 1.8 2001/10/16 17:01:58 knoaman - * Extra constraint checking. - * - * Revision 1.7 2001/10/15 19:29:26 knoaman - * Add support for <notation> declaration. - * - * Revision 1.6 2001/09/18 14:41:56 knoaman - * Add support for <annotation>. - * - * Revision 1.5 2001/08/27 20:14:42 knoaman - * Validate attributes in <all>, <redefine>, <group> and <attributeGroup> declarations. - * Misc. fixes. - * - * Revision 1.4 2001/06/06 13:09:02 knoaman - * Use BooleanDatatypeValidator to validate values. - * - * Revision 1.3 2001/05/18 20:05:30 knoaman - * Modified wording of error messages. - * - * Revision 1.2 2001/05/17 18:11:15 knoaman - * More constraint and attribute checking. - * - * Revision 1.1 2001/05/15 21:59:31 knoaman - * TraverseSchema: add attribute checking + some fixes + more error messages. - * More attribute cheking to come. - * - */ - -// --------------------------------------------------------------------------- -// Includes -// --------------------------------------------------------------------------- -#include <validators/schema/GeneralAttributeCheck.hpp> -#include <validators/schema/SchemaSymbols.hpp> -#include <util/XMLString.hpp> -#include <util/XMLUniDefs.hpp> -#include <util/Janitor.hpp> -#include <dom/DOM_NamedNodeMap.hpp> -#include <framework/XMLErrorCodes.hpp> -#include <validators/schema/TraverseSchema.hpp> -#include <util/PlatformUtils.hpp> -#include <util/XMLRegisterCleanup.hpp> -#include <validators/datatype/DatatypeValidatorFactory.hpp> - -// --------------------------------------------------------------------------- -// Local const data -// --------------------------------------------------------------------------- -const XMLCh fgValueZero[] = -{ - chDigit_0, chNull -}; - -const XMLCh fgValueOne[] = -{ - chDigit_1, chNull -}; - -const XMLCh fgUnbounded[] = -{ - chLatin_u, chLatin_n, chLatin_b, chLatin_o, chLatin_u, chLatin_n, chLatin_d, - chLatin_e, chLatin_d, chNull -}; - -const XMLCh fgLocal[] = -{ - chLatin_l, chLatin_o, chLatin_c, chLatin_a, chLatin_l, chNull -}; - -const XMLCh fgGlobal[] = -{ - chLatin_g, chLatin_l, chLatin_o, chLatin_b, chLatin_a, chLatin_l, chNull -}; - - -// --------------------------------------------------------------------------- -// Static member data initialization -// --------------------------------------------------------------------------- -const unsigned short GeneralAttributeCheck::GlobalContext = 0; -const unsigned short GeneralAttributeCheck::LocalContext = 1; -AttributeInfo** GeneralAttributeCheck::fAttributes = 0; -DatatypeValidator** GeneralAttributeCheck::fValidators = 0; -RefHash2KeysTableOf<RefVectorOfAttributeInfo>* GeneralAttributeCheck::fElementMap = 0; - -// --------------------------------------------------------------------------- -// Static local data -// --------------------------------------------------------------------------- -static XMLMutex* sGeneralAttCheckMutex = 0; -static XMLRegisterCleanup GeneralAttCheckCleanup; - - -// --------------------------------------------------------------------------- -// AttributeInfo: Constructors and Destructor -// --------------------------------------------------------------------------- -AttributeInfo::AttributeInfo(const XMLCh* const name, - const short defaultOption, - const XMLCh* const defaultValue, - const short dvIndex) - : fDefaultOption(defaultOption) - , fValidatorIndex(dvIndex) - , fName(XMLString::replicate(name)) - , fDefaultValue(0) -{ - try { - if (defaultValue) { - fDefaultValue = XMLString::replicate(defaultValue); - } - } - catch(...) { - cleanUp(); - } -} - - -AttributeInfo::~AttributeInfo() -{ - cleanUp(); -} - - - -// --------------------------------------------------------------------------- -// GeneralAttributeCheck: Constructors and Destructor -// --------------------------------------------------------------------------- -GeneralAttributeCheck::GeneralAttributeCheck() - : fIDRefList(0) -{ - mapElements(); -} - -GeneralAttributeCheck::~GeneralAttributeCheck() -{ -} - - -// --------------------------------------------------------------------------- -// GeneralAttributeCheck: Setup methods -// --------------------------------------------------------------------------- -void GeneralAttributeCheck::setUpAttributes() { - - fAttributes = new AttributeInfo*[Att_Count]; - - fAttributes[Att_Abstract_D] = - new AttributeInfo(SchemaSymbols::fgATT_ABSTRACT, Att_Optional_Default, - SchemaSymbols::fgATTVAL_FALSE, DT_Boolean); - - fAttributes[Att_Attribute_FD_D] = - new AttributeInfo(SchemaSymbols::fgATT_ATTRIBUTEFORMDEFAULT, Att_Optional_Default, - SchemaSymbols::fgATTVAL_UNQUALIFIED, DT_Form); - - fAttributes[Att_Base_R] = - new AttributeInfo(SchemaSymbols::fgATT_BASE, Att_Required, - 0, DT_QName); - - fAttributes[Att_Base_N] = - new AttributeInfo(SchemaSymbols::fgATT_BASE, Att_Optional_NoDefault, - 0, DT_QName); - - fAttributes[Att_Block_N] = - new AttributeInfo(SchemaSymbols::fgATT_BLOCK, Att_Optional_NoDefault, - 0, DT_Block); - - fAttributes[Att_Block1_N] = - new AttributeInfo(SchemaSymbols::fgATT_BLOCK, Att_Optional_NoDefault, - 0, DT_Block1); - - fAttributes[Att_Block_D_D] = - new AttributeInfo(SchemaSymbols::fgATT_BLOCKDEFAULT, Att_Optional_Default, - XMLUni::fgZeroLenString, DT_Block); - - fAttributes[Att_Default_N] = - new AttributeInfo(SchemaSymbols::fgATT_DEFAULT, Att_Optional_NoDefault, - 0, DT_String); - - fAttributes[Att_Element_FD_D] = - new AttributeInfo(SchemaSymbols::fgATT_ELEMENTFORMDEFAULT, Att_Optional_Default, - SchemaSymbols::fgATTVAL_UNQUALIFIED, DT_Form); - - fAttributes[Att_Final_N] = - new AttributeInfo(SchemaSymbols::fgATT_FINAL, Att_Optional_NoDefault, - 0, DT_Final); - - fAttributes[Att_Final1_N] = - new AttributeInfo(SchemaSymbols::fgATT_FINAL, Att_Optional_NoDefault, - 0, DT_Final1); - - fAttributes[Att_Final_D_D] = - new AttributeInfo(SchemaSymbols::fgATT_FINALDEFAULT, Att_Optional_Default, - XMLUni::fgZeroLenString, DT_Final); - - fAttributes[Att_Fixed_N] = - new AttributeInfo(SchemaSymbols::fgATT_FIXED, Att_Optional_NoDefault, - 0, DT_String); - - fAttributes[Att_Fixed_D] = - new AttributeInfo(SchemaSymbols::fgATT_FIXED, Att_Optional_Default, - SchemaSymbols::fgATTVAL_FALSE, DT_Boolean); - - fAttributes[Att_Form_N] = - new AttributeInfo(SchemaSymbols::fgATT_FORM, Att_Optional_NoDefault, - 0, DT_Form); - - fAttributes[Att_ID_N] = - new AttributeInfo(SchemaSymbols::fgATT_ID, Att_Optional_NoDefault, - 0, DT_ID); - - fAttributes[Att_ItemType_N] = - new AttributeInfo(SchemaSymbols::fgATT_ITEMTYPE, Att_Optional_NoDefault, - 0, DT_QName); - - fAttributes[Att_MaxOccurs_D] = - new AttributeInfo(SchemaSymbols::fgATT_MAXOCCURS, Att_Optional_Default, - fgValueOne, DT_MaxOccurs); - - fAttributes[Att_MaxOccurs1_D] = - new AttributeInfo(SchemaSymbols::fgATT_MAXOCCURS, Att_Optional_Default, - fgValueOne, DT_MaxOccurs1); - - fAttributes[Att_Member_T_N] = - new AttributeInfo(SchemaSymbols::fgATT_MEMBERTYPES, Att_Optional_NoDefault, - 0, DT_MemberTypes); - - fAttributes[Att_MinOccurs_D] = - new AttributeInfo(SchemaSymbols::fgATT_MINOCCURS, Att_Optional_Default, - fgValueOne, DT_NonNegInt); - - fAttributes[Att_MinOccurs1_D] = - new AttributeInfo(SchemaSymbols::fgATT_MINOCCURS, Att_Optional_Default, - fgValueOne, DT_MinOccurs1); - - fAttributes[Att_Mixed_D] = - new AttributeInfo(SchemaSymbols::fgATT_MIXED, Att_Optional_Default, - SchemaSymbols::fgATTVAL_FALSE, DT_Boolean); - - fAttributes[Att_Mixed_N] = - new AttributeInfo(SchemaSymbols::fgATT_MIXED, Att_Optional_NoDefault, - 0, DT_Boolean); - - fAttributes[Att_Name_R] = - new AttributeInfo(SchemaSymbols::fgATT_NAME, Att_Required, - 0, 0); - - fAttributes[Att_Namespace_D] = - new AttributeInfo(SchemaSymbols::fgATT_NAMESPACE, Att_Optional_Default, - SchemaSymbols::fgATTVAL_TWOPOUNDANY, DT_Namespace); - - fAttributes[Att_Namespace_N] = - new AttributeInfo(SchemaSymbols::fgATT_NAMESPACE, Att_Optional_NoDefault, - 0, 0); - - fAttributes[Att_Nillable_D] = - new AttributeInfo(SchemaSymbols::fgATT_NILLABLE, Att_Optional_Default, - SchemaSymbols::fgATTVAL_FALSE, DT_Boolean); - - fAttributes[Att_Process_C_D] = - new AttributeInfo(SchemaSymbols::fgATT_PROCESSCONTENTS, Att_Optional_Default, - SchemaSymbols::fgATTVAL_STRICT, DT_ProcessContents); - - fAttributes[Att_Public_R] = - new AttributeInfo(SchemaSymbols::fgATT_PUBLIC, Att_Required, - 0, DT_Public); - - fAttributes[Att_Ref_R] = - new AttributeInfo(SchemaSymbols::fgATT_REF, Att_Required, - 0, DT_QName); - - fAttributes[Att_Refer_R] = - new AttributeInfo(SchemaSymbols::fgATT_REFER, Att_Required, - 0, DT_QName); - - fAttributes[Att_Schema_L_R] = - new AttributeInfo(SchemaSymbols::fgATT_SCHEMALOCATION, Att_Required, - 0, 0); - - fAttributes[Att_Schema_L_N] = - new AttributeInfo(SchemaSymbols::fgATT_SCHEMALOCATION, Att_Optional_NoDefault, - 0, 0); - - fAttributes[Att_Source_N] = - new AttributeInfo(SchemaSymbols::fgATT_SOURCE, Att_Optional_NoDefault, - 0, DT_AnyURI); - - fAttributes[Att_Substitution_G_N] = - new AttributeInfo(SchemaSymbols::fgATT_SUBSTITUTIONGROUP, Att_Optional_NoDefault, - 0, DT_QName); - - fAttributes[Att_System_N] = - new AttributeInfo(SchemaSymbols::fgATT_SYSTEM, Att_Optional_NoDefault, - 0, DT_AnyURI); - - fAttributes[Att_Target_N_N] = - new AttributeInfo(SchemaSymbols::fgATT_TARGETNAMESPACE, Att_Optional_NoDefault, - 0, 0); - - fAttributes[Att_Type_N] = - new AttributeInfo(SchemaSymbols::fgATT_TYPE, Att_Optional_NoDefault, - 0, DT_QName); - - fAttributes[Att_Use_D] = - new AttributeInfo(SchemaSymbols::fgATT_USE, Att_Optional_Default, - SchemaSymbols::fgATTVAL_OPTIONAL, DT_Use); - - fAttributes[Att_Value_NNI_N] = - new AttributeInfo(SchemaSymbols::fgATT_VALUE, Att_Optional_NoDefault, - 0, DT_NonNegInt); - - fAttributes[Att_Value_STR_N] = - new AttributeInfo(SchemaSymbols::fgATT_VALUE, Att_Optional_NoDefault, - 0, 0); - - fAttributes[Att_Value_WS_N] = - new AttributeInfo(SchemaSymbols::fgATT_VALUE, Att_Optional_NoDefault, - 0, DT_WhiteSpace); - - fAttributes[Att_Version_N] = - new AttributeInfo(SchemaSymbols::fgATT_VERSION, Att_Optional_NoDefault, - 0, 0); - - fAttributes[Att_XPath_R] = - new AttributeInfo(SchemaSymbols::fgATT_XPATH, Att_Required, 0, DT_String); - - fAttributes[Att_XPath1_R] = - new AttributeInfo(SchemaSymbols::fgATT_XPATH, Att_Required, 0, DT_String); -} - -void GeneralAttributeCheck::setUpValidators() { - - fValidators = new DatatypeValidator*[DT_Count]; - - for (int i=0; i< DT_Count; i++) { - fValidators[i] = 0; - } - - DatatypeValidatorFactory dvFactory; - - dvFactory.expandRegistryToFullSchemaSet(); - fValidators[DT_NonNegInt] = - dvFactory.getDatatypeValidator(SchemaSymbols::fgDT_NONNEGATIVEINTEGER); - - fValidators[DT_Boolean] = - dvFactory.getDatatypeValidator(SchemaSymbols::fgDT_BOOLEAN); - - fValidators[DT_AnyURI] = - dvFactory.getDatatypeValidator(SchemaSymbols::fgDT_ANYURI); - - // TO DO - add remaining valdiators -} - -void GeneralAttributeCheck::mapElements() { - - if (!sGeneralAttCheckMutex) - { - XMLMutex* tmpMutex = new XMLMutex; - if (XMLPlatformUtils::compareAndSwap((void**)&sGeneralAttCheckMutex, tmpMutex, 0)) - { - // Some other thread beat us to it, so let's clean up ours. - delete tmpMutex; - } - else - { - // - // the thread who creates the mutex succesfully, to - // initialize the followings - // - setUpAttributes(); - setUpValidators(); - - RefVectorOf<AttributeInfo>* attList = 0; - int prefixContext = globalPrefix; - - fElementMap = new RefHash2KeysTableOf<RefVectorOfAttributeInfo>(25); - - // element "attribute" - global - attList = new RefVectorOf<AttributeInfo>(5, false); - attList->addElement(fAttributes[Att_Default_N]); - attList->addElement(fAttributes[Att_Fixed_N]); - attList->addElement(fAttributes[Att_ID_N]); - attList->addElement(fAttributes[Att_Name_R]); - attList->addElement(fAttributes[Att_Type_N]); - fElementMap->put((void*) SchemaSymbols::fgELT_ATTRIBUTE, prefixContext, attList); - - // element "element" - global - attList = new RefVectorOf<AttributeInfo>(10, false); - attList->addElement(fAttributes[Att_Abstract_D]); - attList->addElement(fAttributes[Att_Block_N]); - attList->addElement(fAttributes[Att_Default_N]); - attList->addElement(fAttributes[Att_Final_N]); - attList->addElement(fAttributes[Att_Fixed_N]); - attList->addElement(fAttributes[Att_ID_N]); - attList->addElement(fAttributes[Att_Name_R]); - attList->addElement(fAttributes[Att_Nillable_D]); - attList->addElement(fAttributes[Att_Substitution_G_N]); - attList->addElement(fAttributes[Att_Type_N]); - fElementMap->put((void*) SchemaSymbols::fgELT_ELEMENT, prefixContext, attList); - - // element "complexType" - global - attList = new RefVectorOf<AttributeInfo>(6, false); - attList->addElement(fAttributes[Att_Abstract_D]); - attList->addElement(fAttributes[Att_Block1_N]); - attList->addElement(fAttributes[Att_Final_N]); - attList->addElement(fAttributes[Att_ID_N]); - attList->addElement(fAttributes[Att_Mixed_D]); - attList->addElement(fAttributes[Att_Name_R]); - fElementMap->put((void*) SchemaSymbols::fgELT_COMPLEXTYPE, prefixContext, attList); - - // element "simpleType" - global - attList = new RefVectorOf<AttributeInfo>(3, false); - attList->addElement(fAttributes[Att_Final1_N]); - attList->addElement(fAttributes[Att_ID_N]); - attList->addElement(fAttributes[Att_Name_R]); - fElementMap->put((void*) SchemaSymbols::fgELT_SIMPLETYPE, prefixContext, attList); - - // element "schema" - global - attList = new RefVectorOf<AttributeInfo>(7, false); - attList->addElement(fAttributes[Att_Attribute_FD_D]); - attList->addElement(fAttributes[Att_Block_D_D]); - attList->addElement(fAttributes[Att_Element_FD_D]); - attList->addElement(fAttributes[Att_Final_D_D]); - attList->addElement(fAttributes[Att_ID_N]); - attList->addElement(fAttributes[Att_Target_N_N]); - attList->addElement(fAttributes[Att_Version_N]); - // xml:lang = language ??? - fElementMap->put((void*) SchemaSymbols::fgELT_SCHEMA, prefixContext, attList); - - // element "include" - global - attList = new RefVectorOf<AttributeInfo>(2, false); - attList->addElement(fAttributes[Att_ID_N]); - attList->addElement(fAttributes[Att_Schema_L_R]); - fElementMap->put((void*) SchemaSymbols::fgELT_INCLUDE, prefixContext, attList); - - // element "import" - global - attList = new RefVectorOf<AttributeInfo>(3, false); - attList->addElement(fAttributes[Att_ID_N]); - attList->addElement(fAttributes[Att_Namespace_N]); - attList->addElement(fAttributes[Att_Schema_L_N]); - fElementMap->put((void*) SchemaSymbols::fgELT_IMPORT, prefixContext, attList); - - // for element "redefine" - global (same as include) - attList = new RefVectorOf<AttributeInfo>(2, false); - attList->addElement(fAttributes[Att_ID_N]); - attList->addElement(fAttributes[Att_Schema_L_R]); - fElementMap->put((void*) SchemaSymbols::fgELT_REDEFINE, prefixContext, attList); - - - // element "attributeGroup" - global - attList = new RefVectorOf<AttributeInfo>(2, false); - attList->addElement(fAttributes[Att_ID_N]); - attList->addElement(fAttributes[Att_Name_R]); - fElementMap->put((void*) SchemaSymbols::fgELT_ATTRIBUTEGROUP, prefixContext, attList); - - // element "group" - global - attList = new RefVectorOf<AttributeInfo>(2, false); - attList->addElement(fAttributes[Att_ID_N]); - attList->addElement(fAttributes[Att_Name_R]); - fElementMap->put((void*) SchemaSymbols::fgELT_GROUP, prefixContext, attList); - - // element "annotation" - global - attList = new RefVectorOf<AttributeInfo>(1, false); - attList->addElement(fAttributes[Att_ID_N]); - fElementMap->put((void*) SchemaSymbols::fgELT_ANNOTATION, prefixContext, attList); - - // element "notation" - global - attList = new RefVectorOf<AttributeInfo>(4, false); - attList->addElement(fAttributes[Att_ID_N]); - attList->addElement(fAttributes[Att_Name_R]); - attList->addElement(fAttributes[Att_Public_R]); - attList->addElement(fAttributes[Att_System_N]); - fElementMap->put((void*) SchemaSymbols::fgELT_NOTATION, prefixContext, attList); - - // element "attribute" - local ref - prefixContext = localRefPrefix; - attList = new RefVectorOf<AttributeInfo>(5, false); - attList->addElement(fAttributes[Att_Default_N]); - attList->addElement(fAttributes[Att_Fixed_N]); - attList->addElement(fAttributes[Att_ID_N]); - attList->addElement(fAttributes[Att_Ref_R]); - attList->addElement(fAttributes[Att_Use_D]); - fElementMap->put((void*) SchemaSymbols::fgELT_ATTRIBUTE, prefixContext, attList); - - // element "element" - local ref - attList = new RefVectorOf<AttributeInfo>(4, false); - attList->addElement(fAttributes[Att_ID_N]); - attList->addElement(fAttributes[Att_MaxOccurs_D]); - attList->addElement(fAttributes[Att_MinOccurs_D]); - attList->addElement(fAttributes[Att_Ref_R]); - fElementMap->put((void*) SchemaSymbols::fgELT_ELEMENT, prefixContext, attList); - - // element "attributeGroup" - local ref - attList = new RefVectorOf<AttributeInfo>(2, false); - attList->addElement(fAttributes[Att_ID_N]); - attList->addElement(fAttributes[Att_Ref_R]); - fElementMap->put((void*) SchemaSymbols::fgELT_ATTRIBUTEGROUP, prefixContext, attList); - - // element "group" - local ref - attList = new RefVectorOf<AttributeInfo>(4, false); - attList->addElement(fAttributes[Att_ID_N]); - attList->addElement(fAttributes[Att_MaxOccurs_D]); - attList->addElement(fAttributes[Att_MinOccurs_D]); - attList->addElement(fAttributes[Att_Ref_R]); - fElementMap->put((void*) SchemaSymbols::fgELT_GROUP, prefixContext, attList); - - // element "attribute" - local name - prefixContext = localNamePrefix; - attList = new RefVectorOf<AttributeInfo>(7, false); - attList->addElement(fAttributes[Att_Default_N]); - attList->addElement(fAttributes[Att_Fixed_N]); - attList->addElement(fAttributes[Att_Form_N]); - attList->addElement(fAttributes[Att_ID_N]); - attList->addElement(fAttributes[Att_Name_R]); - attList->addElement(fAttributes[Att_Type_N]); - attList->addElement(fAttributes[Att_Use_D]); - fElementMap->put((void*) SchemaSymbols::fgELT_ATTRIBUTE, prefixContext, attList); - - // for element "element" - local name - attList = new RefVectorOf<AttributeInfo>(10, false); - attList->addElement(fAttributes[Att_Block_N]); - attList->addElement(fAttributes[Att_Default_N]); - attList->addElement(fAttributes[Att_Fixed_N]); - attList->addElement(fAttributes[Att_Form_N]); - attList->addElement(fAttributes[Att_ID_N]); - attList->addElement(fAttributes[Att_MaxOccurs_D]); - attList->addElement(fAttributes[Att_MinOccurs_D]); - attList->addElement(fAttributes[Att_Name_R]); - attList->addElement(fAttributes[Att_Nillable_D]); - attList->addElement(fAttributes[Att_Type_N]); - fElementMap->put((void*) SchemaSymbols::fgELT_ELEMENT, prefixContext, attList); - - // element "complexType" - local name - prefixContext = localNamePrefix; - attList = new RefVectorOf<AttributeInfo>(2, false); - attList->addElement(fAttributes[Att_ID_N]); - attList->addElement(fAttributes[Att_Mixed_D]); - fElementMap->put((void*) SchemaSymbols::fgELT_COMPLEXTYPE, prefixContext, attList); - - // element "simpleContent" - local name - attList = new RefVectorOf<AttributeInfo>(1, false); - attList->addElement(fAttributes[Att_ID_N]); - fElementMap->put((void*) SchemaSymbols::fgELT_SIMPLECONTENT, prefixContext, attList); - - // element "restriction" - local name - attList = new RefVectorOf<AttributeInfo>(2, false); - attList->addElement(fAttributes[Att_Base_N]); - attList->addElement(fAttributes[Att_ID_N]); - fElementMap->put((void*) SchemaSymbols::fgELT_RESTRICTION, prefixContext, attList); - - // element "extension" - local name - attList = new RefVectorOf<AttributeInfo>(2, false); - attList->addElement(fAttributes[Att_Base_R]); - attList->addElement(fAttributes[Att_ID_N]); - fElementMap->put((void*) SchemaSymbols::fgELT_EXTENSION, prefixContext, attList); - - // element "anyAttribute" - local name - attList = new RefVectorOf<AttributeInfo>(3, false); - attList->addElement(fAttributes[Att_ID_N]); - attList->addElement(fAttributes[Att_Namespace_D]); - attList->addElement(fAttributes[Att_Process_C_D]); - fElementMap->put((void*) SchemaSymbols::fgELT_ANYATTRIBUTE, prefixContext, attList); - - // element "complexContent" - local name - attList = new RefVectorOf<AttributeInfo>(2, false); - attList->addElement(fAttributes[Att_ID_N]); - attList->addElement(fAttributes[Att_Mixed_N]); - fElementMap->put((void*) SchemaSymbols::fgELT_COMPLEXCONTENT, prefixContext, attList); - - // element "choice" - local name - attList = new RefVectorOf<AttributeInfo>(3, false); - attList->addElement(fAttributes[Att_ID_N]); - attList->addElement(fAttributes[Att_MaxOccurs_D]); - attList->addElement(fAttributes[Att_MinOccurs_D]); - fElementMap->put((void*) SchemaSymbols::fgELT_CHOICE, prefixContext, attList); - - // element "sequence" - local name - attList = new RefVectorOf<AttributeInfo>(3, false); - attList->addElement(fAttributes[Att_ID_N]); - attList->addElement(fAttributes[Att_MaxOccurs_D]); - attList->addElement(fAttributes[Att_MinOccurs_D]); - fElementMap->put((void*) SchemaSymbols::fgELT_SEQUENCE, prefixContext, attList); - - // for element "any" - local name - attList = new RefVectorOf<AttributeInfo>(5, false); - attList->addElement(fAttributes[Att_ID_N]); - attList->addElement(fAttributes[Att_MaxOccurs_D]); - attList->addElement(fAttributes[Att_MinOccurs_D]); - attList->addElement(fAttributes[Att_Namespace_D]); - attList->addElement(fAttributes[Att_Process_C_D]); - fElementMap->put((void*) SchemaSymbols::fgELT_ANY, prefixContext, attList); - - // element "simpleType" - local name - attList = new RefVectorOf<AttributeInfo>(2, false); - attList->addElement(fAttributes[Att_Final1_N]); - attList->addElement(fAttributes[Att_ID_N]); - fElementMap->put((void*) SchemaSymbols::fgELT_SIMPLETYPE, prefixContext, attList); - - // element "list" - local name - attList = new RefVectorOf<AttributeInfo>(2, false); - attList->addElement(fAttributes[Att_ID_N]); - attList->addElement(fAttributes[Att_ItemType_N]); - fElementMap->put((void*) SchemaSymbols::fgELT_LIST, prefixContext, attList); - - // element "union" - local name - attList = new RefVectorOf<AttributeInfo>(2, false); - attList->addElement(fAttributes[Att_ID_N]); - attList->addElement(fAttributes[Att_Member_T_N]); - fElementMap->put((void*) SchemaSymbols::fgELT_UNION, prefixContext, attList); - - // element "length" - local name - attList = new RefVectorOf<AttributeInfo>(3, false); - attList->addElement(fAttributes[Att_ID_N]); - attList->addElement(fAttributes[Att_Value_NNI_N]); - attList->addElement(fAttributes[Att_Fixed_D]); - fElementMap->put((void*) SchemaSymbols::fgELT_LENGTH, prefixContext, attList); - - // element "minLength" - local name - attList = new RefVectorOf<AttributeInfo>(3, false); - attList->addElement(fAttributes[Att_ID_N]); - attList->addElement(fAttributes[Att_Value_NNI_N]); - attList->addElement(fAttributes[Att_Fixed_D]); - fElementMap->put((void*) SchemaSymbols::fgELT_MINLENGTH, prefixContext, attList); - - // element "maxLength" - local name - attList = new RefVectorOf<AttributeInfo>(3, false); - attList->addElement(fAttributes[Att_ID_N]); - attList->addElement(fAttributes[Att_Value_NNI_N]); - attList->addElement(fAttributes[Att_Fixed_D]); - fElementMap->put((void*) SchemaSymbols::fgELT_MAXLENGTH, prefixContext, attList); - - // element "totalDigits" - local name - attList = new RefVectorOf<AttributeInfo>(3, false); - attList->addElement(fAttributes[Att_ID_N]); - attList->addElement(fAttributes[Att_Value_NNI_N]); - attList->addElement(fAttributes[Att_Fixed_D]); - fElementMap->put((void*) SchemaSymbols::fgELT_TOTALDIGITS, prefixContext, attList); - - // element "fractionDigits" - local name - attList = new RefVectorOf<AttributeInfo>(3, false); - attList->addElement(fAttributes[Att_ID_N]); - attList->addElement(fAttributes[Att_Value_NNI_N]); - attList->addElement(fAttributes[Att_Fixed_D]); - fElementMap->put((void*) SchemaSymbols::fgELT_FRACTIONDIGITS, prefixContext, attList); - - // element "pattern" - local name - attList = new RefVectorOf<AttributeInfo>(2, false); - attList->addElement(fAttributes[Att_ID_N]); - attList->addElement(fAttributes[Att_Value_STR_N]); - fElementMap->put((void*) SchemaSymbols::fgELT_PATTERN, prefixContext, attList); - - // element "enumeration" - local name - attList = new RefVectorOf<AttributeInfo>(2, false); - attList->addElement(fAttributes[Att_ID_N]); - attList->addElement(fAttributes[Att_Value_STR_N]); - fElementMap->put((void*) SchemaSymbols::fgELT_ENUMERATION, prefixContext, attList); - - // element "whiteSpace" - local name - attList = new RefVectorOf<AttributeInfo>(3, false); - attList->addElement(fAttributes[Att_ID_N]); - attList->addElement(fAttributes[Att_Value_WS_N]); - attList->addElement(fAttributes[Att_Fixed_D]); - fElementMap->put((void*) SchemaSymbols::fgELT_WHITESPACE, prefixContext, attList); - - // element "maxInclusive" - local name - attList = new RefVectorOf<AttributeInfo>(3, false); - attList->addElement(fAttributes[Att_ID_N]); - attList->addElement(fAttributes[Att_Value_STR_N]); - attList->addElement(fAttributes[Att_Fixed_D]); - fElementMap->put((void*) SchemaSymbols::fgELT_MAXINCLUSIVE, prefixContext, attList); - - // element "maxExclusive" - local name - attList = new RefVectorOf<AttributeInfo>(3, false); - attList->addElement(fAttributes[Att_ID_N]); - attList->addElement(fAttributes[Att_Value_STR_N]); - attList->addElement(fAttributes[Att_Fixed_D]); - fElementMap->put((void*) SchemaSymbols::fgELT_MAXEXCLUSIVE, prefixContext, attList); - - // for element "minInclusive" - local name - attList = new RefVectorOf<AttributeInfo>(3, false); - attList->addElement(fAttributes[Att_ID_N]); - attList->addElement(fAttributes[Att_Value_STR_N]); - attList->addElement(fAttributes[Att_Fixed_D]); - fElementMap->put((void*) SchemaSymbols::fgELT_MININCLUSIVE, prefixContext, attList); - - // for element "minExclusive" - local name - attList = new RefVectorOf<AttributeInfo>(3, false); - attList->addElement(fAttributes[Att_ID_N]); - attList->addElement(fAttributes[Att_Value_STR_N]); - attList->addElement(fAttributes[Att_Fixed_D]); - fElementMap->put((void*) SchemaSymbols::fgELT_MINEXCLUSIVE, prefixContext, attList); - - // element "all" - local name - attList = new RefVectorOf<AttributeInfo>(3, false); - attList->addElement(fAttributes[Att_ID_N]); - attList->addElement(fAttributes[Att_MaxOccurs1_D]); - attList->addElement(fAttributes[Att_MinOccurs1_D]); - fElementMap->put((void*) SchemaSymbols::fgELT_ALL, prefixContext, attList); - - // element "annotation" - local name - attList = new RefVectorOf<AttributeInfo>(1, false); - attList->addElement(fAttributes[Att_ID_N]); - fElementMap->put((void*) SchemaSymbols::fgELT_ANNOTATION, prefixContext, attList); - - // element "appinfo" - local name - attList = new RefVectorOf<AttributeInfo>(1, false); - attList->addElement(fAttributes[Att_Source_N]); - fElementMap->put((void*) SchemaSymbols::fgELT_APPINFO, prefixContext, attList); - - // element "documentation" - local name - attList = new RefVectorOf<AttributeInfo>(1, false); - attList->addElement(fAttributes[Att_Source_N]); - // xml:lang = language ??? - fElementMap->put((void*) SchemaSymbols::fgELT_DOCUMENTATION, prefixContext, attList); - - // element "unique" - local name - attList = new RefVectorOf<AttributeInfo>(2, false); - attList->addElement(fAttributes[Att_ID_N]); - attList->addElement(fAttributes[Att_Name_R]); - fElementMap->put((void*) SchemaSymbols::fgELT_UNIQUE, prefixContext, attList); - - // element "key" - local name - attList = new RefVectorOf<AttributeInfo>(2, false); - attList->addElement(fAttributes[Att_ID_N]); - attList->addElement(fAttributes[Att_Name_R]); - fElementMap->put((void*) SchemaSymbols::fgELT_KEY, prefixContext, attList); - - // element "keyref" - local name - attList = new RefVectorOf<AttributeInfo>(3, false); - attList->addElement(fAttributes[Att_ID_N]); - attList->addElement(fAttributes[Att_Name_R]); - attList->addElement(fAttributes[Att_Refer_R]); - fElementMap->put((void*) SchemaSymbols::fgELT_KEYREF, prefixContext, attList); - - // element "selector" - local name - attList = new RefVectorOf<AttributeInfo>(2, false); - attList->addElement(fAttributes[Att_ID_N]); - attList->addElement(fAttributes[Att_XPath_R]); - fElementMap->put((void*) SchemaSymbols::fgELT_SELECTOR, prefixContext, attList); - - // element "field" - local name - attList = new RefVectorOf<AttributeInfo>(2, false); - attList->addElement(fAttributes[Att_ID_N]); - attList->addElement(fAttributes[Att_XPath1_R]); - fElementMap->put((void*) SchemaSymbols::fgELT_FIELD, prefixContext, attList); - - // This is the real mutex. Register it for cleanup at Termination. - GeneralAttCheckCleanup.registerCleanup(reinitGeneralAttCheck); - } - } -} - - -// ----------------------------------------------------------------------- -// Notification that lazy data has been deleted -// ----------------------------------------------------------------------- -void -GeneralAttributeCheck::reinitGeneralAttCheck() { - - delete sGeneralAttCheckMutex; - sGeneralAttCheckMutex = 0; - - for (unsigned int index = 0; index < Att_Count; index++) { - delete fAttributes[index]; - } - - delete [] fAttributes; - delete [] fValidators; - delete fElementMap; - - fAttributes = 0; - fValidators = 0; - fElementMap = 0; -} - -// --------------------------------------------------------------------------- -// GeneralAttributeCheck: Validation methods -// --------------------------------------------------------------------------- -void -GeneralAttributeCheck::checkAttributes(const DOM_Element& elem, - const unsigned short elemContext, - TraverseSchema* const schema) { - - if (elem == 0 || !fElementMap) { - return; - } - - DOMString name = elem.getLocalName(); - int prefixContext = globalPrefix; - unsigned int nameLen = name.length(); - XMLCh* elemName = 0; - const XMLCh* contextStr = fgGlobal; - RefVectorOf<AttributeInfo>* elemAttrs = 0; - - if (nameLen) { - elemName = new XMLCh[nameLen + 1]; - XMLString::copyNString(elemName, name.rawBuffer(), nameLen); - elemName[nameLen] = chNull; - } - - ArrayJanitor<XMLCh> janName(elemName); - - if (elemContext == LocalContext) { - - contextStr = fgLocal; - - if (elem.getAttribute(SchemaSymbols::fgATT_REF) == 0) { - prefixContext = localNamePrefix; - } - else { - prefixContext = localRefPrefix; - } - } - - elemAttrs = fElementMap->get(elemName, prefixContext); - - if (!elemAttrs) { - - // Try ref, some local declaration can have only a ref - if (prefixContext == localNamePrefix) { - elemAttrs = fElementMap->get(elemName, localRefPrefix); - - if (!elemAttrs) { - return; - } - - prefixContext = localRefPrefix; - } - else { - // We should report an error - return; - } - } - - unsigned int size = elemAttrs->size(); - RefHashTableOf<XMLCh> attNameList(5); - XMLBuffer aBuffer(128); - - for (unsigned int i=0; i< size; i++) { - - AttributeInfo* attInfo = elemAttrs->elementAt(i); - - if (attInfo) { - - XMLCh* attName = attInfo->getName(); - DOMString attValue = elem.getAttribute(attName); - DOM_Attr attNode = elem.getAttributeNode(attName); - unsigned int attValueLen = attValue.length(); - - attNameList.put((void*) attName, 0); - - if (attValueLen > 0) { - - aBuffer.set(attValue.rawBuffer(), attValueLen); - validate(attName, aBuffer.getRawBuffer(), - attInfo->getValidatorIndex(), schema); - } - else if (attNode == 0) { - if (attInfo->getDefaultOption() == Att_Required) { - schema->reportSchemaError(XMLUni::fgXMLErrDomain, - XMLErrs::AttributeRequired, attName, contextStr, elemName); - } - } - } - } - - // ------------------------------------------------------------------ - // Check for disallowed attributes - // ------------------------------------------------------------------ - DOM_NamedNodeMap eltAttrs = elem.getAttributes(); - int attrCount = eltAttrs.getLength(); - - for (int j = 0; j < attrCount; j++) { - - DOM_Node attribute = eltAttrs.item(j); - - if (attribute.isNull()) { - break; - } - - // Bypass attributes that start with xml - DOMString attName = attribute.getNodeName(); - aBuffer.set(attName.rawBuffer(), attName.length()); - XMLCh* tmpName = aBuffer.getRawBuffer(); - - if ((*tmpName == chLatin_X || *tmpName == chLatin_x) - && (*(tmpName+1) == chLatin_M || *(tmpName+1) == chLatin_m) - && (*(tmpName+2) == chLatin_L || *(tmpName+2) == chLatin_l)) { - continue; - } - - // for attributes with namespace prefix - DOMString attrURI = attribute.getNamespaceURI(); - - if (attrURI != 0 && attrURI.length() != 0) { - - // attributes with schema namespace are not allowed - // and not allowed on "documentation" and "appInfo" - if (attrURI.equals(SchemaSymbols::fgURI_SCHEMAFORSCHEMA) || - !XMLString::compareString(elemName, SchemaSymbols::fgELT_APPINFO) || - !XMLString::compareString(elemName, SchemaSymbols::fgELT_DOCUMENTATION)) { - - schema->reportSchemaError(XMLUni::fgXMLErrDomain, - XMLErrs::AttributeDisallowed, tmpName, contextStr, elemName); - } else { - - // Try for a "lax" validation - XMLBuffer tmpBuf(128); - - tmpBuf.set(attrURI.rawBuffer(), attrURI.length()); - attName = attribute.getLocalName(); - aBuffer.set(attName.rawBuffer(), attName.length()); - tmpName = aBuffer.getRawBuffer(); - DatatypeValidator* dv = schema->getDatatypeValidator(tmpBuf.getRawBuffer(), tmpName); - - if (dv) { - - DOMString attrVal = attribute.getNodeValue(); - tmpBuf.set(attrVal.rawBuffer(), attrVal.length()); - - try { - dv->validate(tmpBuf.getRawBuffer()); - } - catch(const XMLException& excep) { - schema->reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::DisplayErrorMessage, excep.getMessage()); - } - catch(...) { - schema->reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::InvalidAttValue, tmpBuf.getRawBuffer(), tmpName); - } - } - // REVISIT: - // If no dv found, store attribute info for a "lax" validation - // after schema traversal ?? - KN - } - - continue; - } - - attName = attribute.getLocalName(); - aBuffer.set(attName.rawBuffer(), attName.length()); - tmpName = aBuffer.getRawBuffer(); - - // check whether this attribute is allowed - if (!attNameList.containsKey(tmpName)) { - schema->reportSchemaError(XMLUni::fgXMLErrDomain, - XMLErrs::AttributeDisallowed, tmpName, contextStr, elemName); - } - } -} - - -void GeneralAttributeCheck::validate(const XMLCh* const attName, - const XMLCh* const attValue, - const short dvIndex, - TraverseSchema* const schema) -{ - bool isInvalid = false; - DatatypeValidator* dv = 0; - - switch (dvIndex) { - case DT_Form: - if (XMLString::compareString(attValue, SchemaSymbols::fgATTVAL_QUALIFIED) != 0 - && XMLString::compareString(attValue, SchemaSymbols::fgATTVAL_UNQUALIFIED) != 0) { - isInvalid = true; - } - break; - case DT_MaxOccurs: - // maxOccurs = (nonNegativeInteger | unbounded) - if (XMLString::compareString(attValue, fgUnbounded) != 0) { - dv = fValidators[DT_NonNegInt]; - } - break; - case DT_MaxOccurs1: - if (XMLString::compareString(attValue, fgValueOne) != 0) { - isInvalid = true; - } - break; - case DT_MinOccurs1: - if (XMLString::compareString(attValue, fgValueZero) != 0 - && XMLString::compareString(attValue, fgValueOne) != 0) { - isInvalid = true; - } - break; - case DT_ProcessContents: - if (XMLString::compareString(attValue, SchemaSymbols::fgATTVAL_SKIP) != 0 - && XMLString::compareString(attValue, SchemaSymbols::fgATTVAL_LAX) != 0 - && XMLString::compareString(attValue, SchemaSymbols::fgATTVAL_STRICT) != 0) { - isInvalid = true; - } - break; - case DT_Use: - if (XMLString::compareString(attValue, SchemaSymbols::fgATTVAL_OPTIONAL) != 0 - && XMLString::compareString(attValue, SchemaSymbols::fgATTVAL_PROHIBITED) != 0 - && XMLString::compareString(attValue, SchemaSymbols::fgATTVAL_REQUIRED) != 0) { - isInvalid = true; - } - break; - case DT_WhiteSpace: - if (XMLString::compareString(attValue, SchemaSymbols::fgWS_PRESERVE) != 0 - && XMLString::compareString(attValue, SchemaSymbols::fgWS_REPLACE) != 0 - && XMLString::compareString(attValue, SchemaSymbols::fgWS_COLLAPSE) != 0) { - isInvalid = true; - } - break; - case DT_Boolean: - dv = fValidators[DT_Boolean]; - break; - case DT_NonNegInt: - dv = fValidators[DT_NonNegInt]; - break; - case DT_AnyURI: - dv = fValidators[DT_AnyURI]; - break; - case DT_ID: - if (fIDRefList) { - - dv = &fIDValidator; - ((IDDatatypeValidator*) dv)->setIDRefList(fIDRefList); - } - break; - } - - if (dv) { - try { - dv->validate(attValue); - } - catch(const XMLException& excep) { - schema->reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::DisplayErrorMessage, excep.getMessage()); - } - catch(...) { - isInvalid = true; - } - } - - if (isInvalid) { - schema->reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::InvalidAttValue, - attValue, attName); - } -} - -/** - * End of file GeneralAttributeCheck.cpp - */ - - diff --git a/src/validators/schema/GeneralAttributeCheck.hpp b/src/validators/schema/GeneralAttributeCheck.hpp deleted file mode 100644 index f7f75c7db647217dc2ac2f17a8cb7e8752e86cf5..0000000000000000000000000000000000000000 --- a/src/validators/schema/GeneralAttributeCheck.hpp +++ /dev/null @@ -1,335 +0,0 @@ -/* - * 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$ - */ - -#if !defined(GENERALATTRIBUTECHECK_HPP) -#define GENERALATTRIBUTECHECK_HPP - - -/** - * A general purpose class to check for valid values of attributes, as well - * as check for proper association with corresponding schema elements. - */ - -// --------------------------------------------------------------------------- -// Includes -// --------------------------------------------------------------------------- -#include <util/RefVectorOf.hpp> -#include <util/RefHashTableOf.hpp> -#include <util/RefHash2KeysTableOf.hpp> -#include <dom/DOM_Element.hpp> -#include <validators/datatype/IDDatatypeValidator.hpp> - -// --------------------------------------------------------------------------- -// Forward declaration -// --------------------------------------------------------------------------- -class TraverseSchema; - - -class AttributeInfo { -public: - // ----------------------------------------------------------------------- - // Constructor/Destructor - // ----------------------------------------------------------------------- - AttributeInfo(const XMLCh* const name, const short defaultOption, - const XMLCh* const defaultValue, const short dvIndex); - ~AttributeInfo(); - - // ----------------------------------------------------------------------- - // Getter methods - // ----------------------------------------------------------------------- - short getDefaultOption() const; - short getValidatorIndex() const; - XMLCh* getName() const; - XMLCh* getDefaultValue() const; - - -private: - // ----------------------------------------------------------------------- - // CleanUp methods - // ----------------------------------------------------------------------- - void cleanUp(); - - // ----------------------------------------------------------------------- - // Private data members - // ----------------------------------------------------------------------- - short fDefaultOption; - short fValidatorIndex; - XMLCh* fName; - XMLCh* fDefaultValue; -}; - - -// --------------------------------------------------------------------------- -// local type declaration -// --------------------------------------------------------------------------- -typedef RefVectorOf<AttributeInfo> RefVectorOfAttributeInfo; - - -class VALIDATORS_EXPORT GeneralAttributeCheck -{ -public: - // ----------------------------------------------------------------------- - // Constructor/Destructor - // ----------------------------------------------------------------------- - GeneralAttributeCheck(); - ~GeneralAttributeCheck(); - - // ----------------------------------------------------------------------- - // Public Constants - // ----------------------------------------------------------------------- - static const unsigned short GlobalContext; - static const unsigned short LocalContext; - - // ----------------------------------------------------------------------- - // Setter methods - // ----------------------------------------------------------------------- - void setIDRefList(RefHashTableOf<XMLRefInfo>* const refList); - - // ----------------------------------------------------------------------- - // Validation methods - // ----------------------------------------------------------------------- - void checkAttributes(const DOM_Element& elem, - const unsigned short elemContext, - TraverseSchema* const schema); - - // ----------------------------------------------------------------------- - // Notification that lazy data has been deleted - // ----------------------------------------------------------------------- - static void reinitGeneralAttCheck(); - -private: - // ----------------------------------------------------------------------- - // Unimplemented constructors and operators - // ----------------------------------------------------------------------- - GeneralAttributeCheck(const GeneralAttributeCheck&); - void operator=(const GeneralAttributeCheck&); - - // ----------------------------------------------------------------------- - // Setup methods - // ----------------------------------------------------------------------- - void setUpAttributes(); - void setUpValidators(); - void mapElements(); - - // ----------------------------------------------------------------------- - // Validation methods - // ----------------------------------------------------------------------- - void validate(const XMLCh* const attName, const XMLCh* const attValue, - const short dvIndex, TraverseSchema* const schema); - - // ----------------------------------------------------------------------- - // Private Constants - // ----------------------------------------------------------------------- - // attributes - enum { - Att_Abstract_D, // starts with 0 - Att_Attribute_FD_D, - Att_Base_R, - Att_Base_N, - Att_Block_N, - Att_Block1_N, - Att_Block_D_D, - Att_Default_N, - Att_Element_FD_D, - Att_Final_N, - Att_Final1_N, - Att_Final_D_D, - Att_Fixed_N, - Att_Fixed_D, - Att_Form_N, - Att_ID_N, - Att_ItemType_N, - Att_MaxOccurs_D, - Att_MaxOccurs1_D, - Att_Member_T_N, - Att_MinOccurs_D, - Att_MinOccurs1_D, - Att_Mixed_D, - Att_Mixed_N, - Att_Name_R, - Att_Namespace_D, - Att_Namespace_N, - Att_Nillable_D, - Att_Process_C_D, - Att_Public_R, - Att_Ref_R, - Att_Refer_R, - Att_Schema_L_R, - Att_Schema_L_N, - Att_Source_N, - Att_Substitution_G_N, - Att_System_N, - Att_Target_N_N, - Att_Type_N, - Att_Use_D, - Att_Value_NNI_N, - Att_Value_STR_N, - Att_Value_WS_N, - Att_Version_N, - Att_XPath_R, - Att_XPath1_R, - - Att_Count - }; - - // direct value compare - enum { - DT_Block = -1, - DT_Block1 = -2, - DT_Final = -3, - DT_Final1 = -4, - DT_Form = -5, - DT_MaxOccurs = -6, - DT_MaxOccurs1 = -7, - DT_MemberTypes = -8, - DT_MinOccurs1 = -9, - DT_Namespace = -10, - DT_ProcessContents = -11, - DT_Public = -12, - DT_Use = -13, - DT_WhiteSpace = -14, - DT_ID = -15 - }; - - // datatype validators - enum { - DT_String, - DT_Token, - DT_AnyURI, - DT_NonNegInt, - DT_QName, - DT_Boolean, - - // add XPath - DT_Count - }; - - // element context prefixes - enum { - globalPrefix, - localNamePrefix, - localRefPrefix - }; - - // optional vs. required attribute - enum { - Att_Required, - Att_Optional_Default, - Att_Optional_NoDefault - }; - - // ----------------------------------------------------------------------- - // Private data members - // ----------------------------------------------------------------------- - static AttributeInfo** fAttributes; - static DatatypeValidator** fValidators; - static RefHash2KeysTableOf<RefVectorOfAttributeInfo>* fElementMap; - IDDatatypeValidator fIDValidator; - RefHashTableOf<XMLRefInfo>* fIDRefList; -}; - - -// --------------------------------------------------------------------------- -// AttributeInfo: Getter methods -// --------------------------------------------------------------------------- -inline short AttributeInfo::getDefaultOption() const { - - return fDefaultOption; -} - -inline short AttributeInfo::getValidatorIndex() const { - - return fValidatorIndex; -} - -inline XMLCh* AttributeInfo::getName() const { - - return fName; -} - -inline XMLCh* AttributeInfo::getDefaultValue() const { - - return fDefaultValue; -} - -// --------------------------------------------------------------------------- -// AttributeInfo: CleanUp methods -// --------------------------------------------------------------------------- -inline void AttributeInfo::cleanUp() { - - delete [] fName; - delete [] fDefaultValue; -} - -// --------------------------------------------------------------------------- -// GeneralAttributeCheck: Setter methods -// --------------------------------------------------------------------------- -inline void -GeneralAttributeCheck::setIDRefList(RefHashTableOf<XMLRefInfo>* const refList) { - - fIDRefList = refList; -} - -#endif - -/** - * End of file GeneralAttributeCheck.hpp - */ - diff --git a/src/validators/schema/Makefile.in b/src/validators/schema/Makefile.in deleted file mode 100644 index d81c49e3fd1b545602456ea4d9adfa26f29831d4..0000000000000000000000000000000000000000 --- a/src/validators/schema/Makefile.in +++ /dev/null @@ -1,206 +0,0 @@ -# -# 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$ -# Revision 1.18 2001/11/02 14:13:45 knoaman -# Add support for identity constraints. -# -# Revision 1.17 2001/08/22 11:33:43 tng -# typo: XercesElementWildcard -# -# Revision 1.16 2001/08/21 15:58:42 tng -# Schema: New files XercesElementWildCard. -# -# Revision 1.15 2001/07/31 15:26:54 knoaman -# Added support for <attributeGroup>. -# -# Revision 1.14 2001/07/24 20:13:30 knoaman -# Added support for <group> + extra constraint checking for complexType -# -# Revision 1.13 2001/07/06 17:12:13 tng -# Automatic build of single-threaded library. By Martin Kalen. -# -# Revision 1.12 2001/06/27 17:09:56 tng -# [Bug 1147] Headers install in wrong directory. By Murray Cumming. -# -# Revision 1.11 2001/05/15 21:59:32 knoaman -# TraverseSchema: add attribute checking + some fixes + more error messages. -# More attribute cheking to come. -# -# Revision 1.10 2001/05/11 13:27:32 tng -# Copyright update. -# -# Revision 1.9 2001/05/10 16:33:15 knoaman -# Traverse Schema Part III + error messages. -# -# Revision 1.8 2001/05/03 20:34:42 tng -# Schema: SchemaValidator update -# -# Revision 1.7 2001/05/03 19:17:57 knoaman -# TraverseSchema Part II. -# -# Revision 1.6 2001/04/19 17:43:14 knoaman -# More schema implementation classes. -# -# Revision 1.5 2001/04/04 18:02:04 tng -# Schema: include failure on Unix for XUtil.cpp. Fixed by Pei Yong Zhang. -# -# Revision 1.4 2001/03/30 16:06:00 tng -# Schema: XUtil, added by Pei Yong Zhang -# -# Revision 1.3 2001/03/21 21:56:33 tng -# Schema: Add Schema Grammar, Schema Validator, and split the DTDValidator into DTDValidator, DTDScanner, and DTDGrammar. -# -# Revision 1.2 2001/03/21 21:39:19 knoaman -# Schema symbols and Datatype validator part I -# -# Revision 1.1 2001/02/27 18:48:22 tng -# Schema: Add SchemaAttDef, SchemaElementDecl, SchemaAttDefList. -# -# - -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 -XML_INCL := $(XML_INCL) -I$(XERCESCROOT)/src - -VALIDATORS_SCHEMA_CPP_PUBHEADERS = \ - ComplexTypeInfo.hpp \ - GeneralAttributeCheck.hpp \ - NamespaceScope.hpp \ - SchemaAttDef.hpp \ - SchemaAttDefList.hpp \ - SchemaElementDecl.hpp \ - SchemaGrammar.hpp \ - SchemaInfo.hpp \ - SchemaSymbols.hpp \ - SchemaValidator.hpp \ - SubstitutionGroupComparator.hpp \ - TraverseSchema.hpp \ - XercesAttGroupInfo.hpp \ - XercesElementWildcard.hpp \ - XercesGroupInfo.hpp \ - XUtil.hpp - -VALIDATORS_SCHEMA_CPP_PRIVHEADERS = - -VALIDATORS_SCHEMA_C_FILES = - -VALIDATORS_SCHEMA_CPP_OBJECTS = \ - ComplexTypeInfo.$(TO) \ - GeneralAttributeCheck.$(TO) \ - NamespaceScope.$(TO) \ - SchemaAttDef.$(TO) \ - SchemaAttDefList.$(TO) \ - SchemaElementDecl.$(TO) \ - SchemaGrammar.$(TO) \ - SchemaInfo.$(TO) \ - SchemaSymbols.$(TO) \ - SchemaValidator.$(TO) \ - SubstitutionGroupComparator.$(TO) \ - TraverseSchema.$(TO) \ - XercesAttGroupInfo.$(TO) \ - XercesElementWildcard.$(TO) \ - XercesGroupInfo.$(TO) \ - XUtil.$(TO) - -all:: includes $(VALIDATORS_SCHEMA_CPP_OBJECTS) identity - -includes:: pubheaders $(VALIDATORS_SCHEMA_C_FILES) - cd identity ; $(MAKE) $@ ; cd .. - -identity:: - cd identity ; $(MAKE) ; cd .. - -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)) - cd identity ; $(MAKE) $@ ; cd .. - -distclean:: clean - $(RM) Makefile $(DEPFILE) - @echo "Removing all $(MODULE)/$(SUBMODULE) header files ..." - $(RM2) $(addprefix $(XML_INC_DIR)/$(MODULE)/$(SUBMODULE)/,$(VALIDATORS_SCHEMA_CPP_PUBHEADERS)) - cd identity ; $(MAKE) $@ ; cd .. - -install:: - -mkdir -p $(PREFIX_INCLUDE)/$(MODULE)/$(SUBMODULE) - $(CP) $(VALIDATORS_SCHEMA_CPP_PUBHEADERS) $(VALIDATORS_SCHEMA_C_FILES) $(PREFIX_INCLUDE)/$(MODULE)/$(SUBMODULE) - cd identity ; $(MAKE) $@ ; cd .. diff --git a/src/validators/schema/NamespaceScope.cpp b/src/validators/schema/NamespaceScope.cpp deleted file mode 100644 index 8b07a37dd3b779c2494ddf88df170e3e0d7b3fb9..0000000000000000000000000000000000000000 --- a/src/validators/schema/NamespaceScope.cpp +++ /dev/null @@ -1,300 +0,0 @@ -/* - * 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$ - * Revision 1.3 2001/07/31 15:26:54 knoaman - * Added support for <attributeGroup>. - * - * Revision 1.2 2001/05/11 13:27:33 tng - * Copyright update. - * - * Revision 1.1 2001/04/19 17:43:15 knoaman - * More schema implementation classes. - * - */ - -// --------------------------------------------------------------------------- -// Includes -// --------------------------------------------------------------------------- -#include <string.h> -#include <util/EmptyStackException.hpp> -#include <validators/schema/NamespaceScope.hpp> - - -// --------------------------------------------------------------------------- -// NamespaceScope: Constructors and Destructor -// --------------------------------------------------------------------------- -NamespaceScope::NamespaceScope() : - - fEmptyNamespaceId(0) - , fStackCapacity(8) - , fStackTop(0) - , fStack(0) -{ - // Do an initial allocation of the stack and zero it out - fStack = new StackElem*[fStackCapacity]; - memset(fStack, 0, fStackCapacity * sizeof(StackElem*)); -} - -NamespaceScope::~NamespaceScope() -{ - // - // Start working from the bottom of the stack and clear it out as we - // go up. Once we hit an uninitialized one, we can break out. - // - for (unsigned int stackInd = 0; stackInd < fStackCapacity; stackInd++) - { - // If this entry has been set, then lets clean it up - if (!fStack[stackInd]) - break; - - // Delete the row for this entry, then delete the row structure - delete [] fStack[stackInd]->fMap; - delete fStack[stackInd]; - } - - // Delete the stack array itself now - delete [] fStack; -} - - -// --------------------------------------------------------------------------- -// NamespaceScope: Stack access -// --------------------------------------------------------------------------- -unsigned int NamespaceScope::increaseDepth() -{ - // See if we need to expand the stack - if (fStackTop == fStackCapacity) - expandStack(); - - // If this element has not been initialized yet, then initialize it - if (!fStack[fStackTop]) - { - fStack[fStackTop] = new StackElem; - fStack[fStackTop]->fMapCapacity = 0; - fStack[fStackTop]->fMap = 0; - } - - // Set up the new top row - fStack[fStackTop]->fMapCount = 0; - - // Bump the top of stack - fStackTop++; - - return fStackTop-1; -} - -unsigned int NamespaceScope::decreaseDepth() -{ - if (!fStackTop) - ThrowXML(EmptyStackException, XMLExcepts::ElemStack_StackUnderflow); - - fStackTop--; - - return fStackTop; -} - - -// --------------------------------------------------------------------------- -// NamespaceScope: Prefix map methods -// --------------------------------------------------------------------------- -void NamespaceScope::addPrefix(const XMLCh* const prefixToAdd, - const unsigned int uriId) { - - if (!fStackTop) - ThrowXML(EmptyStackException, XMLExcepts::ElemStack_EmptyStack); - - // Get a convenience pointer to the stack top row - StackElem* curRow = fStack[fStackTop - 1]; - - // Map the prefix to its unique id - const unsigned int prefId = fPrefixPool.addOrFind(prefixToAdd); - - // - // Add a new element to the prefix map for this element. If its full, - // then expand it out. - // - if (curRow->fMapCount == curRow->fMapCapacity) - expandMap(curRow); - - // - // And now add a new element for this prefix. - // - curRow->fMap[curRow->fMapCount].fPrefId = prefId; - curRow->fMap[curRow->fMapCount].fURIId = uriId; - - // Bump the map count now - curRow->fMapCount++; -} - -unsigned int -NamespaceScope::getNamespaceForPrefix(const XMLCh* const prefixToMap, - const int depthLevel) const { - - // - // Map the prefix to its unique id, from the prefix string pool. If its - // not a valid prefix, then its a failure. - // - unsigned int prefixId = fPrefixPool.getId(prefixToMap); - - if (!prefixId){ - return fEmptyNamespaceId; - } - - // - // Start at the stack top and work backwards until we come to some - // element that mapped this prefix. - // - int startAt = depthLevel; - for (int index = startAt; index >= 0; index--) - { - // Get a convenience pointer to the current element - StackElem* curRow = fStack[index]; - - // If no prefixes mapped at this level, then go the next one - if (!curRow->fMapCount) - continue; - - // Search the map at this level for the passed prefix - for (unsigned int mapIndex = 0; mapIndex < curRow->fMapCount; mapIndex++) - { - if (curRow->fMap[mapIndex].fPrefId == prefixId) - return curRow->fMap[mapIndex].fURIId; - } - } - - return fEmptyNamespaceId; -} - - -// --------------------------------------------------------------------------- -// NamespaceScope: Miscellaneous methods -// --------------------------------------------------------------------------- -void NamespaceScope::reset(const unsigned int emptyId) -{ - // Flush the prefix pool and put back in the standard prefixes - fPrefixPool.flushAll(); - - // Reset the stack top to clear the stack - fStackTop = 0; - - // And store the new special URI ids - fEmptyNamespaceId = emptyId; -} - - -// --------------------------------------------------------------------------- -// Namespace: Private helpers -// --------------------------------------------------------------------------- -void NamespaceScope::expandMap(StackElem* const toExpand) -{ - // For convenience get the old map size - const unsigned int oldCap = toExpand->fMapCapacity; - - // - // Expand the capacity by 25%, or initialize it to 16 if its currently - // empty. Then allocate a new temp buffer. - // - const unsigned int newCapacity = oldCap ? - (unsigned int)(oldCap * 1.25) : 16; - PrefMapElem* newMap = new PrefMapElem[newCapacity]; - - // - // Copy over the old stuff. We DON'T have to zero out the new stuff - // since this is a by value map and the current map index controls what - // is relevant. - // - memcpy(newMap, toExpand->fMap, oldCap * sizeof(PrefMapElem)); - - // Delete the old map and store the new stuff - delete [] toExpand->fMap; - toExpand->fMap = newMap; - toExpand->fMapCapacity = newCapacity; -} - -void NamespaceScope::expandStack() -{ - // Expand the capacity by 25% and allocate a new buffer - const unsigned int newCapacity = (unsigned int)(fStackCapacity * 1.25); - StackElem** newStack = new StackElem*[newCapacity]; - - // Copy over the old stuff - memcpy(newStack, fStack, fStackCapacity * sizeof(StackElem*)); - - // - // And zero out the new stuff. Though we use a stack top, we reuse old - // stack contents so we need to know if elements have been initially - // allocated or not as we push new stuff onto the stack. - // - memset - ( - &newStack[fStackCapacity] - , 0 - , (newCapacity - fStackCapacity) * sizeof(StackElem*) - ); - - // Delete the old array and update our members - delete [] fStack; - fStack = newStack; - fStackCapacity = newCapacity; -} - - -/** - * End of file NamespaceScope.cpp - */ - diff --git a/src/validators/schema/NamespaceScope.hpp b/src/validators/schema/NamespaceScope.hpp deleted file mode 100644 index 124953a65ed9beec701293518474b06e6b3f56f9..0000000000000000000000000000000000000000 --- a/src/validators/schema/NamespaceScope.hpp +++ /dev/null @@ -1,200 +0,0 @@ -/* - * 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$ - */ - -#if !defined(NAMESPACESCOPE_HPP) -#define NAMESPACESCOPE_HPP - -#include <util/XercesDefs.hpp> -#include <util/StringPool.hpp> - -// -// NamespaceScope provides a data structure for mapping namespace prefixes -// to their URI's. The mapping accurately reflects the scoping of namespaces -// at a particular instant in time. -// - -class VALIDATORS_EXPORT NamespaceScope -{ -public : - // ----------------------------------------------------------------------- - // Class specific data types - // - // These really should be private, but some of the compilers we have to - // support are too dumb to deal with that. - // - // PrefMapElem - // fURIId is the id of the URI from the validator's URI map. The - // fPrefId is the id of the prefix from our own prefix pool. The - // namespace stack consists of these elements. - // - // StackElem - // The fMapCapacity is how large fMap has grown so far. fMapCount - // is how many of them are valid right now. - // ----------------------------------------------------------------------- - struct PrefMapElem - { - unsigned int fPrefId; - unsigned int fURIId; - }; - - struct StackElem - { - PrefMapElem* fMap; - unsigned int fMapCapacity; - unsigned int fMapCount; - }; - - - // ----------------------------------------------------------------------- - // Constructors and Destructor - // ----------------------------------------------------------------------- - NamespaceScope(); - ~NamespaceScope(); - - - // ----------------------------------------------------------------------- - // Stack access - // ----------------------------------------------------------------------- - unsigned int increaseDepth(); - unsigned int decreaseDepth(); - - // ----------------------------------------------------------------------- - // Prefix map methods - // ----------------------------------------------------------------------- - void addPrefix(const XMLCh* const prefixToAdd, - const unsigned int uriId); - - unsigned int getNamespaceForPrefix(const XMLCh* const prefixToMap) const; - unsigned int getNamespaceForPrefix(const XMLCh* const prefixToMap, - const int depthLevel) const; - - - // ----------------------------------------------------------------------- - // Miscellaneous methods - // ----------------------------------------------------------------------- - bool isEmpty() const; - void reset(const unsigned int emptyId); - - -private : - // ----------------------------------------------------------------------- - // Unimplemented constructors and operators - // ----------------------------------------------------------------------- - NamespaceScope(const NamespaceScope&); - void operator=(const NamespaceScope&); - - - // ----------------------------------------------------------------------- - // Private helper methods - // ----------------------------------------------------------------------- - void expandMap(StackElem* const toExpand); - void expandStack(); - - - // ----------------------------------------------------------------------- - // Data members - // - // fEmptyNamespaceId - // This is the special URI id for the "" namespace, which is magic - // because of the xmlns="" operation. - // - // fPrefixPool - // This is the prefix pool where prefixes are hashed and given unique - // ids. These ids are used to track prefixes in the element stack. - // - // fStack - // fStackCapacity - // fStackTop - // This the stack array. Its an array of pointers to StackElem - // structures. The capacity is the current high water mark of the - // stack. The top is the current top of stack (i.e. the part of it - // being used.) - // ----------------------------------------------------------------------- - unsigned int fEmptyNamespaceId; - unsigned int fStackCapacity; - unsigned int fStackTop; - XMLStringPool fPrefixPool; - StackElem** fStack; -}; - - -// --------------------------------------------------------------------------- -// NamespaceScope: Stack access -// --------------------------------------------------------------------------- -inline unsigned int -NamespaceScope::getNamespaceForPrefix(const XMLCh* const prefixToMap) const { - - return getNamespaceForPrefix(prefixToMap, (int)(fStackTop - 1)); -} - -// --------------------------------------------------------------------------- -// NamespaceScope: Miscellaneous methods -// --------------------------------------------------------------------------- -inline bool NamespaceScope::isEmpty() const -{ - return (fStackTop == 0); -} - -#endif - -/** - * End of file NameSpaceScope.hpp - */ - diff --git a/src/validators/schema/SchemaAttDef.cpp b/src/validators/schema/SchemaAttDef.cpp deleted file mode 100644 index aaacaa22752cfad40b90a22432fccd51ac286b11..0000000000000000000000000000000000000000 --- a/src/validators/schema/SchemaAttDef.cpp +++ /dev/null @@ -1,161 +0,0 @@ -/* - * 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$ - * Revision 1.4 2001/08/09 15:23:16 knoaman - * add support for <anyAttribute> declaration. - * - * Revision 1.3 2001/07/31 15:26:54 knoaman - * Added support for <attributeGroup>. - * - * Revision 1.2 2001/05/11 13:27:33 tng - * Copyright update. - * - * Revision 1.1 2001/02/27 18:48:22 tng - * Schema: Add SchemaAttDef, SchemaElementDecl, SchemaAttDefList. - * - */ - - -// --------------------------------------------------------------------------- -// Includes -// --------------------------------------------------------------------------- -#include <framework/XMLElementDecl.hpp> -#include <validators/schema/SchemaAttDef.hpp> - -// --------------------------------------------------------------------------- -// SchemaAttDef: Implementation of the XMLAttDef interface -// --------------------------------------------------------------------------- -const XMLCh* SchemaAttDef::getFullName() const -{ - return fAttName->getRawName(); -} - -// --------------------------------------------------------------------------- -// SchemaAttDef: Constructors and Destructor -// --------------------------------------------------------------------------- -SchemaAttDef::SchemaAttDef() : - fElemId(XMLElementDecl::fgInvalidElemId) - , fAttName(0) - , fDatatypeValidator(0) - , fNamespaceList(0) -{ -} - -SchemaAttDef::SchemaAttDef( const XMLCh* const prefix - , const XMLCh* const localPart - , const int uriId - , const XMLAttDef::AttTypes type - , const XMLAttDef::DefAttTypes defType) : - XMLAttDef(type, defType) - , fElemId(XMLElementDecl::fgInvalidElemId) - , fDatatypeValidator(0) - , fNamespaceList(0) -{ - fAttName = new QName(prefix, localPart, uriId); -} - -SchemaAttDef::SchemaAttDef( const XMLCh* const prefix - , const XMLCh* const localPart - , const int uriId - , const XMLCh* const attValue - , const XMLAttDef::AttTypes type - , const XMLAttDef::DefAttTypes defType - , const XMLCh* const enumValues) : - - XMLAttDef(attValue, type, defType, enumValues) - , fElemId(XMLElementDecl::fgInvalidElemId) - , fDatatypeValidator(0) - , fNamespaceList(0) -{ - fAttName = new QName(prefix, localPart, uriId); -} - -SchemaAttDef::SchemaAttDef(const SchemaAttDef* other) : - - XMLAttDef(other->getValue(), other->getType(), - other->getDefaultType(), other->getEnumeration()) - , fElemId(XMLElementDecl::fgInvalidElemId) - , fAttName(0) - , fDatatypeValidator(other->fDatatypeValidator) - , fNamespaceList(0) -{ - QName* otherName = other->getAttName(); - fAttName = new QName(otherName->getPrefix(), - otherName->getLocalPart(), otherName->getURI()); - - if (other->fNamespaceList && other->fNamespaceList->size()) { - fNamespaceList = new ValueVectorOf<unsigned int>(*(other->fNamespaceList)); - } -} - -SchemaAttDef::~SchemaAttDef() -{ - delete fAttName; - delete fNamespaceList; -} - - -// --------------------------------------------------------------------------- -// SchemaAttDef: Setter methods -// --------------------------------------------------------------------------- -void SchemaAttDef::setAttName(const XMLCh* const prefix - , const XMLCh* const localPart - , const int uriId ) -{ - fAttName->setName(prefix, localPart, uriId); -} diff --git a/src/validators/schema/SchemaAttDef.hpp b/src/validators/schema/SchemaAttDef.hpp deleted file mode 100644 index fa9ef3c21f9cfb13b17e18211c113f7e0b6444a2..0000000000000000000000000000000000000000 --- a/src/validators/schema/SchemaAttDef.hpp +++ /dev/null @@ -1,242 +0,0 @@ -/* - * 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$ - * Revision 1.6 2001/08/10 12:34:25 knoaman - * Fix compilation error. - * - * Revision 1.5 2001/08/09 15:23:16 knoaman - * add support for <anyAttribute> declaration. - * - * Revision 1.4 2001/07/31 15:26:54 knoaman - * Added support for <attributeGroup>. - * - * Revision 1.3 2001/05/11 17:17:41 tng - * Schema: DatatypeValidator fixes. By Pei Yong Zhang. - * - * Revision 1.2 2001/05/11 13:27:34 tng - * Copyright update. - * - * Revision 1.1 2001/02/27 18:48:22 tng - * Schema: Add SchemaAttDef, SchemaElementDecl, SchemaAttDefList. - * - */ -#if !defined(SCHEMAATTDEF_HPP) -#define SCHEMAATTDEF_HPP - -#include <util/XMLString.hpp> -#include <framework/XMLAttDef.hpp> -#include <util/ValueVectorOf.hpp> - -class DatatypeValidator; -class QName; - -// -// This class is a derivative of the core XMLAttDef class. This class adds -// any Schema specific data members and provides Schema specific implementations -// of any underlying attribute def virtual methods. -// -class VALIDATORS_EXPORT SchemaAttDef : public XMLAttDef -{ -public : - - // ----------------------------------------------------------------------- - // Constructors and Destructors - // ----------------------------------------------------------------------- - SchemaAttDef(); - SchemaAttDef - ( - const XMLCh* const prefix - , const XMLCh* const localPart - , const int uriId - , const XMLAttDef::AttTypes type = CData - , const XMLAttDef::DefAttTypes defType = Implied - ); - SchemaAttDef - ( - const XMLCh* const prefix - , const XMLCh* const localPart - , const int uriId - , const XMLCh* const attValue - , const XMLAttDef::AttTypes type - , const XMLAttDef::DefAttTypes defType - , const XMLCh* const enumValues = 0 - ); - SchemaAttDef - ( - const SchemaAttDef* other - ); - virtual ~SchemaAttDef(); - - // ----------------------------------------------------------------------- - // Implementation of the XMLAttDef interface - // ----------------------------------------------------------------------- - virtual const XMLCh* getFullName() const; - - - // ----------------------------------------------------------------------- - // Getter methods - // ----------------------------------------------------------------------- - unsigned int getElemId() const; - QName* getAttName() const; - DatatypeValidator* getDatatypeValidator() const; - ValueVectorOf<unsigned int>* getNamespaceList() const; - - // ----------------------------------------------------------------------- - // Setter methods - // ----------------------------------------------------------------------- - void setElemId(const unsigned int newId); - void setAttName - ( - const XMLCh* const prefix - ,const XMLCh* const localPart - ,const int uriId = -1 - ); - void setDatatypeValidator(DatatypeValidator* newDatatypeValidator); - void setNamespaceList(const ValueVectorOf<unsigned int>* const toSet); - void resetNamespaceList(); - - -private : - // ----------------------------------------------------------------------- - // Private data members - // - // fElemId - // This is the id of the element (the id is into the element decl - // pool) of the element this attribute def said it belonged to. - // This is used later to link back to the element, mostly for - // validation purposes. - // - // fAttName - // This is the name of the attribute. - // - // fDatatypeValidator - // The DatatypeValidator used to validate this attribute type. - // - // fNamespaceList - // The list of namespace values for a wildcard attribute - // - // ----------------------------------------------------------------------- - unsigned int fElemId; - QName* fAttName; - DatatypeValidator* fDatatypeValidator; - ValueVectorOf<unsigned int>* fNamespaceList; -}; - - -// --------------------------------------------------------------------------- -// SchemaAttDef: Getter methods -// --------------------------------------------------------------------------- -inline unsigned int SchemaAttDef::getElemId() const -{ - return fElemId; -} - - -inline QName* SchemaAttDef::getAttName() const -{ - return fAttName; -} - -inline DatatypeValidator* SchemaAttDef::getDatatypeValidator() const -{ - return fDatatypeValidator; -} - -inline ValueVectorOf<unsigned int>* -SchemaAttDef::getNamespaceList() const { - return fNamespaceList; -} - - -// --------------------------------------------------------------------------- -// SchemaAttDef: Setter methods -// --------------------------------------------------------------------------- -inline void SchemaAttDef::setElemId(const unsigned int newId) -{ - fElemId = newId; -} - -inline void SchemaAttDef::setDatatypeValidator(DatatypeValidator* newDatatypeValidator) -{ - fDatatypeValidator = newDatatypeValidator; -} - -inline void SchemaAttDef::resetNamespaceList() { - - if (fNamespaceList && fNamespaceList->size()) { - fNamespaceList->removeAllElements(); - } -} - -inline void SchemaAttDef::setNamespaceList(const ValueVectorOf<unsigned int>* const toSet) { - - if (toSet && toSet->size()) { - - if (fNamespaceList) { - *fNamespaceList = *toSet; - } - else { - fNamespaceList = new ValueVectorOf<unsigned int>(*toSet); - } - } - else { - resetNamespaceList(); - } -} - -#endif diff --git a/src/validators/schema/SchemaAttDefList.cpp b/src/validators/schema/SchemaAttDefList.cpp deleted file mode 100644 index 00fc232d20ccef794705126ffa34470b428461f0..0000000000000000000000000000000000000000 --- a/src/validators/schema/SchemaAttDefList.cpp +++ /dev/null @@ -1,151 +0,0 @@ -/* - * 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$ - * Revision 1.2 2001/05/11 13:27:34 tng - * Copyright update. - * - * Revision 1.1 2001/02/27 18:48:22 tng - * Schema: Add SchemaAttDef, SchemaElementDecl, SchemaAttDefList. - * - */ - - -// --------------------------------------------------------------------------- -// Includes -// --------------------------------------------------------------------------- -#include <validators/schema/SchemaAttDefList.hpp> - - -// --------------------------------------------------------------------------- -// SchemaAttDefList: Constructors and Destructor -// --------------------------------------------------------------------------- -SchemaAttDefList::SchemaAttDefList(RefHash2KeysTableOf<SchemaAttDef>* const listToUse) : - - fEnum(0) - , fList(listToUse) -{ - fEnum = new RefHash2KeysTableOfEnumerator<SchemaAttDef>(listToUse); -} - -SchemaAttDefList::~SchemaAttDefList() -{ - delete fEnum; -} - - -// --------------------------------------------------------------------------- -// SchemaAttDefList: Implementation of the virtual interface -// --------------------------------------------------------------------------- -bool SchemaAttDefList::hasMoreElements() const -{ - return fEnum->hasMoreElements(); -} - - -bool SchemaAttDefList::isEmpty() const -{ - return fList->isEmpty(); -} - - -XMLAttDef* SchemaAttDefList::findAttDef(const unsigned long uriID - , const XMLCh* const attName) -{ - QName tempAtt(attName, uriID); - return fList->get((void*)tempAtt.getLocalPart(), uriID); -} - - -const XMLAttDef* -SchemaAttDefList::findAttDef( const unsigned long uriID - , const XMLCh* const attName) const -{ - QName tempAtt(attName, uriID); - return fList->get((void*)tempAtt.getLocalPart(), uriID); -} - - -XMLAttDef* SchemaAttDefList::findAttDef( const XMLCh* const attURI - , const XMLCh* const attName) -{ - //need numeric URI id to locate the attribute, that's how it was stored - ThrowXML(RuntimeException, XMLExcepts::Pool_InvalidId); - return 0; -} - - -const XMLAttDef* -SchemaAttDefList::findAttDef( const XMLCh* const attURI - , const XMLCh* const attName) const -{ - //need numeric URI id to locate the attribute, that's how it was stored - ThrowXML(RuntimeException, XMLExcepts::Pool_InvalidId); - return 0; -} - - -XMLAttDef& SchemaAttDefList::nextElement() -{ - return fEnum->nextElement(); -} - - -void SchemaAttDefList::Reset() -{ - fEnum->Reset(); -} diff --git a/src/validators/schema/SchemaAttDefList.hpp b/src/validators/schema/SchemaAttDefList.hpp deleted file mode 100644 index 1deae95e27044ffc302c37232ec7726c1766fdc5..0000000000000000000000000000000000000000 --- a/src/validators/schema/SchemaAttDefList.hpp +++ /dev/null @@ -1,147 +0,0 @@ -/* - * 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$ - * Revision 1.2 2001/05/11 13:27:34 tng - * Copyright update. - * - * Revision 1.1 2001/02/27 18:48:22 tng - * Schema: Add SchemaAttDef, SchemaElementDecl, SchemaAttDefList. - * - */ - - -#if !defined(SCHEMAATTDEFLIST_HPP) -#define SCHEMAATTDEFLIST_HPP - -#include <util/RefHash2KeysTableOf.hpp> -#include <validators/schema/SchemaElementDecl.hpp> - - -// -// This is a derivative of the framework abstract class which defines the -// interface to a list of attribute defs that belong to a particular -// element. The scanner needs to be able to get a list of the attributes -// that an element supports, for use during the validation process and for -// fixed/default attribute processing. -// -// For us, we just wrap the RefHash2KeysTableOf collection that the SchemaElementDecl -// class uses to store the attributes that belong to it. -// -// This class does not adopt the hash table, it just references it. The -// hash table is owned by the element decl it is a member of. -// -class SchemaAttDefList : public XMLAttDefList -{ -public : - // ----------------------------------------------------------------------- - // Constructors and Destructor - // ----------------------------------------------------------------------- - SchemaAttDefList - ( - RefHash2KeysTableOf<SchemaAttDef>* const listToUse - ); - - ~SchemaAttDefList(); - - - // ----------------------------------------------------------------------- - // Implementation of the virtual interface - // ----------------------------------------------------------------------- - virtual bool hasMoreElements() const; - virtual bool isEmpty() const; - virtual XMLAttDef* findAttDef - ( - const unsigned long uriID - , const XMLCh* const attName - ); - virtual const XMLAttDef* findAttDef - ( - const unsigned long uriID - , const XMLCh* const attName - ) const; - virtual XMLAttDef* findAttDef - ( - const XMLCh* const attURI - , const XMLCh* const attName - ); - virtual const XMLAttDef* findAttDef - ( - const XMLCh* const attURI - , const XMLCh* const attName - ) const; - virtual XMLAttDef& nextElement(); - virtual void Reset(); - - -private : - // ----------------------------------------------------------------------- - // Private data members - // - // fEnum - // This is an enumerator for the list that we use to do the enumerator - // type methods of this class. - // - // fList - // The list of SchemaAttDef objects that represent the attributes that - // a particular element supports. - // ----------------------------------------------------------------------- - RefHash2KeysTableOfEnumerator<SchemaAttDef>* fEnum; - RefHash2KeysTableOf<SchemaAttDef>* fList; -}; - -#endif diff --git a/src/validators/schema/SchemaElementDecl.cpp b/src/validators/schema/SchemaElementDecl.cpp deleted file mode 100644 index 875aed2efc3e2fb933e7db95101e77202898e9dc..0000000000000000000000000000000000000000 --- a/src/validators/schema/SchemaElementDecl.cpp +++ /dev/null @@ -1,373 +0,0 @@ -/* - * 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$ - * Revision 1.18 2002/01/02 15:20:22 tng - * Schema Fix: should not store a temp value as the key in the element pool and the attribute pool. - * - * Revision 1.17 2001/11/02 14:13:45 knoaman - * Add support for identity constraints. - * - * Revision 1.16 2001/10/11 12:07:39 tng - * Schema: model type should be based on complextypeinfo if exists. - * - * Revision 1.15 2001/09/14 14:50:22 tng - * Schema: Fix some wildcard bugs, and some retrieving qualified/unqualified element decl problems. - * - * Revision 1.14 2001/09/11 13:02:40 tng - * [Bug 3523] SchemaElementDecl.cpp(242) : error C2202 : not all control paths return a value - * - * Revision 1.13 2001/08/29 20:52:35 tng - * Schema: xsi:type support - * - * Revision 1.12 2001/08/21 16:06:11 tng - * Schema: Unique Particle Attribution Constraint Checking. - * - * Revision 1.11 2001/07/24 18:33:46 knoaman - * Added support for <group> + extra constraint checking for complexType - * - * Revision 1.10 2001/07/09 15:22:43 knoaman - * complete <any> declaration. - * - * Revision 1.9 2001/06/13 20:51:18 peiyongz - * fIsMixed: to handle mixed Content Model - * - * Revision 1.8 2001/05/11 13:27:35 tng - * Copyright update. - * - * Revision 1.7 2001/05/03 20:34:42 tng - * Schema: SchemaValidator update - * - * Revision 1.6 2001/05/03 19:17:59 knoaman - * TraverseSchema Part II. - * - * Revision 1.5 2001/04/19 17:43:16 knoaman - * More schema implementation classes. - * - * Revision 1.4 2001/03/21 21:56:33 tng - * Schema: Add Schema Grammar, Schema Validator, and split the DTDValidator into DTDValidator, DTDScanner, and DTDGrammar. - * - * Revision 1.3 2001/03/21 19:30:15 tng - * Schema: Content Model Updates, by Pei Yong Zhang. - * - * Revision 1.2 2001/03/07 17:42:12 tng - * fix typo - * - * Revision 1.1 2001/02/27 18:48:22 tng - * Schema: Add SchemaAttDef, SchemaElementDecl, SchemaAttDefList. - * - */ - - -// --------------------------------------------------------------------------- -// Includes -// --------------------------------------------------------------------------- -#include <util/XMLString.hpp> -#include <util/XMLUniDefs.hpp> -#include <util/XMLUni.hpp> -#include <validators/schema/SchemaAttDefList.hpp> -#include <validators/schema/SchemaElementDecl.hpp> -#include <validators/schema/identity/IdentityConstraint.hpp> - -// --------------------------------------------------------------------------- -// SchemaElementDecl: Constructors and Destructor -// --------------------------------------------------------------------------- -SchemaElementDecl::SchemaElementDecl() : - - fModelType(Any) - , fDatatypeValidator(0) - , fEnclosingScope(Grammar::TOP_LEVEL_SCOPE) - , fBlockSet(0) - , fFinalSet(0) - , fMiscFlags(0) - , fDefaultValue(0) - , fSubstitutionGroupName(0) - , fTypeFromAnotherSchemaURI(0) - , fComplexTypeInfo(0) - , fXsiComplexTypeInfo(0) - , fAttDefs(0) - , fIdentityConstraints(0) -{ -} - -SchemaElementDecl::SchemaElementDecl(const XMLCh* const prefix - , const XMLCh* const localPart - , const int uriId - , const SchemaElementDecl::ModelTypes type - , const int enclosingScope - ) : - fModelType(type) - , fDatatypeValidator(0) - , fEnclosingScope(enclosingScope) - , fBlockSet(0) - , fFinalSet(0) - , fMiscFlags(0) - , fDefaultValue(0) - , fSubstitutionGroupName(0) - , fTypeFromAnotherSchemaURI(0) - , fComplexTypeInfo(0) - , fXsiComplexTypeInfo(0) - , fAttDefs(0) - , fIdentityConstraints(0) -{ - setElementName(prefix, localPart, uriId); -} - -SchemaElementDecl::SchemaElementDecl(const QName* const elementName - , const SchemaElementDecl::ModelTypes type - , const int enclosingScope - ) : - fModelType(type) - , fDatatypeValidator(0) - , fEnclosingScope(enclosingScope) - , fBlockSet(0) - , fFinalSet(0) - , fMiscFlags(0) - , fDefaultValue(0) - , fSubstitutionGroupName(0) - , fTypeFromAnotherSchemaURI(0) - , fComplexTypeInfo(0) - , fXsiComplexTypeInfo(0) - , fAttDefs(0) - , fIdentityConstraints(0) -{ - setElementName(elementName); -} - -SchemaElementDecl::~SchemaElementDecl() -{ - delete [] fDefaultValue; - delete [] fSubstitutionGroupName; - delete [] fTypeFromAnotherSchemaURI; - delete fAttDefs; - delete fIdentityConstraints; -} - - -// --------------------------------------------------------------------------- -// SchemaElementDecl: XMLElementDecl virtual interface implementation -// --------------------------------------------------------------------------- -XMLAttDef* SchemaElementDecl::findAttr(const XMLCh* const qName - , const unsigned int uriId - , const XMLCh* const baseName - , const XMLCh* const prefix - , const LookupOpts options - , bool& wasAdded) const -{ - if (fXsiComplexTypeInfo) { - return fXsiComplexTypeInfo->findAttr(qName, uriId, baseName, prefix, options, wasAdded); - } - else if (fComplexTypeInfo) { - return fComplexTypeInfo->findAttr(qName, uriId, baseName, prefix, options, wasAdded); - } - else { - if (options == XMLElementDecl::AddIfNotFound) { - SchemaAttDef* retVal = 0; - - // If no att list exist yet, then create one - if (!fAttDefs) { - // Use a hash modulus of 29 and tell it owns its elements - ((SchemaElementDecl*)this)->fAttDefs = new RefHash2KeysTableOf<SchemaAttDef>(29, true); - } - - retVal = fAttDefs->get(baseName, uriId); - - // Fault it in if not found and ask to add it - if (!retVal) - { - // And add a default attribute for this name - retVal = new SchemaAttDef(prefix, baseName, uriId); - retVal->setElemId(getId()); - fAttDefs->put((void*)retVal->getAttName()->getLocalPart(), uriId, retVal); - - wasAdded = true; - } - else - { - wasAdded = false; - } - return retVal; - } - else { - wasAdded = false; - return 0; - } - } -} - - -XMLAttDefList& SchemaElementDecl::getAttDefList() const -{ - if (fXsiComplexTypeInfo) { - return fXsiComplexTypeInfo->getAttDefList(); - } - else if (fComplexTypeInfo) { - return fComplexTypeInfo->getAttDefList(); - } - else { - ThrowXML(RuntimeException, XMLExcepts::DV_InvalidOperation); - } - - return *(XMLAttDefList*)0 ; -} - - -XMLElementDecl::CharDataOpts SchemaElementDecl::getCharDataOpts() const -{ - SchemaElementDecl::ModelTypes modelType = fModelType; - - if (fXsiComplexTypeInfo) { - modelType = (SchemaElementDecl::ModelTypes) fXsiComplexTypeInfo->getContentType(); - } - else if (fComplexTypeInfo) { - modelType = (SchemaElementDecl::ModelTypes) fComplexTypeInfo->getContentType(); - } - - XMLElementDecl::CharDataOpts retVal; - switch(modelType) - { - case Children : - retVal = XMLElementDecl::SpacesOk; - break; - - case Empty : - retVal = XMLElementDecl::NoCharData; - break; - - default : - retVal = XMLElementDecl::AllCharData; - break; - } - return retVal; -} - - -bool SchemaElementDecl::hasAttDefs() const -{ - if (fXsiComplexTypeInfo) { - return fXsiComplexTypeInfo->hasAttDefs(); - } - else if (fComplexTypeInfo) { - return fComplexTypeInfo->hasAttDefs(); - } - - // If the collection hasn't been faulted in, then no att defs - return false; - -} - - -bool SchemaElementDecl::resetDefs() -{ - if (fXsiComplexTypeInfo) { - return fXsiComplexTypeInfo->resetDefs(); - } - else if (fComplexTypeInfo) { - return fComplexTypeInfo->resetDefs(); - } - else if (fAttDefs) { - //all the attdefs here are faulted-in, so just reset the fAttDefs - //but still return false to indicate there is no real att defs - // defined in this element - fAttDefs->removeAll(); - } - - return false; -} - -const XMLCh* -SchemaElementDecl::getFormattedContentModel() const -{ - if (fXsiComplexTypeInfo) { - return fXsiComplexTypeInfo->getFormattedContentModel(); - } - else if (fComplexTypeInfo) { - return fComplexTypeInfo->getFormattedContentModel(); - } - return 0; -} - -// --------------------------------------------------------------------------- -// SchemaElementDecl: Getter methods -// --------------------------------------------------------------------------- -const SchemaAttDef* SchemaElementDecl::getAttDef(const XMLCh* const baseName, const int uriId) const -{ - if (fXsiComplexTypeInfo) { - return fXsiComplexTypeInfo->getAttDef(baseName, uriId); - } - else if (fComplexTypeInfo) { - return fComplexTypeInfo->getAttDef(baseName, uriId); - } - - // If no complex type, then return a null - return 0; - -} - -SchemaAttDef* SchemaElementDecl::getAttDef(const XMLCh* const baseName, const int uriId) -{ - if (fXsiComplexTypeInfo) { - return fXsiComplexTypeInfo->getAttDef(baseName, uriId); - } - else if (fComplexTypeInfo) { - return fComplexTypeInfo->getAttDef(baseName, uriId); - } - - // If no complex type, then return a null - return 0; -} - diff --git a/src/validators/schema/SchemaElementDecl.hpp b/src/validators/schema/SchemaElementDecl.hpp deleted file mode 100644 index a1a80a164a4ba7c644ce4e3f633d4ac69bfdda6e..0000000000000000000000000000000000000000 --- a/src/validators/schema/SchemaElementDecl.hpp +++ /dev/null @@ -1,564 +0,0 @@ -/* - * 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$ - * Revision 1.16 2001/11/23 18:25:45 tng - * Eliminate Warning from AIX xlC 3.6: 1540-399: (W) "IdentityConstraint" is undefined. The delete operator will not call a destructor. - * - * Revision 1.15 2001/11/02 14:13:45 knoaman - * Add support for identity constraints. - * - * Revision 1.14 2001/10/11 12:07:39 tng - * Schema: model type should be based on complextypeinfo if exists. - * - * Revision 1.13 2001/09/05 20:49:11 knoaman - * Fix for complexTypes with mixed content model. - * - * Revision 1.12 2001/08/29 20:52:35 tng - * Schema: xsi:type support - * - * Revision 1.11 2001/08/21 16:06:11 tng - * Schema: Unique Particle Attribution Constraint Checking. - * - * Revision 1.10 2001/08/09 15:23:16 knoaman - * add support for <anyAttribute> declaration. - * - * Revision 1.9 2001/07/24 18:33:46 knoaman - * Added support for <group> + extra constraint checking for complexType - * - * Revision 1.8 2001/06/13 20:51:15 peiyongz - * fIsMixed: to handle mixed Content Model - * - * Revision 1.7 2001/05/11 13:27:36 tng - * Copyright update. - * - * Revision 1.6 2001/05/03 20:34:43 tng - * Schema: SchemaValidator update - * - * Revision 1.5 2001/05/03 19:18:01 knoaman - * TraverseSchema Part II. - * - * Revision 1.4 2001/04/19 17:43:17 knoaman - * More schema implementation classes. - * - * Revision 1.3 2001/03/21 21:56:33 tng - * Schema: Add Schema Grammar, Schema Validator, and split the DTDValidator into DTDValidator, DTDScanner, and DTDGrammar. - * - * Revision 1.2 2001/03/21 19:30:17 tng - * Schema: Content Model Updates, by Pei Yong Zhang. - * - * Revision 1.1 2001/02/27 18:48:23 tng - * Schema: Add SchemaAttDef, SchemaElementDecl, SchemaAttDefList. - * - */ - - -#if !defined(SCHEMAELEMENTDECL_HPP) -#define SCHEMAELEMENTDECL_HPP - -#include <util/QName.hpp> -#include <validators/common/Grammar.hpp> -#include <validators/schema/ComplexTypeInfo.hpp> -#include <validators/schema/identity/IdentityConstraint.hpp> - -class ContentSpecNode; -class SchemaAttDefList; -class DatatypeValidator; - -// -// This class is a derivative of the basic element decl. This one implements -// the virtuals so that they work for a Schema. -// -class VALIDATORS_EXPORT SchemaElementDecl : public XMLElementDecl -{ -public : - // ----------------------------------------------------------------------- - // Class specific types - // - // ModelTypes - // Indicates the type of content model that an element has. This - // indicates how the content model is represented and validated. - // ----------------------------------------------------------------------- - enum ModelTypes - { - Empty - , Any - , Mixed_Simple - , Mixed_Complex - , Children - , Simple - - , ModelTypes_Count - }; - - - // ----------------------------------------------------------------------- - // Constructors and Destructor - // ----------------------------------------------------------------------- - SchemaElementDecl(); - - SchemaElementDecl - ( - const XMLCh* const prefix - , const XMLCh* const localPart - , const int uriId - , const ModelTypes modelType = Any - , const int enclosingScope = Grammar::TOP_LEVEL_SCOPE - ); - - SchemaElementDecl - ( - const QName* const elementName - , const ModelTypes modelType = Any - , const int enclosingScope = Grammar::TOP_LEVEL_SCOPE - ); - - ~SchemaElementDecl(); - - - // ----------------------------------------------------------------------- - // The virtual element decl interface - // ----------------------------------------------------------------------- - virtual XMLAttDef* findAttr - ( - const XMLCh* const qName - , const unsigned int uriId - , const XMLCh* const baseName - , const XMLCh* const prefix - , const LookupOpts options - , bool& wasAdded - ) const; - virtual XMLAttDefList& getAttDefList() const; - virtual CharDataOpts getCharDataOpts() const; - virtual bool hasAttDefs() const; - virtual bool resetDefs(); - virtual const ContentSpecNode* getContentSpec() const; - virtual ContentSpecNode* getContentSpec(); - virtual void setContentSpec(ContentSpecNode* toAdopt); - virtual XMLContentModel* getContentModel(); - virtual void setContentModel(XMLContentModel* const newModelToAdopt); - virtual const XMLCh* getFormattedContentModel () const; - - - // ----------------------------------------------------------------------- - // Getter methods - // ----------------------------------------------------------------------- - const SchemaAttDef* getAttDef(const XMLCh* const baseName, const int uriId) const; - SchemaAttDef* getAttDef(const XMLCh* const baseName, const int uriId); - const SchemaAttDef* getAttWildCard() const; - SchemaAttDef* getAttWildCard(); - ModelTypes getModelType() const; - DatatypeValidator* getDatatypeValidator() const; - int getEnclosingScope() const; - int getDefinedScope() const; - int getFinalSet() const; - int getBlockSet() const; - int getMiscFlags() const; - XMLCh* getDefaultValue() const; - XMLCh* getSubstitutionGroupName() const; - XMLCh* getTypeFromAnotherSchemaURI() const; - ComplexTypeInfo* getComplexTypeInfo() const; - - - // ----------------------------------------------------------------------- - // Setter methods - // ----------------------------------------------------------------------- - void setModelType(const SchemaElementDecl::ModelTypes toSet); - void setDatatypeValidator(DatatypeValidator* newDatatypeValidator); - void setEnclosingScope(const int enclosingScope); - void setDefinedScope(const int definedScope); - void setFinalSet(const int finalSet); - void setBlockSet(const int blockSet); - void setMiscFlags(const int flags); - void setDefaultValue(const XMLCh* const value); - void setSubstitutionGroupName(const XMLCh* const name); - void setTypeFromAnotherSchemaURI(const XMLCh* const uriStr); - void setComplexTypeInfo(ComplexTypeInfo* const typeInfo); - void setXsiComplexTypeInfo(ComplexTypeInfo* const typeInfo); - - // ----------------------------------------------------------------------- - // IC methods - // ----------------------------------------------------------------------- - void addIdentityConstraint(IdentityConstraint* const ic); - unsigned int getIdentityConstraintCount() const; - IdentityConstraint* getIdentityConstraintAt(unsigned int index) const; - -private : - // ----------------------------------------------------------------------- - // Private data members - // - // fModelType - // The content model type of this element. This tells us what kind - // of content model to create. - // - // fDatatypeValidator - // The DatatypeValidator used to validate this element type. - // - // fEnclosingScope - // The enclosing scope where this element is declared. - // - // fDefinedScope - // The Complex Element that this element belongs to. - // - // fFinalSet - // The value set of the 'final' attribute. - // - // fBlockSet - // The value set of the 'block' attribute. - // - // fMiscFlags - // Stores 'abstract/nullable' values - // - // fDefaultValue - // The defalut/fixed value - // - // fSubstitutionGroupName - // The substitution group full name ("uristring','local") - // - // fTypeFromAnotherSchemaURI - // The URI of type if it belongs to a different schema - // - // fComplexTypeInfo - // Stores complex type information - // (no need to delete - handled by schema grammar) - // - // fAttDefs - // The list of attributes that are faulted in for this element - // when ComplexTypeInfo does not exist. We want to keep track - // of these faulted in attributes to avoid duplicate redundant - // error. - // - // fXsiComplexTypeInfo - // Temporary store the xsi:type ComplexType here for validation - // If it presents, then it takes precedence than its own fComplexTypeInfo. - // - // fIdentityConstraints - // Store information about an element identity constraints. - // ----------------------------------------------------------------------- - ModelTypes fModelType; - DatatypeValidator* fDatatypeValidator; - int fEnclosingScope; - int fDefinedScope; - int fFinalSet; - int fBlockSet; - int fMiscFlags; - XMLCh* fDefaultValue; - XMLCh* fSubstitutionGroupName; - XMLCh* fTypeFromAnotherSchemaURI; - ComplexTypeInfo* fComplexTypeInfo; - RefHash2KeysTableOf<SchemaAttDef>* fAttDefs; - ComplexTypeInfo* fXsiComplexTypeInfo; - RefVectorOf<IdentityConstraint>* fIdentityConstraints; -}; - -// --------------------------------------------------------------------------- -// SchemaElementDecl: XMLElementDecl virtual interface implementation -// --------------------------------------------------------------------------- -inline ContentSpecNode* SchemaElementDecl::getContentSpec() -{ - if (fXsiComplexTypeInfo != 0) { - return fXsiComplexTypeInfo->getContentSpec(); - } - else if (fComplexTypeInfo != 0) { - return fComplexTypeInfo->getContentSpec(); - } - - return 0; -} - -inline const ContentSpecNode* SchemaElementDecl::getContentSpec() const -{ - if (fXsiComplexTypeInfo != 0) { - return fXsiComplexTypeInfo->getContentSpec(); - } - else if (fComplexTypeInfo != 0) { - return fComplexTypeInfo->getContentSpec(); - } - - return 0; -} - -inline void -SchemaElementDecl::setContentSpec(ContentSpecNode* toAdopt) -{ - //Handled by complexType -} - -inline XMLContentModel* SchemaElementDecl::getContentModel() -{ - if (fXsiComplexTypeInfo != 0) { - return fXsiComplexTypeInfo->getContentModel(); - } - else if (fComplexTypeInfo != 0) { - return fComplexTypeInfo->getContentModel(); - } - return 0; -} - -inline void -SchemaElementDecl::setContentModel(XMLContentModel* const newModelToAdopt) -{ - //Handled by complexType -} - - -// --------------------------------------------------------------------------- -// SchemaElementDecl: Getter methods -// --------------------------------------------------------------------------- -inline SchemaElementDecl::ModelTypes SchemaElementDecl::getModelType() const -{ - if (fXsiComplexTypeInfo) { - return (SchemaElementDecl::ModelTypes) fXsiComplexTypeInfo->getContentType(); - } - else if (fComplexTypeInfo) { - return (SchemaElementDecl::ModelTypes) fComplexTypeInfo->getContentType(); - } - - return fModelType; -} - -inline DatatypeValidator* SchemaElementDecl::getDatatypeValidator() const -{ - return fDatatypeValidator; -} - -inline int SchemaElementDecl::getEnclosingScope() const -{ - return fEnclosingScope; -} - -inline int SchemaElementDecl::getDefinedScope() const -{ - return fDefinedScope; -} - -inline int SchemaElementDecl::getFinalSet() const -{ - return fFinalSet; -} - -inline int SchemaElementDecl::getBlockSet() const -{ - return fBlockSet; -} - -inline int SchemaElementDecl::getMiscFlags() const -{ - return fMiscFlags; -} - -inline XMLCh* SchemaElementDecl::getDefaultValue() const -{ - return fDefaultValue; -} - -inline XMLCh* SchemaElementDecl::getSubstitutionGroupName() const -{ - - return fSubstitutionGroupName; -} - -inline XMLCh* SchemaElementDecl::getTypeFromAnotherSchemaURI() const { - - return fTypeFromAnotherSchemaURI; -} - -inline ComplexTypeInfo* SchemaElementDecl::getComplexTypeInfo() const -{ - if (fXsiComplexTypeInfo) { - return fXsiComplexTypeInfo; - } - - return fComplexTypeInfo; -} - -inline const SchemaAttDef* SchemaElementDecl::getAttWildCard() const { - - if (fXsiComplexTypeInfo) { - return fXsiComplexTypeInfo->getAttWildCard(); - } - else if (fComplexTypeInfo) { - return fComplexTypeInfo->getAttWildCard(); - } - - return 0; -} - -inline SchemaAttDef* SchemaElementDecl::getAttWildCard() { - - if (fXsiComplexTypeInfo) { - return fXsiComplexTypeInfo->getAttWildCard(); - } - else if (fComplexTypeInfo) { - return fComplexTypeInfo->getAttWildCard(); - } - - return 0; -} - -// --------------------------------------------------------------------------- -// SchemaElementDecl: Setter methods -// --------------------------------------------------------------------------- -inline void -SchemaElementDecl::setModelType(const SchemaElementDecl::ModelTypes toSet) -{ - fModelType = toSet; -} - -inline void SchemaElementDecl::setDatatypeValidator(DatatypeValidator* newDatatypeValidator) -{ - fDatatypeValidator = newDatatypeValidator; -} - -inline void SchemaElementDecl::setEnclosingScope(const int newEnclosingScope) -{ - fEnclosingScope = newEnclosingScope; -} - -inline void SchemaElementDecl::setDefinedScope(const int newDefinedScope) -{ - fDefinedScope = newDefinedScope; -} - -inline void SchemaElementDecl::setFinalSet(const int finalSet) -{ - fFinalSet = finalSet; -} - -inline void SchemaElementDecl::setBlockSet(const int blockSet) -{ - fBlockSet = blockSet; -} - -inline void SchemaElementDecl::setMiscFlags(const int flags) -{ - fMiscFlags = flags; -} - -inline void SchemaElementDecl::setDefaultValue(const XMLCh* const value) -{ - if (fDefaultValue) { - delete[] fDefaultValue; - } - - fDefaultValue = XMLString::replicate(value); -} - -inline void SchemaElementDecl::setSubstitutionGroupName(const XMLCh* const name) -{ - if (fSubstitutionGroupName) { - delete [] fSubstitutionGroupName; - } - - fSubstitutionGroupName = XMLString::replicate(name); -} - -inline void -SchemaElementDecl::setTypeFromAnotherSchemaURI(const XMLCh* const uriStr) { - - if (fTypeFromAnotherSchemaURI) { - delete [] fTypeFromAnotherSchemaURI; - } - - fTypeFromAnotherSchemaURI = XMLString::replicate(uriStr); -} - -inline void -SchemaElementDecl::setComplexTypeInfo(ComplexTypeInfo* const typeInfo) -{ - fComplexTypeInfo = typeInfo; -} - -inline void -SchemaElementDecl::setXsiComplexTypeInfo(ComplexTypeInfo* const typeInfo) -{ - fXsiComplexTypeInfo = typeInfo; -} - -// --------------------------------------------------------------------------- -// SchemaElementDecl: IC methods -// --------------------------------------------------------------------------- -inline void -SchemaElementDecl::addIdentityConstraint(IdentityConstraint* const ic) { - - if (!fIdentityConstraints) { - fIdentityConstraints = new RefVectorOf<IdentityConstraint>(16); - } - - fIdentityConstraints->addElement(ic); -} - -inline unsigned int SchemaElementDecl::getIdentityConstraintCount() const { - - if (fIdentityConstraints) { - return fIdentityConstraints->size(); - } - - return 0; -} - -inline IdentityConstraint* -SchemaElementDecl::getIdentityConstraintAt(unsigned int index) const { - - if (fIdentityConstraints) { - return fIdentityConstraints->elementAt(index); - } - - return 0; -} - -#endif diff --git a/src/validators/schema/SchemaGrammar.cpp b/src/validators/schema/SchemaGrammar.cpp deleted file mode 100644 index fe23a2370fa42cd789d3cab21d387296df16a3a2..0000000000000000000000000000000000000000 --- a/src/validators/schema/SchemaGrammar.cpp +++ /dev/null @@ -1,217 +0,0 @@ -/* - * 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$ - * Revision 1.11 2002/01/02 15:20:22 tng - * Schema Fix: should not store a temp value as the key in the element pool and the attribute pool. - * - * Revision 1.10 2001/11/19 18:26:31 knoaman - * no message - * - * Revision 1.9 2001/10/09 12:18:26 tng - * Leak fix: should use delete [] to delete fTargetNamespace. - * - * Revision 1.8 2001/09/14 14:50:22 tng - * Schema: Fix some wildcard bugs, and some retrieving qualified/unqualified element decl problems. - * - * Revision 1.7 2001/08/21 16:06:11 tng - * Schema: Unique Particle Attribution Constraint Checking. - * - * Revision 1.6 2001/07/31 15:27:10 knoaman - * Added support for <attributeGroup>. - * - * Revision 1.5 2001/07/24 18:33:46 knoaman - * Added support for <group> + extra constraint checking for complexType - * - * Revision 1.4 2001/06/25 12:51:56 knoaman - * Add constraint checking on elements in complex types to prevent same - * element names from having different definitions - use substitueGroups. - * - * Revision 1.3 2001/05/11 13:27:36 tng - * Copyright update. - * - * Revision 1.2 2001/04/19 17:43:18 knoaman - * More schema implementation classes. - * - * Revision 1.1 2001/03/21 21:56:33 tng - * Schema: Add Schema Grammar, Schema Validator, and split the DTDValidator into DTDValidator, DTDScanner, and DTDGrammar. - * - */ - - -// --------------------------------------------------------------------------- -// Includes -// --------------------------------------------------------------------------- -#include <validators/schema/SchemaGrammar.hpp> -#include <validators/schema/NamespaceScope.hpp> -#include <validators/schema/ComplexTypeInfo.hpp> -#include <validators/schema/SchemaSymbols.hpp> -#include <validators/schema/XercesGroupInfo.hpp> -#include <validators/schema/XercesAttGroupInfo.hpp> - - -// --------------------------------------------------------------------------- -// SchemaGrammar: Constructors and Destructor -// --------------------------------------------------------------------------- -SchemaGrammar::SchemaGrammar() : - fTargetNamespace(0) - , fElemDeclPool(0) - , fGroupElemDeclPool(0) - , fNotationDeclPool(0) - , fAttributeDeclRegistry(0) - , fComplexTypeRegistry(0) - , fGroupInfoRegistry(0) - , fAttGroupInfoRegistry(0) - , fDatatypeRegistry(0) - , fNamespaceScope(0) - , fValidSubstitutionGroups(0) - , fIDRefList(0) - , fUPAChecked(false) -{ - // - // Init all the pool members. - // - // <TBD> Investigate what the optimum values would be for the various - // pools. - // - fElemDeclPool = new RefHash3KeysIdPool<SchemaElementDecl>(109); - fGroupElemDeclPool = new RefHash3KeysIdPool<SchemaElementDecl>(109, false); - fNotationDeclPool = new NameIdPool<XMLNotationDecl>(109); - fIDRefList = new RefHashTableOf<XMLRefInfo>(29); - - // - // Call our own reset method. This lets us have the pool setup stuff - // done in just one place (because this stame setup stuff has to be - // done every time we are reset.) - // - reset(); -} - -SchemaGrammar::~SchemaGrammar() -{ - delete fElemDeclPool; - delete fGroupElemDeclPool; - delete fNotationDeclPool; - delete [] fTargetNamespace; - delete fAttributeDeclRegistry; - delete fComplexTypeRegistry; - delete fGroupInfoRegistry; - delete fAttGroupInfoRegistry; - delete fNamespaceScope; - delete fValidSubstitutionGroups; - delete fIDRefList; -} - - -// ----------------------------------------------------------------------- -// Virtual methods -// ----------------------------------------------------------------------- -XMLElementDecl* SchemaGrammar::findOrAddElemDecl (const unsigned int uriId - , const XMLCh* const baseName - , const XMLCh* const prefixName - , const XMLCh* const qName - , unsigned int scope - , bool& wasAdded ) -{ - // See it it exists - SchemaElementDecl* retVal = fElemDeclPool->getByKey(baseName, uriId, scope); - - if (!retVal) { - retVal = fGroupElemDeclPool->getByKey(baseName, uriId, scope); - } - - // if not, then add this in - if (!retVal) - { - retVal = new SchemaElementDecl(prefixName, baseName, uriId, SchemaElementDecl::Any); - const unsigned int elemId = fElemDeclPool->put((void*)retVal->getBaseName(), uriId, scope, retVal); - retVal->setId(elemId); - wasAdded = true; - } - else - { - wasAdded = false; - } - return retVal; -} - -XMLElementDecl* SchemaGrammar::putElemDecl (const unsigned int uriId - , const XMLCh* const baseName - , const XMLCh* const prefixName - , const XMLCh* const qName - , unsigned int scope) -{ - SchemaElementDecl* retVal = new SchemaElementDecl(prefixName, baseName, uriId, SchemaElementDecl::Any); - const unsigned int elemId = fElemDeclPool->put((void*)retVal->getBaseName(), uriId, scope, retVal); - retVal->setId(elemId); - return retVal; -} - -void SchemaGrammar::reset() -{ - // - // We need to reset all of the pools. - // - fElemDeclPool->removeAll(); - fGroupElemDeclPool->removeAll(); - fNotationDeclPool->removeAll(); - fUPAChecked = false; -} - - - - diff --git a/src/validators/schema/SchemaGrammar.hpp b/src/validators/schema/SchemaGrammar.hpp deleted file mode 100644 index 63d73bd71420cb897e19169161f810ffcd9ae533..0000000000000000000000000000000000000000 --- a/src/validators/schema/SchemaGrammar.hpp +++ /dev/null @@ -1,548 +0,0 @@ -/* - * 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$ - * Revision 1.14 2001/11/19 18:26:31 knoaman - * no message - * - * Revision 1.13 2001/10/09 12:18:26 tng - * Leak fix: should use delete [] to delete fTargetNamespace. - * - * Revision 1.12 2001/10/04 15:11:51 knoaman - * Add support for circular import. - * - * Revision 1.10 2001/09/14 14:50:22 tng - * Schema: Fix some wildcard bugs, and some retrieving qualified/unqualified element decl problems. - * - * Revision 1.9 2001/08/21 16:06:11 tng - * Schema: Unique Particle Attribution Constraint Checking. - * - * Revision 1.8 2001/07/31 15:27:10 knoaman - * Added support for <attributeGroup>. - * - * Revision 1.7 2001/07/24 18:33:46 knoaman - * Added support for <group> + extra constraint checking for complexType - * - * Revision 1.6 2001/06/25 12:51:57 knoaman - * Add constraint checking on elements in complex types to prevent same - * element names from having different definitions - use substitueGroups. - * - * Revision 1.5 2001/05/28 20:56:19 tng - * Schema: Move getTargetNamespace as virtual function in base class Grammar - * - * Revision 1.4 2001/05/11 13:27:36 tng - * Copyright update. - * - * Revision 1.3 2001/05/03 20:34:43 tng - * Schema: SchemaValidator update - * - * Revision 1.2 2001/04/19 17:43:19 knoaman - * More schema implementation classes. - * - * Revision 1.1 2001/03/21 21:56:33 tng - * Schema: Add Schema Grammar, Schema Validator, and split the DTDValidator into DTDValidator, DTDScanner, and DTDGrammar. - * - */ - - - -#if !defined(SCHEMAGRAMMAR_HPP) -#define SCHEMAGRAMMAR_HPP - -#include <framework/XMLNotationDecl.hpp> -#include <util/RefHash3KeysIdPool.hpp> -#include <util/NameIdPool.hpp> -#include <util/StringPool.hpp> -#include <validators/common/Grammar.hpp> -#include <validators/schema/SchemaElementDecl.hpp> -#include <util/ValueVectorOf.hpp> -#include <validators/datatype/IDDatatypeValidator.hpp> - -// -// This class stores the Schema information -// NOTE: Schemas are not namespace aware, so we just use regular NameIdPool -// data structures to store element and attribute decls. They are all set -// to be in the global namespace and the full QName is used as the base name -// of the decl. This means that all the URI parameters below are expected -// to be null pointers (and anything else will cause an exception.) -// - -// --------------------------------------------------------------------------- -// Forward Declarations -// --------------------------------------------------------------------------- -class DatatypeValidatorFactory; -class ComplexTypeInfo; -class NamespaceScope; -class XercesGroupInfo; -class XercesAttGroupInfo; - -// --------------------------------------------------------------------------- -// typedef declaration -// --------------------------------------------------------------------------- -typedef ValueVectorOf<SchemaElementDecl*> ElemVector; - - -class VALIDATORS_EXPORT SchemaGrammar : public Grammar -{ -public: - // ----------------------------------------------------------------------- - // Constructors and Destructor - // ----------------------------------------------------------------------- - SchemaGrammar(); - virtual ~SchemaGrammar(); - - // ----------------------------------------------------------------------- - // Implementation of Virtual Interface - // ----------------------------------------------------------------------- - virtual Grammar::GrammarType getGrammarType(); - virtual const XMLCh* getTargetNamespace() const; - - virtual XMLElementDecl* findOrAddElemDecl - ( - const unsigned int uriId - , const XMLCh* const baseName - , const XMLCh* const prefixName - , const XMLCh* const qName - , unsigned int scope - , bool& wasAdded - ) ; - - virtual unsigned int getElemId - ( - const unsigned int uriId - , const XMLCh* const baseName - , const XMLCh* const qName - , unsigned int scope - ) const ; - - virtual const XMLElementDecl* getElemDecl - ( - const unsigned int uriId - , const XMLCh* const baseName - , const XMLCh* const qName - , unsigned int scope - ) const ; - - virtual XMLElementDecl* getElemDecl - ( - const unsigned int uriId - , const XMLCh* const baseName - , const XMLCh* const qName - , unsigned int scope - ); - - virtual const XMLElementDecl* getElemDecl - ( - const unsigned int elemId - ) const; - - virtual XMLElementDecl* getElemDecl - ( - const unsigned int elemId - ); - - virtual const XMLNotationDecl* getNotationDecl - ( - const XMLCh* const notName - ) const; - - virtual XMLNotationDecl* getNotationDecl - ( - const XMLCh* const notName - ); - - virtual XMLElementDecl* putElemDecl - ( - const unsigned int uriId - , const XMLCh* const baseName - , const XMLCh* const prefixName - , const XMLCh* const qName - , unsigned int scope - ); - - virtual unsigned int putElemDecl - ( - XMLElementDecl* const elemDecl - ) const; - - virtual unsigned int putNotationDecl - ( - XMLNotationDecl* const notationDecl - ) const; - - virtual void reset(); - - // ----------------------------------------------------------------------- - // Getter methods - // ----------------------------------------------------------------------- - RefHash3KeysIdPoolEnumerator<SchemaElementDecl> getElemEnumerator() const; - RefHashTableOf<XMLAttDef>* getAttributeDeclRegistry() const; - RefHashTableOf<ComplexTypeInfo>* getComplexTypeRegistry() const; - RefHashTableOf<XercesGroupInfo>* getGroupInfoRegistry() const; - RefHashTableOf<XercesAttGroupInfo>* getAttGroupInfoRegistry() const; - DatatypeValidatorFactory* getDatatypeRegistry() const; - NamespaceScope* getNamespaceScope() const; - RefHash2KeysTableOf<ElemVector>* getValidSubstitutionGroups() const; - RefHashTableOf<XMLRefInfo>* getIDRefList() const; - bool getUPAChecked() const; - - // ----------------------------------------------------------------------- - // Setter methods - // ----------------------------------------------------------------------- - void setTargetNamespace(const XMLCh* const targetNamespace); - void setAttributeDeclRegistry(RefHashTableOf<XMLAttDef>* const attReg); - void setComplexTypeRegistry(RefHashTableOf<ComplexTypeInfo>* const other); - void setGroupInfoRegistry(RefHashTableOf<XercesGroupInfo>* const other); - void setAttGroupInfoRegistry(RefHashTableOf<XercesAttGroupInfo>* const other); - void setDatatypeRegistry(DatatypeValidatorFactory* const dvRegistry); - void setNamespaceScope(NamespaceScope* const nsScope); - void setValidSubstitutionGroups(RefHash2KeysTableOf<ElemVector>* const); - void setUPAChecked(bool newState); - - // ----------------------------------------------------------------------- - // Helper methods - // ----------------------------------------------------------------------- - unsigned int putGroupElemDecl - ( - XMLElementDecl* const elemDecl - ) const; - -private: - - // ----------------------------------------------------------------------- - // Private data members - // - // fElemDeclPool - // This is the element decl pool. It contains all of the elements - // declared in the Schema (and their associated attributes.) When in - // non-validating mode, its just populated as new elements are seen - // and they are given default characteristics. - // - // fGroupElemDeclPool - // This is the element decl pool for elements in a group that are - // referenced in different scope. It contains all of the elements - // declared in the Schema (and their associated attributes.) - // - // fNotationDeclPool - // This is a pool of NotationDecl objects, which contains all of the - // notations declared in the Schema. - // - // fTargetNamespace - // Target name space for this grammar. - // - // fAttributeDeclRegistry - // Global attribute declarations - // - // fComplexTypeRegistry - // Stores complexType declaration info - // - // fGroupInfoRegistry - // Stores global <group> declaration info - // - // fAttGroupInfoRegistry - // Stores global <attributeGroup> declaration info - // - // fDatatypeRegistry - // Datatype validator factory - // - // fNamespaceScope - // Prefix to Namespace map - // - // fValidSubstitutionGroups - // Valid list of elements that can substitute a given element - // - // fIDRefList - // List of ids of schema declarations extracted during schema grammar - // traversal - // - // fUPAChecked - // Indicates if this Grammar has already been validated for - // schema unique particle attribute constraint checking. - // ----------------------------------------------------------------------- - XMLCh* fTargetNamespace; - RefHash3KeysIdPool<SchemaElementDecl>* fElemDeclPool; - RefHash3KeysIdPool<SchemaElementDecl>* fGroupElemDeclPool; - NameIdPool<XMLNotationDecl>* fNotationDeclPool; - RefHashTableOf<XMLAttDef>* fAttributeDeclRegistry; - RefHashTableOf<ComplexTypeInfo>* fComplexTypeRegistry; - RefHashTableOf<XercesGroupInfo>* fGroupInfoRegistry; - RefHashTableOf<XercesAttGroupInfo>* fAttGroupInfoRegistry; - DatatypeValidatorFactory* fDatatypeRegistry; - NamespaceScope* fNamespaceScope; - RefHash2KeysTableOf<ElemVector>* fValidSubstitutionGroups; - RefHashTableOf<XMLRefInfo>* fIDRefList; - bool fUPAChecked; -}; - - -// --------------------------------------------------------------------------- -// SchemaGrammar: Getter methods -// --------------------------------------------------------------------------- -inline RefHash3KeysIdPoolEnumerator<SchemaElementDecl> -SchemaGrammar::getElemEnumerator() const -{ - return RefHash3KeysIdPoolEnumerator<SchemaElementDecl>(fElemDeclPool); -} - -inline RefHashTableOf<XMLAttDef>* SchemaGrammar::getAttributeDeclRegistry() const { - - return fAttributeDeclRegistry; -} - -inline RefHashTableOf<ComplexTypeInfo>* -SchemaGrammar::getComplexTypeRegistry() const { - - return fComplexTypeRegistry; -} - -inline RefHashTableOf<XercesGroupInfo>* -SchemaGrammar::getGroupInfoRegistry() const { - - return fGroupInfoRegistry; -} - -inline RefHashTableOf<XercesAttGroupInfo>* -SchemaGrammar::getAttGroupInfoRegistry() const { - - return fAttGroupInfoRegistry; -} - -inline DatatypeValidatorFactory* SchemaGrammar::getDatatypeRegistry() const { - - return fDatatypeRegistry; -} - -inline NamespaceScope* SchemaGrammar::getNamespaceScope() const { - - return fNamespaceScope; -} - -inline RefHash2KeysTableOf<ElemVector>* -SchemaGrammar::getValidSubstitutionGroups() const { - - return fValidSubstitutionGroups; -} - -inline bool SchemaGrammar::getUPAChecked() const { - return fUPAChecked; -} - -inline RefHashTableOf<XMLRefInfo>* SchemaGrammar::getIDRefList() const { - - return fIDRefList; -} - -// ----------------------------------------------------------------------- -// Setter methods -// ----------------------------------------------------------------------- -inline void SchemaGrammar::setTargetNamespace(const XMLCh* const targetNamespace) { - delete [] fTargetNamespace; - fTargetNamespace = XMLString::replicate(targetNamespace); -} - -inline void -SchemaGrammar::setAttributeDeclRegistry(RefHashTableOf<XMLAttDef>* const attReg) { - - fAttributeDeclRegistry = attReg; -} - -inline void -SchemaGrammar::setComplexTypeRegistry(RefHashTableOf<ComplexTypeInfo>* const other) { - - fComplexTypeRegistry = other; -} - -inline void -SchemaGrammar::setGroupInfoRegistry(RefHashTableOf<XercesGroupInfo>* const other) { - - fGroupInfoRegistry = other; -} - -inline void -SchemaGrammar::setAttGroupInfoRegistry(RefHashTableOf<XercesAttGroupInfo>* const other) { - - fAttGroupInfoRegistry = other; -} - -inline void -SchemaGrammar::setDatatypeRegistry(DatatypeValidatorFactory* const dvRegistry) { - - fDatatypeRegistry = dvRegistry; -} - -inline void SchemaGrammar::setNamespaceScope(NamespaceScope* const nsScope) { - - fNamespaceScope = nsScope; -} - -inline void -SchemaGrammar::setValidSubstitutionGroups(RefHash2KeysTableOf<ElemVector>* const other) { - - fValidSubstitutionGroups = other; -} - -inline void SchemaGrammar::setUPAChecked(bool newState) { - fUPAChecked = newState; -} - -// --------------------------------------------------------------------------- -// SchemaGrammar: Virtual methods -// --------------------------------------------------------------------------- -inline Grammar::GrammarType SchemaGrammar::getGrammarType() { - return Grammar::SchemaGrammarType; -} - -inline const XMLCh* SchemaGrammar::getTargetNamespace() const { - return fTargetNamespace; -} - -// Element Decl -inline unsigned int SchemaGrammar::getElemId (const unsigned int uriId - , const XMLCh* const baseName - , const XMLCh* const qName - , unsigned int scope ) const -{ - // - // In this case, we don't return zero to mean 'not found', so we have to - // map it to the official not found value if we don't find it. - // - const SchemaElementDecl* decl = fElemDeclPool->getByKey(baseName, uriId, scope); - if (!decl) { - - decl = fGroupElemDeclPool->getByKey(baseName, uriId, scope); - - if (!decl) - return XMLElementDecl::fgInvalidElemId; - } - return decl->getId(); -} - -inline const XMLElementDecl* SchemaGrammar::getElemDecl( const unsigned int uriId - , const XMLCh* const baseName - , const XMLCh* const qName - , unsigned int scope ) const -{ - const SchemaElementDecl* decl = fElemDeclPool->getByKey(baseName, uriId, scope); - - if (!decl) - decl = fGroupElemDeclPool->getByKey(baseName, uriId, scope); - - return decl; -} - -inline XMLElementDecl* SchemaGrammar::getElemDecl (const unsigned int uriId - , const XMLCh* const baseName - , const XMLCh* const qName - , unsigned int scope ) -{ - SchemaElementDecl* decl = fElemDeclPool->getByKey(baseName, uriId, scope); - - if (!decl) - decl = fGroupElemDeclPool->getByKey(baseName, uriId, scope); - - return decl; -} - -inline const XMLElementDecl* SchemaGrammar::getElemDecl(const unsigned int elemId) const -{ - // Look up this element decl by id - const SchemaElementDecl* decl = fElemDeclPool->getById(elemId); - - if (!decl) - decl = fGroupElemDeclPool->getById(elemId); - - return decl; -} - -inline XMLElementDecl* SchemaGrammar::getElemDecl(const unsigned int elemId) -{ - // Look up this element decl by id - SchemaElementDecl* decl = fElemDeclPool->getById(elemId); - - if (!decl) - decl = fGroupElemDeclPool->getById(elemId); - - return decl; -} - -inline unsigned int SchemaGrammar::putElemDecl (XMLElementDecl* const elemDecl) const -{ - return fElemDeclPool->put(elemDecl->getBaseName(), elemDecl->getURI(), ((SchemaElementDecl* )elemDecl)->getEnclosingScope(), (SchemaElementDecl*) elemDecl); -} - -inline unsigned int SchemaGrammar::putGroupElemDecl (XMLElementDecl* const elemDecl) const -{ - return fGroupElemDeclPool->put(elemDecl->getBaseName(), elemDecl->getURI(), ((SchemaElementDecl* )elemDecl)->getEnclosingScope(), (SchemaElementDecl*) elemDecl); -} - -// Notation Decl -inline const XMLNotationDecl* SchemaGrammar::getNotationDecl(const XMLCh* const notName) const -{ - return fNotationDeclPool->getByKey(notName); -} - -inline XMLNotationDecl* SchemaGrammar::getNotationDecl(const XMLCh* const notName) -{ - return fNotationDeclPool->getByKey(notName); -} - -inline unsigned int SchemaGrammar::putNotationDecl(XMLNotationDecl* const notationDecl) const -{ - return fNotationDeclPool->put(notationDecl); -} - -#endif diff --git a/src/validators/schema/SchemaInfo.cpp b/src/validators/schema/SchemaInfo.cpp deleted file mode 100644 index f575d9110c08609f71acba4dd2263e9a649789cf..0000000000000000000000000000000000000000 --- a/src/validators/schema/SchemaInfo.cpp +++ /dev/null @@ -1,245 +0,0 @@ -/* - * 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$ - * Revision 1.6 2001/12/12 20:52:19 peiyongz - * memory leak: fRedefineList - * - * Revision 1.5 2001/10/04 15:08:56 knoaman - * Add support for circular import. - * - * Revision 1.4 2001/07/31 15:26:54 knoaman - * Added support for <attributeGroup>. - * - * Revision 1.3 2001/07/09 14:29:43 knoaman - * Fixes for import/include declarations - * - * Revision 1.2 2001/05/11 13:27:36 tng - * Copyright update. - * - * Revision 1.1 2001/05/10 16:33:16 knoaman - * Traverse Schema Part III + error messages. - * - */ - -// --------------------------------------------------------------------------- -// Includes -// --------------------------------------------------------------------------- -#include <validators/schema/SchemaInfo.hpp> -#include <validators/schema/XUtil.hpp> -#include <validators/schema/SchemaSymbols.hpp> -#include <util/XMLString.hpp> - -// --------------------------------------------------------------------------- -// SchemaInfo: Constructors and Destructor -// --------------------------------------------------------------------------- -SchemaInfo::SchemaInfo(const unsigned short elemAttrDefaultQualified, - const int blockDefault, - const int finalDefault, - const int targetNSURI, - const int currentScope, - const int scopeCount, - const unsigned int namespaceScopeLevel, - XMLCh* const schemaURL, - const XMLCh* const targetNSURIString, - XMLStringPool* const stringPool, - const DOM_Element& root) - : fElemAttrDefaultQualified(elemAttrDefaultQualified) - , fBlockDefault(blockDefault) - , fFinalDefault(finalDefault) - , fTargetNSURI(targetNSURI) - , fCurrentScope(currentScope) - , fScopeCount(scopeCount) - , fNamespaceScopeLevel(namespaceScopeLevel) - , fCurrentSchemaURL(schemaURL) - , fTargetNSURIString(targetNSURIString) - , fStringPool(stringPool) - , fSchemaRootElement(root) - , fIncludeList(0) - , fImportList(0) - , fImportingList(0) - , fRedefineList(0) -{ - fImportingList = new RefVectorOf<SchemaInfo>(4, false); -} - - -SchemaInfo::~SchemaInfo() -{ - delete [] fCurrentSchemaURL; - delete fImportList; - delete fIncludeList; - delete fImportingList; - - fImportList = fIncludeList = fImportingList = 0; - - delete fRedefineList; - fRedefineList = 0; -} - -// --------------------------------------------------------------------------- -// SchemaInfo: -// --------------------------------------------------------------------------- -DOM_Element -SchemaInfo::getTopLevelComponent(const XMLCh* const compCategory, - const XMLCh* const name, - SchemaInfo** enclosingSchema) { - - SchemaInfo* currentInfo = this; - DOM_Element child = getTopLevelComponent(compCategory, name); - - if (child == 0) { - - unsigned int listSize = (fIncludeList) ? fIncludeList->size() : 0; - - for (unsigned int i=0; i < listSize; i++) { - - currentInfo = fIncludeList->elementAt(i); - - child = currentInfo->getTopLevelComponent(compCategory, name); - - if (child != 0) { - - *enclosingSchema = currentInfo; - break; - } - } - - if (child == 0 && fRedefineList) { // try redefine list - - currentInfo = fRedefineList->get(compCategory, fStringPool->addOrFind(name)); - - if (currentInfo) { - child = currentInfo->getTopLevelComponent(compCategory, name); - - if (child != 0) { - *enclosingSchema = currentInfo; - } - } - } - } - - return child; -} - - -DOM_Element -SchemaInfo::getTopLevelComponent(const XMLCh* const compCategory, - const XMLCh* const name) { - - DOM_Element child = XUtil::getFirstChildElement(fSchemaRootElement); - - while (child != 0) { - - if (child.getLocalName().equals(compCategory)) { - - if (child.getAttribute(SchemaSymbols::fgATT_NAME).equals(name)) { - break; - } - } - else if (child.getLocalName().equals(SchemaSymbols::fgELT_REDEFINE)) { // if redefine - - DOM_Element redefineChild = XUtil::getFirstChildElement(child); - - while (redefineChild != 0) { - - if (redefineChild.getLocalName().equals(compCategory)) { - - if (redefineChild.getAttribute(SchemaSymbols::fgATT_NAME).equals(name)) { - break; - } - } - - redefineChild = XUtil::getNextSiblingElement(redefineChild); - } - - if (redefineChild != 0) { - - child = redefineChild; - break; - } - } - - child = XUtil::getNextSiblingElement(child); - } - - return child; -} - -void SchemaInfo::updateImportingInfo(SchemaInfo* const importingInfo) { - - if (!fImportingList->containsElement(importingInfo)) { - fImportingList->addElement(importingInfo); - } - - unsigned int listSize = importingInfo->fImportingList->size(); - - for (unsigned int i=0; i < listSize; i++) { - - SchemaInfo* tmpInfo = importingInfo->fImportingList->elementAt(i); - - if (tmpInfo != this && !fImportingList->containsElement(tmpInfo)) { - fImportingList->addElement(tmpInfo); - } - } -} - -/** - * End of file SchemaInfo.cpp - */ - - diff --git a/src/validators/schema/SchemaInfo.hpp b/src/validators/schema/SchemaInfo.hpp deleted file mode 100644 index d319bfa6ae7d64e600530e8449de904498956364..0000000000000000000000000000000000000000 --- a/src/validators/schema/SchemaInfo.hpp +++ /dev/null @@ -1,337 +0,0 @@ -/* - * 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$ - */ - -#if !defined(SCHEMAINFO_HPP) -#define SCHEMAINFO_HPP - - -/** When in a <redefine>, type definitions being used (and indeed - * refs to <group>'s and <attributeGroup>'s) may refer to info - * items either in the schema being redefined, in the <redefine>, - * or else in the schema doing the redefining. Because of this - * latter we have to be prepared sometimes to look for our type - * definitions outside the schema stored in fSchemaRootElement. - * This simple class does this; it's just a linked list that - * lets us look at the <schema>'s on the queue; note also that this - * should provide us with a mechanism to handle nested <redefine>'s. - * It's also a handy way of saving schema info when importing/including. - */ - -// --------------------------------------------------------------------------- -// Includes -// --------------------------------------------------------------------------- -#include <dom/DOM_Element.hpp> -#include <util/RefVectorOf.hpp> -#include <util/RefHash2KeysTableOf.hpp> -#include <util/StringPool.hpp> - -class SchemaInfo -{ -public: - - enum ListType { - // Redefine is treated as an include - IMPORT = 1, - INCLUDE = 2 - }; - - // ----------------------------------------------------------------------- - // Constructor/Destructor - // ----------------------------------------------------------------------- - SchemaInfo(const unsigned short fElemAttrDefaultQualified, - const int blockDefault, - const int finalDefault, - const int targetNSURI, - const int currentScope, - const int scopeCount, - const unsigned int namespaceScopeLevel, - XMLCh* const schemaURL, - const XMLCh* const targetNSURIString, - XMLStringPool* const stringPool, - const DOM_Element& root); - ~SchemaInfo(); - - - // ----------------------------------------------------------------------- - // Getter methods - // ----------------------------------------------------------------------- - XMLCh* getCurrentSchemaURL() const; - const XMLCh* const getTargetNSURIString() const; - DOM_Element getRoot() const; - int getBlockDefault() const; - int getFinalDefault() const; - int getTargetNSURI() const; - int getCurrentScope() const; - int getScopeCount() const; - unsigned int getNamespaceScopeLevel() const; - unsigned short getElemAttrDefaultQualified() const; - RefVectorEnumerator<SchemaInfo> getImportingListEnumerator() const; - - // ----------------------------------------------------------------------- - // Setter methods - // ----------------------------------------------------------------------- - void setCurrentScope(const int aValue); - void setScopeCount(const int aValue); - - // ----------------------------------------------------------------------- - // Access methods - // ----------------------------------------------------------------------- - void addSchemaInfo(SchemaInfo* const toAdd, const ListType aListType); - void addRedefineInfo(const XMLCh* const categName, const XMLCh* const typeName, - SchemaInfo* const toAdd); - bool containsInfo(const SchemaInfo* const toCheck, const ListType aListType) const; - SchemaInfo* getImportInfo(const unsigned int namespaceURI) const; - SchemaInfo* getRedefInfo(const XMLCh* const categName, - const XMLCh* const typeName); - DOM_Element getTopLevelComponent(const XMLCh* const compCategory, - const XMLCh* const name); - DOM_Element getTopLevelComponent(const XMLCh* const compCategory, - const XMLCh* const name, - SchemaInfo** enclosingSchema); - void updateImportingInfo(SchemaInfo* const importingInfo); - bool circularImportExist(const unsigned int nameSpaceURI); - -private: - // ----------------------------------------------------------------------- - // Private data members - // ----------------------------------------------------------------------- - unsigned short fElemAttrDefaultQualified; - int fBlockDefault; - int fFinalDefault; - int fTargetNSURI; - int fCurrentScope; - int fScopeCount; - unsigned int fNamespaceScopeLevel; - XMLCh* fCurrentSchemaURL; - const XMLCh* fTargetNSURIString; - XMLStringPool* fStringPool; - DOM_Element fSchemaRootElement; - RefVectorOf<SchemaInfo>* fIncludeList; - RefVectorOf<SchemaInfo>* fImportList; - RefVectorOf<SchemaInfo>* fImportingList; - RefHash2KeysTableOf<SchemaInfo>* fRedefineList; -}; - -// --------------------------------------------------------------------------- -// SchemaInfo: Getter methods -// --------------------------------------------------------------------------- -inline unsigned short SchemaInfo::getElemAttrDefaultQualified() const { - - return fElemAttrDefaultQualified; -} - -inline int SchemaInfo::getBlockDefault() const { - - return fBlockDefault; -} - -inline int SchemaInfo::getFinalDefault() const { - - return fFinalDefault; -} - -inline unsigned int SchemaInfo::getNamespaceScopeLevel() const { - return fNamespaceScopeLevel; -} - -inline XMLCh* SchemaInfo::getCurrentSchemaURL() const { - - return fCurrentSchemaURL; -} - -inline const XMLCh* const SchemaInfo::getTargetNSURIString() const { - - return fTargetNSURIString; -} - -inline DOM_Element SchemaInfo::getRoot() const { - - return fSchemaRootElement; -} - -inline int SchemaInfo::getTargetNSURI() const { - - return fTargetNSURI; -} - -inline int SchemaInfo::getCurrentScope() const { - - return fCurrentScope; -} - -inline int SchemaInfo::getScopeCount() const { - - return fScopeCount; -} - -inline RefVectorEnumerator<SchemaInfo> -SchemaInfo::getImportingListEnumerator() const { - - return RefVectorEnumerator<SchemaInfo>(fImportingList); -} - -// --------------------------------------------------------------------------- -// Setter methods -// --------------------------------------------------------------------------- -inline void SchemaInfo::setCurrentScope(const int aValue) { - - fCurrentScope = aValue; -} - -inline void SchemaInfo::setScopeCount(const int aValue) { - - fScopeCount = aValue; -} - -// --------------------------------------------------------------------------- -// SchemaInfo: Access methods -// --------------------------------------------------------------------------- -inline void SchemaInfo::addSchemaInfo(SchemaInfo* const toAdd, - const ListType aListType) { - - if (aListType == IMPORT) { - - if (!fImportList) - fImportList = new RefVectorOf<SchemaInfo>(8, false); - - if (!fImportList->containsElement(toAdd)) { - fImportList->addElement(toAdd); - toAdd->updateImportingInfo(this); - } - } - else { - - if (!fIncludeList) - fIncludeList = new RefVectorOf<SchemaInfo>(8, false); - - if (!fIncludeList->containsElement(toAdd)) - fIncludeList->addElement(toAdd); - } -} - -inline void SchemaInfo::addRedefineInfo(const XMLCh* const categName, - const XMLCh* const typeName, - SchemaInfo* const toAdd) { - - if (!fRedefineList) { - fRedefineList = new RefHash2KeysTableOf<SchemaInfo>(8, false); - } - - fRedefineList->put((void*) categName, fStringPool->addOrFind(typeName), toAdd); -} - -inline SchemaInfo* SchemaInfo::getImportInfo(const unsigned int namespaceURI) const { - - unsigned int importSize = (fImportList) ? fImportList->size() : 0; - SchemaInfo* currInfo = 0; - - for (unsigned int i=0; i < importSize; i++) { - - currInfo = fImportList->elementAt(i); - - if (currInfo->getTargetNSURI() == (int) namespaceURI) - break; - } - - return currInfo; -} - -inline SchemaInfo* SchemaInfo::getRedefInfo(const XMLCh* const categName, - const XMLCh* const typeName) { - - if (fRedefineList) { - return fRedefineList->get(categName, fStringPool->addOrFind(typeName)); - } - - return 0; -} - -inline bool SchemaInfo::containsInfo(const SchemaInfo* const toCheck, - const ListType aListType) const { - - if ((aListType == INCLUDE) && fIncludeList) { - return fIncludeList->containsElement(toCheck); - } - else if ((aListType == IMPORT) && fImportList) { - return fImportList->containsElement(toCheck); - } - - return false; -} - -inline bool SchemaInfo::circularImportExist(const unsigned int namespaceURI) { - - unsigned int importSize = fImportingList->size(); - - for (unsigned int i=0; i < importSize; i++) { - if (fImportingList->elementAt(i)->getTargetNSURI() == (int) namespaceURI) { - return true; - } - } - - return false; -} - -#endif - -/** - * End of file SchemaInfo.hpp - */ - diff --git a/src/validators/schema/SchemaSymbols.cpp b/src/validators/schema/SchemaSymbols.cpp deleted file mode 100644 index 070e7ce722fcecded1129bb9bb2509cc51f8505f..0000000000000000000000000000000000000000 --- a/src/validators/schema/SchemaSymbols.cpp +++ /dev/null @@ -1,1095 +0,0 @@ -/* - * 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$ - * Revision 1.14 2001/11/07 19:20:01 peiyongz - * DateTime Port - * - * Revision 1.13 2001/09/18 14:41:56 knoaman - * Add support for <annotation>. - * - * Revision 1.12 2001/08/24 20:36:37 knoaman - * Add support for <redefine>. - * - * Revision 1.11 2001/08/24 17:12:02 knoaman - * Add support for anySimpleType. - * Remove parameter 'baseValidator' from the virtual method 'newInstance'. - * - * Revision 1.10 2001/08/22 16:57:53 tng - * typo in ##other. - * - * Revision 1.9 2001/08/01 18:49:32 peiyongz - * AnyRUIDatatypeValidator - * - * Revision 1.8 2001/05/16 15:24:51 tng - * Schema: Add Base64 and HexBin. By Pei Yong Zhang. - * - * Revision 1.7 2001/05/15 21:59:34 knoaman - * TraverseSchema: add attribute checking + some fixes + more error messages. - * More attribute cheking to come. - * - * Revision 1.6 2001/05/14 17:53:48 tng - * Schema: Update Schema URL - * - * Revision 1.5 2001/05/11 15:17:43 tng - * Schema: Nillable fixes. - * - * Revision 1.4 2001/05/11 13:27:37 tng - * Copyright update. - * - * Revision 1.3 2001/05/09 18:43:49 tng - * Add StringDatatypeValidator and BooleanDatatypeValidator. By Pei Yong Zhang. - * - * Revision 1.2 2001/05/03 19:18:03 knoaman - * TraverseSchema Part II. - * - * Revision 1.1 2001/03/21 21:39:21 knoaman - * Schema symbols and Datatype validator part I - * - */ - - -// --------------------------------------------------------------------------- -// Includes -// --------------------------------------------------------------------------- -#include <util/XMLUniDefs.hpp> -#include <validators/schema/SchemaSymbols.hpp> - - -// --------------------------------------------------------------------------- -// SchemaSymbols: Static data -// --------------------------------------------------------------------------- -const XMLCh SchemaSymbols::fgURI_XSI[] = -{ - chLatin_h, chLatin_t, chLatin_t, chLatin_p, chColon, chForwardSlash, - chForwardSlash, chLatin_w, chLatin_w, chLatin_w, chPeriod, chLatin_w, - chDigit_3, chPeriod, chLatin_o, chLatin_r, chLatin_g, chForwardSlash, - chDigit_2, chDigit_0, chDigit_0, chDigit_1, chForwardSlash, - chLatin_X, chLatin_M, chLatin_L, chLatin_S, - chLatin_c, chLatin_h, chLatin_e, chLatin_m, chLatin_a, chDash, chLatin_i, - chLatin_n, chLatin_s, chLatin_t, chLatin_a, chLatin_n, chLatin_c, - chLatin_e, chNull -}; - -const XMLCh SchemaSymbols::fgURI_SCHEMAFORSCHEMA[] = -{ - chLatin_h, chLatin_t, chLatin_t, chLatin_p, chColon, chForwardSlash, - chForwardSlash, chLatin_w, chLatin_w, chLatin_w, chPeriod, chLatin_w, - chDigit_3, chPeriod, chLatin_o, chLatin_r, chLatin_g, chForwardSlash, - chDigit_2, chDigit_0, chDigit_0, chDigit_1, chForwardSlash, - chLatin_X, chLatin_M, chLatin_L, chLatin_S, - chLatin_c, chLatin_h, chLatin_e, chLatin_m, chLatin_a, chNull -}; - -const XMLCh SchemaSymbols::fgXSI_SCHEMALOCACTION[] = -{ - chLatin_s, chLatin_c, chLatin_h, chLatin_e, chLatin_m, chLatin_a, - chLatin_L, chLatin_o, chLatin_c, chLatin_a, chLatin_t, chLatin_i, - chLatin_o, chLatin_n, chNull -}; - -const XMLCh SchemaSymbols::fgXSI_NONAMESPACESCHEMALOCACTION[] = -{ - chLatin_n, chLatin_o, chLatin_N, chLatin_a, chLatin_m, chLatin_e, - chLatin_s, chLatin_p, chLatin_a, chLatin_c, chLatin_e, chLatin_S, - chLatin_c, chLatin_h, chLatin_e, chLatin_m, chLatin_a, chLatin_L, - chLatin_o, chLatin_c, chLatin_a, chLatin_t, chLatin_i, chLatin_o, - chLatin_n, chNull -}; - -const XMLCh SchemaSymbols::fgXSI_TYPE[] = -{ - chLatin_t, chLatin_y, chLatin_p, chLatin_e, chNull -}; - -const XMLCh SchemaSymbols::fgELT_ALL[] = -{ - chLatin_a, chLatin_l, chLatin_l, chNull -}; - -const XMLCh SchemaSymbols::fgELT_ANNOTATION[] = -{ - chLatin_a, chLatin_n, chLatin_n, chLatin_o, chLatin_t, chLatin_a, - chLatin_t, chLatin_i, chLatin_o, chLatin_n, chNull -}; - -const XMLCh SchemaSymbols::fgELT_ANY[] = -{ - chLatin_a, chLatin_n, chLatin_y, chNull -}; - -const XMLCh SchemaSymbols::fgELT_WILDCARD[] = -{ - chLatin_a, chLatin_n, chLatin_y, chNull -}; - -const XMLCh SchemaSymbols::fgELT_ANYATTRIBUTE[] = -{ - chLatin_a, chLatin_n, chLatin_y, chLatin_A, chLatin_t, chLatin_t, - chLatin_r, chLatin_i, chLatin_b, chLatin_u, chLatin_t, chLatin_e, chNull -}; - -const XMLCh SchemaSymbols::fgELT_APPINFO[] = -{ - chLatin_a, chLatin_p, chLatin_p, chLatin_i, chLatin_n, chLatin_f, chLatin_o, chNull -}; - -const XMLCh SchemaSymbols::fgELT_ATTRIBUTE[] = -{ - chLatin_a, chLatin_t, chLatin_t, chLatin_r, chLatin_i, chLatin_b, - chLatin_u, chLatin_t, chLatin_e, chNull -}; - -const XMLCh SchemaSymbols::fgELT_ATTRIBUTEGROUP[] = -{ - chLatin_a, chLatin_t, chLatin_t, chLatin_r, chLatin_i, chLatin_b, - chLatin_u, chLatin_t, chLatin_e, chLatin_G, chLatin_r, chLatin_o, - chLatin_u, chLatin_p, chNull -}; - -const XMLCh SchemaSymbols::fgELT_CHOICE[] = -{ - chLatin_c, chLatin_h, chLatin_o, chLatin_i, chLatin_c, chLatin_e, chNull -}; - -const XMLCh SchemaSymbols::fgELT_COMPLEXTYPE[] = -{ - chLatin_c, chLatin_o, chLatin_m, chLatin_p, chLatin_l, chLatin_e, - chLatin_x, chLatin_T, chLatin_y, chLatin_p, chLatin_e, chNull -}; - -const XMLCh SchemaSymbols::fgELT_CONTENT[] = -{ - chLatin_c, chLatin_o, chLatin_n, chLatin_t, chLatin_e, chLatin_n, - chLatin_t, chNull -}; - -const XMLCh SchemaSymbols::fgELT_DOCUMENTATION[] = -{ - chLatin_d, chLatin_o, chLatin_c, chLatin_u, chLatin_m, chLatin_e, chLatin_n, - chLatin_t, chLatin_a, chLatin_t, chLatin_i, chLatin_o, chLatin_n, chNull -}; - -const XMLCh SchemaSymbols::fgELT_DURATION[] = -{ - chLatin_d, chLatin_u, chLatin_r, chLatin_a, chLatin_t, chLatin_i, - chLatin_o, chLatin_n, chNull -}; - -const XMLCh SchemaSymbols::fgELT_ELEMENT[] = -{ - chLatin_e, chLatin_l, chLatin_e, chLatin_m, chLatin_e, chLatin_n, - chLatin_t, chNull -}; - -const XMLCh SchemaSymbols::fgELT_ENCODING[] = -{ - chLatin_e, chLatin_n, chLatin_c, chLatin_o, chLatin_d, chLatin_i, - chLatin_n, chLatin_g, chNull -}; - -const XMLCh SchemaSymbols::fgELT_ENUMERATION[] = -{ - chLatin_e, chLatin_n, chLatin_u, chLatin_m, chLatin_e, chLatin_r, - chLatin_a, chLatin_t, chLatin_i, chLatin_o, chLatin_n, chNull -}; - -const XMLCh SchemaSymbols::fgELT_FIELD[] = -{ - chLatin_f, chLatin_i, chLatin_e, chLatin_l, chLatin_d, chNull -}; - - -const XMLCh SchemaSymbols::fgELT_WHITESPACE[] = -{ - chLatin_w, chLatin_h, chLatin_i, chLatin_t, chLatin_e, chLatin_S, - chLatin_p, chLatin_a, chLatin_c, chLatin_e, chNull -}; - -const XMLCh SchemaSymbols::fgELT_GROUP[] = -{ - chLatin_g, chLatin_r, chLatin_o, chLatin_u, chLatin_p, chNull -}; - -const XMLCh SchemaSymbols::fgELT_IMPORT[] = -{ - chLatin_i, chLatin_m, chLatin_p, chLatin_o, chLatin_r, chLatin_t, chNull -}; - -const XMLCh SchemaSymbols::fgELT_INCLUDE[] = -{ - chLatin_i, chLatin_n, chLatin_c, chLatin_l, chLatin_u, chLatin_d, - chLatin_e, chNull -}; - -const XMLCh SchemaSymbols::fgELT_REDEFINE[] = -{ - chLatin_r, chLatin_e, chLatin_d, chLatin_e, chLatin_f, chLatin_i, - chLatin_n, chLatin_e, chNull -}; - -const XMLCh SchemaSymbols::fgELT_KEY[] = -{ - chLatin_k, chLatin_e, chLatin_y, chNull -}; - -const XMLCh SchemaSymbols::fgELT_KEYREF[] = -{ - chLatin_k, chLatin_e, chLatin_y, chLatin_r, chLatin_e, chLatin_f, chNull -}; - -const XMLCh SchemaSymbols::fgELT_LENGTH[] = -{ - chLatin_l, chLatin_e, chLatin_n, chLatin_g, chLatin_t, chLatin_h, chNull -}; - -const XMLCh SchemaSymbols::fgELT_MAXEXCLUSIVE[] = -{ - chLatin_m, chLatin_a, chLatin_x, chLatin_E, chLatin_x, chLatin_c, - chLatin_l, chLatin_u, chLatin_s, chLatin_i, chLatin_v, chLatin_e, chNull -}; - -const XMLCh SchemaSymbols::fgELT_MAXINCLUSIVE[] = -{ - chLatin_m, chLatin_a, chLatin_x, chLatin_I, chLatin_n, chLatin_c, - chLatin_l, chLatin_u, chLatin_s, chLatin_i, chLatin_v, chLatin_e, chNull -}; - -const XMLCh SchemaSymbols::fgELT_MAXLENGTH[] = -{ - chLatin_m, chLatin_a, chLatin_x, chLatin_L, chLatin_e, chLatin_n, - chLatin_g, chLatin_t, chLatin_h, chNull -}; - -const XMLCh SchemaSymbols::fgELT_MINEXCLUSIVE[] = -{ - chLatin_m, chLatin_i, chLatin_n, chLatin_E, chLatin_x, chLatin_c, - chLatin_l, chLatin_u, chLatin_s, chLatin_i, chLatin_v, chLatin_e, chNull -}; - -const XMLCh SchemaSymbols::fgELT_MININCLUSIVE[] = -{ - chLatin_m, chLatin_i, chLatin_n, chLatin_I, chLatin_n, chLatin_c, - chLatin_l, chLatin_u, chLatin_s, chLatin_i, chLatin_v, chLatin_e, chNull -}; - -const XMLCh SchemaSymbols::fgELT_MINLENGTH[] = -{ - chLatin_m, chLatin_i, chLatin_n, chLatin_L, chLatin_e, chLatin_n, - chLatin_g, chLatin_t, chLatin_h, chNull -}; - -const XMLCh SchemaSymbols::fgELT_NOTATION[] = -{ - chLatin_n, chLatin_o, chLatin_t, chLatin_a, chLatin_t, chLatin_i, - chLatin_o, chLatin_n, chNull -}; - -const XMLCh SchemaSymbols::fgELT_PATTERN[] = -{ - chLatin_p, chLatin_a, chLatin_t, chLatin_t, chLatin_e, chLatin_r, - chLatin_n, chNull -}; - -const XMLCh SchemaSymbols::fgELT_PERIOD[] = -{ - chLatin_p, chLatin_e, chLatin_r, chLatin_i, chLatin_o, chLatin_d, chNull -}; - -const XMLCh SchemaSymbols::fgELT_TOTALDIGITS[] = -{ - chLatin_t, chLatin_o, chLatin_t, chLatin_a, chLatin_l, chLatin_D, - chLatin_i, chLatin_g, chLatin_i, chLatin_t, chLatin_s, chNull -}; - -const XMLCh SchemaSymbols::fgELT_FRACTIONDIGITS[] = -{ - chLatin_f, chLatin_r, chLatin_a, chLatin_c, chLatin_t, chLatin_i, chLatin_o, - chLatin_n, chLatin_D, chLatin_i, chLatin_g, chLatin_i, chLatin_t, chLatin_s, chNull -}; - -const XMLCh SchemaSymbols::fgELT_SCHEMA[] = -{ - chLatin_s, chLatin_c, chLatin_h, chLatin_e, chLatin_m, chLatin_a, chNull -}; - -const XMLCh SchemaSymbols::fgELT_SELECTOR[] = -{ - chLatin_s, chLatin_e, chLatin_l, chLatin_e, chLatin_c, chLatin_t, - chLatin_o, chLatin_r, chNull -}; - -const XMLCh SchemaSymbols::fgELT_SEQUENCE[] = -{ - chLatin_s, chLatin_e, chLatin_q, chLatin_u, chLatin_e, chLatin_n, - chLatin_c, chLatin_e, chNull -}; - -const XMLCh SchemaSymbols::fgELT_SIMPLETYPE[] = -{ - chLatin_s, chLatin_i, chLatin_m, chLatin_p, chLatin_l, chLatin_e, - chLatin_T, chLatin_y, chLatin_p, chLatin_e, chNull -}; - -const XMLCh SchemaSymbols::fgELT_UNION[] = -{ - chLatin_u, chLatin_n, chLatin_i, chLatin_o, chLatin_n, chNull -}; - -const XMLCh SchemaSymbols::fgELT_LIST[] = -{ - chLatin_l, chLatin_i, chLatin_s, chLatin_t, chNull -}; - -const XMLCh SchemaSymbols::fgELT_UNIQUE[] = -{ - chLatin_u, chLatin_n, chLatin_i, chLatin_q, chLatin_u, chLatin_e, chNull -}; - -const XMLCh SchemaSymbols::fgELT_COMPLEXCONTENT[] = -{ - chLatin_c, chLatin_o, chLatin_m, chLatin_p, chLatin_l, chLatin_e, - chLatin_x, chLatin_C, chLatin_o, chLatin_n, chLatin_t, chLatin_e, - chLatin_n, chLatin_t, chNull -}; - -const XMLCh SchemaSymbols::fgELT_SIMPLECONTENT[] = -{ - chLatin_s, chLatin_i, chLatin_m, chLatin_p, chLatin_l, chLatin_e, chLatin_C, - chLatin_o, chLatin_n, chLatin_t, chLatin_e, chLatin_n, chLatin_t, chNull -}; - -const XMLCh SchemaSymbols::fgELT_RESTRICTION[] = -{ - chLatin_r, chLatin_e, chLatin_s, chLatin_t, chLatin_r, chLatin_i, - chLatin_c, chLatin_t, chLatin_i, chLatin_o, chLatin_n, chNull -}; - -const XMLCh SchemaSymbols::fgELT_EXTENSION[] = -{ - chLatin_e, chLatin_x, chLatin_t, chLatin_e, chLatin_n, chLatin_s, - chLatin_i, chLatin_o, chLatin_n, chNull -}; - -const XMLCh SchemaSymbols::fgATT_ABSTRACT[] = -{ - chLatin_a, chLatin_b, chLatin_s, chLatin_t, chLatin_r, chLatin_a, - chLatin_c, chLatin_t, chNull -}; - -const XMLCh SchemaSymbols::fgATT_ATTRIBUTEFORMDEFAULT[] = -{ - chLatin_a, chLatin_t, chLatin_t, chLatin_r, chLatin_i, chLatin_b, - chLatin_u, chLatin_t, chLatin_e, chLatin_F, chLatin_o, chLatin_r, - chLatin_m, chLatin_D, chLatin_e, chLatin_f, chLatin_a, chLatin_u, - chLatin_l, chLatin_t, chNull -}; - -const XMLCh SchemaSymbols::fgATT_BASE[] = -{ - chLatin_b, chLatin_a, chLatin_s, chLatin_e, chNull -}; - -const XMLCh SchemaSymbols::fgATT_ITEMTYPE[] = -{ - chLatin_i, chLatin_t, chLatin_e, chLatin_m, chLatin_T, chLatin_y, - chLatin_p, chLatin_e, chNull -}; - -const XMLCh SchemaSymbols::fgATT_MEMBERTYPES[] = -{ - chLatin_m, chLatin_e, chLatin_m, chLatin_b, chLatin_e, chLatin_r, - chLatin_T, chLatin_y, chLatin_p, chLatin_e, chLatin_s, chNull -}; - -const XMLCh SchemaSymbols::fgATT_BLOCK[] = -{ - chLatin_b, chLatin_l, chLatin_o, chLatin_c, chLatin_k, chNull -}; - -const XMLCh SchemaSymbols::fgATT_BLOCKDEFAULT[] = -{ - chLatin_b, chLatin_l, chLatin_o, chLatin_c, chLatin_k, chLatin_D, - chLatin_e, chLatin_f, chLatin_a, chLatin_u, chLatin_l, chLatin_t, chNull -}; - -const XMLCh SchemaSymbols::fgATT_CONTENT[] = -{ - chLatin_c, chLatin_o, chLatin_n, chLatin_t, chLatin_e, chLatin_n, chLatin_t, chNull -}; - -const XMLCh SchemaSymbols::fgATT_DEFAULT[] = -{ - chLatin_d, chLatin_e, chLatin_f, chLatin_a, chLatin_u, chLatin_l, chLatin_t, chNull -}; - -const XMLCh SchemaSymbols::fgATT_DERIVEDBY[] = -{ - chLatin_d, chLatin_e, chLatin_r, chLatin_i, chLatin_v, chLatin_e, - chLatin_d, chLatin_B, chLatin_y, chNull -}; - -const XMLCh SchemaSymbols::fgATT_ELEMENTFORMDEFAULT[] = -{ - chLatin_e, chLatin_l, chLatin_e, chLatin_m, chLatin_e, chLatin_n, - chLatin_t, chLatin_F, chLatin_o, chLatin_r, chLatin_m, chLatin_D, - chLatin_e, chLatin_f, chLatin_a, chLatin_u, chLatin_l, chLatin_t, chNull -}; - -const XMLCh SchemaSymbols::fgATT_SUBSTITUTIONGROUP[] = -{ - chLatin_s, chLatin_u, chLatin_b, chLatin_s, chLatin_t, chLatin_i, - chLatin_t, chLatin_u, chLatin_t, chLatin_i, chLatin_o, chLatin_n, - chLatin_G, chLatin_r, chLatin_o, chLatin_u, chLatin_p, chNull -}; - -const XMLCh SchemaSymbols::fgATT_FINAL[] = -{ - chLatin_f, chLatin_i, chLatin_n, chLatin_a, chLatin_l, chNull -}; - -const XMLCh SchemaSymbols::fgATT_FINALDEFAULT[] = -{ - chLatin_f, chLatin_i, chLatin_n, chLatin_a, chLatin_l, chLatin_D, - chLatin_e, chLatin_f, chLatin_a, chLatin_u, chLatin_l, chLatin_t, chNull -}; - -const XMLCh SchemaSymbols::fgATT_FIXED[] = -{ - chLatin_f, chLatin_i, chLatin_x, chLatin_e, chLatin_d, chNull -}; - -const XMLCh SchemaSymbols::fgATT_FORM[] = -{ - chLatin_f, chLatin_o, chLatin_r, chLatin_m, chNull -}; - -const XMLCh SchemaSymbols::fgATT_ID[] = -{ - chLatin_i, chLatin_d, chNull -}; - -const XMLCh SchemaSymbols::fgATT_MAXOCCURS[] = -{ - chLatin_m, chLatin_a, chLatin_x, chLatin_O, chLatin_c, chLatin_c, - chLatin_u, chLatin_r, chLatin_s, chNull -}; - -const XMLCh SchemaSymbols::fgATT_MINOCCURS[] = -{ - chLatin_m, chLatin_i, chLatin_n, chLatin_O, chLatin_c, chLatin_c, - chLatin_u, chLatin_r, chLatin_s, chNull -}; - -const XMLCh SchemaSymbols::fgATT_NAME[] = -{ - chLatin_n, chLatin_a, chLatin_m, chLatin_e, chNull -}; - -const XMLCh SchemaSymbols::fgATT_NAMESPACE[] = -{ - chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chLatin_p, - chLatin_a, chLatin_c, chLatin_e, chNull -}; - -const XMLCh SchemaSymbols::fgATT_NILL[] = -{ - chLatin_n, chLatin_i, chLatin_l, chNull -}; - -const XMLCh SchemaSymbols::fgATT_NILLABLE[] = -{ - chLatin_n, chLatin_i, chLatin_l, chLatin_l, chLatin_a, chLatin_b, - chLatin_l, chLatin_e, chNull -}; - -const XMLCh SchemaSymbols::fgATT_PROCESSCONTENTS[] = -{ - chLatin_p, chLatin_r, chLatin_o, chLatin_c, chLatin_e, chLatin_s, - chLatin_s, chLatin_C, chLatin_o, chLatin_n, chLatin_t, chLatin_e, - chLatin_n, chLatin_t, chLatin_s, chNull -}; - -const XMLCh SchemaSymbols::fgATT_REF[] = -{ - chLatin_r, chLatin_e, chLatin_f, chNull -}; - -const XMLCh SchemaSymbols::fgATT_REFER[] = -{ - chLatin_r, chLatin_e, chLatin_f, chLatin_e, chLatin_r, chNull -}; - -const XMLCh SchemaSymbols::fgATT_SCHEMALOCATION[] = -{ - chLatin_s, chLatin_c, chLatin_h, chLatin_e, chLatin_m, chLatin_a, - chLatin_L, chLatin_o, chLatin_c, chLatin_a, chLatin_t, chLatin_i, - chLatin_o, chLatin_n, chNull -}; - -const XMLCh SchemaSymbols::fgATT_SOURCE[] = -{ - chLatin_s, chLatin_o, chLatin_u, chLatin_r, chLatin_c, chLatin_e, chNull -}; - -const XMLCh SchemaSymbols::fgATT_SYSTEM[] = -{ - chLatin_s, chLatin_y, chLatin_s, chLatin_t, chLatin_e, chLatin_m, chNull -}; - -const XMLCh SchemaSymbols::fgATT_PUBLIC[] = -{ - chLatin_p, chLatin_u, chLatin_b, chLatin_l, chLatin_i, chLatin_c, chNull -}; - -const XMLCh SchemaSymbols::fgATT_TARGETNAMESPACE[] = -{ - chLatin_t, chLatin_a, chLatin_r, chLatin_g, chLatin_e, chLatin_t, - chLatin_N, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chLatin_p, - chLatin_a, chLatin_c, chLatin_e, chNull -}; - -const XMLCh SchemaSymbols::fgATT_TYPE[] = -{ - chLatin_t, chLatin_y, chLatin_p, chLatin_e, chNull -}; - -const XMLCh SchemaSymbols::fgATT_USE[] = -{ - chLatin_u, chLatin_s, chLatin_e, chNull -}; - -const XMLCh SchemaSymbols::fgATT_VALUE[] = -{ - chLatin_v, chLatin_a, chLatin_l, chLatin_u, chLatin_e, chNull -}; - -const XMLCh SchemaSymbols::fgATT_MIXED[] = -{ - chLatin_m, chLatin_i, chLatin_x, chLatin_e, chLatin_d, chNull -}; - -const XMLCh SchemaSymbols::fgATT_VERSION[] = -{ - chLatin_v, chLatin_e, chLatin_r, chLatin_s, chLatin_i, - chLatin_o, chLatin_n, chNull -}; - -const XMLCh SchemaSymbols::fgATT_XPATH[] = -{ - chLatin_x, chLatin_p, chLatin_a, chLatin_t, chLatin_h, chNull -}; - -const XMLCh SchemaSymbols::fgATTVAL_TWOPOUNDANY[] = -{ - chPound, chPound, chLatin_a, chLatin_n, chLatin_y, chNull -}; - -const XMLCh SchemaSymbols::fgATTVAL_TWOPOUNDLOCAL[] = -{ - chPound, chPound, chLatin_l, chLatin_o, chLatin_c, chLatin_a, chLatin_l, chNull -}; - -const XMLCh SchemaSymbols::fgATTVAL_TWOPOUNDOTHER[] = -{ - chPound, chPound, chLatin_o, chLatin_t, chLatin_h, chLatin_e, chLatin_r, chNull -}; - -const XMLCh SchemaSymbols::fgATTVAL_TWOPOUNDTRAGETNAMESPACE[] = -{ - chPound, chPound, chLatin_t, chLatin_a, chLatin_r, chLatin_g, chLatin_e, - chLatin_t, chLatin_N, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chLatin_p, - chLatin_a, chLatin_c, chLatin_e, chNull -}; - -const XMLCh SchemaSymbols::fgATTVAL_POUNDALL[] = -{ - chPound, chLatin_a, chLatin_l, chLatin_l, chNull -}; - -const XMLCh SchemaSymbols::fgATTVAL_BASE64[] = -{ - chLatin_b, chLatin_a, chLatin_s, chLatin_e, chDigit_6, chDigit_4, chNull -}; - -const XMLCh SchemaSymbols::fgATTVAL_BOOLEAN[] = -{ - chLatin_b, chLatin_o, chLatin_o, chLatin_l, chLatin_e, chLatin_a, chLatin_n, chNull -}; - -const XMLCh SchemaSymbols::fgATTVAL_DEFAULT[] = -{ - chLatin_d, chLatin_e, chLatin_f, chLatin_a, chLatin_u, chLatin_l, chLatin_t, chNull -}; - -const XMLCh SchemaSymbols::fgATTVAL_ELEMENTONLY[] = -{ - chLatin_e, chLatin_l, chLatin_e, chLatin_m, chLatin_e, chLatin_n, - chLatin_t, chLatin_O, chLatin_n, chLatin_l, chLatin_y, chNull -}; - -const XMLCh SchemaSymbols::fgATTVAL_EMPTY[] = -{ - chLatin_e, chLatin_m, chLatin_p, chLatin_t, chLatin_y, chNull -}; - -const XMLCh SchemaSymbols::fgATTVAL_EXTENSION[] = -{ - chLatin_e, chLatin_x, chLatin_t, chLatin_e, chLatin_n, chLatin_s, - chLatin_i, chLatin_o, chLatin_n, chNull -}; - -const XMLCh SchemaSymbols::fgATTVAL_FALSE[] = -{ - chLatin_f, chLatin_a, chLatin_l, chLatin_s, chLatin_e, chNull -}; - -const XMLCh SchemaSymbols::fgATTVAL_FIXED[] = -{ - chLatin_f, chLatin_i, chLatin_x, chLatin_e, chLatin_d, chNull -}; - -const XMLCh SchemaSymbols::fgATTVAL_HEX[] = -{ - chLatin_h, chLatin_e, chLatin_x, chNull -}; - -const XMLCh SchemaSymbols::fgATTVAL_ID[] = -{ - chLatin_I, chLatin_D, chNull -}; - -const XMLCh SchemaSymbols::fgATTVAL_LAX[] = -{ - chLatin_l, chLatin_a, chLatin_x, chNull -}; - -const XMLCh SchemaSymbols::fgATTVAL_MAXLENGTH[] = -{ - chLatin_m, chLatin_a, chLatin_x, chLatin_L, chLatin_e, chLatin_n, - chLatin_g, chLatin_t, chLatin_h, chNull -}; - -const XMLCh SchemaSymbols::fgATTVAL_MINLENGTH[] = -{ - chLatin_m, chLatin_i, chLatin_n, chLatin_L, chLatin_e, chLatin_n, - chLatin_g, chLatin_t, chLatin_h, chNull -}; - - -const XMLCh SchemaSymbols::fgATTVAL_MIXED[] = -{ - chLatin_m, chLatin_i, chLatin_x, chLatin_e, chLatin_d, chNull -}; - - -const XMLCh SchemaSymbols::fgATTVAL_NCNAME[] = -{ - chLatin_N, chLatin_C, chLatin_N, chLatin_a, chLatin_m, chLatin_e, chNull -}; - -const XMLCh SchemaSymbols::fgATTVAL_OPTIONAL[] = -{ - chLatin_o, chLatin_p, chLatin_t, chLatin_i, chLatin_o, chLatin_n, - chLatin_a, chLatin_l, chNull -}; - -const XMLCh SchemaSymbols::fgATTVAL_PROHIBITED[] = -{ - chLatin_p, chLatin_r, chLatin_o, chLatin_h, chLatin_i, chLatin_b, - chLatin_i, chLatin_t, chLatin_e, chLatin_d, chNull -}; - -const XMLCh SchemaSymbols::fgATTVAL_QNAME[] = -{ - chLatin_Q, chLatin_N, chLatin_a, chLatin_m, chLatin_e, chNull -}; - -const XMLCh SchemaSymbols::fgATTVAL_QUALIFIED[] = -{ - chLatin_q, chLatin_u, chLatin_a, chLatin_l, chLatin_i, chLatin_f, - chLatin_i, chLatin_e, chLatin_d, chNull -}; - -const XMLCh SchemaSymbols::fgATTVAL_REQUIRED[] = -{ - chLatin_r, chLatin_e, chLatin_q, chLatin_u, chLatin_i, chLatin_r, - chLatin_e, chLatin_d, chNull -}; - -const XMLCh SchemaSymbols::fgATTVAL_RESTRICTION[] = -{ - chLatin_r, chLatin_e, chLatin_s, chLatin_t, chLatin_r, chLatin_i, - chLatin_c, chLatin_t, chLatin_i, chLatin_o, chLatin_n, chNull -}; - -const XMLCh SchemaSymbols::fgATTVAL_SKIP[] = -{ - chLatin_s, chLatin_k, chLatin_i, chLatin_p, chNull -}; - -const XMLCh SchemaSymbols::fgATTVAL_STRICT[] = -{ - chLatin_s, chLatin_t, chLatin_r, chLatin_i, chLatin_c, chLatin_t, chNull -}; - -const XMLCh SchemaSymbols::fgATTVAL_STRING[] = -{ - chLatin_s, chLatin_t, chLatin_r, chLatin_i, chLatin_n, chLatin_g, chNull -}; - -const XMLCh SchemaSymbols::fgATTVAL_TEXTONLY[] = -{ - chLatin_t, chLatin_e, chLatin_x, chLatin_t, chLatin_O, chLatin_n, - chLatin_l, chLatin_y, chNull -}; - -const XMLCh SchemaSymbols::fgATTVAL_TIMEDURATION[] = -{ - chLatin_t, chLatin_i, chLatin_m, chLatin_e, chLatin_D, chLatin_u, - chLatin_r, chLatin_a, chLatin_t, chLatin_i, chLatin_o, chLatin_n, chNull -}; - -const XMLCh SchemaSymbols::fgATTVAL_TRUE[] = -{ - chLatin_t, chLatin_r, chLatin_u, chLatin_e, chNull -}; - -const XMLCh SchemaSymbols::fgATTVAL_UNQUALIFIED[] = -{ - chLatin_u, chLatin_n, chLatin_q, chLatin_u, chLatin_a, chLatin_l, - chLatin_i, chLatin_f, chLatin_i, chLatin_e, chLatin_d, chNull -}; - -const XMLCh SchemaSymbols::fgATTVAL_URI[] = -{ - chLatin_u, chLatin_r, chLatin_i, chNull -}; - -const XMLCh SchemaSymbols::fgATTVAL_URIREFERENCE[] = -{ - chLatin_u, chLatin_r, chLatin_i, chLatin_R, chLatin_e, chLatin_f, - chLatin_e, chLatin_r, chLatin_e, chLatin_n, chLatin_c, chLatin_e, chNull -}; - -const XMLCh SchemaSymbols::fgATTVAL_SUBSTITUTIONGROUP[] = -{ - chLatin_s, chLatin_u, chLatin_b, chLatin_s, chLatin_t, chLatin_i, - chLatin_t, chLatin_u, chLatin_t, chLatin_i, chLatin_o, chLatin_n, - chLatin_G, chLatin_r, chLatin_o, chLatin_u, chLatin_p, chNull -}; - -const XMLCh SchemaSymbols::fgATTVAL_SUBSTITUTION[] = -{ - chLatin_s, chLatin_u, chLatin_b, chLatin_s, chLatin_t, chLatin_i, - chLatin_t, chLatin_u, chLatin_t, chLatin_i, chLatin_o, chLatin_n, chNull -}; - -const XMLCh SchemaSymbols::fgATTVAL_ANYTYPE[] = -{ - chLatin_a, chLatin_n, chLatin_y, chLatin_T, chLatin_y, chLatin_p, - chLatin_e, chNull -}; - -const XMLCh SchemaSymbols::fgWS_PRESERVE[] = -{ - chLatin_p, chLatin_r, chLatin_e, chLatin_s, chLatin_e, chLatin_r, - chLatin_v, chLatin_e, chNull -}; - -const XMLCh SchemaSymbols::fgWS_COLLAPSE[] = -{ - chLatin_c, chLatin_o, chLatin_l, chLatin_l, chLatin_a, chLatin_p, - chLatin_s, chLatin_e, chNull -}; - -const XMLCh SchemaSymbols::fgWS_REPLACE[] = -{ - chLatin_r, chLatin_e, chLatin_p, chLatin_l, chLatin_a, chLatin_c, chLatin_e, chNull -}; - -const XMLCh SchemaSymbols::fgDT_STRING[] = -{ - chLatin_s, chLatin_t, chLatin_r, chLatin_i, chLatin_n, chLatin_g, chNull -}; - -const XMLCh SchemaSymbols::fgDT_TOKEN[] = -{ - chLatin_t, chLatin_o, chLatin_k, chLatin_e, chLatin_n, chNull -}; - -const XMLCh SchemaSymbols::fgDT_LANGUAGE[] = -{ - chLatin_l, chLatin_a, chLatin_n, chLatin_g, chLatin_u, chLatin_a, - chLatin_g, chLatin_e, chNull -}; - -const XMLCh SchemaSymbols::fgDT_NAME[] = -{ - chLatin_N, chLatin_a, chLatin_m, chLatin_e, chNull -}; - -const XMLCh SchemaSymbols::fgDT_NCNAME[] = -{ - chLatin_N, chLatin_C, chLatin_N, chLatin_a, chLatin_m, chLatin_e, chNull -}; - -const XMLCh SchemaSymbols::fgDT_INTEGER[] = -{ - chLatin_i, chLatin_n, chLatin_t, chLatin_e, chLatin_g, chLatin_e, chLatin_r, chNull -}; - -const XMLCh SchemaSymbols::fgDT_DECIMAL[] = -{ - chLatin_d, chLatin_e, chLatin_c, chLatin_i, chLatin_m, chLatin_a, chLatin_l, chNull -}; - -const XMLCh SchemaSymbols::fgDT_BOOLEAN[] = -{ - chLatin_b, chLatin_o, chLatin_o, chLatin_l, chLatin_e, chLatin_a, chLatin_n, chNull -}; - -const XMLCh SchemaSymbols::fgDT_NONPOSITIVEINTEGER[] = -{ - chLatin_n, chLatin_o, chLatin_n, chLatin_P, chLatin_o, chLatin_s, - chLatin_i, chLatin_t, chLatin_i, chLatin_v, chLatin_e, chLatin_I, - chLatin_n, chLatin_t, chLatin_e, chLatin_g, chLatin_e, chLatin_r, chNull -}; - -const XMLCh SchemaSymbols::fgDT_NEGATIVEINTEGER[] = -{ - chLatin_n, chLatin_e, chLatin_g, chLatin_a, chLatin_t, chLatin_i, - chLatin_v, chLatin_e, chLatin_I, chLatin_n, chLatin_t, chLatin_e, - chLatin_g, chLatin_e, chLatin_r, chNull -}; - -const XMLCh SchemaSymbols::fgDT_LONG[] = -{ - chLatin_l, chLatin_o, chLatin_n, chLatin_g, chNull -}; - -const XMLCh SchemaSymbols::fgDT_INT[] = -{ - chLatin_i, chLatin_n, chLatin_t, chNull -}; - -const XMLCh SchemaSymbols::fgDT_SHORT[] = -{ - chLatin_s, chLatin_h, chLatin_o, chLatin_r, chLatin_t, chNull -}; - -const XMLCh SchemaSymbols::fgDT_BYTE[] = -{ - chLatin_b, chLatin_y, chLatin_t, chLatin_e, chNull -}; - -const XMLCh SchemaSymbols::fgDT_NONNEGATIVEINTEGER[] = -{ - chLatin_n, chLatin_o, chLatin_n, chLatin_N, chLatin_e, chLatin_g, - chLatin_a, chLatin_t, chLatin_i, chLatin_v, chLatin_e, chLatin_I, - chLatin_n, chLatin_t, chLatin_e, chLatin_g, chLatin_e, chLatin_r, chNull -}; - -const XMLCh SchemaSymbols::fgDT_ULONG[] = -{ - chLatin_u, chLatin_n, chLatin_s, chLatin_i, chLatin_g, chLatin_n, - chLatin_e, chLatin_d, chLatin_L, chLatin_o, chLatin_n, chLatin_g, chNull -}; - -const XMLCh SchemaSymbols::fgDT_UINT[] = -{ - chLatin_u, chLatin_n, chLatin_s, chLatin_i, chLatin_g, chLatin_n, - chLatin_e, chLatin_d, chLatin_I, chLatin_n, chLatin_t, chNull -}; - -const XMLCh SchemaSymbols::fgDT_USHORT[] = -{ - chLatin_u, chLatin_n, chLatin_s, chLatin_i, chLatin_g, chLatin_n, chLatin_e, - chLatin_d, chLatin_S, chLatin_h, chLatin_o, chLatin_r, chLatin_t, chNull -}; - -const XMLCh SchemaSymbols::fgDT_UBYTE[] = -{ - chLatin_u, chLatin_n, chLatin_s, chLatin_i, chLatin_g, chLatin_n, - chLatin_e, chLatin_d, chLatin_B, chLatin_y, chLatin_t, chLatin_e, chNull -}; - -const XMLCh SchemaSymbols::fgDT_POSITIVEINTEGER[] = -{ - chLatin_p, chLatin_o, chLatin_s, chLatin_i, chLatin_t, chLatin_i, - chLatin_v, chLatin_e, chLatin_I, chLatin_n, chLatin_t, chLatin_e, - chLatin_g, chLatin_e, chLatin_r, chNull -}; - -const XMLCh SchemaSymbols::fgDT_DATETIME[] = -{ - chLatin_d, chLatin_a, chLatin_t, chLatin_e, - chLatin_T, chLatin_i, chLatin_m, chLatin_e, chNull -}; - -const XMLCh SchemaSymbols::fgDT_DATE[] = -{ - chLatin_d, chLatin_a, chLatin_t, chLatin_e, chNull -}; - -const XMLCh SchemaSymbols::fgDT_TIME[] = -{ - chLatin_t, chLatin_i, chLatin_m, chLatin_e, chNull -}; - -const XMLCh SchemaSymbols::fgDT_DURATION[] = -{ - chLatin_d, chLatin_u, chLatin_r, chLatin_a, - chLatin_t, chLatin_i, chLatin_o, chLatin_n, chNull -}; - -const XMLCh SchemaSymbols::fgDT_DAY[] = -{ - chLatin_g, chLatin_D, chLatin_a, chLatin_y, chNull -}; - -const XMLCh SchemaSymbols::fgDT_MONTH[] = -{ - chLatin_g, chLatin_M, chLatin_o, chLatin_n, chLatin_t, chLatin_h, chNull -}; - -const XMLCh SchemaSymbols::fgDT_MONTHDAY[] = -{ - chLatin_g, chLatin_M, chLatin_o, chLatin_n, chLatin_t, chLatin_h, - chLatin_D, chLatin_a, chLatin_y, chNull -}; - -const XMLCh SchemaSymbols::fgDT_YEAR[] = -{ - chLatin_g, chLatin_Y, chLatin_e, chLatin_a, chLatin_r, chNull -}; - -const XMLCh SchemaSymbols::fgDT_YEARMONTH[] = -{ - chLatin_g, chLatin_Y, chLatin_e, chLatin_a, chLatin_r, - chLatin_M, chLatin_o, chLatin_n, chLatin_t, chLatin_h, chNull -}; - -const XMLCh SchemaSymbols::fgDT_BASE64BINARY[] = -{ - chLatin_b, chLatin_a, chLatin_s, chLatin_e, chDigit_6, chDigit_4, - chLatin_B, chLatin_i, chLatin_n, chLatin_a, chLatin_r, chLatin_y, chNull -}; - -const XMLCh SchemaSymbols::fgDT_HEXBINARY[] = -{ - chLatin_h, chLatin_e, chLatin_x, - chLatin_B, chLatin_i, chLatin_n, chLatin_a, chLatin_r, chLatin_y, chNull -}; - -const XMLCh SchemaSymbols::fgDT_FLOAT[] = -{ - chLatin_f, chLatin_l, chLatin_o, chLatin_a, chLatin_t, chNull -}; - -const XMLCh SchemaSymbols::fgDT_DOUBLE[] = -{ - chLatin_d, chLatin_o, chLatin_u, chLatin_b, chLatin_l, chLatin_e, chNull -}; - -const XMLCh SchemaSymbols::fgDT_URIREFERENCE[] = -{ - chLatin_u, chLatin_r, chLatin_i, chLatin_R, chLatin_e, chLatin_f, - chLatin_e, chLatin_r, chLatin_e, chLatin_n, chLatin_c, chLatin_e, chNull -}; - -const XMLCh SchemaSymbols::fgDT_ANYURI[] = -{ - chLatin_a, chLatin_n, chLatin_y, chLatin_U, chLatin_R, chLatin_I, chNull -}; - -const XMLCh SchemaSymbols::fgDT_QNAME[] = -{ - chLatin_Q, chLatin_N, chLatin_a, chLatin_m, chLatin_e, chNull -}; - -const XMLCh SchemaSymbols::fgDT_NORMALIZEDSTRING[] = -{ - chLatin_n, chLatin_o, chLatin_r, chLatin_m, chLatin_a, chLatin_l, chLatin_i, - chLatin_z, chLatin_e, chLatin_d, chLatin_S, chLatin_t, chLatin_r, chLatin_i, - chLatin_n, chLatin_g, chNull -}; - -const XMLCh SchemaSymbols::fgDT_ANYSIMPLETYPE[] = -{ - chLatin_a, chLatin_n, chLatin_y, chLatin_S, chLatin_i, chLatin_m, chLatin_p, - chLatin_l, chLatin_e, chLatin_T, chLatin_y, chLatin_p, chLatin_e, chNull -}; - -const XMLCh SchemaSymbols::fgRegEx_XOption[] = -{ - chLatin_X, chNull -}; - -const XMLCh SchemaSymbols::fgRedefIdentifier[] = -{ - chUnderscore, chLatin_r, chLatin_d, chLatin_f, chLatin_n, chNull -}; - -const int SchemaSymbols::fgINT_MIN_VALUE = 0x80000000; - -const int SchemaSymbols::fgINT_MAX_VALUE = 0x7fffffff; - -/** - * End of file SchemaSymbols.cpp - */ - diff --git a/src/validators/schema/SchemaSymbols.hpp b/src/validators/schema/SchemaSymbols.hpp deleted file mode 100644 index ddac6ae6512a28795703201a1f20321250a4dc78..0000000000000000000000000000000000000000 --- a/src/validators/schema/SchemaSymbols.hpp +++ /dev/null @@ -1,283 +0,0 @@ -/* - * 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$ - */ - -#if !defined(SCHEMASYMBOLS_HPP) -#define SCHEMASYMBOLS_HPP - -#include <util/XercesDefs.hpp> - -/* - * Collection of symbols used to parse a Schema Grammar - */ - -class VALIDATORS_EXPORT SchemaSymbols -{ -public : - // ----------------------------------------------------------------------- - // Constant data - // ----------------------------------------------------------------------- - static const XMLCh fgURI_XSI[]; - static const XMLCh fgURI_SCHEMAFORSCHEMA[]; - static const XMLCh fgXSI_SCHEMALOCACTION[]; - static const XMLCh fgXSI_NONAMESPACESCHEMALOCACTION[]; - static const XMLCh fgXSI_TYPE[]; - static const XMLCh fgELT_ALL[]; - static const XMLCh fgELT_ANNOTATION[]; - static const XMLCh fgELT_ANY[]; - static const XMLCh fgELT_WILDCARD[]; - static const XMLCh fgELT_ANYATTRIBUTE[]; - static const XMLCh fgELT_APPINFO[]; - static const XMLCh fgELT_ATTRIBUTE[]; - static const XMLCh fgELT_ATTRIBUTEGROUP[]; - static const XMLCh fgELT_CHOICE[]; - static const XMLCh fgELT_COMPLEXTYPE[]; - static const XMLCh fgELT_CONTENT[]; - static const XMLCh fgELT_DOCUMENTATION[]; - static const XMLCh fgELT_DURATION[]; - static const XMLCh fgELT_ELEMENT[]; - static const XMLCh fgELT_ENCODING[]; - static const XMLCh fgELT_ENUMERATION[]; - static const XMLCh fgELT_FIELD[]; - static const XMLCh fgELT_WHITESPACE[]; - static const XMLCh fgELT_GROUP[]; - static const XMLCh fgELT_IMPORT[]; - static const XMLCh fgELT_INCLUDE[]; - static const XMLCh fgELT_REDEFINE[]; - static const XMLCh fgELT_KEY[]; - static const XMLCh fgELT_KEYREF[]; - static const XMLCh fgELT_LENGTH[]; - static const XMLCh fgELT_MAXEXCLUSIVE[]; - static const XMLCh fgELT_MAXINCLUSIVE[]; - static const XMLCh fgELT_MAXLENGTH[]; - static const XMLCh fgELT_MINEXCLUSIVE[]; - static const XMLCh fgELT_MININCLUSIVE[]; - static const XMLCh fgELT_MINLENGTH[]; - static const XMLCh fgELT_NOTATION[]; - static const XMLCh fgELT_PATTERN[]; - static const XMLCh fgELT_PERIOD[]; - static const XMLCh fgELT_TOTALDIGITS[]; - static const XMLCh fgELT_FRACTIONDIGITS[]; - static const XMLCh fgELT_SCHEMA[]; - static const XMLCh fgELT_SELECTOR[]; - static const XMLCh fgELT_SEQUENCE[]; - static const XMLCh fgELT_SIMPLETYPE[]; - static const XMLCh fgELT_UNION[]; - static const XMLCh fgELT_LIST[]; - static const XMLCh fgELT_UNIQUE[]; - static const XMLCh fgELT_COMPLEXCONTENT[]; - static const XMLCh fgELT_SIMPLECONTENT[]; - static const XMLCh fgELT_RESTRICTION[]; - static const XMLCh fgELT_EXTENSION[]; - static const XMLCh fgATT_ABSTRACT[]; - static const XMLCh fgATT_ATTRIBUTEFORMDEFAULT[]; - static const XMLCh fgATT_BASE[]; - static const XMLCh fgATT_ITEMTYPE[]; - static const XMLCh fgATT_MEMBERTYPES[]; - static const XMLCh fgATT_BLOCK[]; - static const XMLCh fgATT_BLOCKDEFAULT[]; - static const XMLCh fgATT_CONTENT[]; - static const XMLCh fgATT_DEFAULT[]; - static const XMLCh fgATT_DERIVEDBY[]; - static const XMLCh fgATT_ELEMENTFORMDEFAULT[]; - static const XMLCh fgATT_SUBSTITUTIONGROUP[]; - static const XMLCh fgATT_FINAL[]; - static const XMLCh fgATT_FINALDEFAULT[]; - static const XMLCh fgATT_FIXED[]; - static const XMLCh fgATT_FORM[]; - static const XMLCh fgATT_ID[]; - static const XMLCh fgATT_MAXOCCURS[]; - static const XMLCh fgATT_MINOCCURS[]; - static const XMLCh fgATT_NAME[]; - static const XMLCh fgATT_NAMESPACE[]; - static const XMLCh fgATT_NILL[]; - static const XMLCh fgATT_NILLABLE[]; - static const XMLCh fgATT_PROCESSCONTENTS[]; - static const XMLCh fgATT_REF[]; - static const XMLCh fgATT_REFER[]; - static const XMLCh fgATT_SCHEMALOCATION[]; - static const XMLCh fgATT_SOURCE[]; - static const XMLCh fgATT_SYSTEM[]; - static const XMLCh fgATT_PUBLIC[]; - static const XMLCh fgATT_TARGETNAMESPACE[]; - static const XMLCh fgATT_TYPE[]; - static const XMLCh fgATT_USE[]; - static const XMLCh fgATT_VALUE[]; - static const XMLCh fgATT_MIXED[]; - static const XMLCh fgATT_VERSION[]; - static const XMLCh fgATT_XPATH[]; - static const XMLCh fgATTVAL_TWOPOUNDANY[]; - static const XMLCh fgATTVAL_TWOPOUNDLOCAL[]; - static const XMLCh fgATTVAL_TWOPOUNDOTHER[]; - static const XMLCh fgATTVAL_TWOPOUNDTRAGETNAMESPACE[]; - static const XMLCh fgATTVAL_POUNDALL[]; - static const XMLCh fgATTVAL_BASE64[]; - static const XMLCh fgATTVAL_BOOLEAN[]; - static const XMLCh fgATTVAL_DEFAULT[]; - static const XMLCh fgATTVAL_ELEMENTONLY[]; - static const XMLCh fgATTVAL_EMPTY[]; - static const XMLCh fgATTVAL_EXTENSION[]; - static const XMLCh fgATTVAL_FALSE[]; - static const XMLCh fgATTVAL_FIXED[]; - static const XMLCh fgATTVAL_HEX[]; - static const XMLCh fgATTVAL_ID[]; - static const XMLCh fgATTVAL_LAX[]; - static const XMLCh fgATTVAL_MAXLENGTH[]; - static const XMLCh fgATTVAL_MINLENGTH[]; - static const XMLCh fgATTVAL_MIXED[]; - static const XMLCh fgATTVAL_NCNAME[]; - static const XMLCh fgATTVAL_OPTIONAL[]; - static const XMLCh fgATTVAL_PROHIBITED[]; - static const XMLCh fgATTVAL_QNAME[]; - static const XMLCh fgATTVAL_QUALIFIED[]; - static const XMLCh fgATTVAL_REQUIRED[]; - static const XMLCh fgATTVAL_RESTRICTION[]; - static const XMLCh fgATTVAL_SKIP[]; - static const XMLCh fgATTVAL_STRICT[]; - static const XMLCh fgATTVAL_STRING[]; - static const XMLCh fgATTVAL_TEXTONLY[]; - static const XMLCh fgATTVAL_TIMEDURATION[]; - static const XMLCh fgATTVAL_TRUE[]; - static const XMLCh fgATTVAL_UNQUALIFIED[]; - static const XMLCh fgATTVAL_URI[]; - static const XMLCh fgATTVAL_URIREFERENCE[]; - static const XMLCh fgATTVAL_SUBSTITUTIONGROUP[]; - static const XMLCh fgATTVAL_SUBSTITUTION[]; - static const XMLCh fgATTVAL_ANYTYPE[]; - static const XMLCh fgWS_PRESERVE[]; - static const XMLCh fgWS_COLLAPSE[]; - static const XMLCh fgWS_REPLACE[]; - static const XMLCh fgDT_STRING[]; - static const XMLCh fgDT_TOKEN[]; - static const XMLCh fgDT_LANGUAGE[]; - static const XMLCh fgDT_NAME[]; - static const XMLCh fgDT_NCNAME[]; - static const XMLCh fgDT_INTEGER[]; - static const XMLCh fgDT_DECIMAL[]; - static const XMLCh fgDT_BOOLEAN[]; - static const XMLCh fgDT_NONPOSITIVEINTEGER[]; - static const XMLCh fgDT_NEGATIVEINTEGER[]; - static const XMLCh fgDT_LONG[]; - static const XMLCh fgDT_INT[]; - static const XMLCh fgDT_SHORT[]; - static const XMLCh fgDT_BYTE[]; - static const XMLCh fgDT_NONNEGATIVEINTEGER[]; - static const XMLCh fgDT_ULONG[]; - static const XMLCh fgDT_UINT[]; - static const XMLCh fgDT_USHORT[]; - static const XMLCh fgDT_UBYTE[]; - static const XMLCh fgDT_POSITIVEINTEGER[]; -//datetime - static const XMLCh fgDT_DATETIME[]; - static const XMLCh fgDT_DATE[]; - static const XMLCh fgDT_TIME[]; - static const XMLCh fgDT_DURATION[]; - static const XMLCh fgDT_DAY[]; - static const XMLCh fgDT_MONTH[]; - static const XMLCh fgDT_MONTHDAY[]; - static const XMLCh fgDT_YEAR[]; - static const XMLCh fgDT_YEARMONTH[]; - - static const XMLCh fgDT_BASE64BINARY[]; - static const XMLCh fgDT_HEXBINARY[]; - static const XMLCh fgDT_FLOAT[]; - static const XMLCh fgDT_DOUBLE[]; - static const XMLCh fgDT_URIREFERENCE[]; - static const XMLCh fgDT_ANYURI[]; - static const XMLCh fgDT_QNAME[]; - static const XMLCh fgDT_NORMALIZEDSTRING[]; - static const XMLCh fgDT_ANYSIMPLETYPE[]; - static const XMLCh fgRegEx_XOption[]; - static const XMLCh fgRedefIdentifier[]; - static const int fgINT_MIN_VALUE; - static const int fgINT_MAX_VALUE; - - enum { - EMPTY_SET = 0, - SUBSTITUTION = 1, - EXTENSION = 2, - RESTRICTION = 4, - LIST = 8, - UNION = 16, - ENUMERATION = 32 - }; - - // group orders - enum { - CHOICE = 0, - SEQUENCE= 1, - ALL = 2 - }; - - enum { - INFINITY = -2, - UNBOUNDED = -1, - NILLABLE = 1, - ABSTRACT = 2, - FIXED = 4 - }; - -}; - -#endif - -/** - * End of file SchemaSymbols.hpp - */ - diff --git a/src/validators/schema/SchemaValidator.cpp b/src/validators/schema/SchemaValidator.cpp deleted file mode 100644 index c790d25394d920617833ebb82ec6e9d183d843bd..0000000000000000000000000000000000000000 --- a/src/validators/schema/SchemaValidator.cpp +++ /dev/null @@ -1,889 +0,0 @@ -/* - * 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$ - * Revision 1.26 2001/11/21 18:05:09 tng - * Schema Fix: Check both XMLAttDef::Fixed and XMLAttDef::Required_And_Fixed for default values. - * - * Revision 1.25 2001/11/21 14:30:13 knoaman - * Fix for UPA checking. - * - * Revision 1.24 2001/11/20 20:32:52 knoaman - * Bypass validating element's simple content if it's empty and element is nillable. - * - * Revision 1.23 2001/11/13 13:25:08 tng - * Deprecate function XMLValidator::checkRootElement. - * - * Revision 1.22 2001/11/09 18:10:58 tng - * Schema Fix: should concatenate all characters for validation. - * - * Revision 1.21 2001/10/23 13:35:36 tng - * Schema fix: Resolve notation prefix to an URI. - * - * Revision 1.20 2001/10/12 20:44:01 tng - * Schema Fix: Notation Uri Binding. - * - * Revision 1.19 2001/10/04 15:08:56 knoaman - * Add support for circular import. - * - * Revision 1.18 2001/09/10 14:06:22 tng - * Schema: AnyAttribute support in Scanner and Validator. - * - * Revision 1.17 2001/09/05 20:49:11 knoaman - * Fix for complexTypes with mixed content model. - * - * Revision 1.16 2001/08/30 15:47:46 tng - * Schema: xsi:type fixes - * - * Revision 1.15 2001/08/29 20:52:35 tng - * Schema: xsi:type support - * - * Revision 1.14 2001/08/28 19:20:54 tng - * Schema: xsi:type support - * - * Revision 1.13 2001/08/21 16:06:11 tng - * Schema: Unique Particle Attribution Constraint Checking. - * - * Revision 1.12 2001/08/09 15:23:16 knoaman - * add support for <anyAttribute> declaration. - * - * Revision 1.11 2001/07/26 17:04:11 tng - * Schema: Process should stop after fatal error, and user throws need to be rethrown. - * - * Revision 1.10 2001/07/24 21:23:40 tng - * Schema: Use DatatypeValidator for ID/IDREF/ENTITY/ENTITIES/NOTATION. - * - * Revision 1.9 2001/07/11 21:39:58 peiyongz - * fix to normalizeWhiteSpace: synchronize fDatatypeBuffer with toFill. - * - * Revision 1.8 2001/05/17 18:14:32 tng - * Schema Fix: if nillable, it's an error to have default value - * - * Revision 1.7 2001/05/11 15:17:46 tng - * Schema: Nillable fixes. - * - * Revision 1.6 2001/05/11 13:27:37 tng - * Copyright update. - * - * Revision 1.5 2001/05/10 17:49:42 tng - * Schema: SchemaValidator fixes - * - * Revision 1.4 2001/05/03 20:34:44 tng - * Schema: SchemaValidator update - * - * Revision 1.3 2001/04/19 18:17:39 tng - * Schema: SchemaValidator update, and use QName in Content Model - * - * Revision 1.2 2001/03/30 16:35:19 tng - * Schema: Whitespace normalization. - * - * Revision 1.1 2001/03/21 21:56:33 tng - * Schema: Add Schema Grammar, Schema Validator, and split the DTDValidator into DTDValidator, DTDScanner, and DTDGrammar. - * - */ - -// --------------------------------------------------------------------------- -// Includes -// --------------------------------------------------------------------------- -#include <util/Janitor.hpp> -#include <util/KVStringPair.hpp> -#include <framework/XMLDocumentHandler.hpp> -#include <internal/XMLReader.hpp> -#include <internal/XMLScanner.hpp> -#include <validators/datatype/DatatypeValidatorFactory.hpp> -#include <validators/datatype/InvalidDatatypeValueException.hpp> -#include <validators/datatype/InvalidDatatypeFacetException.hpp> -#include <validators/datatype/ListDatatypeValidator.hpp> -#include <validators/datatype/UnionDatatypeValidator.hpp> -#include <validators/datatype/ENTITYDatatypeValidator.hpp> -#include <validators/datatype/IDDatatypeValidator.hpp> -#include <validators/datatype/IDREFDatatypeValidator.hpp> -#include <validators/schema/SchemaSymbols.hpp> -#include <validators/schema/SchemaValidator.hpp> -#include <validators/schema/SubstitutionGroupComparator.hpp> - -// --------------------------------------------------------------------------- -// SchemaValidator: Constructors and Destructor -// --------------------------------------------------------------------------- -SchemaValidator::SchemaValidator(XMLErrorReporter* const errReporter) : - - XMLValidator(errReporter) - , fGrammarResolver(0) - , fSchemaGrammar(0) - , fTrailing(false) - , fXsiType(0) - , fXsiTypeValidator(0) - , fNil(false) -{ -} - -SchemaValidator::~SchemaValidator() -{ - delete fXsiType; -} - -// --------------------------------------------------------------------------- -// SchemaValidator: Implementation of the XMLValidator interface -// --------------------------------------------------------------------------- -int SchemaValidator::checkContent (XMLElementDecl* const elemDecl - , QName** const children - , const unsigned int childCount) -{ - // - // Look up the element id in our element decl pool. This will get us - // the element decl in our own way of looking at them. - // - if (!elemDecl) - ThrowXML(RuntimeException, XMLExcepts::Val_InvalidElemId); - - // - // Get the content spec type of this element. This will tell us what - // to do to validate it. - // - const SchemaElementDecl::ModelTypes modelType = ((SchemaElementDecl*) elemDecl)->getModelType(); - - if (modelType == SchemaElementDecl::Empty) - { - // - // We can do this one here. It cannot have any children. If it does - // we return 0 as the index of the first bad child. - // - if (childCount) - return 0; - } - else if (modelType == SchemaElementDecl::Any) - { - // We pass no judgement on this one, anything goes - } - else if ((modelType == SchemaElementDecl::Mixed_Simple) - || (modelType == SchemaElementDecl::Mixed_Complex) - || (modelType == SchemaElementDecl::Children)) - { - // if nillable, it's an error to have value - // XML Schema REC: Validation Rule: Element Locally Valid (Element) - // 3.2.1 The element information item must have no - // character or element information item [children]. - // - if (fNil) { - if (childCount > 0 || XMLString::compareString(fDatatypeBuffer.getRawBuffer(), XMLUni::fgZeroLenString)) - emitError(XMLValid::NilAttrNotEmpty, elemDecl->getFullName()); - - } - else { - // Get the element's content model or fault it in - XMLContentModel* elemCM = elemDecl->getContentModel(); - - // Ask it to validate and return its return - unsigned int emptyNS = getScanner()->getEmptyNamespaceId(); - int result = elemCM->validateContent(children, childCount, emptyNS); - if (result != -1) { - result = elemCM->validateContentSpecial(children - , childCount - , emptyNS - , fGrammarResolver - , getScanner()->getURIStringPool()); - } - return result; - } - } - else if (modelType == SchemaElementDecl::Simple) - { - if (childCount > 0) { - emitError(XMLValid::SimpleTypeHasChild, elemDecl->getFullName()); - } else { - try { - DatatypeValidator* fCurrentDV = ((SchemaElementDecl*)elemDecl)->getDatatypeValidator(); - // If there is xsi:type validator, substitute it. - if (fXsiTypeValidator) { - fCurrentDV = fXsiTypeValidator; - fXsiTypeValidator = 0; - } - if (!fCurrentDV) { - emitError(XMLValid::NoDatatypeValidatorForSimpleType, elemDecl->getFullName()); - } else { - XMLCh* value = fDatatypeBuffer.getRawBuffer(); - XMLCh* elemDefaultValue = ((SchemaElementDecl*) elemDecl)->getDefaultValue(); - - if (elemDefaultValue) { - // a default value was specified - - // if nillable, it's an error to have default value - if (fNil) - emitError(XMLValid::NilAttrNotEmpty, elemDecl->getFullName()); - - if (!XMLString::compareString(value, XMLUni::fgZeroLenString)) { - // if this element didn't specified any value - // use default value - getScanner()->getDocHandler()->docCharacters(elemDefaultValue, XMLString::stringLen(elemDefaultValue), false); - } - else { - // this element has specified some value - // if the flag is FIXED, then this value must be same as default value - if ((((SchemaElementDecl*)elemDecl)->getMiscFlags() == SchemaSymbols::FIXED) != 0) { - if (fCurrentDV->compare(value, elemDefaultValue) != 0 ) - emitError(XMLValid::FixedDifferentFromActual, elemDecl->getFullName()); - } - - // if nillable, it's an error to have value - if (fNil) - emitError(XMLValid::NilAttrNotEmpty, elemDecl->getFullName()); - else - fCurrentDV->validate(value); - } - } - else { - // no default value, then check nillable - if (!XMLString::compareString(value, XMLUni::fgZeroLenString)) { - if ((((SchemaElementDecl*)elemDecl)->getMiscFlags() & SchemaSymbols::NILLABLE) == 0) - fCurrentDV->validate(value); - } - else if (fNil) { - emitError(XMLValid::NilAttrNotEmpty, elemDecl->getFullName()); - } - else - fCurrentDV->validate(value); - } - } - } catch (InvalidDatatypeValueException idve) { - emitError (XMLValid::DatatypeError, idve.getType(), idve.getMessage()); - } - catch (InvalidDatatypeFacetException idve) { - emitError (XMLValid::DatatypeError, idve.getType(), idve.getMessage()); - } - catch (...) { - emitError(XMLValid::GenericError); - throw; - } - } - } - else - { - ThrowXML(RuntimeException, XMLExcepts::CM_UnknownCMType); - } - - fDatatypeBuffer.reset(); - fNil = false; - fTrailing=false; - - // Went ok, so return success - return -1; -} - -void SchemaValidator::faultInAttr (XMLAttr& toFill, const XMLAttDef& attDef) const -{ - // - // At this level, we cannot set the URI id. So we just set it to zero - // and leave it at that. The scanner, who called us, will look at the - // prefix we stored (if any), resolve it, and store the URL id if any. - // - SchemaAttDef* schemaAttDef = (SchemaAttDef*) &attDef; - QName* attName = schemaAttDef->getAttName(); - - toFill.set - ( - attName->getURI() - , attName->getLocalPart() - , attName->getPrefix() - , schemaAttDef->getValue() - , schemaAttDef->getType() - ); -} - -void SchemaValidator::reset() -{ - fTrailing = false; - delete fXsiType; - fXsiType = 0; - fXsiTypeValidator = 0; - fNil = false; - fDatatypeBuffer.reset(); -} - -bool SchemaValidator::requiresNamespaces() const -{ - return true; -} - -void SchemaValidator::validateAttrValue (const XMLAttDef* attDef - , const XMLCh* const attrValue) -{ - // - // Get quick refs to lot of the stuff in the passed objects in - // order to simplify the code below, which will reference them very - // often. - // - XMLAttDef::AttTypes type = attDef->getType(); - const XMLAttDef::DefAttTypes defType = attDef->getDefaultType(); - const XMLCh* const fullName = attDef->getFullName(); - - // - // If the default type is fixed, then make sure the passed value maps - // to the fixed value. - // - if (defType == XMLAttDef::Fixed || defType == XMLAttDef::Required_And_Fixed) - { - const XMLCh* const valueText = attDef->getValue(); - if (XMLString::compareString(attrValue, valueText)) - emitError(XMLValid::NotSameAsFixedValue, fullName, attrValue, valueText); - } - - // An empty string cannot be valid for non_CDATA any of the other types - if (!attrValue[0] && type != XMLAttDef::Simple) - { - emitError(XMLValid::InvalidEmptyAttValue, fullName); - return; - } - - DatatypeValidator* attDefDV = ((SchemaAttDef*) attDef)->getDatatypeValidator(); - if (!attDefDV) { - emitError(XMLValid::NoDatatypeValidatorForAttribute, fullName); - } - else { - try { - DatatypeValidator::ValidatorType attDefDVType = attDefDV->getType(); - - // set up the entitydeclpool in ENTITYDatatypeValidator - // and the idreflist in ID/IDREFDatatypeValidator - - if (attDefDVType == DatatypeValidator::List) { - DatatypeValidator* itemDTV = ((ListDatatypeValidator*)attDefDV)->getItemTypeDTV(); - DatatypeValidator::ValidatorType itemDTVType = itemDTV->getType(); - if (itemDTVType == DatatypeValidator::ENTITY) - ((ENTITYDatatypeValidator*)itemDTV)->setEntityDeclPool(getScanner()->getEntityDeclPool()); - else if (itemDTVType == DatatypeValidator::ID) - ((IDDatatypeValidator*)itemDTV)->setIDRefList(getScanner()->getIDRefList()); - else if (itemDTVType == DatatypeValidator::IDREF) - ((IDREFDatatypeValidator*)itemDTV)->setIDRefList(getScanner()->getIDRefList()); - } - else if (attDefDVType == DatatypeValidator::Union) { - RefVectorOf<DatatypeValidator>* memberDTV = ((UnionDatatypeValidator*)attDefDV)->getMemberTypeValidators(); - unsigned int memberTypeNumber = memberDTV->size(); - for ( unsigned int memberIndex = 0; memberIndex < memberTypeNumber; ++memberIndex) - { - DatatypeValidator::ValidatorType memberDTVType = memberDTV->elementAt(memberIndex)->getType(); - if (memberDTVType == DatatypeValidator::ENTITY) - ((ENTITYDatatypeValidator*)memberDTV->elementAt(memberIndex))->setEntityDeclPool(getScanner()->getEntityDeclPool()); - else if (memberDTVType == DatatypeValidator::ID) - ((IDDatatypeValidator*)memberDTV->elementAt(memberIndex))->setIDRefList(getScanner()->getIDRefList()); - else if (memberDTVType == DatatypeValidator::IDREF) - ((IDREFDatatypeValidator*)memberDTV->elementAt(memberIndex))->setIDRefList(getScanner()->getIDRefList()); - } - } - else if (attDefDVType == DatatypeValidator::ENTITY) - ((ENTITYDatatypeValidator*)attDefDV)->setEntityDeclPool(getScanner()->getEntityDeclPool()); - else if (attDefDVType == DatatypeValidator::ID) - ((IDDatatypeValidator*)attDefDV)->setIDRefList(getScanner()->getIDRefList()); - else if (attDefDVType == DatatypeValidator::IDREF) - ((IDREFDatatypeValidator*)attDefDV)->setIDRefList(getScanner()->getIDRefList()); - - // now validate the attribute value - // if notation, need to bind URI to notation first - if (attDefDVType == DatatypeValidator::NOTATION) - { - // - // Make sure that this value maps to one of the - // notation values in the enumList parameter. We don't have to - // look it up in the notation pool (if a notation) because we - // will look up the enumerated values themselves. If they are in - // the notation pool (after the Grammar is parsed), then obviously - // this value will be legal since it matches one of them. - // - XMLBuffer nameBuf(XMLString::stringLen(attrValue)+1); - XMLBuffer prefixBuf(XMLString::stringLen(attrValue)+1); - XMLBuffer notationBuf; - unsigned int uriId = getScanner()->resolveQName(attrValue, nameBuf, prefixBuf, ElemStack::Mode_Element); - notationBuf.set(getScanner()->getURIText(uriId)); - notationBuf.append(chColon); - notationBuf.append(nameBuf.getRawBuffer()); - - attDefDV->validate(notationBuf.getRawBuffer()); - } - else - attDefDV->validate(attrValue); - } catch (InvalidDatatypeValueException idve) { - emitError (XMLValid::DatatypeError, idve.getType(), idve.getMessage()); - } - catch (InvalidDatatypeFacetException idve) { - emitError (XMLValid::DatatypeError, idve.getType(), idve.getMessage()); - } - catch (...) { - emitError(XMLValid::GenericError); - throw; - } - } - fDatatypeBuffer.reset(); - fTrailing = false; -} - -void SchemaValidator::validateElement(const XMLElementDecl* elemDef) -{ - if (fXsiType) { - // handle "xsi:type" right here - unsigned int uri = fXsiType->getURI(); - const XMLCh* localPart = fXsiType->getLocalPart(); - - if (uri != XMLElementDecl::fgInvalidElemId || uri != XMLElementDecl::fgPCDataElemId) { - // retrieve Grammar for the uri - const XMLCh* uriStr = getScanner()->getURIText(uri); - SchemaGrammar* sGrammar = (SchemaGrammar*) fGrammarResolver->getGrammar(uriStr); - - if (!sGrammar || sGrammar->getGrammarType() != Grammar::SchemaGrammarType) { - // Grammar not found - emitError(XMLValid::GrammarNotFound, uriStr); - } - else { - // retrieve complexType registry and DatatypeValidator registry - RefHashTableOf<ComplexTypeInfo>* complexTypeRegistry = sGrammar->getComplexTypeRegistry(); - DatatypeValidatorFactory* dataTypeReg = fGrammarResolver->getDatatypeRegistry(); - - if (!complexTypeRegistry || !dataTypeReg) - emitError(XMLValid::BadXsiType, fXsiType->getRawName()); - else { - // retrieve the typeInfo specified in xsi:type - XMLBuffer aBuffer; - aBuffer.set(uriStr); - aBuffer.append(chComma); - aBuffer.append(localPart); - ComplexTypeInfo* typeInfo = complexTypeRegistry->get(aBuffer.getRawBuffer()); - - if (typeInfo) { - // typeInfo is found - bool error = false; - - if (typeInfo->getAbstract()) { - emitError(XMLValid::NoAbstractInXsiType, aBuffer.getRawBuffer()); - error = true; - } - - ComplexTypeInfo* destType = ((SchemaElementDecl*)elemDef)->getComplexTypeInfo(); - ComplexTypeInfo* tempType = typeInfo; - if (destType) { - while (tempType) { - if (!XMLString::compareString(tempType->getTypeName(), destType->getTypeName())) - break; - tempType = tempType->getBaseComplexTypeInfo(); - } - if (!tempType) { - emitError(XMLValid::NonDerivedXsiType, fXsiType->getRawName(), elemDef->getFullName()); - error = true; - } - else { - int derivationMethod = typeInfo->getDerivedBy(); - if ((((SchemaElementDecl*)elemDef)->getBlockSet() & derivationMethod) != 0) { - emitError(XMLValid::NoSubforBlock, fXsiType->getRawName(), elemDef->getFullName()); - error = true; - } - } - } - else { - // if the original type is a simple type, check derivation ok. - DatatypeValidator* ancestorValidator = ((SchemaElementDecl*)elemDef)->getDatatypeValidator(); - if (ancestorValidator && !ancestorValidator->isSubstitutableBy(fXsiTypeValidator)) { - // the type is not derived from ancestor - emitError(XMLValid::NonDerivedXsiType, fXsiType->getRawName(), elemDef->getFullName()); - error = true; - } - } - - if (!error) - ((SchemaElementDecl*)elemDef)->setXsiComplexTypeInfo(typeInfo); - } - else { - // typeInfo not found - if (!XMLString::compareString(uriStr, SchemaSymbols::fgURI_SCHEMAFORSCHEMA)) - fXsiTypeValidator = dataTypeReg->getDatatypeValidator(localPart); - else - fXsiTypeValidator = dataTypeReg->getDatatypeValidator(aBuffer.getRawBuffer()); - - if (!fXsiTypeValidator) - emitError(XMLValid::BadXsiType, fXsiType->getRawName()); - else { - DatatypeValidator* ancestorValidator = ((SchemaElementDecl*)elemDef)->getDatatypeValidator(); - if (ancestorValidator && !ancestorValidator->isSubstitutableBy(fXsiTypeValidator)) { - // the type is not derived from ancestor - emitError(XMLValid::NonDerivedXsiType, fXsiType->getRawName(), elemDef->getFullName()); - } - else { - // the type is derived from ancestor - if (((SchemaElementDecl*)elemDef)->getBlockSet() == SchemaSymbols::RESTRICTION) - emitError(XMLValid::NoSubforBlock, fXsiType->getRawName(), elemDef->getFullName()); - if (elemDef->hasAttDefs()) { - // if we have an attribute but xsi:type's type is simple, we have a problem... - emitError(XMLValid::NonDerivedXsiType, fXsiType->getRawName(), elemDef->getFullName()); - } - } - - } - } - } - } - } - delete fXsiType; - fXsiType = 0; - } - else { - // - // xsi:type was not specified... - // If the corresponding type is abstract, detect an error - // - ComplexTypeInfo* typeInfo = ((SchemaElementDecl*)elemDef)->getComplexTypeInfo(); - - if (typeInfo) { - if (typeInfo->getAbstract()) { - emitError(XMLValid::NoUseAbstractType, elemDef->getFullName()); - } - } - } - - // - // Check whether this element is abstract. If so, an error - // - int miscFlags = ((SchemaElementDecl*)elemDef)->getMiscFlags(); - if ((miscFlags & SchemaSymbols::ABSTRACT) != 0) { - emitError(XMLValid::NoDirectUseAbstractElement, elemDef->getFullName()); - } - - // - // Check whether this element allows Nillable - // - if (fNil && (miscFlags & SchemaSymbols::NILLABLE) == 0 ) { - fNil = false; - emitError(XMLValid::NillNotAllowed, elemDef->getFullName()); - } - - fDatatypeBuffer.reset(); - fTrailing = false; -} - -void SchemaValidator::preContentValidation(bool reuseGrammar) -{ - // Lets go through all the grammar in the GrammarResolver - // and validate those that has not been validated yet - // - // Lets enumerate all of the elements in the element decl pool - // and put out an error for any that did not get declared. - // We also check all of the attributes as well. - // - // And enumerate all the complextype info in the grammar - // and do Unique Particle Attribution Checking - - RefHashTableOfEnumerator<Grammar> grammarEnum = fGrammarResolver->getGrammarEnumerator(); - while (grammarEnum.hasMoreElements()) - { - SchemaGrammar& sGrammar = (SchemaGrammar&) grammarEnum.nextElement(); - if (sGrammar.getGrammarType() != Grammar::SchemaGrammarType || sGrammar.getUPAChecked()) - continue; - - sGrammar.setUPAChecked(true); - - RefHash3KeysIdPoolEnumerator<SchemaElementDecl> elemEnum = sGrammar.getElemEnumerator(); - - while (elemEnum.hasMoreElements()) - { - SchemaElementDecl& curElem = elemEnum.nextElement(); - - // First check if declared or not - // - // See if this element decl was ever marked as declared. If - // not, then put out an error. In some cases its just - // a warning, such as being referenced in a content model. - // - const SchemaElementDecl::CreateReasons reason = curElem.getCreateReason(); - - if (reason != XMLElementDecl::Declared) - { - if (reason == XMLElementDecl::AttList) - { - getScanner()->emitError - ( - XMLErrs::UndeclaredElemInAttList - , curElem.getFullName() - ); - } - else if (reason == XMLElementDecl::AsRootElem) - { - emitError - ( - XMLValid::UndeclaredElemInDocType - , curElem.getFullName() - ); - } - else if (reason == XMLElementDecl::InContentModel) - { - getScanner()->emitError - ( - XMLErrs::UndeclaredElemInCM - , curElem.getFullName() - ); - } - else - { - } - } - - // - // Then check all of the attributes of the current element. - // We check for: - // - // 1) Multiple ID attributes - // 2) That all of the default values of attributes are - // valid for their type. - // 3) That for any notation types, that their lists - // of possible values refer to declared notations. - // - if (curElem.hasAttDefs()) { - XMLAttDefList& attDefList = curElem.getAttDefList(); - bool seenId = false; - while (attDefList.hasMoreElements()) - { - const XMLAttDef& curAttDef = attDefList.nextElement(); - - if (curAttDef.getType() == XMLAttDef::ID) - { - if (seenId) - { - emitError - ( - XMLValid::MultipleIdAttrs - , curElem.getFullName() - ); - break; - } - - seenId = true; - } - else if (curAttDef.getType() == XMLAttDef::Notation) - { - // - // We need to verify that all of its possible values - // (in the enum list) refer to valid notations. - // - XMLCh* list = XMLString::replicate(curAttDef.getEnumeration()); - ArrayJanitor<XMLCh> janList(list); - - // - // Search forward for a space or a null. If a null, - // we are done. If a space, cap it and look it up. - // - bool breakFlag = false; - XMLCh* listPtr = list; - XMLCh* lastPtr = listPtr; - while (true) - { - while (*listPtr && (*listPtr != chSpace)) - listPtr++; - - // - // If at the end, indicate we need to break after - // this one. Else, cap it off here. - // - if (!*listPtr) - breakFlag = true; - else - *listPtr = chNull; - - if (!sGrammar.getNotationDecl(lastPtr)) - { - emitError - ( - XMLValid::UnknownNotRefAttr - , curAttDef.getFullName() - , lastPtr - ); - } - - // Break out if we hit the end last time - if (breakFlag) - break; - - // Else move upwards and try again - listPtr++; - lastPtr = listPtr; - } - } - - // If it has a default/fixed value, then validate it - if (curAttDef.getValue()) - { - validateAttrValue - ( - &curAttDef - , curAttDef.getValue() - ); - } - } - } - } - - // For each complex type info, check the Unique Particle Attribution - if (getScanner()->getValidationSchemaFullChecking()) { - RefHashTableOf<ComplexTypeInfo>* complexTypeRegistry = sGrammar.getComplexTypeRegistry(); - - RefHashTableOfEnumerator<ComplexTypeInfo> complexTypeEnum(complexTypeRegistry); - while (complexTypeEnum.hasMoreElements()) - { - ComplexTypeInfo& curTypeInfo = complexTypeEnum.nextElement(); - curTypeInfo.checkUniqueParticleAttribution(&sGrammar, fGrammarResolver, getScanner()->getURIStringPool(), this); - } - } - } -} - -void SchemaValidator::postParseValidation() -{ - // - // At this time, there is nothing to do here. The scanner itself handles - // ID/IDREF validation, since that is the same no matter what kind of - // validator. - // -} - -// --------------------------------------------------------------------------- -// SchemaValidator: Validator method -// --------------------------------------------------------------------------- -// Do Schema Normalization depends on the WhiteSpace Facet -// preserve : No normalization is done -// replace : All occurrences of #x9 (tab), #xA (linefeed) and #xD (carriage return) -// are replaced with #x20 (space). -// collapse : Subsequent to the replacements specified above under replace, -// contiguous sequences of #x20s are collapsed to a single #x20, -// and initial and/or final #x20s are deleted. -// -void SchemaValidator::normalizeWhiteSpace(DatatypeValidator* dV, const XMLCh* const value, XMLBuffer& toFill) -{ - short fWhiteSpace = DatatypeValidator::PRESERVE; - if (dV) - fWhiteSpace = dV->getWSFacet(); - - enum States - { - InWhitespace - , InContent - }; - - States curState = InContent; - toFill.reset(); - - // - // Loop through the chars of the source value and normalize it according - // to the whitespace facet - // - bool firstNonWS = false; - XMLCh nextCh; - const XMLCh* srcPtr = value; - - if ((fWhiteSpace==DatatypeValidator::COLLAPSE) && fTrailing) - toFill.append(chSpace); - - while (*srcPtr) - { - nextCh = *srcPtr; - - if (fWhiteSpace == DatatypeValidator::PRESERVE) - { - // do nothing - } - else if (fWhiteSpace == DatatypeValidator::REPLACE) - { - if (XMLReader::isWhitespace(nextCh)) - nextCh = chSpace; - } - else // COLLAPSE case - { - if (curState == InWhitespace) - { - if (!XMLReader::isWhitespace(nextCh)) - { - if (firstNonWS) - toFill.append(chSpace); - curState = InContent; - firstNonWS = true; - } - else - { - srcPtr++; - continue; - } - } - else if (curState == InContent) - { - if (XMLReader::isWhitespace(nextCh)) - { - curState = InWhitespace; - srcPtr++; - continue; - } - firstNonWS = true; - } - } - // Add this char to the target buffer - toFill.append(nextCh); - - // stored the content for validation later - //fDatatypeBuffer.append(nextCh); - - // And move up to the next character in the source - srcPtr++; - } - srcPtr--; - nextCh = *srcPtr; - if (XMLReader::isWhitespace(nextCh)) - fTrailing = true; - - fDatatypeBuffer.append(toFill.getRawBuffer()); -} - diff --git a/src/validators/schema/SchemaValidator.hpp b/src/validators/schema/SchemaValidator.hpp deleted file mode 100644 index 1fb838ab8ca22aa5c20a8f51f3fa6ac484543072..0000000000000000000000000000000000000000 --- a/src/validators/schema/SchemaValidator.hpp +++ /dev/null @@ -1,265 +0,0 @@ -/* - * 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$ - * Revision 1.8 2001/11/13 13:25:08 tng - * Deprecate function XMLValidator::checkRootElement. - * - * Revision 1.7 2001/06/05 16:51:21 knoaman - * Add 'const' to getGrammar - submitted by Peter A. Volchek. - * - * Revision 1.6 2001/05/11 15:17:48 tng - * Schema: Nillable fixes. - * - * Revision 1.5 2001/05/11 13:27:37 tng - * Copyright update. - * - * Revision 1.4 2001/05/03 20:34:45 tng - * Schema: SchemaValidator update - * - * Revision 1.3 2001/04/19 18:17:40 tng - * Schema: SchemaValidator update, and use QName in Content Model - * - * Revision 1.2 2001/03/30 16:35:20 tng - * Schema: Whitespace normalization. - * - * Revision 1.1 2001/03/21 21:56:33 tng - * Schema: Add Schema Grammar, Schema Validator, and split the DTDValidator into DTDValidator, DTDScanner, and DTDGrammar. - * - */ - - - -#if !defined(SCHEMAVALIDATOR_HPP) -#define SCHEMAVALIDATOR_HPP - -#include <framework/XMLBuffer.hpp> -#include <framework/XMLValidator.hpp> -#include <util/RefVectorOf.hpp> -#include <validators/common/GrammarResolver.hpp> -#include <validators/datatype/DatatypeValidator.hpp> -#include <validators/schema/SchemaElementDecl.hpp> -#include <validators/schema/SchemaGrammar.hpp> - -// -// This is a derivative of the abstract validator interface. This class -// implements a validator that supports standard XML Schema semantics. -// This class handles scanning the of the schema, and provides -// the standard validation services against the Schema info it found. -// -class VALIDATORS_EXPORT SchemaValidator : public XMLValidator -{ -public: - // ----------------------------------------------------------------------- - // Constructors and Destructor - // ----------------------------------------------------------------------- - SchemaValidator(XMLErrorReporter* const errReporter = 0); - virtual ~SchemaValidator(); - - // ----------------------------------------------------------------------- - // Setter methods - // ----------------------------------------------------------------------- - void setGrammarResolver(GrammarResolver* grammarResolver); - - void setXsiType(const XMLCh* const prefix - , const XMLCh* const localPart - , const unsigned int uriId); - - void setNillable(bool isNil); - - // ----------------------------------------------------------------------- - // Implementation of the XMLValidator interface - // ----------------------------------------------------------------------- - virtual int checkContent - ( - XMLElementDecl* const elemDecl - , QName** const children - , const unsigned int childCount - ); - - virtual void faultInAttr - ( - XMLAttr& toFill - , const XMLAttDef& attDef - ) const; - - virtual void preContentValidation(bool reuseGrammar); - - virtual void postParseValidation(); - - virtual void reset(); - - virtual bool requiresNamespaces() const; - - virtual void validateAttrValue - ( - const XMLAttDef* attDef - , const XMLCh* const attrValue - ); - - virtual void validateElement - ( - const XMLElementDecl* elemDef - ); - - virtual Grammar* getGrammar() const; - virtual void setGrammar(Grammar* aGrammar); - - // ----------------------------------------------------------------------- - // Virtual DTD handler interface. - // ----------------------------------------------------------------------- - virtual bool handlesDTD() const; - - // ----------------------------------------------------------------------- - // Virtual Schema handler interface. handlesSchema() always return false. - // ----------------------------------------------------------------------- - virtual bool handlesSchema() const; - - // ----------------------------------------------------------------------- - // Schema Validator methods - // ----------------------------------------------------------------------- - void normalizeWhiteSpace(DatatypeValidator* dV, const XMLCh* const value, XMLBuffer& toFill); - -private: - // ----------------------------------------------------------------------- - // Private data members - // - // ----------------------------------------------------------------------- - // The following comes from or set by the Scanner - // fSchemaGrammar - // The current schema grammar used by the validator - // - // fGrammarResolver - // All the schema grammar stored - // - // fXsiType - // Store the Schema Type Attribute Value if schema type is specified - // - // fNil - // Indicates if Nillable has been set - // ----------------------------------------------------------------------- - // The following used internally in the validator - // - // fXsiTypeValidator - // The validator used for xsi type validation - // - // fDatatypeBuffer - // Buffer for simple type element string content - // - // fTrailing - // Previous chunk had a trailing space - // ----------------------------------------------------------------------- - SchemaGrammar* fSchemaGrammar; - GrammarResolver* fGrammarResolver; - QName* fXsiType; - bool fNil; - - DatatypeValidator* fXsiTypeValidator; - - XMLBuffer fDatatypeBuffer; - bool fTrailing; -}; - - -// --------------------------------------------------------------------------- -// SchemaValidator: Setter methods -// --------------------------------------------------------------------------- -inline void SchemaValidator::setGrammarResolver(GrammarResolver* grammarResolver) { - fGrammarResolver = grammarResolver; -} - -inline void SchemaValidator::setXsiType(const XMLCh* const prefix - , const XMLCh* const localPart - , const unsigned int uriId) -{ - delete fXsiType; - fXsiType = new QName(prefix, localPart, uriId); -} - -inline void SchemaValidator::setNillable(bool isNil) { - fNil = isNil; -} - -// --------------------------------------------------------------------------- -// Virtual interface -// --------------------------------------------------------------------------- -inline Grammar* SchemaValidator::getGrammar() const { - return fSchemaGrammar; -} - -inline void SchemaValidator::setGrammar(Grammar* aGrammar) { - fSchemaGrammar = (SchemaGrammar*) aGrammar; -} - -// --------------------------------------------------------------------------- -// SchemaValidator: DTD handler interface -// --------------------------------------------------------------------------- -inline bool SchemaValidator::handlesDTD() const -{ - // No DTD scanning - return false; -} - -// --------------------------------------------------------------------------- -// SchemaValidator: Schema handler interface -// --------------------------------------------------------------------------- -inline bool SchemaValidator::handlesSchema() const -{ - return true; -} - -#endif diff --git a/src/validators/schema/SubstitutionGroupComparator.cpp b/src/validators/schema/SubstitutionGroupComparator.cpp deleted file mode 100644 index d2dc30782048488ca99bf26abf14cb6282dcde65..0000000000000000000000000000000000000000 --- a/src/validators/schema/SubstitutionGroupComparator.cpp +++ /dev/null @@ -1,276 +0,0 @@ -/* - * 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$ - * Revision 1.11 2001/11/28 16:46:03 tng - * Schema fix: Initialize the temporary string as null terminated. - * - * Revision 1.10 2001/11/21 14:30:13 knoaman - * Fix for UPA checking. - * - * Revision 1.9 2001/11/07 21:50:28 tng - * Fix comment log that lead to error. - * - * Revision 1.8 2001/11/07 21:12:15 tng - * Performance: Create QName in ContentSpecNode only if it is a leaf/Any/PCDataNode. - * - * Revision 1.7 2001/10/04 15:08:56 knoaman - * Add support for circular import. - * - * Revision 1.6 2001/08/21 15:57:51 tng - * Schema: Add isAllowedByWildcard. Help from James Murphy. - * - * Revision 1.5 2001/05/29 19:47:22 knoaman - * Fix bug - memory was not allocated before call to XMLString::subString - * - * Revision 1.4 2001/05/28 20:55:42 tng - * Schema: Null pointer checking in SubsitutionGropuComparator - * - * Revision 1.3 2001/05/11 13:27:37 tng - * Copyright update. - * - * Revision 1.2 2001/05/04 14:50:28 tng - * Fixed the cvs symbols. - * - * - */ - - -// --------------------------------------------------------------------------- -// Includes -// --------------------------------------------------------------------------- -#include <validators/schema/SubstitutionGroupComparator.hpp> -#include <validators/common/Grammar.hpp> -#include <validators/schema/SchemaGrammar.hpp> -#include <validators/schema/ComplexTypeInfo.hpp> -#include <validators/schema/SchemaSymbols.hpp> - -bool SubstitutionGroupComparator::isEquivalentTo(QName* const anElement - , QName* const exemplar) -{ - if (!anElement && !exemplar) - return true; - - if ((!anElement && exemplar) || (anElement && !exemplar)) - return false; - - - if ((XMLString::compareString(anElement->getLocalPart(), exemplar->getLocalPart()) == 0) && - (anElement->getURI() == exemplar->getURI())) - return true; // they're the same! - - if (!fGrammarResolver || !fStringPool ) - { - ThrowXML(RuntimeException, XMLExcepts::SubGrpComparator_NGR); - } - - unsigned int uriId = anElement->getURI(); - if (uriId == XMLContentModel::gEOCFakeId || - uriId == XMLContentModel::gEpsilonFakeId || - uriId == XMLElementDecl::fgPCDataElemId) - return false; - - const XMLCh* uri = fStringPool->getValueForId(uriId); - const XMLCh* localpart = anElement->getLocalPart(); - - // In addition to simply trying to find a chain between anElement and exemplar, - // we need to make sure that no steps in the chain are blocked. - // That is, at every step, we need to make sure that the element - // being substituted for will permit being substituted - // for, and whether the type of the element will permit derivations in - // instance documents of this sort. - - if (!uri) - return false; - - SchemaGrammar *sGrammar = (SchemaGrammar*) fGrammarResolver->getGrammar(uri); - if (!sGrammar || sGrammar->getGrammarType() == Grammar::DTDGrammarType) - return false; - - SchemaElementDecl* pElemDecl = (SchemaElementDecl*) sGrammar->getElemDecl(uriId, localpart, 0, Grammar::TOP_LEVEL_SCOPE); - if (!pElemDecl) - return false; - - SchemaElementDecl* anElementDecl = pElemDecl; // to preserve the ElementDecl for anElement - XMLCh* substitutionGroupFullName = pElemDecl->getSubstitutionGroupName(); - bool foundIt = false; - - while (substitutionGroupFullName) - { - int commaAt = XMLString::indexOf(substitutionGroupFullName, chComma); - XMLCh tmpURI[256]; - tmpURI[0] = chNull; - XMLCh tmpLocalpart[256]; - tmpLocalpart[0] = chNull; - - if (commaAt >= 0) - { - if (commaAt > 0) - XMLString::subString(tmpURI, substitutionGroupFullName, 0, commaAt); - - XMLString::subString(tmpLocalpart, substitutionGroupFullName, commaAt+1, XMLString::stringLen(substitutionGroupFullName)); - } - else { - XMLString::subString(tmpLocalpart, substitutionGroupFullName, 0, XMLString::stringLen(substitutionGroupFullName)); - } - - sGrammar = (SchemaGrammar*) fGrammarResolver->getGrammar(tmpURI); - if (!sGrammar || sGrammar->getGrammarType() == Grammar::DTDGrammarType) - return false; - - uriId = fStringPool->addOrFind(tmpURI); - pElemDecl = (SchemaElementDecl*) sGrammar->getElemDecl(uriId, tmpLocalpart, 0, Grammar::TOP_LEVEL_SCOPE); - - if (!pElemDecl) - return false; - - if ((XMLString::compareString(tmpLocalpart, exemplar->getLocalPart()) == 0) && - (uriId == exemplar->getURI())) - { - // time to check for block value on element - if((pElemDecl->getBlockSet() & SchemaSymbols::SUBSTITUTION) != 0) - return false; - - foundIt = true; - break; - } - - substitutionGroupFullName = pElemDecl->getSubstitutionGroupName(); - }//while - - if (!foundIt) - return false; - - // this will contain anElement's complexType information. - ComplexTypeInfo *aComplexType = anElementDecl->getComplexTypeInfo(); - int exemplarBlockSet = pElemDecl->getBlockSet(); - - if(!aComplexType) - { - // check on simpleType case - DatatypeValidator *anElementDV = anElementDecl->getDatatypeValidator(); - DatatypeValidator *exemplarDV = pElemDecl->getDatatypeValidator(); - - return((anElementDV == 0) || - ((anElementDV == exemplarDV) || - ((exemplarBlockSet & SchemaSymbols::RESTRICTION) == 0))); - } - - // now we have to make sure there are no blocks on the complexTypes that this is based upon - int anElementDerivationMethod = aComplexType->getDerivedBy(); - if((anElementDerivationMethod & exemplarBlockSet) != 0) - return false; - - // this will contain exemplar's complexType information. - ComplexTypeInfo *exemplarComplexType = pElemDecl->getComplexTypeInfo(); - - for(ComplexTypeInfo *tempType = aComplexType; - tempType != 0 && tempType != exemplarComplexType; - tempType = tempType->getBaseComplexTypeInfo()) - { - if((tempType->getBlockSet() & anElementDerivationMethod) != 0) - return false; - }//for - - return true; -} - - -bool SubstitutionGroupComparator::isAllowedByWildcard(SchemaGrammar* const pGrammar, - QName* const element, - unsigned int wuri, bool wother) -{ - // whether the uri is allowed directly by the wildcard - unsigned int uriId = element->getURI(); - - if ((!wother && uriId == wuri) || - (wother && uriId != wuri && uriId != XMLContentModel::gEOCFakeId && uriId != XMLContentModel::gEpsilonFakeId)) - { - return true; - } - - // get all elements that can substitute the current element - RefHash2KeysTableOf<ElemVector>* theValidSubstitutionGroups = pGrammar->getValidSubstitutionGroups(); - - if (!theValidSubstitutionGroups) - return false; - - ValueVectorOf<SchemaElementDecl*>* subsElements = theValidSubstitutionGroups->get(element->getLocalPart(), uriId); - - if (!subsElements) - return false; - - // then check whether there exists one element that is allowed by the wildcard - int size = subsElements->size(); - - for (int i = 0; i < size; i++) - { - unsigned int subUriId = subsElements->elementAt(i)->getElementName()->getURI(); - - if ((!wother && subUriId == wuri) || - (wother && subUriId != wuri && subUriId != XMLContentModel::gEOCFakeId && subUriId != XMLContentModel::gEpsilonFakeId)) - { - return true; - } - } - return false; -} - -/** - * End of file SubstitutionGroupComparator.cpp - */ - diff --git a/src/validators/schema/SubstitutionGroupComparator.hpp b/src/validators/schema/SubstitutionGroupComparator.hpp deleted file mode 100644 index d1586a374444c6d1f58810ffdd12c8e95403785d..0000000000000000000000000000000000000000 --- a/src/validators/schema/SubstitutionGroupComparator.hpp +++ /dev/null @@ -1,162 +0,0 @@ -/* - * 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$ - */ - -#if !defined(SUBSTITUTIONGROUPCOMPARATOR_HPP) -#define SUBSTITUTIONGROUPCOMPARATOR_HPP - -#include <util/StringPool.hpp> -#include <util/QName.hpp> -#include <validators/common/GrammarResolver.hpp> - -class SchemaGrammar; - -class VALIDATORS_EXPORT SubstitutionGroupComparator -{ -public: - - // ----------------------------------------------------------------------- - // Public Constructor - // ----------------------------------------------------------------------- - /** @name Constructor. */ - //@{ - - SubstitutionGroupComparator(GrammarResolver* const pGrammarResolver - , XMLStringPool* const pStringPool); - - - //@} - - // ----------------------------------------------------------------------- - // Public Destructor - // ----------------------------------------------------------------------- - /** @name Destructor. */ - //@{ - - ~SubstitutionGroupComparator(); - - //@} - - // ----------------------------------------------------------------------- - // Validation methods - // ----------------------------------------------------------------------- - /** @name Validation Function */ - //@{ - - /** - * Checks that the "anElement" is within the subsitution group. - * - * @param anElement QName of the element - * - * @param exeplar QName of the head element in the group - */ - bool isEquivalentTo(QName* const anElement - , QName* const exemplar); - //@} - - /* - * check whether one element or any element in its substitution group - * is allowed by a given wildcard uri - * - * @param pGrammar the grammar where the wildcard is declared - * @param element the QName of a given element - * @param wuri the uri of the wildcard - * @param wother whether the uri is from ##other, so wuri is excluded - * - * @return whether the element is allowed by the wildcard - */ - bool isAllowedByWildcard(SchemaGrammar* const pGrammar, QName* const element, unsigned int wuri, bool wother); - -protected: - -private: - // ----------------------------------------------------------------------- - // Unimplemented Ctor - // ----------------------------------------------------------------------- - SubstitutionGroupComparator(); - - // ----------------------------------------------------------------------- - // Private data members - // - // - // ----------------------------------------------------------------------- - GrammarResolver *fGrammarResolver; - XMLStringPool *fStringPool; - -}; - - -// --------------------------------------------------------------------------- -// SubstitutionGroupComparator: Getters -// --------------------------------------------------------------------------- -inline SubstitutionGroupComparator::SubstitutionGroupComparator(GrammarResolver* const pGrammarResolver - , XMLStringPool* const pStringPool) -:fGrammarResolver(pGrammarResolver) -,fStringPool(pStringPool) -{} - -inline SubstitutionGroupComparator::~SubstitutionGroupComparator() -{} - -#endif - -/** - * End of file SubstitutionGroupComparator.hpp - */ - diff --git a/src/validators/schema/TraverseSchema.cpp b/src/validators/schema/TraverseSchema.cpp deleted file mode 100644 index 003a0ce45cbe835fc29b9b5334a3a36b2f1cc792..0000000000000000000000000000000000000000 --- a/src/validators/schema/TraverseSchema.cpp +++ /dev/null @@ -1,8579 +0,0 @@ -/* - * 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$ - */ - -// --------------------------------------------------------------------------- -// Includes -// --------------------------------------------------------------------------- -#include <validators/schema/TraverseSchema.hpp> -#include <sax/EntityResolver.hpp> -#include <validators/schema/identity/IC_Key.hpp> -#include <validators/schema/identity/IC_KeyRef.hpp> -#include <validators/schema/identity/IC_Unique.hpp> -#include <validators/schema/identity/IC_Field.hpp> -#include <validators/schema/identity/IC_Selector.hpp> -#include <validators/schema/identity/XercesXPath.hpp> -#include <validators/datatype/DatatypeValidatorFactory.hpp> -#include <util/XMLStringTokenizer.hpp> -#include <validators/schema/XUtil.hpp> -#include <validators/common/GrammarResolver.hpp> -#include <validators/schema/SchemaGrammar.hpp> -#include <validators/schema/SchemaAttDef.hpp> -#include <internal/XMLReader.hpp> -#include <validators/schema/ComplexTypeInfo.hpp> -#include <validators/schema/NamespaceScope.hpp> -#include <validators/schema/SchemaAttDefList.hpp> -#include <internal/XMLScanner.hpp> -#include <internal/XMLInternalErrorHandler.hpp> -#include <framework/LocalFileInputSource.hpp> -#include <framework/URLInputSource.hpp> -#include <parsers/DOMParser.hpp> -#include <validators/schema/identity/XPathException.hpp> -#include <validators/schema/GeneralAttributeCheck.hpp> -#include <validators/schema/XercesGroupInfo.hpp> -#include <validators/schema/XercesAttGroupInfo.hpp> -#include <util/HashPtr.hpp> - -// --------------------------------------------------------------------------- -// TraverseSchema: Local declaration -// --------------------------------------------------------------------------- -typedef RefVectorOf<DatatypeValidator> DVRefVector; - - -// --------------------------------------------------------------------------- -// TraverseSchema: Static member data -// --------------------------------------------------------------------------- - - -// --------------------------------------------------------------------------- -// TraverseSchema: Local const data -// --------------------------------------------------------------------------- -const XMLCh fgXMLNS_Str[] = -{ - chLatin_x, chLatin_m, chLatin_l, chLatin_n, chLatin_s, chColon, chNull -}; - -const XMLCh fgAnonSNamePrefix[] = -{ - chLatin_S, chNull -}; - -const XMLCh fgAnonCNamePrefix[] = -{ - chLatin_C, chNull -}; - -const XMLCh fgUnbounded[] = -{ - chLatin_u, chLatin_n, chLatin_b, chLatin_o, chLatin_u, chLatin_n, chLatin_d, - chLatin_e, chLatin_d, chNull -}; - -const XMLCh fgSkip[] = -{ - chLatin_s, chLatin_k, chLatin_i, chLatin_p, chNull -}; - -const XMLCh fgLax[] = -{ - chLatin_l, chLatin_a, chLatin_x, chNull -}; - -const XMLCh fgStrict[] = -{ - chLatin_s, chLatin_t, chLatin_r, chLatin_i, chLatin_c, chLatin_t, chNull -}; - -const XMLCh fgValueOne[] = -{ - chDigit_1, chNull -}; - -const XMLCh fgValueZero[] = -{ - chDigit_0, chNull -}; - -const XMLCh fgForwardSlash[] = -{ - chForwardSlash, chNull -}; - -const XMLCh fgDot[] = -{ - chPeriod, chNull -}; - -const XMLCh fgDotForwardSlash[] = -{ - chPeriod, chForwardSlash, chNull -}; - -const XMLCh* fgIdentityConstraints[] = -{ - SchemaSymbols::fgELT_UNIQUE, - SchemaSymbols::fgELT_KEY, - SchemaSymbols::fgELT_KEYREF -}; - -// --------------------------------------------------------------------------- -// TraverseSchema: Constructors and Destructor -// --------------------------------------------------------------------------- -TraverseSchema::TraverseSchema( const DOM_Element& schemaRoot - , XMLStringPool* const uriStringPool - , SchemaGrammar* const schemaGrammar - , GrammarResolver* const grammarResolver - , XMLScanner* const xmlScanner - , XMLValidator* const xmlValidator - , const XMLCh* const schemaURL - , EntityResolver* const entityResolver - , ErrorHandler* const errorHandler) - : fFullConstraintChecking(false) - , fElemAttrDefaultQualified(0) - , fTargetNSURI(-1) - , fEmptyNamespaceURI(-1) - , fCurrentScope(Grammar::TOP_LEVEL_SCOPE) - , fFinalDefault(0) - , fBlockDefault(0) - , fScopeCount(0) - , fRecursingElemIndex(0) - , fAnonXSTypeCount(0) - , fCircularCheckIndex(0) - , fTargetNSURIString(0) - , fDatatypeRegistry(0) - , fGrammarResolver(grammarResolver) - , fSchemaGrammar(schemaGrammar) - , fEntityResolver(entityResolver) - , fErrorHandler(errorHandler) - , fURIStringPool(uriStringPool) - , fStringPool(0) - , fValidator(xmlValidator) - , fScanner(xmlScanner) - , fNamespaceScope(0) - , fAttributeDeclRegistry(0) - , fComplexTypeRegistry(0) - , fGroupRegistry(0) - , fAttGroupRegistry(0) - , fSchemaInfoList(0) - , fSchemaInfo(0) - , fCurrentGroupInfo(0) - , fCurrentAttGroupInfo(0) - , fCurrentComplexType(0) - , fCurrentTypeNameStack(0) - , fCurrentGroupStack(0) - , fIC_NamespaceDepth(0) - , fIC_Elements(0) - , fGlobalDeclarations(0) - , fNotationRegistry(0) - , fRedefineComponents(0) - , fIdentityConstraintNames(0) - , fSubstitutionGroups(0) - , fValidSubstitutionGroups(0) - , fRefElements(0) - , fRefElemScope(0) - , fIC_NodeListNS(0) - , fIC_ElementsNS(0) - , fIC_NamespaceDepthNS(0) - , fRecursingAnonTypes(0) - , fRecursingTypeNames(0) -{ - - try { - - if (fGrammarResolver && !schemaRoot.isNull()) { - - init(); - doTraverseSchema(schemaRoot, schemaURL); - } - } - catch(...) { - - cleanUp(); - throw; - } -} - - -TraverseSchema::~TraverseSchema() -{ - cleanUp(); -} - - -// --------------------------------------------------------------------------- -// TraverseSchema: Traversal methods -// --------------------------------------------------------------------------- -void TraverseSchema::doTraverseSchema(const DOM_Element& schemaRoot, - const XMLCh* const schemaURL) { - - // Make sure namespace binding is defaulted - DOM_Element rootElem = schemaRoot; - DOMString rootPrefix = schemaRoot.getPrefix(); - - if (rootPrefix == 0 || rootPrefix.length() == 0) { - - DOMString xmlns = rootElem.getAttribute(XMLUni::fgXMLNSString); - - if (xmlns.length() == 0) { - rootElem.setAttribute(XMLUni::fgXMLNSString, SchemaSymbols::fgURI_SCHEMAFORSCHEMA); - } - } - - if (fFullConstraintChecking) { - - fRefElements = new RefVectorOf<QName>(32); - fRefElemScope = new ValueVectorOf<int>(32); - } - - // Set schemaGrammar data and add it to GrammarResolver - // For complex type registry, attribute decl registry , group/attGroup - // and namespace mapping, needs to check whether the passed in - // Grammar was a newly instantiated one. - fComplexTypeRegistry = fSchemaGrammar->getComplexTypeRegistry(); - - if (fComplexTypeRegistry == 0 ) { - - fComplexTypeRegistry = new RefHashTableOf<ComplexTypeInfo>(29); - fSchemaGrammar->setComplexTypeRegistry(fComplexTypeRegistry); - } - - fGroupRegistry = fSchemaGrammar->getGroupInfoRegistry(); - - if (fGroupRegistry == 0 ) { - - fGroupRegistry = new RefHashTableOf<XercesGroupInfo>(13); - fSchemaGrammar->setGroupInfoRegistry(fGroupRegistry); - } - - fAttGroupRegistry = fSchemaGrammar->getAttGroupInfoRegistry(); - - if (fAttGroupRegistry == 0 ) { - - fAttGroupRegistry = new RefHashTableOf<XercesAttGroupInfo>(13); - fSchemaGrammar->setAttGroupInfoRegistry(fAttGroupRegistry); - } - - fAttributeDeclRegistry = fSchemaGrammar->getAttributeDeclRegistry(); - - if (fAttributeDeclRegistry == 0) { - - fAttributeDeclRegistry = new RefHashTableOf<XMLAttDef>(29); - fSchemaGrammar->setAttributeDeclRegistry(fAttributeDeclRegistry); - } - - fNamespaceScope = fSchemaGrammar->getNamespaceScope(); - - if (fNamespaceScope == 0) { - - fNamespaceScope = new NamespaceScope(); - fNamespaceScope->reset(fEmptyNamespaceURI); - fSchemaGrammar->setNamespaceScope(fNamespaceScope); - } - - unsigned int namespaceDepth = fNamespaceScope->increaseDepth(); - - fValidSubstitutionGroups = fSchemaGrammar->getValidSubstitutionGroups(); - - if (!fValidSubstitutionGroups) { - - fValidSubstitutionGroups = new RefHash2KeysTableOf<ElemVector>(29); - fSchemaGrammar->setValidSubstitutionGroups(fValidSubstitutionGroups); - } - - //Retrieve the targetnamespace URI information - DOMString targetNSURIStr = schemaRoot.getAttribute(SchemaSymbols::fgATT_TARGETNAMESPACE); - - if (targetNSURIStr == 0) { - fSchemaGrammar->setTargetNamespace(XMLUni::fgZeroLenString); - } - else { - - fBuffer.set(targetNSURIStr.rawBuffer(), targetNSURIStr.length()); - fSchemaGrammar->setTargetNamespace(fBuffer.getRawBuffer()); - } - - fTargetNSURIString = fSchemaGrammar->getTargetNamespace(); - fTargetNSURI = fURIStringPool->addOrFind(fTargetNSURIString); - fGrammarResolver->putGrammar(fTargetNSURIString, fSchemaGrammar); - fAttributeCheck.setIDRefList(fSchemaGrammar->getIDRefList()); - - traverseSchemaHeader(rootElem); - - // Save current schema info - SchemaInfo* currInfo = new SchemaInfo(fElemAttrDefaultQualified, fBlockDefault, - fFinalDefault, fTargetNSURI, fCurrentScope, - fScopeCount, namespaceDepth, - XMLString::replicate(schemaURL), - fTargetNSURIString, fStringPool, schemaRoot); - - if (fSchemaInfo) { - fSchemaInfo->addSchemaInfo(currInfo, SchemaInfo::IMPORT); - } - - fSchemaInfo = currInfo; - fSchemaInfoList->put((void*) fSchemaInfo->getCurrentSchemaURL(), fSchemaInfo->getTargetNSURI(), fSchemaInfo); - - // process children nodes - fCurrentScope = Grammar::TOP_LEVEL_SCOPE; - fScopeCount = 0; - processChildren(schemaRoot); - - // Handle identity constraints - keyref - if (fIC_ElementsNS && fIC_ElementsNS->containsKey(fTargetNSURIString)) { - - fIC_Elements = fIC_ElementsNS->get(fTargetNSURIString); - fIC_NamespaceDepth = fIC_NamespaceDepthNS->get(fTargetNSURIString); - - unsigned int icListSize = fIC_Elements->size(); - - for (unsigned int i=0; i < icListSize; i++) { - - SchemaElementDecl* curElem = fIC_Elements->elementAt(i); - ValueVectorOf<DOM_Element>* icNodes = fIC_NodeListNS->get(curElem); - unsigned int icNodesSize = icNodes->size(); - unsigned int scopeDepth = fIC_NamespaceDepth->elementAt(i); - - for (unsigned int j = 0; j < icNodesSize; j++) { - traverseKeyRef(icNodes->elementAt(j), curElem, scopeDepth); - } - } - } - - // Element consistency checks - substitution groups - if (fFullConstraintChecking) { - checkRefElementConsistency(); - checkParticleDerivation(); - } -} - - -void TraverseSchema::traverseSchemaHeader(const DOM_Element& schemaRoot) { - - // ----------------------------------------------------------------------- - // Check Attributes - // ----------------------------------------------------------------------- - unsigned short scope = GeneralAttributeCheck::GlobalContext; - fAttributeCheck.checkAttributes(schemaRoot, scope, this); - - retrieveNamespaceMapping(schemaRoot); - fElemAttrDefaultQualified = 0; - - if (schemaRoot.getAttribute(SchemaSymbols::fgATT_ELEMENTFORMDEFAULT).equals(SchemaSymbols::fgATTVAL_QUALIFIED)) { - fElemAttrDefaultQualified |= Elem_Def_Qualified; - } - - if (schemaRoot.getAttribute(SchemaSymbols::fgATT_ATTRIBUTEFORMDEFAULT).equals(SchemaSymbols::fgATTVAL_QUALIFIED)) { - fElemAttrDefaultQualified |= Attr_Def_Qualified; - } - - // Get finalDefault/blockDefault values - const XMLCh* defaultVal = getElementAttValue(schemaRoot, SchemaSymbols::fgATT_BLOCKDEFAULT); - const XMLCh* finalVal = getElementAttValue(schemaRoot, SchemaSymbols::fgATT_FINALDEFAULT); - - fBlockDefault = parseBlockSet(defaultVal, ES_Block); - fFinalDefault = parseFinalSet(finalVal, ECS_Final); -} - - -void TraverseSchema::traverseAnnotationDecl(const DOM_Element& annotationElem) { - - // ----------------------------------------------------------------------- - // Check Attributes - // ----------------------------------------------------------------------- - bool topLevel = isTopLevelComponent(annotationElem); - int scope = (topLevel) ? GeneralAttributeCheck::GlobalContext - : GeneralAttributeCheck::LocalContext; - - fAttributeCheck.checkAttributes(annotationElem, scope, this); - - for (DOM_Element child = XUtil::getFirstChildElement(annotationElem); - child != 0; - child = XUtil::getNextSiblingElement(child)) { - - DOMString name = child.getLocalName(); - - if (!name.equals(SchemaSymbols::fgELT_APPINFO) && - !name.equals(SchemaSymbols::fgELT_DOCUMENTATION)) { - reportSchemaError(XMLUni::fgXMLErrDomain, 0, 0); //"an <annotation> can only contain <appinfo> and <documentation> elements" - } - - // General Attribute Checking - fAttributeCheck.checkAttributes(child, GeneralAttributeCheck::LocalContext, this); - } -} - - -/** - * Traverse include - * - * <include - * id = ID - * schemaLocation = anyURI - * {any attributes with non-schema namespace . . .}> - * Content: (annotation?) - * </include> - */ -void TraverseSchema::traverseInclude(const DOM_Element& elem) { - - // ------------------------------------------------------------------ - // Check attributes - // ------------------------------------------------------------------ - unsigned short scope = GeneralAttributeCheck::GlobalContext; - fAttributeCheck.checkAttributes(elem, scope, this); - - // ------------------------------------------------------------------ - // First, handle any ANNOTATION declaration - // ------------------------------------------------------------------ - if (checkContent(elem, XUtil::getFirstChildElement(elem), true) != 0) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::OnlyAnnotationExpected); - } - - // ------------------------------------------------------------------ - // Get 'schemaLocation' attribute - // ------------------------------------------------------------------ - const XMLCh* schemaLocation = getElementAttValue(elem, SchemaSymbols::fgATT_SCHEMALOCATION); - - if (XMLString::stringLen(schemaLocation) == 0) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::DeclarationNoSchemaLocation, SchemaSymbols::fgELT_INCLUDE); - return; - } - - // ------------------------------------------------------------------ - // Resolve schema location - // ------------------------------------------------------------------ - InputSource* srcToFill = resolveSchemaLocation(schemaLocation); - Janitor<InputSource> janSrc(srcToFill); - - // Nothing to do - if (!srcToFill) { - return; - } - - const XMLCh* includeURL = srcToFill->getSystemId(); - SchemaInfo* includeSchemaInfo = fSchemaInfoList->get(includeURL, fTargetNSURI); - - if (includeSchemaInfo) { - - fSchemaInfo->addSchemaInfo(includeSchemaInfo, SchemaInfo::INCLUDE); - return; - } - - // ------------------------------------------------------------------ - // Parse input source - // ------------------------------------------------------------------ - DOMParser parser; - XMLInternalErrorHandler internalErrorHandler(fErrorHandler); - - parser.setValidationScheme(DOMParser::Val_Never); - parser.setDoNamespaces(true); - parser.setErrorHandler((ErrorHandler*) &internalErrorHandler); - parser.setEntityResolver(fEntityResolver); - - // Should just issue warning if the schema is not found - const bool flag = srcToFill->getIssueFatalErrorIfNotFound(); - srcToFill->setIssueFatalErrorIfNotFound(false); - - parser.parse(*srcToFill) ; - - // Reset the InputSource - srcToFill->setIssueFatalErrorIfNotFound(flag); - - if (internalErrorHandler.getSawFatal() && fScanner->getExitOnFirstFatal()) - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::SchemaScanFatalError); - - // ------------------------------------------------------------------ - // Get root element - // ------------------------------------------------------------------ - DOM_Document document = parser.getDocument(); - - if (!document.isNull()) { - - DOM_Element root = document.getDocumentElement(); - - if (!root.isNull()) { - - const XMLCh* targetNSURIString = getTargetNamespaceString(root); - unsigned int targetNSLength = XMLString::stringLen(targetNSURIString); - - // check to see if targetNameSpace is right - if (targetNSLength != 0 - && XMLString::compareString(targetNSURIString,fTargetNSURIString) != 0){ - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::IncludeNamespaceDifference, - schemaLocation, targetNSURIString); - return; - } - - // if targetNamespace is empty, change it to includ'g schema - // targetNamespace - if (targetNSLength == 0 && root.getAttributeNode(XMLUni::fgXMLNSString) == 0 - && fTargetNSURI != fEmptyNamespaceURI) { - root.setAttribute(XMLUni::fgXMLNSString, fTargetNSURIString); - } - - // -------------------------------------------------------- - // Update schema information with included schema - // -------------------------------------------------------- - unsigned int namespaceDepth = fNamespaceScope->increaseDepth(); - fElemAttrDefaultQualified = 0; - traverseSchemaHeader(root); - - // and now we'd better save this stuff! - SchemaInfo* saveInfo = fSchemaInfo; - fSchemaInfo = new SchemaInfo(fElemAttrDefaultQualified, fBlockDefault, - fFinalDefault, fTargetNSURI, fCurrentScope, - fScopeCount, namespaceDepth, - XMLString::replicate(includeURL), - fTargetNSURIString, fStringPool, root); - - fSchemaInfoList->put((void*) fSchemaInfo->getCurrentSchemaURL(), fSchemaInfo->getTargetNSURI(), fSchemaInfo); - saveInfo->addSchemaInfo(fSchemaInfo, SchemaInfo::INCLUDE); - processChildren(root); - - // -------------------------------------------------------- - // Restore old schema information - // -------------------------------------------------------- - restoreSchemaInfo(saveInfo); - } - } -} - -/** - * Traverse import - * - * <import - * id = ID - * namespace = anyURI - * schemaLocation = anyURI - * {any attributes with non-schema namespace . . .}> - * Content: (annotation?) - * </import> - */ -void TraverseSchema::traverseImport(const DOM_Element& elem) { - - // ------------------------------------------------------------------ - // Check attributes - // ------------------------------------------------------------------ - unsigned short scope = GeneralAttributeCheck::GlobalContext; - fAttributeCheck.checkAttributes(elem, scope, this); - - // ------------------------------------------------------------------ - // First, handle any ANNOTATION declaration - // ------------------------------------------------------------------ - if (checkContent(elem, XUtil::getFirstChildElement(elem), true) != 0) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::OnlyAnnotationExpected); - } - - // ------------------------------------------------------------------ - // Handle 'namespace' attribute - // ------------------------------------------------------------------ - const XMLCh* nameSpace = getElementAttValue(elem, SchemaSymbols::fgATT_NAMESPACE); - - if (!XMLString::compareString(nameSpace, fTargetNSURIString)) { - - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::Import_1_1); - return; - } - - if (!XMLString::stringLen(nameSpace) && fTargetNSURI == fEmptyNamespaceURI) { - - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::Import_1_2); - return; - } - - // ------------------------------------------------------------------ - // Resolve namespace to a grammar - // ------------------------------------------------------------------ - if (nameSpace) { - - Grammar* aGrammar = fGrammarResolver->getGrammar(nameSpace); - - if (aGrammar) { - - if (aGrammar->getGrammarType() == Grammar::SchemaGrammarType) { - return; - } - else { // empty string namespace - //REVISIT - } - } - } - - // ------------------------------------------------------------------ - // Get 'schemaLocation' attribute - // ------------------------------------------------------------------ - const XMLCh* schemaLocation = getElementAttValue(elem, SchemaSymbols::fgATT_SCHEMALOCATION); - - if (XMLString::stringLen(schemaLocation) == 0) { - return; - } - - // ------------------------------------------------------------------ - // Resolve schema location - // ------------------------------------------------------------------ - InputSource* srcToFill = resolveSchemaLocation(schemaLocation); - Janitor<InputSource> janSrc(srcToFill); - - // Nothing to do - if (!srcToFill) { - return; - } - - const XMLCh* importURL = srcToFill->getSystemId(); - SchemaInfo* importSchemaInfo = 0; - - if (nameSpace) - importSchemaInfo = fSchemaInfoList->get(importURL, fURIStringPool->addOrFind(nameSpace)); - else - importSchemaInfo = fSchemaInfoList->get(importURL, fEmptyNamespaceURI); - - if (importSchemaInfo) { - - fSchemaInfo->addSchemaInfo(importSchemaInfo, SchemaInfo::IMPORT); - return; - } - - // ------------------------------------------------------------------ - // Parse input source - // ------------------------------------------------------------------ - DOMParser parser; - XMLInternalErrorHandler internalErrorHandler(fErrorHandler); - - parser.setValidationScheme(DOMParser::Val_Never); - parser.setDoNamespaces(true); - parser.setErrorHandler((ErrorHandler*) &internalErrorHandler); - parser.setEntityResolver(fEntityResolver); - - // Should just issue warning if the schema is not found - const bool flag = srcToFill->getIssueFatalErrorIfNotFound(); - srcToFill->setIssueFatalErrorIfNotFound(false); - - parser.parse(*srcToFill) ; - - // Reset the InputSource - srcToFill->setIssueFatalErrorIfNotFound(flag); - - if (internalErrorHandler.getSawFatal() && fScanner->getExitOnFirstFatal()) - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::SchemaScanFatalError); - - // ------------------------------------------------------------------ - // Get root element - // ------------------------------------------------------------------ - DOM_Document document = parser.getDocument(); - - if (!document.isNull()) { - - DOM_Element root = document.getDocumentElement(); - - if (root.isNull()) { - return; - } - - const XMLCh* targetNSURIString = getTargetNamespaceString(root); - - if (XMLString::compareString(targetNSURIString, nameSpace) != 0) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::ImportNamespaceDifference, - schemaLocation, targetNSURIString, nameSpace); - } - else { - - // -------------------------------------------------------- - // Traverse new schema - // -------------------------------------------------------- - SchemaInfo* saveInfo = fSchemaInfo; - fSchemaGrammar = new SchemaGrammar(); - Janitor<RefVectorOf<QName> > janElem(fRefElements); - Janitor<ValueVectorOf<int> > janElemScope(fRefElemScope); - doTraverseSchema(root, importURL); - - // -------------------------------------------------------- - // Restore old schema information - // -------------------------------------------------------- - restoreSchemaInfo(saveInfo, SchemaInfo::IMPORT); - - // reset fRefElements && fRefElemScope - if (fFullConstraintChecking) { - - RefVectorOf<QName>* tmpElems = fRefElements; - ValueVectorOf<int>* tmpElemScope = fRefElemScope; - - fRefElements = janElem.release(); - fRefElemScope = janElemScope.release(); - janElem.reset(tmpElems); - janElemScope.reset(tmpElemScope); - } - } - } -} - -/** - * Traverse redefine declaration - * - * <redefine> - * schemaLocation = uriReference - * {any attributes with non-schema namespace . . .}> - * Content: (annotation | ( - * attributeGroup | complexType | group | simpleType))* - * </redefine> - */ -void TraverseSchema::traverseRedefine(const DOM_Element& redefineElem) { - - // ------------------------------------------------------------------ - // Check attributes - // ------------------------------------------------------------------ - unsigned short scope = GeneralAttributeCheck::GlobalContext; - fAttributeCheck.checkAttributes(redefineElem, scope, this); - - // First, we look through the children of redefineElem. Each one will - // correspond to an element of the redefined schema that we need to - // redefine. To do this, we rename the element of the redefined schema, - // and rework the base or ref tag of the kid we're working on to refer to - // the renamed group or derive the renamed type. Once we've done this, we - // actually go through the schema being redefined and convert it to a - // grammar. Only then do we run through redefineDecl's kids and put them - // in the grammar. - SchemaInfo* redefiningInfo = fSchemaInfo; - - if (!openRedefinedSchema(redefineElem)) { - return; - } - - if (!fRedefineComponents) { - fRedefineComponents = new RefHash2KeysTableOf<XMLCh>(13, false); - } - - SchemaInfo* redefinedInfo = fSchemaInfo; - renameRedefinedComponents(redefineElem, redefiningInfo, redefinedInfo); - - // Now we have to march through our nicely-renamed schemas. When - // we do these traversals other <redefine>'s may perhaps be - // encountered; we leave recursion to sort this out. - restoreSchemaInfo(redefinedInfo); - processChildren(fSchemaInfo->getRoot()); - - // Now traverse our own <redefine> - restoreSchemaInfo(redefiningInfo); - processChildren(redefineElem); -} - - -/** - * Traverse the Choice, Sequence declaration - * - * <choice-sequqnce - * id = ID - * maxOccurs = (nonNegativeInteger | unbounded) : 1 - * minOccurs = nonNegativeInteger : 1 - * Content: (annotation?, (element | group | choice | sequence | any)*) - * </choice-sequence> - */ -ContentSpecNode* -TraverseSchema::traverseChoiceSequence(const DOM_Element& elem, - const int modelGroupType) -{ - - // ------------------------------------------------------------------ - // Check attributes - // ------------------------------------------------------------------ - unsigned short scope = GeneralAttributeCheck::LocalContext; - fAttributeCheck.checkAttributes(elem, scope, this); - - // ------------------------------------------------------------------ - // Process contents - // ------------------------------------------------------------------ - DOM_Element child = checkContent(elem, XUtil::getFirstChildElement(elem), true); - ContentSpecNode* left = 0; - ContentSpecNode* right = 0; - bool hadContent = false; - - for (; child != 0; child = XUtil::getNextSiblingElement(child)) { - - ContentSpecNode* contentSpecNode = 0; - bool seeParticle = false; - DOMString childName = child.getLocalName(); - - if (childName.equals(SchemaSymbols::fgELT_ELEMENT)) { - - bool toDelete = true; - Janitor<QName> janQName(0); - QName* eltQName = traverseElementDecl(child, toDelete); - - if (eltQName == 0) { - continue; - } - - if (toDelete) { - janQName.reset(eltQName); - } - - contentSpecNode = new ContentSpecNode(eltQName); - seeParticle = true; - } - else if (childName.equals(SchemaSymbols::fgELT_GROUP)) { - - XercesGroupInfo* grpInfo = traverseGroupDecl(child); - - if (!grpInfo) { - continue; - } - - contentSpecNode = grpInfo->getContentSpec(); - - if (!contentSpecNode) { - continue; - } - - if (hasAllContent(contentSpecNode)) { - - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::AllContentLimited); - continue; - } - - contentSpecNode = new ContentSpecNode(*contentSpecNode); - seeParticle = true; - } - else if (childName.equals(SchemaSymbols::fgELT_CHOICE)) { - - contentSpecNode = traverseChoiceSequence(child,ContentSpecNode::Choice); - seeParticle = true; - } - else if (childName.equals(SchemaSymbols::fgELT_SEQUENCE)) { - contentSpecNode = traverseChoiceSequence(child,ContentSpecNode::Sequence); - seeParticle = true; - } - else if (childName.equals(SchemaSymbols::fgELT_ANY)) { - - contentSpecNode = traverseAny(child); - seeParticle = true; - } - else { - fBuffer.set(childName.rawBuffer(), childName.length()); - reportSchemaError(XMLUni::fgValidityDomain, XMLValid::GroupContentRestricted, - fBuffer.getRawBuffer()); - } - - if (contentSpecNode) { - hadContent = true; - } - - if (seeParticle) { - checkMinMax(contentSpecNode, child, Not_All_Context); - } - - if (left == 0) { - left = contentSpecNode; - } - else if (right == 0) { - right = contentSpecNode; - } - else { - left = new ContentSpecNode((ContentSpecNode::NodeTypes) modelGroupType, left, right); - right = contentSpecNode; - } - } - - if (hadContent) { - left = new ContentSpecNode((ContentSpecNode::NodeTypes) modelGroupType, left, right); - } - - return left; -} - -/** - * Traverse SimpleType declaration: - * <simpleType - * id = ID - * name = NCName> - * Content: (annotation? , ((list | restriction | union))) - * </simpleType> - * - * traverse <list>|<restriction>|<union> - */ -int TraverseSchema::traverseSimpleTypeDecl(const DOM_Element& childElem, - int baseRefContext) -{ - bool topLevel = isTopLevelComponent(childElem); - - // ------------------------------------------------------------------ - // Process contents - // ------------------------------------------------------------------ - const XMLCh* name = getElementAttValue(childElem,SchemaSymbols::fgATT_NAME); - - if (topLevel && XMLString::stringLen(name) == 0) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::NoNameGlobalElement, - SchemaSymbols::fgELT_SIMPLETYPE); - return -1; - } - - if (XMLString::stringLen(name) == 0) { // anonymous simpleType - name = genAnonTypeName(fgAnonSNamePrefix); - } - else if (!XMLString::isValidNCName(name)) { - - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::InvalidDeclarationName, - SchemaSymbols::fgELT_SIMPLETYPE, name); - return -1; - } - - fBuffer.set(fTargetNSURIString); - fBuffer.append(chComma); - fBuffer.append(name); - - int fullTypeNameId = fStringPool->addOrFind(fBuffer.getRawBuffer()); - const XMLCh* fullName = fStringPool->getValueForId(fullTypeNameId); - - //check if we have already traversed the same simpleType decl - if (fDatatypeRegistry->getDatatypeValidator(fullName)!= 0) { - return fullTypeNameId; - } - - // ------------------------------------------------------------------ - // Check attributes - // ------------------------------------------------------------------ - unsigned short scope = (topLevel) ? GeneralAttributeCheck::GlobalContext - : GeneralAttributeCheck::LocalContext; - - fAttributeCheck.checkAttributes(childElem, scope, this); - - // Circular constraint checking - if (fCurrentTypeNameStack->containsElement(fullTypeNameId)){ - - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::NoCircularDefinition, name); - return -1; - } - - fCurrentTypeNameStack->addElement(fullTypeNameId); - - // Get 'final' values - const XMLCh* finalVal = getElementAttValue(childElem, SchemaSymbols::fgATT_FINAL); - int finalSet = parseFinalSet(finalVal, S_Final); - - // annotation?,(list|restriction|union) - DOM_Element content= checkContent(childElem, - XUtil::getFirstChildElement(childElem), - false); - - if (content == 0) { - - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::EmptySimpleTypeContent); - return resetCurrentTypeNameStack(-1); - } - - DOMString varietyName = content.getLocalName(); - int newSimpleTypeName = fStringPool->addOrFind(name); - - // ----------------------------------------------------------------------- - // Check Attributes - // ----------------------------------------------------------------------- - fAttributeCheck.checkAttributes(content, GeneralAttributeCheck::LocalContext, this); - - // Remark: some code will be repeated in list|restriction| union but it - // is cleaner that way - if (varietyName.equals(SchemaSymbols::fgELT_LIST)) { //traverse List - if (baseRefContext & SchemaSymbols::LIST != 0) { - - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::AtomicItemType); - return resetCurrentTypeNameStack(-1); - } - - return traverseByList(childElem, content, newSimpleTypeName, finalSet); - } - else if (varietyName.equals(SchemaSymbols::fgELT_RESTRICTION)) { //traverse Restriction - return traverseByRestriction(childElem, content, newSimpleTypeName, finalSet); - } - else if (varietyName.equals(SchemaSymbols::fgELT_UNION)) { //traverse union - return traverseByUnion(childElem, content, newSimpleTypeName, finalSet, baseRefContext); - } - else { - - fBuffer.set(varietyName.rawBuffer(), varietyName.length()); - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::FeatureUnsupported,fBuffer.getRawBuffer()); - } - - return resetCurrentTypeNameStack(-1); -} - -/** - * Traverse ComplexType Declaration - CR Implementation. - * - * <complexType - * abstract = boolean - * block = #all or (possibly empty) subset of {extension, restriction} - * final = #all or (possibly empty) subset of {extension, restriction} - * id = ID - * mixed = boolean : false - * name = NCName> - * Content: (annotation? , (simpleContent | complexContent | - * ( (group | all | choice | sequence)? , - * ( (attribute | attributeGroup)* , anyAttribute?)))) - * </complexType> - */ -int TraverseSchema::traverseComplexTypeDecl(const DOM_Element& elem, - const XMLCh* const recursingTypeName) { - - // Get the attributes of the complexType - const XMLCh* name = getElementAttValue(elem, SchemaSymbols::fgATT_NAME); - bool topLevel = isTopLevelComponent(elem); - - if (XMLString::stringLen(name) == 0) { - - if (topLevel) { - - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::TopLevelNoNameComplexType); - return -1; - } - - if (recursingTypeName) - name = recursingTypeName; - else - name = genAnonTypeName(fgAnonCNamePrefix); - } - - if (!XMLString::isValidNCName(name)) { - - //REVISIT - Should we return or continue and save type with wrong name? - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::InvalidDeclarationName, - SchemaSymbols::fgELT_COMPLEXTYPE, name); - return -1; - } - - // ------------------------------------------------------------------ - // Check if the type has already been registered - // ------------------------------------------------------------------ - fBuffer.set(fTargetNSURIString); - fBuffer.append(chComma); - fBuffer.append(name); - - int typeNameIndex = fStringPool->addOrFind(fBuffer.getRawBuffer()); - const XMLCh* fullName = fStringPool->getValueForId(typeNameIndex); - ComplexTypeInfo* typeInfo = 0; - - if (topLevel || recursingTypeName) { - - typeInfo = fComplexTypeRegistry->get(fullName); - - if (typeInfo && !typeInfo->getPreprocessed()) { - return typeNameIndex; - } - } - - // ----------------------------------------------------------------------- - // Check Attributes - // ----------------------------------------------------------------------- - unsigned short scope = (topLevel) ? GeneralAttributeCheck::GlobalContext - : GeneralAttributeCheck::LocalContext; - fAttributeCheck.checkAttributes(elem, scope, this); - - // ----------------------------------------------------------------------- - // Create a new instance - // ----------------------------------------------------------------------- - bool preProcessFlag = (typeInfo) ? typeInfo->getPreprocessed() : false; - unsigned int previousCircularCheckIndex = fCircularCheckIndex; - int previousScope = fCurrentScope; - - if (preProcessFlag) { - - fCurrentScope = typeInfo->getScopeDefined(); - typeInfo->setPreprocessed(false); - } - else { - - // ------------------------------------------------------------------ - // Register the type - // ------------------------------------------------------------------ - typeInfo = new ComplexTypeInfo(); - fCurrentScope = fScopeCount++; - fComplexTypeRegistry->put((void*) fullName, typeInfo); - typeInfo->setTypeName(fullName); - typeInfo->setScopeDefined(fCurrentScope); - } - - fCurrentTypeNameStack->addElement(typeNameIndex); - ComplexTypeInfo* saveTypeInfo = fCurrentComplexType; - fCurrentComplexType = typeInfo; - - // ------------------------------------------------------------------ - // First, handle any ANNOTATION declaration and get next child - // ------------------------------------------------------------------ - DOM_Element child = checkContent(elem, XUtil::getFirstChildElement(elem), - true); - - // ------------------------------------------------------------------ - // Process the content of the complex type declaration - // ------------------------------------------------------------------ - try { - if (child == 0) { - // EMPTY complexType with complexContent - processComplexContent(name, child, typeInfo, 0,0,0, false); - } - else { - - DOMString childName = child.getLocalName(); - const XMLCh* mixedVal = getElementAttValue(elem,SchemaSymbols::fgATT_MIXED); - bool isMixed = false; - - if (XMLString::stringLen(mixedVal) - && (!XMLString::compareString(SchemaSymbols::fgATTVAL_TRUE, mixedVal) - || !XMLString::compareString(fgValueOne, mixedVal))) { - isMixed = true; - } - - if (childName.equals(SchemaSymbols::fgELT_SIMPLECONTENT)) { - - // SIMPLE CONTENT element - traverseSimpleContentDecl(name, child, typeInfo); - - if (XUtil::getNextSiblingElement(child) != 0) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::InvalidChildFollowingSimpleContent); - } - } - else if (childName.equals(SchemaSymbols::fgELT_COMPLEXCONTENT)) { - - // COMPLEX CONTENT element - traverseComplexContentDecl(name, child, typeInfo, isMixed); - - if (XUtil::getNextSiblingElement(child) != 0) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::InvalidChildFollowingConplexContent); - } - } - else { - // We must have .... - // GROUP, ALL, SEQUENCE or CHOICE, followed by optional attributes - // Note that it's possible that only attributes are specified. - processComplexContent(name, child, typeInfo, 0, 0, 0, isMixed); - } - } - } - catch(const TraverseSchema::ExceptionCodes aCode) { - if (aCode == TraverseSchema::InvalidComplexTypeInfo) - defaultComplexTypeInfo(typeInfo); - else if (aCode == TraverseSchema::RecursingElement) - typeInfo->setPreprocessed(); - } - - // ------------------------------------------------------------------ - // Finish the setup of the typeInfo - // ------------------------------------------------------------------ - if (!preProcessFlag) { - - const XMLCh* blockAttVal = getElementAttValue(elem, SchemaSymbols::fgATT_BLOCK); - const XMLCh* finalAttVal = getElementAttValue(elem, SchemaSymbols::fgATT_FINAL); - const XMLCh* abstractAttVal = getElementAttValue(elem, SchemaSymbols::fgATT_ABSTRACT); - int blockSet = parseBlockSet(blockAttVal, C_Block); - int finalSet = parseFinalSet(finalAttVal, EC_Final); - - typeInfo->setBlockSet(blockSet); - typeInfo->setFinalSet(finalSet); - - if (XMLString::stringLen(abstractAttVal) - && (!XMLString::compareString(abstractAttVal, SchemaSymbols::fgATTVAL_TRUE) - || !XMLString::compareString(abstractAttVal, fgValueOne))) { - typeInfo->setAbstract(true); - } - else { - typeInfo->setAbstract(false); - } - } - - // ------------------------------------------------------------------ - // Traverse anonymous complex types for recursing elements - // ------------------------------------------------------------------ - resetCurrentTypeNameStack(0); - fCircularCheckIndex = previousCircularCheckIndex; - - int i = fRecursingElemIndex - 1; - int recursingTypeIndex = typeInfo->getRecursingTypeIndex(); - - for (; i >= recursingTypeIndex && recursingTypeIndex != -1; i--) { - - DOM_Element elem = fRecursingAnonTypes->elementAt(i); - const XMLCh* typeName = fRecursingTypeNames->elementAt(i); - - fRecursingAnonTypes->removeElementAt(i); - fRecursingTypeNames->removeElementAt(i); - fRecursingElemIndex--; - traverseComplexTypeDecl(elem, typeName); - } - - // ------------------------------------------------------------------ - // Before exiting, restore the scope, mainly for nested anonymous types - // ------------------------------------------------------------------ - fCurrentScope = previousScope; - fCurrentComplexType = saveTypeInfo; - - return typeNameIndex; -} - -/** - * Traverse Group Declaration. - * - * <group - * id = ID - * maxOccurs = string - * minOccurs = nonNegativeInteger - * name = NCName - * ref = QName> - * Content: (annotation? , (all | choice | sequence)?) - * <group/> - * - */ -XercesGroupInfo* -TraverseSchema::traverseGroupDecl(const DOM_Element& elem) { - - bool topLevel = isTopLevelComponent(elem); - const XMLCh* name = getElementAttValue(elem, SchemaSymbols::fgATT_NAME); - const XMLCh* ref = getElementAttValue(elem, SchemaSymbols::fgATT_REF); - bool nameEmpty = (XMLString::stringLen(name) == 0) ? true : false; - bool refEmpty = (XMLString::stringLen(ref) == 0) ? true : false; - - if (nameEmpty && topLevel) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::NoNameGlobalElement, - SchemaSymbols::fgELT_GROUP); - return 0; - } - - if (nameEmpty && refEmpty) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::NoNameRefGroup); - return 0; - } - - // ------------------------------------------------------------------ - // Check attributes - // ------------------------------------------------------------------ - unsigned short scope = (topLevel) ? GeneralAttributeCheck::GlobalContext - : GeneralAttributeCheck::LocalContext; - fAttributeCheck.checkAttributes(elem, scope, this); - - // ------------------------------------------------------------------ - // Check for annotations - // ------------------------------------------------------------------ - DOM_Element content = checkContent(elem, XUtil::getFirstChildElement(elem), - true); - - // ------------------------------------------------------------------ - // Handle "ref=" - // ------------------------------------------------------------------ - if (!topLevel) { - - if (refEmpty) { - return 0; - } - - return processGroupRef(elem, ref); - } - - // ------------------------------------------------------------------ - // Process contents of global groups - // ------------------------------------------------------------------ - // name must be a valid NCName - if (!XMLString::isValidNCName(name)) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::InvalidDeclarationName, - SchemaSymbols::fgELT_GROUP, name); - return 0; - } - - fBuffer.set(fTargetNSURIString); - fBuffer.append(chComma); - fBuffer.append(name); - - unsigned int nameIndex = fStringPool->addOrFind(fBuffer.getRawBuffer()); - const XMLCh* fullName = fStringPool->getValueForId(nameIndex); - XercesGroupInfo* groupInfo = fGroupRegistry->get(fullName); - - if (groupInfo) { - return groupInfo; - } - - int saveScope = fCurrentScope; - ContentSpecNode* specNode = 0; - XercesGroupInfo* saveGroupInfo = fCurrentGroupInfo; - - groupInfo = new XercesGroupInfo(); - fCurrentGroupStack->addElement(nameIndex); - fCurrentGroupInfo = groupInfo; - - if (!saveGroupInfo && !fCurrentComplexType) { - fCurrentScope = fScopeCount++; - } - - fCurrentGroupInfo->setScope(fCurrentScope); - - if (content == 0) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::GroupContentError, name); - } - else { - - if (content.getAttributeNode(SchemaSymbols::fgATT_MINOCCURS) != 0 - || content.getAttributeNode(SchemaSymbols::fgATT_MAXOCCURS) != 0) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::MinMaxOnGroupChild); - } - - bool illegalChild = false; - DOMString childName = content.getLocalName(); - - if (childName.equals(SchemaSymbols::fgELT_SEQUENCE)) { - specNode = traverseChoiceSequence(content, ContentSpecNode::Sequence); - } - else if (childName.equals(SchemaSymbols::fgELT_CHOICE)) { - specNode = traverseChoiceSequence(content, ContentSpecNode::Choice); - } - else if (childName.equals(SchemaSymbols::fgELT_ALL)) { - specNode = traverseAll(content); - } - else { - illegalChild = true; - } - - if (illegalChild || XUtil::getNextSiblingElement(content) != 0) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::GroupContentError, name); - } - } - - // ------------------------------------------------------------------ - // Set groupInfo and pop group name from stack - // ------------------------------------------------------------------ - unsigned int stackSize = fCurrentGroupStack->size(); - - if (stackSize != 0) { - fCurrentGroupStack->removeElementAt(stackSize - 1); - } - - fCurrentGroupInfo->setContentSpec(specNode); - fGroupRegistry->put((void*) fullName, fCurrentGroupInfo); - fCurrentGroupInfo = saveGroupInfo; - fCurrentScope = saveScope; - - if (fRedefineComponents && fRedefineComponents->get(SchemaSymbols::fgELT_GROUP, nameIndex)) { - - fBuffer.set(fullName); - fBuffer.append(SchemaSymbols::fgRedefIdentifier); - XercesGroupInfo* baseGroupInfo = fGroupRegistry->get(fBuffer.getRawBuffer()); - - try { - checkParticleDerivationOk(groupInfo->getContentSpec(), groupInfo->getScope(), - baseGroupInfo->getContentSpec(), baseGroupInfo->getScope()); - } - catch (const XMLException& excep) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::DisplayErrorMessage, excep.getMessage()); - } - } - - return groupInfo; -} - - -/** - * Traverse attributeGroup Declaration. - * - * <attributeGroup - * id = ID - * name = NCName - * ref = QName> - * Content: (annotation? , (attribute|attributeGroup)*, anyAttribute?) - * <attributeGroup/> - * - */ -XercesAttGroupInfo* -TraverseSchema::traverseAttributeGroupDecl(const DOM_Element& elem, - ComplexTypeInfo* const typeInfo) { - - bool topLevel = isTopLevelComponent(elem); - const XMLCh* name = getElementAttValue(elem, SchemaSymbols::fgATT_NAME); - const XMLCh* ref = getElementAttValue(elem, SchemaSymbols::fgATT_REF); - bool nameEmpty = (XMLString::stringLen(name) == 0) ? true : false; - bool refEmpty = (XMLString::stringLen(ref) == 0) ? true : false; - - if (nameEmpty && topLevel) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::NoNameGlobalElement, - SchemaSymbols::fgELT_ATTRIBUTEGROUP); - return 0; - } - - if (nameEmpty && refEmpty) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::NoNameRefAttGroup); - return 0; - } - - // ------------------------------------------------------------------ - // Check attributes - // ------------------------------------------------------------------ - unsigned short scope = (topLevel) ? GeneralAttributeCheck::GlobalContext - : GeneralAttributeCheck::LocalContext; - fAttributeCheck.checkAttributes(elem, scope, this); - - // ------------------------------------------------------------------ - // Handle "ref=" - // ------------------------------------------------------------------ - if (!topLevel) { - - if (refEmpty) { - return 0; - } - - return processAttributeGroupRef(elem, ref, typeInfo); - } - - // ------------------------------------------------------------------ - // Handle "name=" - // ------------------------------------------------------------------ - // name must be a valid NCName - if (!XMLString::isValidNCName(name)) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::InvalidDeclarationName, - SchemaSymbols::fgELT_ATTRIBUTEGROUP, name); - return 0; - } - - // ------------------------------------------------------------------ - // Check for annotations - // ------------------------------------------------------------------ - DOM_Element content = checkContent(elem, XUtil::getFirstChildElement(elem), - true); - - // ------------------------------------------------------------------ - // Process contents of global attributeGroups - // ------------------------------------------------------------------ - XercesAttGroupInfo* saveAttGroupInfo = fCurrentAttGroupInfo; - XercesAttGroupInfo* attGroupInfo = new XercesAttGroupInfo(); - - fAttGroupRegistry->put((void*) name, attGroupInfo); - fCurrentAttGroupInfo = attGroupInfo; - - for (; content !=0; content = XUtil::getNextSiblingElement(content)) { - - if (content.getLocalName().equals(SchemaSymbols::fgELT_ATTRIBUTE)) { - traverseAttributeDecl(content, typeInfo); - } - else if (content.getLocalName().equals(SchemaSymbols::fgELT_ATTRIBUTEGROUP)) { - traverseAttributeGroupDecl(content, typeInfo); - } - else { - break; - } - } - - if (content != 0) { - - if (content.getLocalName().equals(SchemaSymbols::fgELT_ANYATTRIBUTE)) { - - SchemaAttDef* anyAtt = traverseAnyAttribute(content); - - if (anyAtt) { - fCurrentAttGroupInfo->addAnyAttDef(anyAtt); - } - - if (XUtil::getNextSiblingElement(content) != 0) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::AttGroupContentError, name); - } - } - else { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::AttGroupContentError, name); - } - } - - // ------------------------------------------------------------------ - // Restore old attGroupInfo - // ------------------------------------------------------------------ - fCurrentAttGroupInfo = saveAttGroupInfo; - - // ------------------------------------------------------------------ - // Check Attribute Derivation Restriction OK - // ------------------------------------------------------------------ - fBuffer.set(fTargetNSURIString); - fBuffer.append(chComma); - fBuffer.append(name); - - unsigned int nameIndex = fStringPool->addOrFind(fBuffer.getRawBuffer()); - - if (fRedefineComponents && fRedefineComponents->get(SchemaSymbols::fgELT_ATTRIBUTEGROUP, nameIndex)) { - - fBuffer.set(name); - fBuffer.append(SchemaSymbols::fgRedefIdentifier); - XercesAttGroupInfo* baseAttGroupInfo = fAttGroupRegistry->get(fBuffer.getRawBuffer()); - - if (baseAttGroupInfo) { - checkAttDerivationOK(baseAttGroupInfo, attGroupInfo); - } - } - - return attGroupInfo; -} - - -inline XercesAttGroupInfo* -TraverseSchema::traverseAttributeGroupDeclNS(const XMLCh* const uriStr, - const XMLCh* const name) { - - // ------------------------------------------------------------------ - // Get grammar information - // ------------------------------------------------------------------ - Grammar* aGrammar = fGrammarResolver->getGrammar(uriStr); - - if (!aGrammar || aGrammar->getGrammarType() != Grammar::SchemaGrammarType) { - - reportSchemaError(XMLUni::fgValidityDomain, XMLValid::GrammarNotFound, uriStr); - return 0; - } - - XercesAttGroupInfo* attGroupInfo = ((SchemaGrammar*)aGrammar)->getAttGroupInfoRegistry()->get(name); - - return attGroupInfo; -} - -/** - * Traverse Any declaration - * - * <any - * id = ID - * maxOccurs = (nonNegativeInteger | unbounded) : 1 - * minOccurs = nonNegativeInteger : 1 - * namespace = ((##any | ##other) | List of (anyURI | - * (##targetNamespace | ##local)) ) : ##any - * processContents = (lax | skip | strict) : strict - * {any attributes with non-schema namespace . . .}> - * Content: (annotation?) - * </any> - */ -ContentSpecNode* -TraverseSchema::traverseAny(const DOM_Element& elem) { - - // ----------------------------------------------------------------------- - // Check Attributes - // ----------------------------------------------------------------------- - unsigned short scope = GeneralAttributeCheck::LocalContext; - fAttributeCheck.checkAttributes(elem, scope, this); - - // ------------------------------------------------------------------ - // First, handle any ANNOTATION declaration - // ------------------------------------------------------------------ - if (checkContent(elem, XUtil::getFirstChildElement(elem), true) != 0) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::OnlyAnnotationExpected); - } - - // ------------------------------------------------------------------ - // Get attributes - // ------------------------------------------------------------------ - const XMLCh* const processContents = - getElementAttValue(elem, SchemaSymbols::fgATT_PROCESSCONTENTS); - const XMLCh* const nameSpace = - getElementAttValue(elem, SchemaSymbols::fgATT_NAMESPACE); - - // ------------------------------------------------------------------ - // Set default node type based on 'processContents' value - // ------------------------------------------------------------------ - ContentSpecNode::NodeTypes anyType = ContentSpecNode::Any; - ContentSpecNode::NodeTypes anyLocalType = ContentSpecNode::Any_NS; - ContentSpecNode::NodeTypes anyOtherType = ContentSpecNode::Any_Other; - - if (XMLString::stringLen(processContents) > 0 - && XMLString::compareString(processContents, fgStrict)) { - - if (!XMLString::compareString(processContents, fgLax)) { - - anyType = ContentSpecNode::Any_Lax; - anyOtherType = ContentSpecNode::Any_Other_Lax; - anyLocalType = ContentSpecNode::Any_NS_Lax; - } - else if (!XMLString::compareString(processContents, fgSkip)) { - - anyType = ContentSpecNode::Any_Skip; - anyOtherType = ContentSpecNode::Any_Other_Skip; - anyLocalType = ContentSpecNode::Any_NS_Skip; - } - } - - // ------------------------------------------------------------------ - // Process 'namespace' attribute - // ------------------------------------------------------------------ - ContentSpecNode* retSpecNode = 0; - - if (XMLString::stringLen(nameSpace) == 0 - || !XMLString::compareString(nameSpace, SchemaSymbols::fgATTVAL_TWOPOUNDANY)) { - retSpecNode = new ContentSpecNode(new QName(XMLUni::fgZeroLenString, - XMLUni::fgZeroLenString, - fEmptyNamespaceURI), - false); - retSpecNode->setType(anyType); - } - else if (!XMLString::compareString(nameSpace, SchemaSymbols::fgATTVAL_TWOPOUNDOTHER)) { - retSpecNode = new ContentSpecNode(new QName(XMLUni::fgZeroLenString, - XMLUni::fgZeroLenString, - fTargetNSURI), - false); - retSpecNode->setType(anyOtherType); - } - else { - - RefVectorOf<XMLCh>* nameSpaceTokens = XMLString::tokenizeString(nameSpace); - ValueVectorOf<unsigned int> uriList(8); - ContentSpecNode* firstNode = 0; - ContentSpecNode* secondNode = 0; - unsigned int tokensSize = nameSpaceTokens->size(); - - for (unsigned int i=0; i < tokensSize; i++) { - - const XMLCh* tokenElem = nameSpaceTokens->elementAt(i); - int uriIndex = fEmptyNamespaceURI; - - if (XMLString::compareString(tokenElem,SchemaSymbols::fgATTVAL_TWOPOUNDLOCAL)) { // not ##local - - if (!XMLString::compareString(tokenElem,SchemaSymbols::fgATTVAL_TWOPOUNDTRAGETNAMESPACE)) { - uriIndex = fTargetNSURI; - } - else { - uriIndex = fURIStringPool->addOrFind(tokenElem); - } - } - - if (uriList.containsElement(uriIndex)) { - continue; - } - - uriList.addElement(uriIndex); - - firstNode = new ContentSpecNode(new QName(XMLUni::fgZeroLenString, - XMLUni::fgZeroLenString, - uriIndex), - false); - firstNode->setType(anyLocalType); - - if (secondNode == 0) { - secondNode = firstNode; - } - else { - secondNode = new ContentSpecNode(ContentSpecNode::Choice, secondNode, firstNode); - } - } - - retSpecNode = secondNode; - delete nameSpaceTokens; - } - - return retSpecNode; -} - - -/** - * Traverse all - * - * <all - * id = ID - * maxOccurs = 1 : 1 - * minOccurs = (0 | 1) : 1 - * {any attributes with non-schema namespace . . .}> - * Content: (annotation?, element*) - * </all> - */ -ContentSpecNode* -TraverseSchema::traverseAll(const DOM_Element& elem) { - - // ------------------------------------------------------------------ - // Check attributes - // ------------------------------------------------------------------ - unsigned short scope = GeneralAttributeCheck::LocalContext; - fAttributeCheck.checkAttributes(elem, scope, this); - - // ------------------------------------------------------------------ - // Process contents - // ------------------------------------------------------------------ - DOM_Element child = checkContent(elem, XUtil::getFirstChildElement(elem), true); - - if (child == 0) { - return 0; - } - - ContentSpecNode* left = 0; - ContentSpecNode* right = 0; - bool hadContent = false; - - for (; child != 0; child = XUtil::getNextSiblingElement(child)) { - - ContentSpecNode* contentSpecNode = 0; - DOMString childName = child.getLocalName(); - - if (childName.equals(SchemaSymbols::fgELT_ELEMENT)) { - - bool toDelete = true; - Janitor<QName> janQName(0); - QName* eltQName = traverseElementDecl(child, toDelete); - - if (eltQName == 0) { - continue; - } - - if (toDelete) { - janQName.reset(eltQName); - } - - contentSpecNode = new ContentSpecNode(eltQName); - checkMinMax(contentSpecNode, child, All_Element); - } - else { - - fBuffer.set(childName.rawBuffer(), childName.length()); - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::AllContentError, fBuffer.getRawBuffer()); - continue; - } - - hadContent = true; - - if (!left) { - left = contentSpecNode; - } - else if (!right) { - right = contentSpecNode; - } - else { - left = new ContentSpecNode(ContentSpecNode::All, left, right); - right = contentSpecNode; - } - } - - if (hadContent) { - left = new ContentSpecNode(ContentSpecNode::All, left, right); - } - - return left; -} - -/** - * Traverses Schema attribute declaration. - * - * <attribute - * fixed = string - * default = string - * form = qualified | unqualified - * id = ID - * name = NCName - * ref = QName - * type = QName - * use = optional | prohibited | required : optional - > - * Content: (annotation? , simpleType?) - * <attribute/> - * - * @param elem: the declaration of the attribute under consideration - * - * @param typeInfo: Contains the complex type info of the element to which - * the attribute declaration is attached. - * - */ -void TraverseSchema::traverseAttributeDecl(const DOM_Element& elem, - ComplexTypeInfo* const typeInfo) { - - bool topLevel = isTopLevelComponent(elem); - const XMLCh* name = getElementAttValue(elem, SchemaSymbols::fgATT_NAME); - const XMLCh* ref = getElementAttValue(elem, SchemaSymbols::fgATT_REF); - bool nameEmpty = (XMLString::stringLen(name) == 0) ? true : false; - bool refEmpty = (XMLString::stringLen(ref) == 0) ? true : false; - - if (nameEmpty && refEmpty) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::NoNameRefAttribute); - return; - } - - if (topLevel) { - - if (nameEmpty) { - - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::TopLevelNoNameAttribute); - return; - } - else { - if (!refEmpty) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::GlobalAttributeWithNameRef, name); - } - } - } - else { - if (!typeInfo && !fCurrentAttGroupInfo) { - // Nothing to do - where to save that attribute info? - return; - } - } - - // ------------------------------------------------------------------ - // Check attributes - // ------------------------------------------------------------------ - unsigned short scope = (topLevel) ? GeneralAttributeCheck::GlobalContext - : GeneralAttributeCheck::LocalContext; - fAttributeCheck.checkAttributes(elem, scope, this); - - const XMLCh* defaultVal = getElementAttValue(elem, SchemaSymbols::fgATT_DEFAULT); - const XMLCh* fixedVal = getElementAttValue(elem, SchemaSymbols::fgATT_FIXED); - const XMLCh* useVal = getElementAttValue(elem, SchemaSymbols::fgATT_USE); - const XMLCh* attForm = getElementAttValue(elem, SchemaSymbols::fgATT_FORM); - const XMLCh* dvType = getElementAttValue(elem, SchemaSymbols::fgATT_TYPE); - DOM_Element simpleType = checkContent(elem, XUtil::getFirstChildElement(elem), true); - bool badContent = false; - - while (simpleType != 0) { - - DOMString contentName = simpleType.getLocalName(); - fBuffer.set(contentName.rawBuffer(), contentName.length()); - - if (XMLString::compareString(SchemaSymbols::fgELT_SIMPLETYPE, - fBuffer.getRawBuffer()) == 0) { - - if (XUtil::getNextSiblingElement(simpleType) != 0) { - badContent = true; - } - break; - } - - badContent = true; - simpleType = XUtil::getNextSiblingElement(simpleType); - } - - if (badContent) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::InvalidAttributeContent, - (name) ? SchemaSymbols::fgATT_NAME : SchemaSymbols::fgATT_REF, - (name) ? name : ref); - } - - if (defaultVal) { - - if (fixedVal) { - - fixedVal = 0; - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::AttributeDefaultFixedValue); - } - - if (XMLString::stringLen(useVal) != 0 - && XMLString::compareString(useVal, SchemaSymbols::fgATTVAL_OPTIONAL) != 0) { - - useVal = 0; - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::NotOptionalDefaultAttValue); - } - } - - // processing ref - if (nameEmpty || (!refEmpty && !topLevel)) { - - if (!nameEmpty) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::LocalAttributeWithNameRef, name); - } - - // Check ref representation OK - 3.2.3::3.2 - if (attForm || dvType || (simpleType != 0)) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::AttributeRefContentError); - } - - processAttributeDeclRef(elem, typeInfo, ref, useVal, defaultVal, fixedVal); - return; - } - - // processing 'name' - if (!XMLString::isValidNCName(name) - || XMLString::compareString(name, XMLUni::fgXMLNSString) == 0) { - - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::InvalidDeclarationName, SchemaSymbols::fgELT_ATTRIBUTE, name); - return; - } - - // Check for duplicate declaration - const XMLCh* qualified = SchemaSymbols::fgATTVAL_QUALIFIED; - int uriIndex = fEmptyNamespaceURI; - - if (XMLString::stringLen(fTargetNSURIString) != 0 - && (topLevel || XMLString::compareString(attForm, qualified) == 0 - || ((fSchemaInfo->getElemAttrDefaultQualified() & Attr_Def_Qualified) - && XMLString::stringLen(attForm) == 0))) { - uriIndex = fTargetNSURI; - } - - if (typeInfo && typeInfo->getAttDef(name, uriIndex) != 0) { - - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::DuplicateAttribute, name); - return; - } - else if (fCurrentAttGroupInfo && fCurrentAttGroupInfo->containsAttribute(name, uriIndex)) { - - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::DuplicateAttribute, name); - return; - } - - DatatypeValidator* dv = 0; - XMLAttDef::AttTypes attType; - SchemaInfo* saveInfo = fSchemaInfo; - - if (simpleType != 0) { - - if (XMLString::stringLen(dvType) != 0) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::AttributeWithTypeAndSimpleType); - } - - int datatypeSymbol = traverseSimpleTypeDecl(simpleType); - - attType = XMLAttDef::Simple; - - if (datatypeSymbol != -1) { - dv = fDatatypeRegistry->getDatatypeValidator(fStringPool->getValueForId(datatypeSymbol)); - } - - } - else if (XMLString::stringLen(dvType) == 0) { - - attType = XMLAttDef::Simple; - dv = fDatatypeRegistry->getDatatypeValidator(SchemaSymbols::fgDT_STRING); - } - else { - - checkEnumerationRequiredNotation(name, dvType); - - const XMLCh* localPart = getLocalPart(dvType); - const XMLCh* prefix = getPrefix(dvType); - const XMLCh* typeURI = resolvePrefixToURI(prefix); - - if (XMLString::compareString(typeURI, SchemaSymbols::fgURI_SCHEMAFORSCHEMA) == 0) { - - dv = getDatatypeValidator(SchemaSymbols::fgURI_SCHEMAFORSCHEMA, localPart); - - if (XMLString::compareString(localPart,XMLUni::fgIDString) == 0) { - attType = XMLAttDef::ID; - } - else if (XMLString::compareString(localPart,XMLUni::fgIDRefString) == 0) { - attType = XMLAttDef::IDRef; - } - else if (XMLString::compareString(localPart,XMLUni::fgIDRefsString) == 0) { - attType = XMLAttDef::IDRefs; - } - else if (XMLString::compareString(localPart,XMLUni::fgEntityString) == 0) { - attType = XMLAttDef::Entity; - } - else if (XMLString::compareString(localPart,XMLUni::fgEntitiesString) == 0) { - attType = XMLAttDef::Entities; - } - else if (XMLString::compareString(localPart,XMLUni::fgNmTokenString) == 0) { - attType = XMLAttDef::NmToken; - } - else if (XMLString::compareString(localPart,XMLUni::fgNmTokensString) == 0) { - attType = XMLAttDef::NmTokens; - } - else if (XMLString::compareString(localPart,XMLUni::fgNotationString) == 0) { - attType = XMLAttDef::Notation; - } - else { - - attType = XMLAttDef::Simple; - - if (dv == 0 && XMLString::stringLen(typeURI) == 0) { - - DOM_Element topLevelType = - fSchemaInfo->getTopLevelComponent(SchemaSymbols::fgELT_SIMPLETYPE, localPart, &fSchemaInfo); - - if (topLevelType != 0) { - - traverseSimpleTypeDecl(topLevelType); - dv = getDatatypeValidator(typeURI, localPart); - } - else { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::AttributeSimpleTypeNotFound, - typeURI, localPart, name); - } - } - } - } - else { //isn't of the schema for schemas namespace... - - // check if the type is from the same Schema - dv = getDatatypeValidator(typeURI, localPart); - - if (dv == 0 && !XMLString::compareString(typeURI, fTargetNSURIString)) { - - DOM_Element topLevelType = - fSchemaInfo->getTopLevelComponent(SchemaSymbols::fgELT_SIMPLETYPE, localPart, &fSchemaInfo); - - if (topLevelType != 0) { - - traverseSimpleTypeDecl(topLevelType); - dv = getDatatypeValidator(typeURI, localPart); - } - else { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::AttributeSimpleTypeNotFound, - typeURI, localPart, name); - } - } - - attType = XMLAttDef::Simple; - } - - if (!dv) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::TypeNotFound, typeURI, localPart); - } - } - - // restore schema information, if necessary - fSchemaInfo = saveInfo; - - bool required = false; - bool prohibited = false; - - if (XMLString::stringLen(useVal) != 0) { - - if (!XMLString::compareString(useVal, SchemaSymbols::fgATTVAL_REQUIRED)) { - required = true; - } - else if (!XMLString::compareString(useVal, SchemaSymbols::fgATTVAL_PROHIBITED)) { - prohibited = true; - } - } - - // validate fixed/default values - const XMLCh* valueToCheck = defaultVal ? defaultVal : fixedVal; - bool ofTypeID = (dv && dv->getType() == DatatypeValidator::ID); - - if (attType == XMLAttDef::Simple && dv && valueToCheck) { - - if (ofTypeID) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::AttDeclPropCorrect3, - SchemaSymbols::fgATT_NAME, name); - } - else { - try { - dv->validate(valueToCheck); - } - catch (const XMLException& excep) { - reportSchemaError(XMLUni::fgValidityDomain, XMLValid::DisplayErrorMessage, excep.getMessage()); - } - catch(...) { - reportSchemaError(XMLUni::fgValidityDomain, XMLValid::DatatypeValidationFailure, valueToCheck); - } - } - } - - // check for multiple attributes with type derived from ID - if (!topLevel && ofTypeID) { - - if (fCurrentAttGroupInfo) { - - if (fCurrentAttGroupInfo->containsTypeWithId()) { - - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::AttGrpPropCorrect3, name); - return; - } - - fCurrentAttGroupInfo->setTypeWithId(true); - } - else { - - if (typeInfo->containsAttWithTypeId()) { - - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::AttDeclPropCorrect5, name); - return; - } - - typeInfo->setAttWithTypeId(true); - } - } - - // create SchemaAttDef - SchemaAttDef* attDef = new SchemaAttDef(XMLUni::fgZeroLenString, name, uriIndex, attType); - - attDef->setDatatypeValidator(dv); - - if (prohibited) { - attDef->setDefaultType(XMLAttDef::Prohibited); - } - else if (required) { - - if (fixedVal) { - attDef->setDefaultType(XMLAttDef::Required_And_Fixed); - } - else { - attDef->setDefaultType(XMLAttDef::Required); - } - } - else { - - if (fixedVal) { - attDef->setDefaultType(XMLAttDef::Fixed); - } - else if (defaultVal) { - attDef->setDefaultType(XMLAttDef::Default); - } - } - - if (valueToCheck) { - attDef->setValue(valueToCheck); - } - - if (topLevel) { - fAttributeDeclRegistry->put((void*) name, attDef); - } - else { - - bool toClone = false; - - if (typeInfo) { - - toClone = true; - typeInfo->addAttDef(attDef); - } - - if (fCurrentAttGroupInfo) { - fCurrentAttGroupInfo->addAttDef(attDef, toClone); - } - } -} - - -/** - * Traverses Schema element declaration. - * - * <element - * abstract = boolean : false - * block = (#all | List of (substitution | extension | restriction - * | list | union)) - * default = string - * final = (#all | List of (extension | restriction)) - * fixed = string - * form = (qualified | unqualified) - * id = ID - * maxOccurs = (nonNegativeInteger | unbounded) : 1 - * minOccurs = nonNegativeInteger : 1 - * name = NCName - * nillable = boolean : false - * ref = QName - * substitutionGroup = QName - * type = QName - * Content: (annotation?, ((simpleType | complexType)?, (unique | key | keyref)*)) - * </element> - * - * @param elem: the declaration of the element under consideration - */ -QName* TraverseSchema::traverseElementDecl(const DOM_Element& elem, bool& toDelete) { - - bool topLevel = isTopLevelComponent(elem); - const XMLCh* name = getElementAttValue(elem, SchemaSymbols::fgATT_NAME); - const XMLCh* ref = getElementAttValue(elem, SchemaSymbols::fgATT_REF); - const XMLCh* fixed = getElementAttValue(elem, SchemaSymbols::fgATT_FIXED); - const XMLCh* deflt = getElementAttValue(elem, SchemaSymbols::fgATT_DEFAULT); - bool nameEmpty = (XMLString::stringLen(name) == 0) ? true : false; - bool refEmpty = (XMLString::stringLen(ref) == 0) ? true : false; - - if (nameEmpty && topLevel) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::GlobalNoNameElement); - return 0; - } - - if (nameEmpty && refEmpty) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::NoNameRefElement); - return 0; - } - - // ------------------------------------------------------------------ - // Check attributes - // ------------------------------------------------------------------ - unsigned short scope = (topLevel) ? GeneralAttributeCheck::GlobalContext - : GeneralAttributeCheck::LocalContext; - fAttributeCheck.checkAttributes(elem, scope, this); - - // ------------------------------------------------------------------ - // Process contents - // ------------------------------------------------------------------ - if(XMLString::stringLen(fixed) != 0 && XMLString::stringLen(deflt) != 0) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::ElementWithFixedAndDefault); - } - - if (nameEmpty || (!refEmpty && !topLevel)) { - - if (!nameEmpty) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::DeclarationWithNameRef, - SchemaSymbols::fgELT_ELEMENT, name); - } - - if (!isValidRefDeclaration(elem)) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::BadAttWithRef); - } - - return processElementDeclRef(elem, ref, toDelete); - } - - // Name is notEmpty - if (!XMLString::isValidNCName(name)) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::InvalidDeclarationName, - SchemaSymbols::fgELT_ELEMENT, name); - return 0; - } - - const XMLCh* anotherSchemaURI = 0; - int scopeDefined = Grammar::UNKNOWN_SCOPE; - bool noErrorFound = true; - bool anonymousType = false; - DatatypeValidator* validator = 0; - DatatypeValidator* subGroupValidator = 0; - ComplexTypeInfo* typeInfo = 0; - ComplexTypeInfo* subGroupTypeInfo = 0; - ContentSpecNode* contentSpecNode = 0; - SchemaElementDecl::ModelTypes contentSpecType = SchemaElementDecl::Any; - - if (topLevel) { - - if (!refEmpty) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::GlobalElementWithRef, name); - } - - if (fSchemaGrammar->getElemDecl(fTargetNSURI, name, 0, Grammar::TOP_LEVEL_SCOPE) != 0) { - return new QName(name, fTargetNSURI); - } - } - - // Create element decl - bool isDuplicate = false; - SchemaElementDecl* elemDecl = - createSchemaElementDecl(elem, topLevel, contentSpecType, isDuplicate, (fixed != 0)); - - if (elemDecl == 0) { - return 0; - } - - if (!isDuplicate) { - - fSchemaGrammar->putElemDecl(elemDecl); - - if (fCurrentGroupInfo && - elemDecl->getEnclosingScope() == fCurrentGroupInfo->getScope()) { - fCurrentGroupInfo->addElement(elemDecl); - } - - if (fCurrentComplexType && - elemDecl->getEnclosingScope() == fCurrentComplexType->getScopeDefined()) { - fCurrentComplexType->addElement(elemDecl); - } - } - - // Resolve the type for the element - DOM_Element content = checkContent(elem, XUtil::getFirstChildElement(elem), true); - - if (content != 0) { - - DOMString contentName = content.getLocalName(); - - if (contentName.equals(SchemaSymbols::fgELT_COMPLEXTYPE)) { - - if (content.getAttribute(SchemaSymbols::fgATT_NAME).length() > 0) { - // REVISIT - we are bypassing the complex type declaration. - // Is this the right way to go? - noErrorFound = false; - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::AnonComplexTypeWithName, name); - } - else { - typeInfo = checkForComplexTypeInfo(content); - } - - if (typeInfo == 0) { - noErrorFound = false; - } - else if (!isDuplicate) { - - typeInfo->setElementId(elemDecl->getId()); - - //Recursing element - if (typeInfo->getPreprocessed()) { - - const XMLCh* typeInfoName = typeInfo->getTypeName(); - - if (!fRecursingAnonTypes) { - fRecursingAnonTypes = new ValueVectorOf<DOM_Element>(8); - fRecursingTypeNames = new ValueVectorOf<const XMLCh*>(8); - } - - fRecursingAnonTypes->addElement(content); - fRecursingTypeNames->addElement(typeInfoName + XMLString::indexOf(typeInfoName, chComma) + 1); - typeInfo->getBaseComplexTypeInfo()->setRecursingTypeIndex(fRecursingElemIndex); - fRecursingElemIndex++; - } - } - - anonymousType = true; - content = XUtil::getNextSiblingElement(content); - } - else if (contentName.equals(SchemaSymbols::fgELT_SIMPLETYPE)) { - - if (content.getAttribute(SchemaSymbols::fgATT_NAME).length() > 0) { - // REVISIT - we are bypassing the simple type declaration. - // Is this the right way to go? - noErrorFound = false; - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::AnonSimpleTypeWithName, name); - } - else { - validator = checkForSimpleTypeValidator(content); - } - - if (validator == 0) { - noErrorFound = false; - } - - contentSpecType = SchemaElementDecl::Simple; - anonymousType = true; - content = XUtil::getNextSiblingElement(content); - } - - // Check for identity constraints - if (content != 0) { - - content = checkIdentityConstraintContent(content); - if (content != 0) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::InvalidElementContent); - } - } - } - - // Handle 'type' attribute - const XMLCh* typeStr = getElementAttValue(elem, SchemaSymbols::fgATT_TYPE); - if (XMLString::stringLen(typeStr) > 0) { - - if (anonymousType) { - - noErrorFound = false; - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::ElementWithTypeAndAnonType, name); - } - else { - - if (!isAnyType(typeStr)) { - - checkEnumerationRequiredNotation(name, typeStr); - - anotherSchemaURI = checkTypeFromAnotherSchema(typeStr); - - // get complex type info - typeInfo = getElementComplexTypeInfo(typeStr, noErrorFound, anotherSchemaURI); - - // get simple type validtor - if not a complex type - if (typeInfo == 0) { - validator = getElementTypeValidator(typeStr, noErrorFound, - anotherSchemaURI,true); - } - } - } - } - - // Set element declararion type information - handle case when we have - // circular substitution group (a subs b and b subs a) - if (!isDuplicate) { - elemDecl->setDatatypeValidator(validator); - elemDecl->setComplexTypeInfo(typeInfo); - } - - // Handle the substitutionGroup - const XMLCh* subsGroupName = - getElementAttValue(elem, SchemaSymbols::fgATT_SUBSTITUTIONGROUP); - - if (XMLString::stringLen(subsGroupName) != 0) { - - SchemaElementDecl* subsElemDecl = getSubstituteGroupElemDecl(subsGroupName, noErrorFound); - - if (subsElemDecl != 0) { - - // An element cannot substitute itself - if (subsElemDecl == elemDecl) { - // REVISIT - add proper error message - - } - else { - - // Check for substitution validity constraint - // Substitution allowed (block and blockDefault) && same type - if (isSubstitutionGroupValid(subsElemDecl,typeInfo,validator,name)) { - - if (typeInfo == 0 && validator == 0 && noErrorFound) { - - typeInfo = subsElemDecl->getComplexTypeInfo(); - validator = subsElemDecl->getDatatypeValidator(); - } - - // set element substitutionGroup full name - const XMLCh* uri = resolvePrefixToURI(getPrefix(subsGroupName)); - const XMLCh* localPart = getLocalPart(subsGroupName); - - fBuffer.set(uri); - fBuffer.append(chComma); - fBuffer.append(localPart); - - if (!isDuplicate) { - - XMLCh* elemBaseName = elemDecl->getBaseName(); - XMLCh* subsElemBaseName = subsElemDecl->getBaseName(); - int elemURI = elemDecl->getURI(); - int subsElemURI = subsElemDecl->getURI(); - - elemDecl->setSubstitutionGroupName(fBuffer.getRawBuffer()); - fSubstitutionGroups->put((void*) elemBaseName, elemURI, subsElemDecl); - ValueVectorOf<SchemaElementDecl*>* subsElements = - fValidSubstitutionGroups->get(subsElemBaseName, subsElemURI); - - if (!subsElements && fTargetNSURI != subsElemURI) { - - SchemaGrammar* aGrammar = (SchemaGrammar*) - fGrammarResolver->getGrammar(fURIStringPool->getValueForId(subsElemURI)); - - if (aGrammar) { - subsElements = aGrammar->getValidSubstitutionGroups()->get(subsElemBaseName, subsElemURI); - - if (subsElements) { - subsElements = new ValueVectorOf<SchemaElementDecl*>(*subsElements); - fValidSubstitutionGroups->put(subsElemBaseName, subsElemURI, subsElements); - } - else if (fSchemaInfo->circularImportExist(subsElemURI)) { - aGrammar->getValidSubstitutionGroups()->put( - subsElemBaseName, subsElemURI, new ValueVectorOf<SchemaElementDecl*>(8)); - } - } - } - - if (!subsElements) { - subsElements = new ValueVectorOf<SchemaElementDecl*>(8); - fValidSubstitutionGroups->put(subsElemBaseName, subsElemURI, subsElements); - } - - subsElements->addElement(elemDecl); - - // update related subs. info in case of circular import - RefVectorEnumerator<SchemaInfo> importingEnum = fSchemaInfo->getImportingListEnumerator(); - - while (importingEnum.hasMoreElements()) { - - const SchemaInfo& curRef = importingEnum.nextElement(); - SchemaGrammar* aGrammar = (SchemaGrammar*) - fGrammarResolver->getGrammar(curRef.getTargetNSURIString()); - ValueVectorOf<SchemaElementDecl*>* subsElemList = - aGrammar->getValidSubstitutionGroups()->get(subsElemBaseName, subsElemURI); - - if (subsElemList && !subsElemList->containsElement(elemDecl)) { - subsElemList->addElement(elemDecl); - } - } - - buildValidSubstitutionListB(elemDecl, subsElemDecl); - buildValidSubstitutionListF(elemDecl, subsElemDecl); - } - } - else { - noErrorFound = false; - } - } - } - } - - if (typeInfo == 0 && validator == 0) { - - if (noErrorFound) { // ur type - contentSpecType = SchemaElementDecl::Any; - } - else { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::UntypedElement, name); - } - } - - // if element belongs to a compelx type - if (typeInfo != 0) { - - contentSpecNode = typeInfo->getContentSpec(); - contentSpecType = (SchemaElementDecl::ModelTypes) typeInfo->getContentType(); - scopeDefined = typeInfo->getScopeDefined(); - validator = typeInfo->getDatatypeValidator(); - } - - // if element belongs to a simple type - if (validator != 0) { - - contentSpecType = SchemaElementDecl::Simple; - - if (typeInfo == 0) { - anotherSchemaURI = 0; // not to switch schema in this case - } - } - - // Now we can handle validation etc. of default and fixed attributes, - // since we finally have all the type information. - if(XMLString::stringLen(fixed) != 0) { - deflt = fixed; - } - - if(XMLString::stringLen(deflt) != 0) { - - try { - if(validator == 0) { // in this case validate according to xs:string - fDatatypeRegistry->getDatatypeValidator( - SchemaSymbols::fgDT_STRING)->validate(deflt); - } else { - validator->validate(deflt); - } - } - catch (const XMLException& excep) { - reportSchemaError(XMLUni::fgValidityDomain, XMLValid::DisplayErrorMessage, excep.getMessage()); - } - catch(...) { - reportSchemaError(XMLUni::fgValidityDomain, XMLValid::DatatypeValidationFailure, deflt); - } - - if(typeInfo != 0 && - contentSpecType != SchemaElementDecl::Simple && - contentSpecType != SchemaElementDecl::Mixed_Simple && - contentSpecType != SchemaElementDecl::Mixed_Complex) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::NotSimpleOrMixedElement, name); - } - - if(typeInfo != 0 && - ((contentSpecType == SchemaElementDecl::Mixed_Complex - || contentSpecType == SchemaElementDecl::Mixed_Simple) - && !emptiableParticle(contentSpecNode))) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::EmptiableMixedContent, name); - } - - if (validator && (validator->getType() == DatatypeValidator::ID)) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::ElemIDValueConstraint, name, deflt); - } - } - - // set element information, but first check for duplicate elements with - // different types. - if (isDuplicate) { - - DatatypeValidator* eltDV = elemDecl->getDatatypeValidator(); - ComplexTypeInfo* eltTypeInfo = elemDecl->getComplexTypeInfo(); - - if ( (eltTypeInfo != typeInfo) || (eltDV != validator)) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::DuplicateElementDeclaration, name); - } - } - else { - - elemDecl->setDatatypeValidator(validator); - elemDecl->setComplexTypeInfo(typeInfo); - elemDecl->setDefaultValue(deflt); - elemDecl->setDefinedScope(scopeDefined); - elemDecl->setModelType(contentSpecType); - elemDecl->setContentSpec(contentSpecNode); - elemDecl->setTypeFromAnotherSchemaURI(anotherSchemaURI); - - // key/keyref/unique processing - DOM_Element ic = XUtil::getFirstChildElementNS(elem, fgIdentityConstraints, - SchemaSymbols::fgURI_SCHEMAFORSCHEMA, 3); - ValueVectorOf<DOM_Element>* icNodes = 0; - - while (ic != 0) { - - if ( ic.getLocalName().equals(SchemaSymbols::fgELT_KEY) ) { - traverseKey(ic, elemDecl); - } - else if ( ic.getLocalName().equals(SchemaSymbols::fgELT_UNIQUE) ) { - traverseUnique(ic, elemDecl); - } - else { - - if (!icNodes) { - icNodes = new ValueVectorOf<DOM_Element>(8); - } - - icNodes->addElement(ic); - } - - ic = XUtil::getNextSiblingElementNS(ic, fgIdentityConstraints, - SchemaSymbols::fgURI_SCHEMAFORSCHEMA, 3); - } - - if (icNodes) { - - if (!fIC_ElementsNS) { - - fIC_ElementsNS = new RefHashTableOf<ElemVector>(13); - fIC_NamespaceDepthNS = new RefHashTableOf<ValueVectorOf<unsigned int> >(13); - fIC_NodeListNS = new RefHashTableOf<ValueVectorOf<DOM_Element> >(29, true, new HashPtr()); - } - - if (fIC_ElementsNS->containsKey(fTargetNSURIString)) { - - fIC_Elements = fIC_ElementsNS->get(fTargetNSURIString); - fIC_NamespaceDepth = fIC_NamespaceDepthNS->get(fTargetNSURIString); - } - - if (!fIC_Elements) { - - fIC_Elements = new ValueVectorOf<SchemaElementDecl*>(8); - fIC_NamespaceDepth = new ValueVectorOf<unsigned int>(8); - fIC_ElementsNS->put((void*) fTargetNSURIString, fIC_Elements); - fIC_NamespaceDepthNS->put((void*) fTargetNSURIString, fIC_NamespaceDepth); - } - - fIC_NodeListNS->put(elemDecl, icNodes); - fIC_Elements->addElement(elemDecl); - fIC_NamespaceDepth->addElement(fSchemaInfo->getNamespaceScopeLevel()); - } - } - - return new QName(elemDecl->getElementName()); -} - -const XMLCh* TraverseSchema::traverseNotationDecl(const DOM_Element& elem) { - - // ------------------------------------------------------------------ - // Check attributes - // ------------------------------------------------------------------ - fAttributeCheck.checkAttributes(elem, GeneralAttributeCheck::GlobalContext, this); - - // ------------------------------------------------------------------ - // Process notation attributes/elements - // ------------------------------------------------------------------ - const XMLCh* name = getElementAttValue(elem, SchemaSymbols::fgATT_NAME); - bool nameEmpty = (XMLString::stringLen(name) == 0) ? true : false; - - if (nameEmpty) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::NoNameGlobalElement, - SchemaSymbols::fgELT_NOTATION); - return 0; - } - - if (fNotationRegistry->containsKey(name, fTargetNSURI)) { - return name; - } - - const XMLCh* publicId = getElementAttValue(elem, SchemaSymbols::fgATT_PUBLIC); - const XMLCh* systemId = getElementAttValue(elem, SchemaSymbols::fgATT_SYSTEM); - - if (XMLString::stringLen(publicId) == 0 && XMLString::stringLen(systemId) == 0) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::Notation_InvalidDecl, name); - } - - fNotationRegistry->put((void*) name, fTargetNSURI, 0); - - //we don't really care if something inside <notation> is wrong.. - checkContent(elem, XUtil::getFirstChildElement(elem), true); - - return name; -} - -const XMLCh* TraverseSchema::traverseNotationDecl(const XMLCh* const name, - const XMLCh* const uriStr) { - - unsigned int uriId = fURIStringPool->addOrFind(uriStr); - SchemaInfo* saveInfo = fSchemaInfo; - - if (fTargetNSURI != (int) uriId) { - - Grammar* grammar = fGrammarResolver->getGrammar(uriStr); - - if (grammar == 0 || grammar->getGrammarType() != Grammar::SchemaGrammarType) { - - reportSchemaError(XMLUni::fgValidityDomain, XMLValid::GrammarNotFound, uriStr); - return 0; - } - - SchemaInfo* impInfo = fSchemaInfo->getImportInfo(uriId); - - if (!impInfo) { - - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::TypeNotFound, uriStr, name); - return 0; - } - - fSchemaInfo = impInfo; - fTargetNSURI = fSchemaInfo->getTargetNSURI(); - } - - DOM_Element notationElem = fSchemaInfo->getTopLevelComponent(SchemaSymbols::fgELT_NOTATION, name, &fSchemaInfo); - - if (notationElem == 0) { - - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::Notation_DeclNotFound, uriStr, name); - return 0; - } - - const XMLCh* notationName = traverseNotationDecl(notationElem); - - fSchemaInfo = saveInfo; - fTargetNSURI = fSchemaInfo->getTargetNSURI(); - - return notationName; -} - -int TraverseSchema::traverseByList(const DOM_Element& rootElem, - const DOM_Element& contentElem, - const int typeNameIndex, - const int finalSet) { - - DatatypeValidator* baseValidator = 0; - DOM_Element content = contentElem; - const XMLCh* typeName = fStringPool->getValueForId(typeNameIndex); - const XMLCh* baseTypeName = getElementAttValue(content, - SchemaSymbols::fgATT_ITEMTYPE); - - if (XUtil::getNextSiblingElement(content) != 0) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::SimpleTypeContentError); - } - - if (XMLString::stringLen(baseTypeName) == 0) { // must 'see' <simpleType> - - content = checkContent(rootElem, XUtil::getFirstChildElement(content), false); - - if (content == 0) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::ExpectedSimpleTypeInList, typeName); - return resetCurrentTypeNameStack(-1); - } - - if (content.getLocalName().equals(SchemaSymbols::fgELT_SIMPLETYPE)) { - baseValidator = checkForSimpleTypeValidator(content, SchemaSymbols::LIST); - } - else { - - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::ListUnionRestrictionError, typeName); - return resetCurrentTypeNameStack(-1); - } - - content = XUtil::getNextSiblingElement(content); - } - else { // base was provided - get proper validator - - baseValidator = findDTValidator(rootElem, baseTypeName, - SchemaSymbols::LIST); - - content = checkContent(rootElem, XUtil::getFirstChildElement(content), true); - } - - if (baseValidator == 0) { - return resetCurrentTypeNameStack(-1); - } - - if (!baseValidator->isAtomic()) { - - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::AtomicItemType, baseTypeName); - return resetCurrentTypeNameStack(-1); - } - - // 'content' should be empty - // If an annotation was encountered we have already traversed it in - // checkContent in the case of a base provided (only allowed child is - // an annotation). - if (content != 0) { // report an error and continue - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::SimpleTypeDerivationByListError, typeName); - } - - // create & register validator for "generated" type if it doesn't exist - int strId = fStringPool->addOrFind(getQualifiedName(typeNameIndex)); - const XMLCh* qualifiedName = fStringPool->getValueForId(strId); - - try { - - DatatypeValidator* newValidator = - fDatatypeRegistry->getDatatypeValidator(qualifiedName); - - if (newValidator == 0) { - - fDatatypeRegistry->createDatatypeValidator( - qualifiedName, baseValidator, 0, 0, true, finalSet); - } - } - catch (const XMLException& excep) { - reportSchemaError(XMLUni::fgValidityDomain, XMLValid::DisplayErrorMessage, excep.getMessage()); - } - catch(...) { - reportSchemaError(XMLUni::fgXMLErrDomain, - XMLErrs::DatatypeValidatorCreationError, typeName); - } - - return resetCurrentTypeNameStack(strId); -} - -int TraverseSchema::traverseByRestriction(const DOM_Element& rootElem, - const DOM_Element& contentElem, - const int typeNameIndex, - const int finalSet) { - - DatatypeValidator* baseValidator = 0; - DOM_Element content = contentElem; - const XMLCh* typeName = fStringPool->getValueForId(typeNameIndex); - const XMLCh* baseTypeName = getElementAttValue(content, - SchemaSymbols::fgATT_BASE); - - if (XUtil::getNextSiblingElement(content) != 0) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::SimpleTypeContentError); - } - - if (XMLString::stringLen(baseTypeName) == 0) { // must 'see' <simpleType> - - content = checkContent(rootElem, XUtil::getFirstChildElement(content), false); - - if (content == 0) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::ExpectedSimpleTypeInRestriction); - return resetCurrentTypeNameStack(-1); - } - - if (content.getLocalName().equals(SchemaSymbols::fgELT_SIMPLETYPE)) { - baseValidator = checkForSimpleTypeValidator(content); - } - else { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::ListUnionRestrictionError, typeName); - return resetCurrentTypeNameStack(-1); - } - - // Check for facets - content = XUtil::getNextSiblingElement(content); - } - else { // base was provided - get proper validator - - baseValidator = findDTValidator(rootElem, baseTypeName, - SchemaSymbols::RESTRICTION); - content = checkContent(rootElem, XUtil::getFirstChildElement(content), true); - } - - if (baseValidator == 0) { - return resetCurrentTypeNameStack(-1); - } - - // Get facets if any existing - RefHashTableOf<KVStringPair>* facets = 0; - RefVectorOf<XMLCh>* enums = 0; - XMLBuffer pattern; - DOMString facetName; - XMLCh fixedFlagStr[16]; - unsigned int fixedFlag = 0; - unsigned int scope = GeneralAttributeCheck::LocalContext; - bool isFirstPattern = true; - - while (content != 0) { - - if (content.getNodeType() == DOM_Node::ELEMENT_NODE) { - - fAttributeCheck.checkAttributes(content, scope, this); - facetName = content.getLocalName(); - fBuffer.set(facetName.rawBuffer(), facetName.length()); - - int facetId = fStringPool->addOrFind(fBuffer.getRawBuffer()); - const XMLCh* facetStr = fStringPool->getValueForId(facetId); - DOMString attValue = content.getAttribute(SchemaSymbols::fgATT_VALUE); - int attValueLen = attValue.length(); - - if (facets == 0) { - facets = new RefHashTableOf<KVStringPair>(29, true); - } - - if (XMLString::compareString(facetStr, - SchemaSymbols::fgELT_ENUMERATION) == 0) { - - // REVISIT - // if validator is a notation datatype validator, we need - // to get the qualified name first before adding it to the - // enum buffer - if (!enums) { - enums = new RefVectorOf<XMLCh>(8, true); - } - - fBuffer.set(attValue.rawBuffer(), attValueLen); - - if (baseValidator->getType() == DatatypeValidator::NOTATION) { - - unsigned int enumValId = fStringPool->addOrFind(fBuffer.getRawBuffer()); - const XMLCh* const enumVal = fStringPool->getValueForId(enumValId); - const XMLCh* localPart = getLocalPart(enumVal); - const XMLCh* prefix = getPrefix(enumVal); - const XMLCh* uriStr = (XMLString::stringLen(prefix)) ? resolvePrefixToURI(prefix) : fTargetNSURIString; - unsigned int uriId = fURIStringPool->addOrFind(uriStr); - - if (!fNotationRegistry->containsKey(localPart, uriId)) { - traverseNotationDecl(localPart, uriStr); - } - - fBuffer.set(uriStr); - fBuffer.append(chColon); - fBuffer.append(localPart); - } - - enums->addElement(XMLString::replicate(fBuffer.getRawBuffer())); - } - else if (XMLString::compareString(facetStr, - SchemaSymbols::fgELT_PATTERN) == 0) { - - if (isFirstPattern) { // fBuffer.isEmpty() - overhead call - - isFirstPattern = false; - pattern.set(attValue.rawBuffer(), attValueLen); - } - else { //datatypes: 5.2.4 pattern - - pattern.append(chPipe); - pattern.append(attValue.rawBuffer(), attValueLen); - } - } - else if (XMLString::compareString(facetStr, - SchemaSymbols::fgELT_ANNOTATION) == 0 - || XMLString::compareString(facetStr, - SchemaSymbols::fgELT_SIMPLETYPE) == 0) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::ListUnionRestrictionError, typeName); - } - else { - - if (facets->containsKey(facetStr)) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::DuplicateFacet, facetStr); - } - else { - - fBuffer.set(attValue.rawBuffer(), attValueLen); - - const XMLCh* attVal = fBuffer.getRawBuffer(); - - if (!XMLString::compareString(facetStr, SchemaSymbols::fgELT_WHITESPACE) - && baseValidator->getType() != DatatypeValidator::String - && XMLString::compareString(attVal, SchemaSymbols::fgWS_COLLAPSE) != 0) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::WS_CollapseExpected, - attVal); - } - else { - facets->put((void*) facetStr, new KVStringPair(facetStr, attVal)); - checkFixedFacet(content, facetStr, baseValidator, fixedFlag); - } - } - } - - // REVISIT - // check for annotation content - we are not checking whether the - // return is empty or not. If not empty we should report an error - checkContent(rootElem, XUtil::getFirstChildElement(content), true); - } - - content = XUtil::getNextSiblingElement(content); - } // end while - - if (!pattern.isEmpty()) { - facets->put((void*) SchemaSymbols::fgELT_PATTERN, - new KVStringPair(SchemaSymbols::fgELT_PATTERN, pattern.getRawBuffer())); - } - - if (fixedFlag) { - - XMLString::binToText(fixedFlag, fixedFlagStr, 15, 10); - facets->put((void*) SchemaSymbols::fgATT_FIXED, - new KVStringPair(SchemaSymbols::fgATT_FIXED, fixedFlagStr)); - } - - int strId = fStringPool->addOrFind(getQualifiedName(typeNameIndex)); - const XMLCh* qualifiedName = fStringPool->getValueForId(strId); - - try { - - DatatypeValidator* newValidator = - fDatatypeRegistry->getDatatypeValidator(qualifiedName); - - if (newValidator == 0) { - - fDatatypeRegistry->createDatatypeValidator - (qualifiedName, baseValidator, facets, enums, false, finalSet); - } - } - catch (const XMLException& excep) { - reportSchemaError(XMLUni::fgValidityDomain, XMLValid::DisplayErrorMessage, excep.getMessage()); - } - catch(...) { - - reportSchemaError(XMLUni::fgXMLErrDomain, - XMLErrs::DatatypeValidatorCreationError, typeName); - } - - return resetCurrentTypeNameStack(strId); -} - - -int TraverseSchema::traverseByUnion(const DOM_Element& rootElem, - const DOM_Element& contentElem, - const int typeNameIndex, - const int finalSet, - int baseRefContext) { - - int size = 1; - DOM_Element content = contentElem; - const XMLCh* const typeName = - fStringPool->getValueForId(typeNameIndex); - const XMLCh* baseTypeName = getElementAttValue(content, - SchemaSymbols::fgATT_MEMBERTYPES); - DatatypeValidator* baseValidator = 0; - RefVectorOf<DatatypeValidator>* validators = - new RefVectorOf<DatatypeValidator>(4, false); - Janitor<DVRefVector> janValidators(validators); - - if (XUtil::getNextSiblingElement(content) != 0) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::SimpleTypeContentError); - } - - if (XMLString::stringLen(baseTypeName)) { //base was provided - get proper validator. - - XMLStringTokenizer unionMembers(baseTypeName); - int tokCount = unionMembers.countTokens(); - - for (int i = 0; i < tokCount; i++) { - - const XMLCh* typeName = unionMembers.nextToken(); - - baseValidator = findDTValidator(rootElem, typeName, SchemaSymbols::UNION); - - if (baseValidator == 0) { - return resetCurrentTypeNameStack(-1); - } - - validators->addElement(baseValidator); - } - - content = checkContent(rootElem, XUtil::getFirstChildElement(content), true); - } - else { // must 'see' <simpleType> - - content = checkContent(rootElem, XUtil::getFirstChildElement(content), false); - - if (content == 0) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::ExpectedSimpleTypeInUnion, typeName); - return resetCurrentTypeNameStack(-1); - } - - if (!content.getLocalName().equals(SchemaSymbols::fgELT_SIMPLETYPE)) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::ListUnionRestrictionError, typeName); - return resetCurrentTypeNameStack(-1); - } - } - - // process union content of simpleType children if any - while (content != 0) { - - if (content.getLocalName().equals(SchemaSymbols::fgELT_SIMPLETYPE)) { - - baseValidator = checkForSimpleTypeValidator(content, baseRefContext | SchemaSymbols::UNION); - - if (baseValidator == 0) { - return resetCurrentTypeNameStack(-1); - } - - validators->addElement(baseValidator); - } - else { - // REVISIT - should we break. For now, we will continue and move to - // the next sibling - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::ListUnionRestrictionError, typeName); - } - - content = XUtil::getNextSiblingElement(content); - } // end while - - int strId = fStringPool->addOrFind(getQualifiedName(typeNameIndex)); - const XMLCh* qualifiedName = fStringPool->getValueForId(strId); - - try { - - DatatypeValidator* newValidator = - fDatatypeRegistry->getDatatypeValidator(qualifiedName); - - if (newValidator == 0) { - - if (fDatatypeRegistry->createDatatypeValidator( - qualifiedName, validators, finalSet) != 0) { - janValidators.orphan(); - } - } - } - catch (const XMLException& excep) { - janValidators.orphan(); - reportSchemaError(XMLUni::fgValidityDomain, XMLValid::DisplayErrorMessage, excep.getMessage()); - } - catch(...) { - janValidators.orphan(); - reportSchemaError(XMLUni::fgXMLErrDomain, - XMLErrs::DatatypeValidatorCreationError, typeName); - } - - return resetCurrentTypeNameStack(strId); -} - - -/** - * Traverse SimpleContent Declaration - * - * <simpleContent - * id = ID - * {any attributes with non-schema namespace...}> - * - * Content: (annotation? , (restriction | extension)) - * </simpleContent> - * - * <restriction - * base = QNAME - * id = ID - * {any attributes with non-schema namespace...}> - * - * Content: (annotation?, (simpleType?, (minExclusive | minInclusive - * | maxExclusive | maxInclusive | totalDigits | fractionDigits - * | length | minLength | maxLength | enumeration | pattern - * | whiteSpace)*)?, ((attribute | attributeGroup)* , anyAttribute?)) - * </restriction> - * - * <extension - * base = QNAME - * id = ID - * {any attributes with non-schema namespace...}> - * Content: (annotation? , ((attribute | attributeGroup)* , anyAttribute?)) - * </extension> - * - */ -void TraverseSchema::traverseSimpleContentDecl(const XMLCh* const typeName, - const DOM_Element& contentDecl, - ComplexTypeInfo* const typeInfo) -{ - // ----------------------------------------------------------------------- - // Check Attributes - // ----------------------------------------------------------------------- - unsigned short scope = GeneralAttributeCheck::LocalContext; - fAttributeCheck.checkAttributes(contentDecl, scope, this); - - // ----------------------------------------------------------------------- - // Set the content type to be simple, and initialize content spec handle - // ----------------------------------------------------------------------- - typeInfo->setContentType(SchemaElementDecl::Simple); - - DOM_Element simpleContent = - checkContent(contentDecl, XUtil::getFirstChildElement(contentDecl),false); - - // If there are no children, return - if (simpleContent == 0) { - - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::EmptySimpleTypeContent); - throw TraverseSchema::InvalidComplexTypeInfo; - } - - fAttributeCheck.checkAttributes(simpleContent, scope, this); - - // ----------------------------------------------------------------------- - // The content should be either "restriction" or "extension" - // ----------------------------------------------------------------------- - DOMString contentName = simpleContent.getLocalName(); - - if (contentName.equals(SchemaSymbols::fgATTVAL_RESTRICTION)) { - typeInfo->setDerivedBy(SchemaSymbols::RESTRICTION); - } - else if (contentName.equals(SchemaSymbols::fgATTVAL_EXTENSION)) { - typeInfo->setDerivedBy(SchemaSymbols::EXTENSION); - } - else { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::InvalidSimpleContent); - throw TraverseSchema::InvalidComplexTypeInfo; - } - - // ----------------------------------------------------------------------- - // Handle the base type name - // ----------------------------------------------------------------------- - const XMLCh* baseName = - getElementAttValue(simpleContent, SchemaSymbols::fgATT_BASE); - - if (XMLString::stringLen(baseName) == 0) { - - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::UnspecifiedBase); - throw TraverseSchema::InvalidComplexTypeInfo; - } - - const XMLCh* prefix = getPrefix(baseName); - const XMLCh* localPart = getLocalPart(baseName); - const XMLCh* uri = resolvePrefixToURI(prefix); - DatatypeValidator* baseValidator = getDatatypeValidator(uri, localPart); - - if (baseValidator != 0) { - - // check that the simpleType does not preclude derivation by extension - if ((baseValidator->getFinalSet() & SchemaSymbols::EXTENSION) == typeInfo->getDerivedBy()) { - - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::DisallowedSimpleTypeExtension, - baseName, typeName); - throw TraverseSchema::InvalidComplexTypeInfo; - } - - typeInfo->setBaseComplexTypeInfo(0); - typeInfo->setBaseDatatypeValidator(baseValidator); - } - else { - - // check for 'anyType' - if (!XMLString::compareString(uri, SchemaSymbols::fgURI_SCHEMAFORSCHEMA) - && !XMLString::compareString(localPart, SchemaSymbols::fgATTVAL_ANYTYPE)) { - - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::InvalidSimpleContentBase, baseName); - throw TraverseSchema::InvalidComplexTypeInfo; - } - - processBaseTypeInfo(baseName, localPart, uri, typeInfo); - } - - // check that the base isn't a complex type with complex content - // and that derivation method is not included in 'final' - ComplexTypeInfo* baseTypeInfo = typeInfo->getBaseComplexTypeInfo(); - - if (baseTypeInfo) { - - if (baseTypeInfo->getContentType() != SchemaElementDecl::Simple) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::InvalidSimpleContentBase, baseName); - throw TraverseSchema::InvalidComplexTypeInfo; - } - - if ((baseTypeInfo->getFinalSet() & typeInfo->getDerivedBy()) != 0) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::ForbiddenDerivation, baseName); - throw TraverseSchema::InvalidComplexTypeInfo; - } - } - - // ----------------------------------------------------------------------- - // Process the content of the derivation - // ----------------------------------------------------------------------- - //Skip over any annotations in the restriction or extension elements - DOM_Element content = checkContent(simpleContent, - XUtil::getFirstChildElement(simpleContent), true); - - if (typeInfo->getDerivedBy() == SchemaSymbols::RESTRICTION) { - - //Schema Spec: 5.11: Complex Type Definition Properties Correct: 2 - if (typeInfo->getBaseDatatypeValidator() != 0) { - - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::InvalidComplexTypeBase, baseName); - throw TraverseSchema::InvalidComplexTypeInfo; - } - else { - typeInfo->setBaseDatatypeValidator(baseTypeInfo->getDatatypeValidator()); - } - - if (content != 0) { - - // --------------------------------------------------------------- - // There may be a simple type definition in the restriction - // element. The data type validator will be based on it, if - // specified - // --------------------------------------------------------------- - if (content.getLocalName().equals(SchemaSymbols::fgELT_SIMPLETYPE)) { - - int simpleTypeNameIndex = traverseSimpleTypeDecl(content); - - if (simpleTypeNameIndex !=-1) { - - DatatypeValidator* simpleTypeDV = - fDatatypeRegistry->getDatatypeValidator(fStringPool->getValueForId(simpleTypeNameIndex)); - - // Check that the simpleType validator is validly derived - // from base - DatatypeValidator* baseDV = typeInfo->getBaseDatatypeValidator(); - - if (baseDV && !baseDV->isSubstitutableBy(simpleTypeDV)) { - - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::InvalidContentRestriction); - throw TraverseSchema::InvalidComplexTypeInfo; - } - - typeInfo->setBaseDatatypeValidator(simpleTypeDV); - content = XUtil::getNextSiblingElement(content); - } - else { - throw TraverseSchema::InvalidComplexTypeInfo; - } - } - - // --------------------------------------------------------------- - // Build up the facet info - // --------------------------------------------------------------- - RefHashTableOf<KVStringPair>* facets = 0; - RefVectorOf<XMLCh>* enums = 0; - XMLBuffer pattern; - const XMLCh* facetName; - XMLCh fixedFlagStr[16]; - unsigned int fixedFlag = 0; - int facetId; - bool isFirstPattern = true; - - while (content != 0) { - - fBuffer.set(content.getLocalName().rawBuffer(), content.getLocalName().length()); - facetId = fStringPool->addOrFind(fBuffer.getRawBuffer()); - facetName = fStringPool->getValueForId(facetId); - - // if not a valid facet, break from the loop - if (!isValidFacet(SchemaSymbols::fgELT_SIMPLECONTENT, facetName)) { - break; - } - - if (content.getNodeType() == DOM_Node::ELEMENT_NODE) { - - fAttributeCheck.checkAttributes(content, scope, this); - - DOMString attValue = - content.getAttribute(SchemaSymbols::fgATT_VALUE); - - if (facets == 0) { - facets = new RefHashTableOf<KVStringPair>(29, true); - } - - fBuffer.set(attValue.rawBuffer(), attValue.length()); - - if (XMLString::compareString(facetName, - SchemaSymbols::fgELT_ENUMERATION) == 0) { - - if (!enums) { - enums = new RefVectorOf<XMLCh>(8, true); - } - - enums->addElement(XMLString::replicate(fBuffer.getRawBuffer())); - } - else if (XMLString::compareString(facetName, - SchemaSymbols::fgELT_PATTERN) == 0) { - - if (isFirstPattern) { // fBuffer.isEmpty() - overhead call - - isFirstPattern = false; - pattern.set(fBuffer.getRawBuffer()); - } - else { //datatypes: 5.2.4 pattern - - pattern.append(chPipe); - pattern.append(fBuffer.getRawBuffer()); - } - } - else { - - if (facets->containsKey(facetName)) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::DuplicateFacet, facetName); - } - else { - facets->put((void*) facetName, - new KVStringPair(facetName,fBuffer.getRawBuffer())); - checkFixedFacet(content, facetName, typeInfo->getBaseDatatypeValidator(), fixedFlag); - } - } - } - - content = XUtil::getNextSiblingElement(content); - } - - if (facets) { - - if (!pattern.isEmpty()) { - facets->put - ( - (void*) SchemaSymbols::fgELT_PATTERN, - new KVStringPair - ( - SchemaSymbols::fgELT_PATTERN, - pattern.getRawBuffer() - ) - ); - } - - if (fixedFlag) { - - XMLString::binToText(fixedFlag, fixedFlagStr, 15, 10); - facets->put((void*) SchemaSymbols::fgATT_FIXED, - new KVStringPair(SchemaSymbols::fgATT_FIXED, fixedFlagStr)); - } - - int nameId = fStringPool->addOrFind(getQualifiedName(fStringPool->addOrFind(typeName))); - const XMLCh* qualifiedName = fStringPool->getValueForId(nameId); - - try { - - typeInfo->setDatatypeValidator - ( - fDatatypeRegistry->createDatatypeValidator - ( - qualifiedName, - typeInfo->getBaseDatatypeValidator(), - facets, enums, false, 0 - ) - ); - } - catch (const XMLException& excep) { - reportSchemaError(XMLUni::fgValidityDomain, XMLValid::DisplayErrorMessage, excep.getMessage()); - } - catch(...) { - reportSchemaError(XMLUni::fgXMLErrDomain, - XMLErrs::DatatypeValidatorCreationError, typeName); - } - } - else { - typeInfo->setDatatypeValidator( - typeInfo->getBaseDatatypeValidator()); - } - } - else { - typeInfo->setDatatypeValidator(typeInfo->getBaseDatatypeValidator()); - } - } // end RESTRICTION - else { // EXTENSION - - ComplexTypeInfo* baseTypeInfo = typeInfo->getBaseComplexTypeInfo(); - - if (baseTypeInfo!= 0) { - - typeInfo->setBaseDatatypeValidator(baseTypeInfo->getDatatypeValidator()); - } - - typeInfo->setDatatypeValidator(typeInfo->getBaseDatatypeValidator()); - } - - // ----------------------------------------------------------------------- - // Process attributes if any - // ----------------------------------------------------------------------- - if (content != 0 && isAttrOrAttrGroup(content)) { - processAttributes(content, baseName, localPart, uri, typeInfo); - } - - if (XUtil::getNextSiblingElement(simpleContent) != 0) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::InvalidChildInSimpleContent); - } - -} // End of function traverseSimpleContentDecl - -/** - * Traverse complexContent Declaration - * - * <complexContent - * id = ID - * mixed = boolean - * {any attributes with non-schema namespace...}> - * - * Content: (annotation? , (restriction | extension)) - * </complexContent> - * - * <restriction - * base = QNAME - * id = ID - * {any attributes with non-schema namespace...}> - * - * Content: (annotation? , (group | all | choice | sequence)?, - * ((attribute | attributeGroup)* , anyAttribute?)) - * </restriction> - * - * <extension - * base = QNAME - * id = ID - * {any attributes with non-schema namespace...}> - * Content: (annotation? , (group | all | choice | sequence)?, - * ((attribute | attributeGroup)* , anyAttribute?)) - * </extension> - */ -void TraverseSchema::traverseComplexContentDecl(const XMLCh* const typeName, - const DOM_Element& contentDecl, - ComplexTypeInfo* const typeInfo, - const bool isMixed) -{ - // ------------------------------------------------------------------ - // Check attributes - // ------------------------------------------------------------------ - unsigned short scope = GeneralAttributeCheck::LocalContext; - fAttributeCheck.checkAttributes(contentDecl, scope, this); - - // ----------------------------------------------------------------------- - // Determine whether the content is mixed, or element-only - // Setting here overrides any setting on the complex type decl - // ----------------------------------------------------------------------- - const XMLCh* const mixed = - getElementAttValue(contentDecl, SchemaSymbols::fgATT_MIXED); - - bool mixedContent = isMixed; - - if (mixed) { - if (!XMLString::compareString(mixed, SchemaSymbols::fgATTVAL_TRUE) - || !XMLString::compareString(mixed, fgValueOne)) { - mixedContent = true; - } - else if (!XMLString::compareString(mixed, SchemaSymbols::fgATTVAL_FALSE) - || !XMLString::compareString(mixed, fgValueZero)) { - mixedContent = false; - } - } - - // ----------------------------------------------------------------------- - // Since the type must have complex content, set the simple type validators - // to null - // ----------------------------------------------------------------------- - typeInfo->setDatatypeValidator(0); - typeInfo->setBaseDatatypeValidator(0); - - DOM_Element complexContent = - checkContent(contentDecl,XUtil::getFirstChildElement(contentDecl),false); - - // If there are no children, return - if (complexContent == 0) { - throw TraverseSchema::InvalidComplexTypeInfo; - } - - // ----------------------------------------------------------------------- - // The content should be either "restriction" or "extension" - // ----------------------------------------------------------------------- - DOMString complexContentName = complexContent.getLocalName(); - - if (complexContentName.equals(SchemaSymbols::fgELT_RESTRICTION)) { - typeInfo->setDerivedBy(SchemaSymbols::RESTRICTION); - } - else if (complexContentName.equals(SchemaSymbols::fgELT_EXTENSION)) { - typeInfo->setDerivedBy(SchemaSymbols::EXTENSION); - } - else { - - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::InvalidComplexContent); - throw TraverseSchema::InvalidComplexTypeInfo; - } - - // ----------------------------------------------------------------------- - // Handle the base type name - // ----------------------------------------------------------------------- - const XMLCh* baseName = - getElementAttValue(complexContent, SchemaSymbols::fgATT_BASE); - - if (XMLString::stringLen(baseName) == 0) { - - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::UnspecifiedBase); - throw TraverseSchema::InvalidComplexTypeInfo; - } - - const XMLCh* prefix = getPrefix(baseName); - const XMLCh* localPart = getLocalPart(baseName); - const XMLCh* uri = resolvePrefixToURI(prefix); - bool isBaseAnyType = false; - - // ------------------------------------------------------------- - // check if the base is "anyType" - // ------------------------------------------------------------- - if (XMLString::compareString(uri, SchemaSymbols::fgURI_SCHEMAFORSCHEMA) == 0 && - XMLString::compareString(localPart, SchemaSymbols::fgATTVAL_ANYTYPE) == 0) { - isBaseAnyType = true; - } - else { - - processBaseTypeInfo(baseName, localPart, uri, typeInfo); - - //Check that the base is a complex type - if (typeInfo->getBaseComplexTypeInfo() == 0) { - - reportSchemaError(XMLUni::fgXMLErrDomain, - XMLErrs::BaseNotComplexType); - throw TraverseSchema::InvalidComplexTypeInfo; - } - } - - // ----------------------------------------------------------------------- - // Process the content of the derivation - // ----------------------------------------------------------------------- - //Skip over any annotations in the restriction or extension elements - DOM_Element content = checkContent(complexContent, - XUtil::getFirstChildElement(complexContent), true); - - processComplexContent(typeName, content, typeInfo, baseName, localPart, - uri, mixedContent, isBaseAnyType); - - if (XUtil::getNextSiblingElement(complexContent) != 0) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::InvalidChildInComplexContent); - } -} - - -/** - * <anyAttribute - * id = ID - * namespace = ((##any | ##other) | list of (anyURI | (##targetNamespace | ##local)))> - * processContents = (lax | skip | strict) : strict - * Content: (annotation?) - * </anyAttribute> - */ -SchemaAttDef* TraverseSchema::traverseAnyAttribute(const DOM_Element& elem) { - - // ----------------------------------------------------------------------- - // Check Attributes - // ----------------------------------------------------------------------- - unsigned short scope = GeneralAttributeCheck::LocalContext; - fAttributeCheck.checkAttributes(elem, scope, this); - - // ------------------------------------------------------------------ - // First, handle any ANNOTATION declaration - // ------------------------------------------------------------------ - if (checkContent(elem, XUtil::getFirstChildElement(elem), true) != 0) { - reportSchemaError(XMLUni::fgXMLErrDomain, - XMLErrs::AnyAttributeContentError); - } - - // ------------------------------------------------------------------ - // Get attributes - // ------------------------------------------------------------------ - const XMLCh* const processContents = - getElementAttValue(elem, SchemaSymbols::fgATT_PROCESSCONTENTS); - const XMLCh* const nameSpace = - getElementAttValue(elem, SchemaSymbols::fgATT_NAMESPACE); - - // ------------------------------------------------------------------ - // Set default att type based on 'processContents' value - // ------------------------------------------------------------------ - XMLAttDef::DefAttTypes attDefType = XMLAttDef::ProcessContents_Strict; - - if (XMLString::stringLen(processContents) == 0 - || XMLString::compareString(processContents, SchemaSymbols::fgATTVAL_STRICT) == 0) { - // Do nothing - defaulted already - } - else if (XMLString::compareString(processContents, - SchemaSymbols::fgATTVAL_SKIP) == 0) { - attDefType = XMLAttDef::ProcessContents_Skip; - } - else if (XMLString::compareString(processContents, - SchemaSymbols::fgATTVAL_LAX) == 0) { - attDefType = XMLAttDef::ProcessContents_Lax; - } - - // ------------------------------------------------------------------ - // Process 'namespace' attribute - // ------------------------------------------------------------------ - int uriIndex = fEmptyNamespaceURI; - XMLAttDef::AttTypes attType = XMLAttDef::Any_Any; - ValueVectorOf<unsigned int> namespaceList(8); - - if (XMLString::stringLen(nameSpace) == 0 - || XMLString::compareString(nameSpace, SchemaSymbols::fgATTVAL_TWOPOUNDANY) == 0) { - // Do nothing - defaulted already - } - else if (XMLString::compareString(nameSpace, SchemaSymbols::fgATTVAL_TWOPOUNDOTHER) == 0) { - - attType = XMLAttDef::Any_Other; - uriIndex = fTargetNSURI; - } - else { - - XMLStringTokenizer tokenizer(nameSpace); - - attType = XMLAttDef::Any_List; - - while (tokenizer.hasMoreTokens()) { - - const XMLCh* token = tokenizer.nextToken(); - - if (!XMLString::compareString(token, SchemaSymbols::fgATTVAL_TWOPOUNDLOCAL)) { - uriIndex = fEmptyNamespaceURI; - } - else if (!XMLString::compareString(token, SchemaSymbols::fgATTVAL_TWOPOUNDTRAGETNAMESPACE)) { - uriIndex = fTargetNSURI; - } - else { - uriIndex = fURIStringPool->addOrFind(token); - } - - if (!namespaceList.containsElement(uriIndex)) { - namespaceList.addElement(uriIndex); - } - } - - uriIndex = fEmptyNamespaceURI; - } - - // ------------------------------------------------------------------ - // Create wildcard attribute - // ------------------------------------------------------------------ - SchemaAttDef* attDef = new SchemaAttDef(XMLUni::fgZeroLenString, - XMLUni::fgZeroLenString, - uriIndex, attType, attDefType); - - - if (namespaceList.size()) { - attDef->setNamespaceList(&namespaceList); - } - - return attDef; -} - -/** - * <key - * id = ID - * name = NCName - * Content: (annotation?, (selector, field+)) - * </key> - */ -void TraverseSchema::traverseKey(const DOM_Element& icElem, - SchemaElementDecl* const elemDecl) { - - // ----------------------------------------------------------------------- - // Check Attributes - // ----------------------------------------------------------------------- - unsigned short scope = GeneralAttributeCheck::LocalContext; - fAttributeCheck.checkAttributes(icElem, scope, this); - - // ----------------------------------------------------------------------- - // Create identity constraint - // ----------------------------------------------------------------------- - const XMLCh* name = getElementAttValue(icElem, SchemaSymbols::fgATT_NAME); - - if (!XMLString::stringLen(name)) { - return; - } - - if (!XMLString::isValidNCName(name)) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::InvalidDeclarationName, - SchemaSymbols::fgELT_KEY, name); - return; - } - - - if (!fIdentityConstraintNames) { - fIdentityConstraintNames = new RefHash2KeysTableOf<IdentityConstraint>(29, false); - } - - if (fIdentityConstraintNames->containsKey(name, fTargetNSURI)) { - - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::IC_DuplicateDecl, name); - return; - } - - IC_Key* icKey = new IC_Key(name, elemDecl->getBaseName()); - Janitor<IC_Key> janKey(icKey); - - fIdentityConstraintNames->put((void*) name, fTargetNSURI, icKey); - - // ----------------------------------------------------------------------- - // Get selector and fields - // ----------------------------------------------------------------------- - if (!traverseIdentityConstraint(icKey, icElem)) { - - fIdentityConstraintNames->put((void*) name, fTargetNSURI, 0); - return; - } - - // ----------------------------------------------------------------------- - // Add key to element declaration - // ----------------------------------------------------------------------- - elemDecl->addIdentityConstraint(icKey); - janKey.orphan(); -} - -/** - * <unique - * id = ID - * name = NCName - * Content: (annotation?, (selector, field+)) - * </unique> - */ -void TraverseSchema::traverseUnique(const DOM_Element& icElem, - SchemaElementDecl* const elemDecl) { - - // ----------------------------------------------------------------------- - // Check Attributes - // ----------------------------------------------------------------------- - unsigned short scope = GeneralAttributeCheck::LocalContext; - fAttributeCheck.checkAttributes(icElem, scope, this); - - // ----------------------------------------------------------------------- - // Create identity constraint - // ----------------------------------------------------------------------- - const XMLCh* name = getElementAttValue(icElem, SchemaSymbols::fgATT_NAME); - - if (!XMLString::stringLen(name)) { - return; - } - - if (!XMLString::isValidNCName(name)) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::InvalidDeclarationName, - SchemaSymbols::fgELT_UNIQUE, name); - return; - } - - if (!fIdentityConstraintNames) { - fIdentityConstraintNames = new RefHash2KeysTableOf<IdentityConstraint>(29, false); - } - - if (fIdentityConstraintNames->containsKey(name, fTargetNSURI)) { - - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::IC_DuplicateDecl, name); - return; - } - - IC_Unique* icUnique = new IC_Unique(name, elemDecl->getBaseName()); - Janitor<IC_Unique> janUnique(icUnique); - - fIdentityConstraintNames->put((void*) name, fTargetNSURI, icUnique); - - // ----------------------------------------------------------------------- - // Get selector and fields - // ----------------------------------------------------------------------- - if (!traverseIdentityConstraint(icUnique, icElem)) { - - fIdentityConstraintNames->put((void*) name, fTargetNSURI, 0); - return; - } - - // ----------------------------------------------------------------------- - // Add identity cosntraints to element declaration - // ----------------------------------------------------------------------- - elemDecl->addIdentityConstraint(icUnique); - janUnique.orphan(); -} - -/** - * <keyref - * id = ID - * name = NCName - * refer = QName - * Content: (annotation?, (selector, field+)) - * </keyref> - */ -void TraverseSchema::traverseKeyRef(const DOM_Element& icElem, - SchemaElementDecl* const elemDecl, - const unsigned int namespaceDepth) { - - // ----------------------------------------------------------------------- - // Check Attributes - // ----------------------------------------------------------------------- - unsigned short scope = GeneralAttributeCheck::LocalContext; - fAttributeCheck.checkAttributes(icElem, scope, this); - - // ----------------------------------------------------------------------- - // Verify that key reference "refer" attribute is valid - // ----------------------------------------------------------------------- - const XMLCh* name = getElementAttValue(icElem, SchemaSymbols::fgATT_NAME); - const XMLCh* refer = getElementAttValue(icElem, SchemaSymbols::fgATT_REFER); - - if (!XMLString::stringLen(name) || !XMLString::stringLen(refer)) { - return; - } - - if (!XMLString::isValidNCName(name)) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::InvalidDeclarationName, - SchemaSymbols::fgELT_KEYREF, name); - return; - } - - const XMLCh* prefix = getPrefix(refer); - const XMLCh* localPart = getLocalPart(refer); - const XMLCh* uriStr = resolvePrefixToURI(prefix, namespaceDepth); - IdentityConstraint* icKey = (fIdentityConstraintNames) - ? fIdentityConstraintNames->get(localPart, fURIStringPool->addOrFind(uriStr)) : 0; - - if (!icKey) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::IC_KeyRefReferNotFound, name, localPart); - return; - } - - // ----------------------------------------------------------------------- - // Create identity constraint - // ----------------------------------------------------------------------- - if(fIdentityConstraintNames->containsKey(name, fTargetNSURI)) { - - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::IC_DuplicateDecl, name); - return; - } - - IC_KeyRef* icKeyRef = new IC_KeyRef(name, elemDecl->getBaseName(), icKey); - Janitor<IC_KeyRef> janKeyRef(icKeyRef); - - fIdentityConstraintNames->put((void*) name, fTargetNSURI, icKeyRef); - - // ----------------------------------------------------------------------- - // Get selector and fields - // ----------------------------------------------------------------------- - if (!traverseIdentityConstraint(icKeyRef, icElem)) { - - fIdentityConstraintNames->put((void*) name, fTargetNSURI, 0); - return; - } - - // ----------------------------------------------------------------------- - // Add key reference to element decl - // ----------------------------------------------------------------------- - if (icKeyRef->getFieldCount() != icKey->getFieldCount()) { - - fIdentityConstraintNames->put((void*) name, fTargetNSURI, 0); - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::IC_KeyRefCardinality, - name, icKey->getIdentityConstraintName()); - } - else { - - elemDecl->addIdentityConstraint(icKeyRef); - janKeyRef.orphan(); - } -} - - -bool TraverseSchema::traverseIdentityConstraint(IdentityConstraint* const ic, - const DOM_Element& icElem) { - - // ------------------------------------------------------------------ - // First, handle any ANNOTATION declaration - // ------------------------------------------------------------------ - unsigned short scope = GeneralAttributeCheck::LocalContext; - DOM_Element elem = XUtil::getFirstChildElement(icElem); - - if (elem == 0) { - - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::IC_BadContent); - return false; - } - - elem = checkContent(icElem, elem, false); - - // ------------------------------------------------------------------ - // Get selector - // ------------------------------------------------------------------ - if (!elem.getLocalName().equals(SchemaSymbols::fgELT_SELECTOR)) { - - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::IC_BadContent); - return false; - } - - fAttributeCheck.checkAttributes(elem, scope, this); - checkContent(icElem, XUtil::getFirstChildElement(elem), true); - - // ------------------------------------------------------------------ - // Get xpath attribute - // ------------------------------------------------------------------ - const XMLCh* xpathExpr = getElementAttValue(elem, SchemaSymbols::fgATT_XPATH, true); - unsigned int xpathLen = XMLString::stringLen(xpathExpr); - - if (!xpathExpr || !xpathLen) { - - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::IC_XPathExprMissing); - return false; - } - - fBuffer.reset(); - - unsigned int startIndex = 0; - - while (startIndex < xpathLen) { - - if (!XMLString::startsWith(xpathExpr + startIndex, fgForwardSlash) - && !XMLString::startsWith(xpathExpr + startIndex, fgDot)) { - fBuffer.append(fgDotForwardSlash); - } - - int chOffset = XMLString::indexOf(xpathExpr, chPipe, startIndex); - - if (chOffset == -1) - break; - - fBuffer.append(xpathExpr + startIndex, chOffset + 1 - startIndex); - startIndex = chOffset + 1; - } - - if (startIndex < xpathLen) - fBuffer.append(xpathExpr + startIndex); - - // ------------------------------------------------------------------ - // Parse xpath expression - // ------------------------------------------------------------------ - try { - - XercesXPath* sXPath = new XercesXPath(fBuffer.getRawBuffer(), fStringPool, fNamespaceScope, fEmptyNamespaceURI, true); - IC_Selector* icSelector = new IC_Selector(sXPath, ic); - ic->setSelector(icSelector); - } - catch (const XPathException& e) { - - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::DisplayErrorMessage, e.getMessage()); - return false; - } - - // ------------------------------------------------------------------ - // Get fields - // ------------------------------------------------------------------ - elem = XUtil::getNextSiblingElement(elem); - - if (elem == 0) { - - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::IC_BadContent); - return false; - } - - while (elem != 0) { - - if (!elem.getLocalName().equals(SchemaSymbols::fgELT_FIELD)) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::IC_BadContent); - } - else { - // General Attribute Checking - fAttributeCheck.checkAttributes(elem, scope, this); - checkContent(icElem, XUtil::getFirstChildElement(elem), true); - - // xpath expression parsing - xpathExpr = getElementAttValue(elem, SchemaSymbols::fgATT_XPATH, true); - - if (!xpathExpr || !XMLString::stringLen(xpathExpr)) { - - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::IC_XPathExprMissing); - return false; - } - - if (XMLString::startsWith(xpathExpr, fgForwardSlash) - || XMLString::startsWith(xpathExpr, fgDot)) { - fBuffer.set(xpathExpr); - } - else { - - fBuffer.set(fgDotForwardSlash); - fBuffer.append(xpathExpr); - } - - try { - - XercesXPath* fieldXPath = new XercesXPath(fBuffer.getRawBuffer(), fStringPool, fNamespaceScope, fEmptyNamespaceURI); - IC_Field* icField = new IC_Field(fieldXPath, ic); - ic->addField(icField); - } - catch (const XPathException& e) { - - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::DisplayErrorMessage, e.getMessage()); - return false; - } - } - - elem = XUtil::getNextSiblingElement(elem); - } - - if (ic->getFieldCount() == 0) { - return false; - } - - return true; -} - -// --------------------------------------------------------------------------- -// TraverseSchema: Helper methods -// --------------------------------------------------------------------------- -void TraverseSchema::retrieveNamespaceMapping(const DOM_Element& schemaRoot) { - - DOM_NamedNodeMap schemaEltAttrs = schemaRoot.getAttributes(); - bool seenXMLNS = false; - int attrCount = schemaEltAttrs.getLength(); - - for (int i = 0; i < attrCount; i++) { - - DOM_Node attribute = schemaEltAttrs.item(i); - - if (attribute.isNull()) { - break; - } - - DOMString attName = attribute.getNodeName(); - - fBuffer.set(attName.rawBuffer(), attName.length()); - int nameId = fStringPool->addOrFind(fBuffer.getRawBuffer()); - const XMLCh* name = fStringPool->getValueForId(nameId); - - // starts with 'xmlns:' - if (XMLString::startsWith(name, fgXMLNS_Str)) { - - XMLCh prefix[256]; - int offsetIndex = XMLString::indexOf(name, chColon); - DOMString attValue = attribute.getNodeValue(); - - XMLString::subString(prefix, name, offsetIndex + 1, XMLString::stringLen(name)); - fBuffer.set(attValue.rawBuffer(), attValue.length()); - fNamespaceScope->addPrefix(prefix, fURIStringPool->addOrFind(fBuffer.getRawBuffer())); - } - else if (attName.equals(XMLUni::fgXMLNSString)) { // == 'xmlns' - - DOMString attValue = attribute.getNodeValue(); - - fBuffer.set(attValue.rawBuffer(), attValue.length()); - fNamespaceScope->addPrefix( XMLUni::fgZeroLenString, fURIStringPool->addOrFind(fBuffer.getRawBuffer())); - seenXMLNS = true; - } - } // end for - - if (!seenXMLNS && XMLString::stringLen(fTargetNSURIString) == 0 ) { - fNamespaceScope->addPrefix(XMLUni::fgZeroLenString, fEmptyNamespaceURI); - } -} - -void TraverseSchema::processChildren(const DOM_Element& root) { - - // process <redefine>, <include> and <import> info items. - DOM_Element child = XUtil::getFirstChildElement(root); - - for (; child != 0; child = XUtil::getNextSiblingElement(child)) { - - DOMString name = child.getLocalName(); - - if (name.equals(SchemaSymbols::fgELT_ANNOTATION)) { - traverseAnnotationDecl(child); - } - else if (name.equals(SchemaSymbols::fgELT_INCLUDE)) { - traverseInclude(child); - } - else if (name.equals(SchemaSymbols::fgELT_IMPORT)) { - traverseImport(child); - } - else if (name.equals(SchemaSymbols::fgELT_REDEFINE)) { - traverseRedefine(child); - } - else - break; - } - - // child refers to the first info item which is not <annotation> or - // one of the schema inclusion/importation declarations. - for (; child != 0; child = XUtil::getNextSiblingElement(child)) { - - DOMString name = child.getLocalName(); - const XMLCh* typeName = getElementAttValue(child, SchemaSymbols::fgATT_NAME); - int fullNameId = 0; - - if (typeName) { - - fBuffer.set(fTargetNSURIString); - fBuffer.append(chComma); - fBuffer.append(typeName); - fullNameId = fStringPool->addOrFind(fBuffer.getRawBuffer()); - } - - if (name.equals(SchemaSymbols::fgELT_ANNOTATION)) { - traverseAnnotationDecl(child); - } - else if (name.equals(SchemaSymbols::fgELT_SIMPLETYPE)) { - - if (XMLString::stringLen(typeName)) { - if (fGlobalDeclarations->containsKey(SchemaSymbols::fgELT_SIMPLETYPE, fullNameId) - || fGlobalDeclarations->containsKey(SchemaSymbols::fgELT_COMPLEXTYPE, fullNameId)) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::DuplicateGlobalType, - SchemaSymbols::fgELT_SIMPLETYPE, typeName, SchemaSymbols::fgELT_COMPLEXTYPE); - continue; - } - else { - fGlobalDeclarations->put((void*) SchemaSymbols::fgELT_SIMPLETYPE, fullNameId, 0); - } - } - - traverseSimpleTypeDecl(child); - } - else if (name.equals(SchemaSymbols::fgELT_COMPLEXTYPE)) { - - if (XMLString::stringLen(typeName)) { - if (fGlobalDeclarations->containsKey(SchemaSymbols::fgELT_SIMPLETYPE, fullNameId) - || fGlobalDeclarations->containsKey(SchemaSymbols::fgELT_COMPLEXTYPE, fullNameId)) { - - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::DuplicateGlobalType, - SchemaSymbols::fgELT_COMPLEXTYPE, typeName, SchemaSymbols::fgELT_SIMPLETYPE); - continue; - } - else { - fGlobalDeclarations->put((void*) SchemaSymbols::fgELT_COMPLEXTYPE, fullNameId, 0); - } - } - - traverseComplexTypeDecl(child); - } - else if (name.equals(SchemaSymbols::fgELT_ELEMENT)) { - - if (XMLString::stringLen(typeName)) { - if (fGlobalDeclarations->containsKey(SchemaSymbols::fgELT_ELEMENT, fullNameId)) { - - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::DuplicateGlobalDeclaration, - SchemaSymbols::fgELT_ELEMENT, typeName); - continue; - } - else { - fGlobalDeclarations->put((void*) SchemaSymbols::fgELT_ELEMENT, fullNameId, 0); - } - } - - bool toDelete = true; - QName* elmQName = traverseElementDecl(child, toDelete); - delete elmQName; - } - else if (name.equals(SchemaSymbols::fgELT_ATTRIBUTEGROUP)) { - - if (XMLString::stringLen(typeName)) { - if (fGlobalDeclarations->containsKey(SchemaSymbols::fgELT_ATTRIBUTEGROUP, fullNameId)) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::DuplicateGlobalDeclaration, - SchemaSymbols::fgELT_ATTRIBUTEGROUP, typeName); - continue; - } - else { - fGlobalDeclarations->put((void*) SchemaSymbols::fgELT_ATTRIBUTEGROUP, fullNameId, 0); - } - } - - if (!typeName || !fAttGroupRegistry->containsKey(typeName)) { - traverseAttributeGroupDecl(child, 0); - } - } - else if (name.equals(SchemaSymbols::fgELT_ATTRIBUTE)) { - - if (XMLString::stringLen(typeName)) { - if (fGlobalDeclarations->containsKey(SchemaSymbols::fgELT_ATTRIBUTE, fullNameId)) { - - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::DuplicateAttribute, typeName); - continue; - } - else { - fGlobalDeclarations->put((void*) SchemaSymbols::fgELT_ATTRIBUTE, fullNameId, 0); - } - } - - if (!typeName || !fAttributeDeclRegistry->containsKey(typeName)) { - traverseAttributeDecl( child, 0); - } - } - else if (name.equals(SchemaSymbols::fgELT_GROUP)) { - - if (XMLString::stringLen(typeName)) { - if (fGlobalDeclarations->containsKey(SchemaSymbols::fgELT_GROUP, fullNameId)) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::DuplicateGlobalDeclaration, - SchemaSymbols::fgELT_GROUP, typeName); - continue; - } - else { - fGlobalDeclarations->put((void*) SchemaSymbols::fgELT_GROUP, fullNameId, 0); - } - } - - if (!typeName || !fGroupRegistry->containsKey(fBuffer.getRawBuffer())) { - traverseGroupDecl(child); - } - } - else if (name.equals(SchemaSymbols::fgELT_NOTATION)) { - traverseNotationDecl(child); - } else { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::SchemaElementContentError); - } - } // for each child node -} - - -DOM_Element TraverseSchema::checkContent(const DOM_Element& rootElem, - const DOM_Element& contentElem, - const bool isEmpty) { - - DOM_Element content = contentElem; - const XMLCh* name = getElementAttValue(rootElem,SchemaSymbols::fgATT_NAME); - - if (content == 0) { - if (!isEmpty) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::ContentError, name); - } - - return 0; - } - - if (content.getLocalName().equals(SchemaSymbols::fgELT_ANNOTATION)) { - - traverseAnnotationDecl(contentElem); - content = XUtil::getNextSiblingElement(content); - - if (content == 0) { // must be followed by content - - if (!isEmpty) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::ContentError, name); - } - - return 0; - } - - if (content.getLocalName().equals(SchemaSymbols::fgELT_ANNOTATION)) { - - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::AnnotationError, name); - return 0; - } - } - - return content; -} - - -DatatypeValidator* -TraverseSchema::getDatatypeValidator(const XMLCh* const uriStr, - const XMLCh* const localPartStr) { - - DatatypeValidator* dv = 0; - - if (XMLString::compareString(uriStr, SchemaSymbols::fgURI_SCHEMAFORSCHEMA) == 0) { - dv = fDatatypeRegistry->getDatatypeValidator(localPartStr); - } - else { - - fBuffer.set(uriStr); - fBuffer.append(chComma); - fBuffer.append(localPartStr); - dv = fDatatypeRegistry->getDatatypeValidator(fBuffer.getRawBuffer()); - } - - return dv; -} - - -XMLCh* TraverseSchema::getQualifiedName(const int typeNameIndex) { - - const XMLCh* typeName = fStringPool->getValueForId(typeNameIndex); - - fBuffer.set(fTargetNSURIString); - fBuffer.append(chComma); - fBuffer.append(typeName); - - return fBuffer.getRawBuffer(); -} - - -DatatypeValidator* -TraverseSchema::checkForSimpleTypeValidator(const DOM_Element& content, - int baseRefContext) { - - int typeNameIndex = traverseSimpleTypeDecl(content, baseRefContext); - DatatypeValidator* baseValidator = 0; - - if (typeNameIndex != -1) { - - baseValidator = fDatatypeRegistry->getDatatypeValidator( - fStringPool->getValueForId(typeNameIndex)); - } - - if (typeNameIndex == -1 || baseValidator == 0) { - - const XMLCh* name = getElementAttValue(content,SchemaSymbols::fgATT_NAME); - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::UnknownSimpleType, name); - } - - return baseValidator; -} - -ComplexTypeInfo* -TraverseSchema::checkForComplexTypeInfo(const DOM_Element& content) { - - int typeNameIndex = traverseComplexTypeDecl(content); - ComplexTypeInfo* baseTypeInfo = 0; - - if (typeNameIndex != -1) { - baseTypeInfo = fComplexTypeRegistry->get( - fStringPool->getValueForId(typeNameIndex)); - } - - if (typeNameIndex == -1 || baseTypeInfo == 0) { - - const XMLCh* name = getElementAttValue(content,SchemaSymbols::fgATT_NAME); - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::UnknownComplexType, name); - } - - return baseTypeInfo; -} - -DatatypeValidator* -TraverseSchema::findDTValidator(const DOM_Element& rootElem, - const XMLCh* const baseTypeStr, - const int baseRefContext) { - - const XMLCh* prefix = getPrefix(baseTypeStr); - const XMLCh* localPart = getLocalPart(baseTypeStr); - const XMLCh* uri = resolvePrefixToURI(prefix); - DatatypeValidator* baseValidator = getDatatypeValidator(uri, localPart); - - if (baseValidator == 0) { - - SchemaInfo* saveInfo = fSchemaInfo; - DOM_Element baseTypeNode = - fSchemaInfo->getTopLevelComponent(SchemaSymbols::fgELT_SIMPLETYPE, localPart, &fSchemaInfo); - - if (baseTypeNode != 0) { - - traverseSimpleTypeDecl(baseTypeNode); - baseValidator = getDatatypeValidator(uri, localPart); - - // restore schema information, if necessary - fSchemaInfo = saveInfo; - } - } - - if (baseValidator == 0) { - reportSchemaError(XMLUni::fgValidityDomain, XMLValid::UnknownBaseDatatype, baseTypeStr, - getElementAttValue(rootElem, SchemaSymbols::fgATT_NAME)); - } - else { - - int finalSet = baseValidator->getFinalSet(); - - if (finalSet !=0 && ((finalSet & baseRefContext) != 0)) { - - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::DisallowedBaseDerivation, baseTypeStr); - return 0; - } - } - - return baseValidator; -} - - -const XMLCh* TraverseSchema::resolvePrefixToURI(const XMLCh* const prefix) { - - int nameSpaceIndex = fNamespaceScope->getNamespaceForPrefix(prefix, fSchemaInfo->getNamespaceScopeLevel()); - const XMLCh* uriStr = fURIStringPool->getValueForId(nameSpaceIndex); - - if (!XMLString::stringLen(uriStr) && XMLString::stringLen(prefix)) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::UnresolvedPrefix, prefix); - return XMLUni::fgZeroLenString; - } - - return uriStr; -} - -const XMLCh* TraverseSchema::resolvePrefixToURI(const XMLCh* const prefix, - const unsigned int namespaceDepth) { - - int nameSpaceIndex = fNamespaceScope->getNamespaceForPrefix(prefix, namespaceDepth); - const XMLCh* uriStr = fURIStringPool->getValueForId(nameSpaceIndex); - - if (!XMLString::stringLen(uriStr) && XMLString::stringLen(prefix)) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::UnresolvedPrefix, prefix); - return XMLUni::fgZeroLenString; - } - - return uriStr; -} - - -bool TraverseSchema::isTopLevelComponent(const DOM_Element& elem) { - - DOMString parentName = elem.getParentNode().getLocalName(); - - fBuffer.set(parentName.rawBuffer(), parentName.length()); - XMLCh* nameStr = fBuffer.getRawBuffer(); - - return (XMLString::endsWith(nameStr, SchemaSymbols::fgELT_SCHEMA)) - || (XMLString::endsWith(nameStr, SchemaSymbols::fgELT_REDEFINE)); -} - -QName* TraverseSchema::processElementDeclRef(const DOM_Element& elem, - const XMLCh* const refName, - bool& toDelete) { - - DOM_Element content = checkContent(elem, XUtil::getFirstChildElement(elem), - true); - - if (content != 0) { - reportSchemaError(XMLUni::fgValidityDomain, XMLValid::NoContentForRef, SchemaSymbols::fgELT_ELEMENT); - } - - const XMLCh* prefix = getPrefix(refName); - const XMLCh* localPart = getLocalPart(refName); - const XMLCh* uriStr = resolvePrefixToURI(prefix); - QName* eltName = new QName(prefix , localPart, uriStr != 0 - ? fURIStringPool->addOrFind(uriStr) - : fEmptyNamespaceURI); // StringPool.EMPTY_STRING == 0 - - //if from another schema, just return the element QName - if (XMLString::compareString(uriStr, fTargetNSURIString) != 0) { - return eltName; - } - - unsigned int uriID = eltName->getURI(); - SchemaElementDecl* refElemDecl = (SchemaElementDecl*) - fSchemaGrammar->getElemDecl(uriID, localPart, 0, Grammar::TOP_LEVEL_SCOPE); - - //if not found, traverse the top level element that is referenced - if (!refElemDecl) { - - SchemaInfo* saveInfo = fSchemaInfo; - DOM_Element targetElem = fSchemaInfo->getTopLevelComponent(SchemaSymbols::fgELT_ELEMENT, localPart, &fSchemaInfo); - - if (targetElem == 0) { - - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::RefElementNotFound, localPart); - // REVISIT do we return 0 or what? for now we will return QName created - return eltName; - } - else { - - // problems with recursive declarations -/* - delete eltName; - eltName = traverseElementDecl(targetElem); - refElemDecl = (SchemaElementDecl*) - fSchemaGrammar->getElemDecl(uriID, localPart, 0, Grammar::TOP_LEVEL_SCOPE); -*/ - - // restore schema information - fSchemaInfo = saveInfo; - } - } - - if (fFullConstraintChecking) { - - toDelete = false; - fRefElements->addElement(eltName); - fRefElemScope->addElement(fCurrentScope); - } - - return eltName; -} - -int TraverseSchema::parseBlockSet(const XMLCh* const blockStr, - const int blockType) { - - if (!XMLString::stringLen(blockStr)) { - return fBlockDefault; - } - - int blockSet = 0; - - if (!XMLString::compareString(blockStr, SchemaSymbols::fgATTVAL_POUNDALL)) { - - blockSet = SchemaSymbols::EXTENSION + SchemaSymbols::RESTRICTION + SchemaSymbols::SUBSTITUTION; - return blockSet; - } - - XMLStringTokenizer tokenizer(blockStr); - - while (tokenizer.hasMoreTokens()) { - - XMLCh* token = tokenizer.nextToken(); - - if (!XMLString::compareString(token, SchemaSymbols::fgATTVAL_SUBSTITUTION) - && blockType == ES_Block) { - - if ((blockSet & SchemaSymbols::SUBSTITUTION) == 0 ) { - blockSet += SchemaSymbols::SUBSTITUTION; - } - else { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::SubstitutionRepeated); - } - } - else if (!XMLString::compareString(token, SchemaSymbols::fgATTVAL_EXTENSION)) { - - if ((blockSet & SchemaSymbols::EXTENSION) == 0) { - blockSet += SchemaSymbols::EXTENSION; - } - else { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::ExtensionRepeated); - } - } - else if (!XMLString::compareString(token, SchemaSymbols::fgATTVAL_RESTRICTION)) { - - if ((blockSet & SchemaSymbols::RESTRICTION) == 0 ) { - blockSet += SchemaSymbols::RESTRICTION; - } - else { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::RestrictionRepeated); - } - } - else { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::InvalidBlockValue, blockStr); - } - } //end while - - return (blockSet == 0 ? fBlockDefault : blockSet); -} - -int TraverseSchema::parseFinalSet(const XMLCh* const finalStr, - const int finalType) { - - if (!XMLString::stringLen(finalStr)) { - return fFinalDefault; - } - - int finalSet = 0; - - if (!XMLString::compareString(finalStr, SchemaSymbols::fgATTVAL_POUNDALL)) { - - finalSet = SchemaSymbols::RESTRICTION + SchemaSymbols::LIST + - SchemaSymbols::UNION + SchemaSymbols::EXTENSION; - return finalSet; - } - - XMLStringTokenizer tokenizer(finalStr); - - while (tokenizer.hasMoreTokens()) { - - XMLCh* token = tokenizer.nextToken(); - - if (!XMLString::compareString(token, SchemaSymbols::fgELT_UNION) - && finalType == S_Final) { - - if ((finalSet & SchemaSymbols::UNION) == 0) { - finalSet += SchemaSymbols::UNION; - } - else { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::UnionRepeated); - } - } - else if (!XMLString::compareString(token, SchemaSymbols::fgATTVAL_EXTENSION) - && finalType != S_Final) { - - if ((finalSet & SchemaSymbols::EXTENSION) == 0) { - finalSet += SchemaSymbols::EXTENSION; - } - else { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::ExtensionRepeated); - } - } - else if (!XMLString::compareString(token, SchemaSymbols::fgELT_LIST) - && finalType == S_Final) { - - if ((finalSet & SchemaSymbols::LIST) == 0 ) { - finalSet += SchemaSymbols::LIST; - } - else { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::ListRepeated); - } - } - else if (!XMLString::compareString(token, SchemaSymbols::fgATTVAL_RESTRICTION)) { - - if ((finalSet & SchemaSymbols::RESTRICTION) == 0 ) { - finalSet += SchemaSymbols::RESTRICTION; - } - else { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::RestrictionRepeated); - } - } - else { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::InvalidFinalValue, finalStr); - } - } //end while - - return (finalSet == 0 ? fFinalDefault : finalSet); -} - - -DOM_Element -TraverseSchema::checkIdentityConstraintContent(const DOM_Element& content) { - - DOM_Element child = content; - - if (child != 0) { - - do { - - DOMString childName = child.getLocalName(); - fBuffer.set(childName.rawBuffer(), childName.length()); - - if (!isIdentityConstraintName(fBuffer.getRawBuffer())) { - break; - } - - child = XUtil::getNextSiblingElement(child); - - } while (child != 0); - } - - return child; -} - -bool TraverseSchema::isIdentityConstraintName(const XMLCh* const name) { - - return (XMLString::compareString(name, SchemaSymbols::fgELT_KEY) == 0 - || XMLString::compareString(name, SchemaSymbols::fgELT_KEYREF) == 0 - || XMLString::compareString(name, SchemaSymbols::fgELT_UNIQUE) == 0); -} - -const XMLCh* -TraverseSchema::checkTypeFromAnotherSchema(const XMLCh* const typeStr) { - - const XMLCh* prefix = getPrefix(typeStr); - const XMLCh* typeURI = resolvePrefixToURI(prefix); - - if (XMLString::compareString(typeURI, fTargetNSURIString) != 0 - && XMLString::compareString(typeURI, - SchemaSymbols::fgURI_SCHEMAFORSCHEMA) != 0 - && XMLString::stringLen(typeURI) != 0) { - return typeURI; - } - - return 0; -} - -DatatypeValidator* -TraverseSchema::getElementTypeValidator(const XMLCh* const typeStr, - bool& noErrorDetected, - const XMLCh* const otherSchemaURI, - bool errorCheck) -{ - const XMLCh* localPart = getLocalPart(typeStr); - const XMLCh* typeURI = otherSchemaURI; - DatatypeValidator* dv = 0; - - if (otherSchemaURI != 0) { - dv = getDatatypeValidator(typeURI, localPart); - } - else { - const XMLCh* prefix = getPrefix(typeStr); - - typeURI = resolvePrefixToURI(prefix); - dv = getDatatypeValidator(typeURI, localPart); - - if (dv == 0) { - - if (XMLString::compareString(typeURI, SchemaSymbols::fgURI_SCHEMAFORSCHEMA) != 0 - || XMLString::compareString(fTargetNSURIString, SchemaSymbols::fgURI_SCHEMAFORSCHEMA) == 0) { - - SchemaInfo* saveInfo = fSchemaInfo; - DOM_Element elem = fSchemaInfo->getTopLevelComponent(SchemaSymbols::fgELT_SIMPLETYPE, localPart, &fSchemaInfo); - - if (elem != 0 && traverseSimpleTypeDecl(elem) != -1) { - dv = getDatatypeValidator(typeURI, localPart); - } - - // restore schema information - fSchemaInfo = saveInfo; - } - } - } - - if (dv == 0 && errorCheck) { - noErrorDetected = false; - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::TypeNotFound, typeURI, localPart); - } - - return dv; -} - - -ComplexTypeInfo* -TraverseSchema::getElementComplexTypeInfo(const XMLCh* const typeStr, - bool& noErrorDetected, - const XMLCh* const otherSchemaURI) -{ - const XMLCh* localPart = getLocalPart(typeStr); - const XMLCh* prefix = getPrefix(typeStr); - const XMLCh* typeURI = (otherSchemaURI) ? otherSchemaURI : resolvePrefixToURI(prefix); - ComplexTypeInfo* typeInfo = 0; - SchemaInfo* saveInfo = fSchemaInfo; - SchemaInfo::ListType infoType = SchemaInfo::INCLUDE; - - fBuffer.set(typeURI); - fBuffer.append(chComma); - fBuffer.append(localPart); - - if (otherSchemaURI != 0) { - - Grammar* aGrammar = fGrammarResolver->getGrammar(typeURI); - - if (!aGrammar || aGrammar->getGrammarType() != Grammar::SchemaGrammarType) { - - reportSchemaError(XMLUni::fgValidityDomain, XMLValid::GrammarNotFound, typeURI); - return 0; - } - - typeInfo = ((SchemaGrammar*)aGrammar)->getComplexTypeRegistry()->get(fBuffer.getRawBuffer()); - - if (typeInfo) { - return typeInfo; - } - - SchemaInfo* impInfo = fSchemaInfo->getImportInfo(fURIStringPool->addOrFind(typeURI)); - - if (!impInfo) { - return 0; - } - - infoType = SchemaInfo::IMPORT; - fSchemaInfo->setCurrentScope(fCurrentScope); - fSchemaInfo->setScopeCount(fScopeCount); - restoreSchemaInfo(impInfo, infoType); - } - else { - typeInfo = fComplexTypeRegistry->get(fBuffer.getRawBuffer()); - } - - if (!typeInfo) { - - if (XMLString::compareString(typeURI, SchemaSymbols::fgURI_SCHEMAFORSCHEMA) != 0 || - XMLString::compareString(fTargetNSURIString, SchemaSymbols::fgURI_SCHEMAFORSCHEMA) == 0) { - - DOM_Element elem = fSchemaInfo->getTopLevelComponent(SchemaSymbols::fgELT_COMPLEXTYPE, localPart, &fSchemaInfo); - - if (elem != 0) { - - int typeIndex = traverseComplexTypeDecl(elem); - typeInfo = fComplexTypeRegistry->get(fStringPool->getValueForId(typeIndex)); - } - } - } - - // restore schema information, if necessary - if (saveInfo != fSchemaInfo) { - restoreSchemaInfo(saveInfo, infoType); - } - - return typeInfo; -} - - -SchemaElementDecl* -TraverseSchema::getSubstituteGroupElemDecl(const XMLCh* const name, - bool& noErrorDetected) { - - const XMLCh* nameURI = resolvePrefixToURI(getPrefix(name)); - const XMLCh* localPart = getLocalPart(name); - SchemaElementDecl* elemDecl = 0; - SchemaInfo* saveInfo = fSchemaInfo; - SchemaInfo::ListType infoType = SchemaInfo::INCLUDE; - - if (XMLString::compareString(nameURI, fTargetNSURIString) != 0) { - - Grammar* grammar = fGrammarResolver->getGrammar(nameURI); - unsigned int uriId = fURIStringPool->addOrFind(nameURI); - - if (grammar && grammar->getGrammarType() == Grammar::SchemaGrammarType) { - elemDecl = (SchemaElementDecl*) - grammar->getElemDecl(uriId, localPart, 0, Grammar::TOP_LEVEL_SCOPE); - } - else { - - reportSchemaError(XMLUni::fgValidityDomain, XMLValid::GrammarNotFound, nameURI); - return 0; - } - - if (!elemDecl) { - - SchemaInfo* impInfo = fSchemaInfo->getImportInfo(uriId); - - if (!impInfo) { - - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::TypeNotFound, nameURI, localPart); - return 0; - } - - infoType = SchemaInfo::IMPORT; - fSchemaInfo->setCurrentScope(fCurrentScope); - fSchemaInfo->setScopeCount(fScopeCount); - restoreSchemaInfo(impInfo, infoType); - } - } - else { - elemDecl = (SchemaElementDecl*) - fSchemaGrammar->getElemDecl(fTargetNSURI, localPart, 0, Grammar::TOP_LEVEL_SCOPE); - } - - if (!elemDecl) { - - DOM_Element subsGroupElem = fSchemaInfo->getTopLevelComponent(SchemaSymbols::fgELT_ELEMENT,localPart, &fSchemaInfo); - - if (subsGroupElem != 0) { - - bool toDelete = true; - QName* subsGroupQName = traverseElementDecl(subsGroupElem, toDelete); - Janitor<QName> janQName(subsGroupQName); - - if (subsGroupQName) { - elemDecl = (SchemaElementDecl*) fSchemaGrammar->getElemDecl(fTargetNSURI, localPart,0, Grammar::TOP_LEVEL_SCOPE); - } - - if (!elemDecl) { - - noErrorDetected = false; - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::TypeNotFound, nameURI, localPart); - } - } - else { - noErrorDetected = false; - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::TypeNotFound, nameURI, localPart); - } - } - - // restore schema information, if necessary - if (saveInfo != fSchemaInfo) { - restoreSchemaInfo(saveInfo, infoType); - } - - return elemDecl; -} - -bool -TraverseSchema::isSubstitutionGroupValid(const SchemaElementDecl* const subsElemDecl, - const ComplexTypeInfo* const typeInfo, - const DatatypeValidator* const validator, - const XMLCh* const elemName, - const bool toEmit) { - - // here we must do two things: - // 1. Make sure there actually *is* a relation between the types of - // the element being nominated and the element doing the nominating; - // (see PR 3.3.6 point #3 in the first tableau, for instance; this - // and the corresponding tableaux from 3.4.6 and 3.14.6 rule out the nominated - // element having an anonymous type declaration. - // 2. Make sure the nominated element allows itself to be nominated by - // an element with the given type-relation. - // Note: we assume that (complex|simple)Type processing checks - // whether the type in question allows itself to - // be modified as this element desires. - - // if substitution element has any as content model type, return true - if (subsElemDecl->getModelType() == SchemaElementDecl::Any) { - return true; - } - - bool subsRestricted = false; - - // Check for type relationship; - // that is, make sure that the type we're deriving has some relatoinship - // to substitutionGroupElt's type. - if (typeInfo) { // do complexType case ...need testing - - int derivationMethod = typeInfo->getDerivedBy(); - - if (typeInfo->getContentType() == SchemaElementDecl::Simple) { // take care of complexType based on simpleType case... - - DatatypeValidator* elemDV = typeInfo->getDatatypeValidator(); - DatatypeValidator* subsValidator = subsElemDecl->getDatatypeValidator(); - - if (subsValidator && subsValidator->isSubstitutableBy(elemDV)) { - if ((subsElemDecl->getFinalSet() & derivationMethod) == 0) { - return true; - } - else { - subsRestricted = true; - } - } - } - else { // complex content - - ComplexTypeInfo* subsTypeInfo = subsElemDecl->getComplexTypeInfo(); - const ComplexTypeInfo* elemTypeInfo = typeInfo; - - for (; elemTypeInfo && elemTypeInfo != subsTypeInfo; - elemTypeInfo = elemTypeInfo->getBaseComplexTypeInfo()) { - } - - if (elemTypeInfo) { - if ((subsElemDecl->getFinalSet() & derivationMethod) == 0) { - return true; - } - else { - subsRestricted = true; - } - } - } - } - else if (validator) { // do simpleType case... - - // first, check for type relation. - DatatypeValidator* subsValidator = subsElemDecl->getDatatypeValidator(); - - if (subsValidator && subsValidator->isSubstitutableBy(validator) - && ((subsElemDecl->getFinalSet() & SchemaSymbols::RESTRICTION) == 0)) { - return true; - } - } - - if (toEmit) { - if (subsRestricted) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::InvalidSubstitutionGroupElement, - elemName, subsElemDecl->getBaseName()); - } - else { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::SubstitutionGroupTypeMismatch, elemName); - } - } - - return false; -} - - -SchemaElementDecl* -TraverseSchema::createSchemaElementDecl(const DOM_Element& elem, - const bool topLevel, - const unsigned short elemType, - bool& isDuplicate, - const bool isFixedVal) -{ - const XMLCh* name = getElementAttValue(elem, SchemaSymbols::fgATT_NAME); - const XMLCh* elemForm = getElementAttValue(elem, SchemaSymbols::fgATT_FORM); - int enclosingScope = fCurrentScope; - int uriIndex = fEmptyNamespaceURI; - - //refer to 4.3.2 in "XML Schema Part 1: Structures" - if (topLevel) { - - uriIndex = fTargetNSURI; - enclosingScope = Grammar::TOP_LEVEL_SCOPE; - } - else if ((XMLString::stringLen(elemForm) == 0 && - (fSchemaInfo->getElemAttrDefaultQualified() & Elem_Def_Qualified)) - || XMLString::compareString(elemForm,SchemaSymbols::fgATTVAL_QUALIFIED) == 0) { - - uriIndex = fTargetNSURI; - } - - // Check for duplicate elements - SchemaElementDecl* other = (SchemaElementDecl*) - fSchemaGrammar->getElemDecl(uriIndex, name, 0, enclosingScope); - - if (other != 0) { - - isDuplicate = true; - return other; - } - - const XMLCh* block = getElementAttValue(elem,SchemaSymbols::fgATT_BLOCK); - const XMLCh* final = getElementAttValue(elem,SchemaSymbols::fgATT_FINAL); - int blockSet = parseBlockSet(block, ES_Block); - int finalSet = parseFinalSet(final, EC_Final); - int elementMiscFlags = 0; - const XMLCh* nillable = getElementAttValue(elem, SchemaSymbols::fgATT_NILLABLE); - const XMLCh* abstract = getElementAttValue(elem, SchemaSymbols::fgATT_ABSTRACT); - - if (XMLString::stringLen(nillable)) { - - if (!XMLString::compareString(nillable, SchemaSymbols::fgATTVAL_TRUE) - || !XMLString::compareString(nillable, fgValueOne)) { - elementMiscFlags += SchemaSymbols::NILLABLE; - } - } - - if (XMLString::stringLen(abstract)) { - - if (!XMLString::compareString(abstract, SchemaSymbols::fgATTVAL_TRUE) - || !XMLString::compareString(abstract, fgValueOne)) { - elementMiscFlags += SchemaSymbols::ABSTRACT; - } - } - - if (isFixedVal) { - elementMiscFlags += SchemaSymbols::FIXED; - } - - const XMLCh* prefix = getPrefix(name); - SchemaElementDecl* elemDecl = - new SchemaElementDecl(prefix, name, uriIndex, - (SchemaElementDecl::ModelTypes) elemType, - enclosingScope); - - elemDecl->setFinalSet(finalSet); - elemDecl->setBlockSet(blockSet); - elemDecl->setMiscFlags(elementMiscFlags); - elemDecl->setCreateReason(XMLElementDecl::Declared); - - return elemDecl; -} - - -void TraverseSchema::processAttributeDeclRef(const DOM_Element& elem, - ComplexTypeInfo* const typeInfo, - const XMLCh* const refName, - const XMLCh* const useAttr, - const XMLCh* const defaultVal, - const XMLCh* const fixedVal) { - - if (!typeInfo && !fCurrentAttGroupInfo) { - return; - } - - const XMLCh* prefix = getPrefix(refName); - const XMLCh* localPart = getLocalPart(refName); - const XMLCh* uriStr = resolvePrefixToURI(prefix); - unsigned int attURI = fURIStringPool->addOrFind(uriStr); - - // Check for duplicate references - if (typeInfo && typeInfo->getAttDef(localPart, attURI)) { - - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::DuplicateRefAttribute, uriStr, localPart); - return; - } - else if (fCurrentAttGroupInfo && fCurrentAttGroupInfo->containsAttribute(localPart, attURI)) { - - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::DuplicateRefAttribute, uriStr, localPart); - return; - } - - // check for different namespace - SchemaInfo* saveInfo = fSchemaInfo; - SchemaInfo::ListType infoType = SchemaInfo::INCLUDE; - SchemaAttDef* refAttDef = 0; - - if (XMLString::compareString(uriStr, fTargetNSURIString) != 0) { - - Grammar* grammar = fGrammarResolver->getGrammar(uriStr); - - if (grammar == 0 || grammar->getGrammarType() != Grammar::SchemaGrammarType) { - - reportSchemaError(XMLUni::fgValidityDomain, XMLValid::GrammarNotFound, uriStr); - return; - } - - refAttDef = (SchemaAttDef*) ((SchemaGrammar*) grammar)->getAttributeDeclRegistry()->get(localPart); - - if (!refAttDef) { - - SchemaInfo* impInfo = fSchemaInfo->getImportInfo(attURI); - - if (!impInfo) { - - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::TopLevelAttributeNotFound, refName); - return; - } - - infoType = SchemaInfo::IMPORT; - fSchemaInfo->setCurrentScope(fCurrentScope); - fSchemaInfo->setScopeCount(fScopeCount); - restoreSchemaInfo(impInfo, infoType); - } - } - - // if Global attribute registry does not contain the ref attribute, get - // the referred attribute declaration and traverse it. - if (!refAttDef) { - - if (fAttributeDeclRegistry->containsKey(localPart) == false) { - - DOM_Element referredAttribute = - fSchemaInfo->getTopLevelComponent(SchemaSymbols::fgELT_ATTRIBUTE, localPart, &fSchemaInfo); - - if (referredAttribute != 0) { - traverseAttributeDecl(referredAttribute, 0); - } - } - - refAttDef = (SchemaAttDef*) fAttributeDeclRegistry->get(localPart); - } - - // restore schema information, if necessary - if (fSchemaInfo != saveInfo) { - restoreSchemaInfo(saveInfo, infoType); - } - - if (!refAttDef) { - - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::TopLevelAttributeNotFound, refName); - return; - } - - XMLAttDef::DefAttTypes refAttDefType = refAttDef->getDefaultType(); - const XMLCh* refAttValue = refAttDef->getValue(); - bool invalidAttUse = false; - - if (refAttDefType == XMLAttDef::Fixed && - (defaultVal || (fixedVal && XMLString::compareString(fixedVal, refAttValue)))) { - - invalidAttUse = true; - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::AttUseCorrect, refName); - } - - DatatypeValidator* attDV = refAttDef->getDatatypeValidator(); - - //check for multiple attributes with type derived from ID - if (attDV && attDV->getType() == DatatypeValidator::ID) { - - if (fCurrentAttGroupInfo) { - - if (fCurrentAttGroupInfo->containsTypeWithId()) { - - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::AttGrpPropCorrect3, refName); - return; - } - - fCurrentAttGroupInfo->setTypeWithId(true); - } - else { - - if (typeInfo->containsAttWithTypeId()) { - - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::AttDeclPropCorrect5, refName); - return; - } - - typeInfo->setAttWithTypeId(true); - } - } - - bool required = (XMLString::compareString(useAttr,SchemaSymbols::fgATTVAL_REQUIRED) == 0); - bool prohibited = (XMLString::compareString(useAttr,SchemaSymbols::fgATTVAL_PROHIBITED) == 0); - QName* attQName = refAttDef->getAttName(); - SchemaAttDef* attDef = new SchemaAttDef(attQName->getPrefix(), - attQName->getLocalPart(), - attQName->getURI(), - refAttValue, - refAttDef->getType(), - refAttDefType); - - if (refAttDefType == XMLAttDef::Fixed) { - if (required && !invalidAttUse) { - attDef->setDefaultType(XMLAttDef::Required_And_Fixed); - } - } - else { - - if (prohibited) { - attDef->setDefaultType(XMLAttDef::Prohibited); - } - else { - - const XMLCh* valueConstraint = defaultVal; - - if (required){ - - if (fixedVal) { - - attDef->setDefaultType(XMLAttDef::Required_And_Fixed); - valueConstraint = fixedVal; - } - else { - attDef->setDefaultType(XMLAttDef::Required); - } - } - - if (valueConstraint) { - - // validate content of value constraint - if (attDV) { - - if (attDV->getType() == DatatypeValidator::ID) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::AttDeclPropCorrect3, - SchemaSymbols::fgATT_REF, refName); - } - else { - try { - attDV->validate(valueConstraint); - } - catch(const XMLException& excep) { - reportSchemaError(XMLUni::fgValidityDomain, XMLValid::DisplayErrorMessage, excep.getMessage()); - } - catch (...) { - reportSchemaError(XMLUni::fgValidityDomain, XMLValid::DatatypeValidationFailure, valueConstraint); - } - } - } - - attDef->setValue(valueConstraint); - } - } - } - - attDef->setDatatypeValidator(attDV); - - bool toClone = false; - - if (typeInfo) { - - toClone = true; - typeInfo->addAttDef(attDef); - } - - if (fCurrentAttGroupInfo) { - fCurrentAttGroupInfo->addAttDef(attDef, toClone); - } -} - - -void TraverseSchema::checkMinMax(ContentSpecNode* const specNode, - const DOM_Element& elem, - const int allContextFlag) { - - unsigned int minOccurs = 0; - unsigned int maxOccurs = 0; - const XMLCh* minOccursStr = - getElementAttValue(elem, SchemaSymbols::fgATT_MINOCCURS, true); - const XMLCh* maxOccursStr = - getElementAttValue(elem, SchemaSymbols::fgATT_MAXOCCURS, true); - - if (XMLString::stringLen(minOccursStr) == 0) { - if (specNode) - minOccurs = specNode->getMinOccurs(); - else - minOccurs = 1; - } - else { - XMLString::textToBin(minOccursStr, minOccurs); - if (specNode) - specNode->setMinOccurs(minOccurs); - } - - bool isMaxUnbounded = - (XMLString::compareString(maxOccursStr, fgUnbounded) == 0); - - if (isMaxUnbounded) { - maxOccurs = SchemaSymbols::UNBOUNDED; - if (specNode) - specNode->setMaxOccurs(maxOccurs); - } - else { - if (XMLString::stringLen(maxOccursStr) == 0) { - if (specNode) - maxOccurs = specNode->getMaxOccurs(); - else - maxOccurs = 1; - } - else { - XMLString::textToBin(maxOccursStr, maxOccurs); - if (specNode) - specNode->setMaxOccurs(maxOccurs); - } - } - - // Constraint checking for min/max value - if (!isMaxUnbounded) { - - XMLCh tmpMinStr[128]; - XMLCh tmpMaxStr[128]; - - XMLString::binToText(minOccurs, tmpMinStr, 127, 10); - XMLString::binToText(maxOccurs, tmpMaxStr, 127, 10); - - if (maxOccurs < 1) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::InvalidAttValue, - tmpMaxStr, SchemaSymbols::fgATT_MAXOCCURS); - if (specNode) - specNode->setMaxOccurs(minOccurs); - } - else if (maxOccurs < minOccurs) { - - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::InvalidMin2MaxOccurs, - tmpMinStr, tmpMaxStr); - if (specNode) - specNode->setMaxOccurs(minOccurs); - } - } - - if (minOccurs == 0 && maxOccurs == 0){ - return; - } - - // Constraint checking for 'all' content - bool isAllElement = (allContextFlag == All_Element); - bool isAllGroup = (allContextFlag == All_Group); - bool isGroupRefAll = (allContextFlag == Group_Ref_With_All); - - if (isAllElement || isAllGroup || isGroupRefAll) { - - if (maxOccurs != 1 - || ((isAllGroup || isGroupRefAll || minOccurs != 0) - && minOccurs != 1)) { - - // set back correct value in order to carry on - if (specNode) { - specNode->setMaxOccurs(1); - if (isAllGroup || isGroupRefAll) - specNode->setMinOccurs(1); - else - specNode->setMinOccurs(0); - } - - if (isAllElement) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::BadMinMaxAllElem); - } - else { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::BadMinMaxAllCT); - } - } - } -} - - -void TraverseSchema::processComplexContent(const XMLCh* const typeName, - const DOM_Element& childElem, - ComplexTypeInfo* const typeInfo, - const XMLCh* const baseRawName, - const XMLCh* const baseLocalPart, - const XMLCh* const baseURI, - const bool isMixed, - const bool isBaseAnyType) { - - ContentSpecNode* specNode = 0; - DOM_Element attrNode; - int typeDerivedBy = SchemaSymbols::EMPTY_SET; - ComplexTypeInfo* baseTypeInfo = typeInfo->getBaseComplexTypeInfo(); - - if (baseTypeInfo) { - - if (typeInfo->getDerivedBy() == SchemaSymbols::RESTRICTION) { - - typeDerivedBy = SchemaSymbols::RESTRICTION; - - // check to see if the baseType permits derivation by restriction - if((baseTypeInfo->getFinalSet() & typeDerivedBy) != 0) { - - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::ForbiddenDerivationByRestriction, - baseLocalPart); - throw TraverseSchema::InvalidComplexTypeInfo; - } - } - else { - - typeDerivedBy = SchemaSymbols::EXTENSION; - - // check to see if the baseType permits derivation by extension - if((baseTypeInfo->getFinalSet() & typeDerivedBy) != 0) { - - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::ForbiddenDerivationByExtension, baseLocalPart); - throw TraverseSchema::InvalidComplexTypeInfo; // REVISIT - should we continue - } - - // Check for derivation valid (extension) - 1.4.2.2 - int baseContentType = baseTypeInfo->getContentType(); - - if (baseContentType != SchemaElementDecl::Empty) { - if ((isMixed && baseContentType == SchemaElementDecl::Children) - || (!isMixed && baseContentType == SchemaElementDecl::Mixed_Complex)) { - - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::MixedOrElementOnly, baseLocalPart, typeName); - throw TraverseSchema::InvalidComplexTypeInfo; //REVISIT - should we continue - } - } - - processElements(baseTypeInfo, typeInfo); - } - } - - if (childElem != 0) { - - fCircularCheckIndex = fCurrentTypeNameStack->size(); - - // -------------------------------------------------------------------- - // GROUP, ALL, SEQUENCE or CHOICE, followed by attributes, if specified. - // Note that it's possible that only attributes are specified. - // -------------------------------------------------------------------- - DOMString childName = childElem.getLocalName(); - - if (childName.equals(SchemaSymbols::fgELT_GROUP)) { - - XercesGroupInfo* grpInfo = traverseGroupDecl(childElem); - - if (grpInfo) { - - specNode = grpInfo->getContentSpec(); - - if (specNode) { - - int contentContext = hasAllContent(specNode) ? Group_Ref_With_All : Not_All_Context; - - specNode = new ContentSpecNode(*specNode); - checkMinMax(specNode, childElem, contentContext); - } - } - - attrNode = XUtil::getNextSiblingElement(childElem); - - } - else if (childName.equals(SchemaSymbols::fgELT_SEQUENCE)) { - - specNode = traverseChoiceSequence(childElem, ContentSpecNode::Sequence); - checkMinMax(specNode, childElem); - attrNode = XUtil::getNextSiblingElement(childElem); - } - else if (childName.equals(SchemaSymbols::fgELT_CHOICE)) { - - specNode = traverseChoiceSequence(childElem, ContentSpecNode::Choice); - checkMinMax(specNode, childElem); - attrNode = XUtil::getNextSiblingElement(childElem); - } - else if (childName.equals(SchemaSymbols::fgELT_ALL)) { - - specNode = traverseAll(childElem); - checkMinMax(specNode, childElem, All_Group); - attrNode = XUtil::getNextSiblingElement(childElem); - } - else if (isAttrOrAttrGroup(childElem)) { - // reset the contentType - typeInfo->setContentType(SchemaElementDecl::Any); - attrNode = childElem; - } - else { - - fBuffer.set(childName.rawBuffer(), childName.length()); - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::InvalidChildInComplexType, - fBuffer.getRawBuffer()); - } - } - - typeInfo->setContentSpec(specNode); - typeInfo->setAdoptContentSpec(true); - - // ----------------------------------------------------------------------- - // Merge in information from base, if it exists - // ----------------------------------------------------------------------- - if (baseTypeInfo != 0) { - - ContentSpecNode* baseSpecNode = baseTypeInfo->getContentSpec(); - - if (typeDerivedBy == SchemaSymbols::RESTRICTION) { - - //check derivation valid - content type is empty (5.2) - if (!typeInfo->getContentSpec()) { - - if (baseTypeInfo->getContentType() != SchemaElementDecl::Empty - && !emptiableParticle(baseSpecNode)) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::EmptyComplexRestrictionDerivation); - } - } - else { // if base has no content spec, invalid derivation - if (!baseTypeInfo->getContentSpec()) { - - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::PD_EmptyBase); - throw TraverseSchema::InvalidComplexTypeInfo; //REVISIT - should we continue - } - } - - // Delay particle constraint checking (5.3) until we have processed - // the whole schema. - } - else { - - // Compose the final content model by concatenating the base and - // the current in sequence - if (!specNode) { - - if (baseSpecNode) { - specNode = new ContentSpecNode(*baseSpecNode); - typeInfo->setContentSpec(specNode); - typeInfo->setAdoptContentSpec(true); - } - } - else if (baseSpecNode != 0) { - - typeInfo->setAdoptContentSpec(false); - typeInfo->setContentSpec( - new ContentSpecNode(ContentSpecNode::Sequence, - new ContentSpecNode(*baseSpecNode), - specNode)); - typeInfo->setAdoptContentSpec(true); - } - } - } - else { - - if (isBaseAnyType && !specNode) { - - QName elemName(XMLUni::fgZeroLenString, XMLUni::fgZeroLenString, fEmptyNamespaceURI); - specNode = new ContentSpecNode(&elemName); - specNode->setType(ContentSpecNode::Any); - specNode->setMinOccurs(0); - specNode->setMaxOccurs(SchemaSymbols::UNBOUNDED); - typeInfo->setContentSpec(specNode); - } - - typeInfo->setDerivedBy(0); - } - - // ------------------------------------------------------------- - // Set the content type - // ------------------------------------------------------------- - if (isMixed) { - - if (specNode != 0) { - typeInfo->setContentType(SchemaElementDecl::Mixed_Complex); - } - else { - // add #PCDATA leaf and set its minOccurs to 0 - ContentSpecNode* pcdataNode = - new ContentSpecNode(new QName(XMLUni::fgZeroLenString, - XMLUni::fgZeroLenString, - XMLElementDecl::fgPCDataElemId), - false); - - pcdataNode->setMinOccurs(0); - typeInfo->setContentSpec(pcdataNode); - typeInfo->setAdoptContentSpec(true); - typeInfo->setContentType(SchemaElementDecl::Mixed_Simple); - } - - - } - else if (typeInfo->getContentSpec() == 0) { - typeInfo->setContentType(SchemaElementDecl::Empty); - } - else { - typeInfo->setContentType(SchemaElementDecl::Children); - } - - // ------------------------------------------------------------- - // Now, check attributes and handle - // ------------------------------------------------------------- - if (attrNode != 0) { - - if (!isAttrOrAttrGroup(attrNode)) { - - fBuffer.set(attrNode.getLocalName().rawBuffer(), - attrNode.getLocalName().length()); - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::InvalidChildInComplexType, - fBuffer.getRawBuffer()); - } - else { - processAttributes(attrNode, baseRawName, baseLocalPart, - baseURI, typeInfo); - } - } - else if (baseTypeInfo != 0) { - processAttributes(0, baseRawName, baseLocalPart, baseURI, typeInfo); - } -} - - -void TraverseSchema::processBaseTypeInfo(const XMLCh* const baseName, - const XMLCh* const localPart, - const XMLCh* const uriStr, - ComplexTypeInfo* const typeInfo) { - - SchemaInfo* saveInfo = fSchemaInfo; - ComplexTypeInfo* baseComplexTypeInfo = 0; - DatatypeValidator* baseDTValidator = 0; - SchemaInfo::ListType infoType = SchemaInfo::INCLUDE; - - // ------------------------------------------------------------- - // check if the base type is from another schema - // ------------------------------------------------------------- - if (isBaseFromAnotherSchema(uriStr)) { - - baseComplexTypeInfo = getTypeInfoFromNS(uriStr, localPart); - - if (!baseComplexTypeInfo) { - - SchemaInfo* impInfo = fSchemaInfo->getImportInfo(fURIStringPool->addOrFind(uriStr)); - - if (!impInfo) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::BaseTypeNotFound, baseName); - throw TraverseSchema::InvalidComplexTypeInfo; - } - - infoType = SchemaInfo::IMPORT; - fSchemaInfo->setCurrentScope(fCurrentScope); - fSchemaInfo->setScopeCount(fScopeCount); - restoreSchemaInfo(impInfo, infoType); - } - } - else { - - fBuffer.set(uriStr); - fBuffer.append(chComma); - fBuffer.append(localPart); - - // assume the base is a complexType and try to locate the base type first - const XMLCh* fullBaseName = fBuffer.getRawBuffer(); - baseComplexTypeInfo = fComplexTypeRegistry->get(fullBaseName); - - // Circular check - if (baseComplexTypeInfo) { - - if (fCurrentTypeNameStack->containsElement(fStringPool->addOrFind(fullBaseName), fCircularCheckIndex)) { - - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::NoCircularDefinition, fullBaseName); - throw TraverseSchema::InvalidComplexTypeInfo; - } - else if (fCurrentTypeNameStack->containsElement(fStringPool->addOrFind(fullBaseName))) { - - typeInfo->setBaseComplexTypeInfo(baseComplexTypeInfo); - throw TraverseSchema::RecursingElement; - } - else if (baseComplexTypeInfo->getPreprocessed()) { - baseComplexTypeInfo = 0; - } - } - } - - // if not found, 2 possibilities: - // 1: ComplexType in question has not been compiled yet; - // 2: base is SimpleTYpe; - if (!baseComplexTypeInfo) { - - baseDTValidator = getDatatypeValidator(uriStr, localPart); - - if (baseDTValidator == 0) { - - DOM_Element baseTypeNode = - fSchemaInfo->getTopLevelComponent(SchemaSymbols::fgELT_COMPLEXTYPE, localPart, &fSchemaInfo); - - if (baseTypeNode != 0) { - - int baseTypeSymbol = traverseComplexTypeDecl(baseTypeNode); - baseComplexTypeInfo = fComplexTypeRegistry->get(fStringPool->getValueForId(baseTypeSymbol)); - } - else { - - baseTypeNode = fSchemaInfo->getTopLevelComponent(SchemaSymbols::fgELT_SIMPLETYPE, localPart, &fSchemaInfo); - - if (baseTypeNode != 0) { - - int baseTypeSymbol = traverseSimpleTypeDecl(baseTypeNode); - baseDTValidator = getDatatypeValidator(uriStr, localPart); - - if (baseDTValidator == 0) { - - // restore schema information, if necessary - if (saveInfo != fSchemaInfo) { - restoreSchemaInfo(saveInfo, infoType); - } - - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::TypeNotFound, uriStr, localPart, uriStr); - throw TraverseSchema::InvalidComplexTypeInfo; - } - } - else { - - // restore schema information, if necessary - if (saveInfo != fSchemaInfo) { - restoreSchemaInfo(saveInfo, infoType); - } - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::BaseTypeNotFound, baseName); - throw TraverseSchema::InvalidComplexTypeInfo; - } - } - } - } // end if - - // restore schema information, if necessary - if (saveInfo != fSchemaInfo) { - restoreSchemaInfo(saveInfo, infoType); - } - - typeInfo->setBaseComplexTypeInfo(baseComplexTypeInfo); - typeInfo->setBaseDatatypeValidator(baseDTValidator); -} - - -ComplexTypeInfo* TraverseSchema::getTypeInfoFromNS(const XMLCh* const uriStr, - const XMLCh* const localPart) -{ - Grammar* grammar = fGrammarResolver->getGrammar(uriStr); - - if (grammar != 0 && grammar->getGrammarType() == Grammar::SchemaGrammarType) { - - fBuffer.set(uriStr); - fBuffer.append(chComma); - fBuffer.append(localPart); - - ComplexTypeInfo* typeInfo = - ((SchemaGrammar*)grammar)->getComplexTypeRegistry()->get(fBuffer.getRawBuffer()); - - return typeInfo; - } - else { - reportSchemaError(XMLUni::fgValidityDomain, XMLValid::GrammarNotFound, uriStr); - } - - return 0; -} - - -bool TraverseSchema::isValidFacet(const XMLCh* const component, - const XMLCh* const name) { - - if (!XMLString::compareString(name, SchemaSymbols::fgELT_MINEXCLUSIVE) || - !XMLString::compareString(name, SchemaSymbols::fgELT_MININCLUSIVE) || - !XMLString::compareString(name, SchemaSymbols::fgELT_MAXEXCLUSIVE) || - !XMLString::compareString(name, SchemaSymbols::fgELT_MAXINCLUSIVE) || - !XMLString::compareString(name, SchemaSymbols::fgELT_TOTALDIGITS) || - !XMLString::compareString(name, SchemaSymbols::fgELT_FRACTIONDIGITS) || - !XMLString::compareString(name, SchemaSymbols::fgELT_LENGTH) || - !XMLString::compareString(name, SchemaSymbols::fgELT_MINLENGTH) || - !XMLString::compareString(name, SchemaSymbols::fgELT_MAXLENGTH) || - !XMLString::compareString(name, SchemaSymbols::fgELT_ENUMERATION) || - !XMLString::compareString(name, SchemaSymbols::fgELT_WHITESPACE) || - !XMLString::compareString(name, SchemaSymbols::fgELT_PATTERN) || - !XMLString::compareString(name, SchemaSymbols::fgELT_ANNOTATION)) { - return true; - } - - return false; -} - - -void TraverseSchema::processAttributes(const DOM_Element& attElem, - const XMLCh* const baseRawName, - const XMLCh* const baseLocalPart, - const XMLCh* const baseURI, - ComplexTypeInfo* const typeInfo) { - - // If we do not have a complexTypeInfo, then what is the point of - // processing. - if (typeInfo == 0) { - return; - } - - DOM_Element child = attElem; - SchemaAttDef* attWildCard = 0; - Janitor<SchemaAttDef> janAttWildCard(0); - XercesAttGroupInfo* attGroupInfo = 0; - ValueVectorOf<XercesAttGroupInfo*> attGroupList(4); - - for (; child != 0; child = XUtil::getNextSiblingElement(child)) { - - DOMString childName = child.getLocalName(); - - if (childName.equals(SchemaSymbols::fgELT_ATTRIBUTE)) { - traverseAttributeDecl(child, typeInfo); - } - else if (childName.equals(SchemaSymbols::fgELT_ATTRIBUTEGROUP)) { - attGroupInfo = traverseAttributeGroupDecl(child, typeInfo); - if (attGroupInfo && !attGroupList.containsElement(attGroupInfo)) { - attGroupList.addElement(attGroupInfo); - } - } - else if (childName.equals(SchemaSymbols::fgELT_ANYATTRIBUTE) ) { - attWildCard = traverseAnyAttribute(child); - janAttWildCard.reset(attWildCard); - } - else { - - fBuffer.set(childName.rawBuffer(), childName.length()); - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::InvalidChildInComplexType, - fBuffer.getRawBuffer()); - } - } - - // ------------------------------------------------------------- - // Handle wild card/any attribute - // ------------------------------------------------------------- - ComplexTypeInfo* baseTypeInfo = typeInfo->getBaseComplexTypeInfo(); - SchemaAttDef* baseAttWildCard = (baseTypeInfo) ? baseTypeInfo->getAttWildCard() : 0; - int derivedBy = typeInfo->getDerivedBy(); - unsigned int attGroupListSize = attGroupList.size(); - - if (attGroupListSize) { - - SchemaAttDef* completeWildCard = 0; - Janitor<SchemaAttDef> janCompleteWildCard(0); - XMLAttDef::DefAttTypes defAttType; - bool defAttTypeSet = false; - - for (unsigned int i=0; i < attGroupListSize; i++) { - - attGroupInfo = attGroupList.elementAt(i); - unsigned int anyAttCount = attGroupInfo->anyAttributeCount(); - - if (anyAttCount) { - - if (!defAttTypeSet) { - - defAttType = (attWildCard) ? attWildCard->getDefaultType() - : attGroupInfo->anyAttributeAt(0)->getDefaultType(); - defAttTypeSet = true; - } - - SchemaAttDef* attGroupWildCard = attGroupInfo->getCompleteWildCard(); - - if (!attGroupWildCard) { - - attGroupWildCard = new SchemaAttDef(attGroupInfo->anyAttributeAt(0)); - - for (unsigned int i= 1; i < anyAttCount; i++) { - attWildCardIntersection(attGroupWildCard, attGroupInfo->anyAttributeAt(i)); - } - - attGroupInfo->setCompleteWildCard(attGroupWildCard); - } - - if (completeWildCard) { - attWildCardIntersection(completeWildCard, attGroupWildCard); - } - else { - completeWildCard = new SchemaAttDef(attGroupWildCard); - janCompleteWildCard.reset(completeWildCard); - } - } - - } - - if (completeWildCard) { - - if (attWildCard) { - attWildCardIntersection(attWildCard, completeWildCard); - } - else { - - attWildCard = completeWildCard; - janCompleteWildCard.orphan(); - janAttWildCard.reset(attWildCard); - } - - attWildCard->setDefaultType(defAttType); - } - } - - if (derivedBy == SchemaSymbols::EXTENSION && baseAttWildCard && attWildCard) { - - XMLAttDef::DefAttTypes saveDefType = attWildCard->getDefaultType(); - attWildCardUnion(attWildCard, baseAttWildCard); - attWildCard->setDefaultType(saveDefType); - } - - // ------------------------------------------------------------- - // insert wildcard attribute - // ------------------------------------------------------------- - if (attWildCard) { - - typeInfo->setAttWildCard(attWildCard); - janAttWildCard.orphan(); - - if (attWildCard->getType() == XMLAttDef::AttTypes_Unknown) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::NotExpressibleWildCardIntersection); - } - } - else if (baseAttWildCard && derivedBy == SchemaSymbols::EXTENSION) { - - SchemaAttDef* newWildCard = new SchemaAttDef(baseAttWildCard); - typeInfo->setAttWildCard(newWildCard); - } - - // ------------------------------------------------------------- - // Check attributes derivation OK - // ------------------------------------------------------------- - bool baseWithAttributes = (baseTypeInfo && baseTypeInfo->hasAttDefs()); - bool childWithAttributes = (typeInfo->hasAttDefs() || typeInfo->getAttWildCard()); - - if (derivedBy == SchemaSymbols::RESTRICTION && childWithAttributes) { - - if (!baseWithAttributes && !baseAttWildCard) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::BadAttDerivation_1); - } - else { - checkAttDerivationOK(baseTypeInfo, typeInfo); - } - } - - // ------------------------------------------------------------- - // merge in base type's attribute decls - // ------------------------------------------------------------- - if (baseTypeInfo && baseTypeInfo->hasAttDefs()) { - - SchemaAttDefList& baseAttList = (SchemaAttDefList&) - baseTypeInfo->getAttDefList(); - - while (baseAttList.hasMoreElements()) { - - SchemaAttDef& attDef = (SchemaAttDef&) baseAttList.nextElement(); - QName* attName = attDef.getAttName(); - const XMLCh* localPart = attName->getLocalPart(); - - // if found a duplicate, then skip the one from the base type - if (typeInfo->getAttDef(localPart, attName->getURI()) != 0) { - - if (derivedBy == SchemaSymbols::EXTENSION) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::DuplicateAttInDerivation, localPart); - } - - continue; - } - - if (attDef.getDefaultType() != XMLAttDef::Prohibited) { - - SchemaAttDef* newAttDef = new SchemaAttDef(attName->getPrefix(), - attName->getLocalPart(), - attName->getURI(), - attDef.getValue(), - attDef.getType(), - attDef.getDefaultType(), - attDef.getEnumeration()); - - newAttDef->setDatatypeValidator(attDef.getDatatypeValidator()); - typeInfo->addAttDef(newAttDef); - } - } - } -} - - -void TraverseSchema::defaultComplexTypeInfo(ComplexTypeInfo* const typeInfo) { - - if (typeInfo) { - - typeInfo->setDerivedBy(0); - typeInfo->setContentType(SchemaElementDecl::Any); - typeInfo->setDatatypeValidator(0); - typeInfo->setContentSpec(0); - typeInfo->setBaseComplexTypeInfo(0); - typeInfo->setBaseDatatypeValidator(0); - } -} - - -InputSource* TraverseSchema::resolveSchemaLocation(const XMLCh* const loc) { - - // ------------------------------------------------------------------ - // Create an input source - // ------------------------------------------------------------------ - InputSource* srcToFill = 0; - - if (fEntityResolver){ - srcToFill = fEntityResolver->resolveEntity(XMLUni::fgZeroLenString, - loc); - } - - // If they didn't create a source via the entity resolver, then we - // have to create one on our own. - if (!srcToFill) { - - try { - - XMLURL urlTmp(fSchemaInfo->getCurrentSchemaURL(), loc); - - if (urlTmp.isRelative()) { - ThrowXML(MalformedURLException, - XMLExcepts::URL_NoProtocolPresent); - } - - srcToFill = new URLInputSource(urlTmp); - } - catch(const MalformedURLException&) { - // Its not a URL, so lets assume its a local file name. - srcToFill = new LocalFileInputSource(fSchemaInfo->getCurrentSchemaURL(),loc); - } - } - - return srcToFill; -} - - -void TraverseSchema::restoreSchemaInfo(SchemaInfo* const toRestore, - SchemaInfo::ListType const aListType) { - - - if (aListType == SchemaInfo::IMPORT) { // restore grammar info - - int targetNSURI = toRestore->getTargetNSURI(); - fSchemaGrammar = (SchemaGrammar*) fGrammarResolver->getGrammar(toRestore->getTargetNSURIString()); - - if (!fSchemaGrammar) { - - reportSchemaError(XMLUni::fgValidityDomain, XMLValid::GrammarNotFound, fURIStringPool->getValueForId(targetNSURI)); - return; - } - - fTargetNSURI = targetNSURI; - fCurrentScope = toRestore->getCurrentScope(); - fScopeCount = toRestore->getScopeCount(); - fTargetNSURIString = fSchemaGrammar->getTargetNamespace(); - fGroupRegistry = fSchemaGrammar->getGroupInfoRegistry(); - fAttGroupRegistry = fSchemaGrammar->getAttGroupInfoRegistry(); - fAttributeDeclRegistry = fSchemaGrammar->getAttributeDeclRegistry(); - fComplexTypeRegistry = fSchemaGrammar->getComplexTypeRegistry(); - fValidSubstitutionGroups = fSchemaGrammar->getValidSubstitutionGroups(); - fNamespaceScope = fSchemaGrammar->getNamespaceScope(); - fAttributeCheck.setIDRefList(fSchemaGrammar->getIDRefList()); - } - - fSchemaInfo = toRestore; - fElemAttrDefaultQualified = fSchemaInfo->getElemAttrDefaultQualified(); - fBlockDefault = fSchemaInfo->getBlockDefault(); - fFinalDefault = fSchemaInfo->getFinalDefault(); -} - - -bool -TraverseSchema::emptiableParticle(const ContentSpecNode* const specNode) { - - if (!fFullConstraintChecking || - (getMinTotalRange(specNode) == 0)) { - return true; - } - - return false; -} - -int TraverseSchema::getMinTotalRange(const ContentSpecNode* const specNode) { - - if (!specNode) { - return 0; - } - - ContentSpecNode::NodeTypes nodeType = specNode->getType(); - const ContentSpecNode* first = 0; - const ContentSpecNode* second = 0; - int min = specNode->getMinOccurs(); - - if (nodeType == ContentSpecNode::Sequence - || nodeType == ContentSpecNode::All - || nodeType == ContentSpecNode::Choice) { - - first = specNode->getFirst(); - second = specNode->getSecond(); - int minFirst = getMinTotalRange(first); - - if (second) { - - int minSecond = getMinTotalRange(second); - - if (nodeType == ContentSpecNode::Choice) { - min = min * ((minFirst < minSecond)? minFirst : minSecond); - } - else { - min = min * (minFirst + minSecond); - } - } - else - min = min * minFirst; - } - - return min; -} - -int TraverseSchema::getMaxTotalRange(const ContentSpecNode* const specNode) { - - if (!specNode) { - return 0; - } - - ContentSpecNode::NodeTypes nodeType = specNode->getType(); - const ContentSpecNode* first = 0; - const ContentSpecNode* second = 0; - int max = specNode->getMaxOccurs(); - - if (max == SchemaSymbols::UNBOUNDED) { - return SchemaSymbols::UNBOUNDED; - } - - if (nodeType == ContentSpecNode::Sequence - || nodeType == ContentSpecNode::All - || nodeType == ContentSpecNode::Choice) { - - first = specNode->getFirst(); - second = specNode->getSecond(); - int maxFirst = getMaxTotalRange(first); - - if (maxFirst == SchemaSymbols::UNBOUNDED) { - return SchemaSymbols::UNBOUNDED; - } - - if (second) { - - int maxSecond = getMaxTotalRange(second); - - if (maxSecond == SchemaSymbols::UNBOUNDED) { - return SchemaSymbols::UNBOUNDED; - } - else { - - if (nodeType == ContentSpecNode::Choice) { - max = max * (maxFirst > maxSecond) ? maxFirst : maxSecond; - } - else { - max = max * (maxFirst + maxSecond); - } - } - } - else { - max = max * maxFirst; - } - } - - return max; -} - -void TraverseSchema::checkFixedFacet(const DOM_Element& elem, - const XMLCh* const facetName, - const DatatypeValidator* const baseDV, - unsigned int& flags) -{ - const XMLCh* fixedFacet = getElementAttValue(elem, SchemaSymbols::fgATT_FIXED); - - if (XMLString::stringLen(fixedFacet) && - (!XMLString::compareString(fixedFacet, SchemaSymbols::fgATTVAL_TRUE) - || !XMLString::compareString(fixedFacet, fgValueOne))) { - - if (!XMLString::compareString(SchemaSymbols::fgELT_MINLENGTH, facetName)) { - flags |= DatatypeValidator::FACET_MINLENGTH; - } - else if (!XMLString::compareString(SchemaSymbols::fgELT_MAXLENGTH, facetName)) { - flags |= DatatypeValidator::FACET_MAXLENGTH; - } - else if (!XMLString::compareString(SchemaSymbols::fgELT_MAXEXCLUSIVE, facetName)) { - flags |= DatatypeValidator::FACET_MAXEXCLUSIVE; - } - else if (!XMLString::compareString(SchemaSymbols::fgELT_MAXINCLUSIVE, facetName)) { - flags |= DatatypeValidator::FACET_MAXINCLUSIVE; - } - else if (!XMLString::compareString(SchemaSymbols::fgELT_MINEXCLUSIVE, facetName)) { - flags |= DatatypeValidator::FACET_MINEXCLUSIVE; - } - else if (!XMLString::compareString(SchemaSymbols::fgELT_MININCLUSIVE, facetName)) { - flags |= DatatypeValidator::FACET_MININCLUSIVE; - } - else if (!XMLString::compareString(SchemaSymbols::fgELT_TOTALDIGITS, facetName)) { - flags |= DatatypeValidator::FACET_TOTALDIGITS; - } - else if (!XMLString::compareString(SchemaSymbols::fgELT_FRACTIONDIGITS, facetName)) { - flags |= DatatypeValidator::FACET_FRACTIONDIGITS; - } - else if ((!XMLString::compareString(SchemaSymbols::fgELT_WHITESPACE, facetName)) && - baseDV->getType() == DatatypeValidator::String) { - flags |= DatatypeValidator::FACET_WHITESPACE; - } - } -} - -void TraverseSchema::checkRefElementConsistency() { - - unsigned int refElemSize = fRefElements->size(); - - for (unsigned int i=0; i < refElemSize; i++) { - - int elemScope = fRefElemScope->elementAt(i); - QName* elemQName = fRefElements->elementAt(i); - unsigned int elemURI = elemQName->getURI(); - const XMLCh* elemName = elemQName->getLocalPart(); - const SchemaElementDecl* elemDecl = (SchemaElementDecl*) - fSchemaGrammar->getElemDecl(elemURI, elemName, 0, Grammar::TOP_LEVEL_SCOPE); - - if (elemDecl) { - - const SchemaElementDecl* other = (SchemaElementDecl*) - fSchemaGrammar->getElemDecl(elemURI, elemName, 0, elemScope); - - if (other - && (elemDecl->getComplexTypeInfo() != other->getComplexTypeInfo() || - elemDecl->getDatatypeValidator() != other->getDatatypeValidator())) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::DuplicateElementDeclaration, elemName); - continue; - } - - ValueVectorOf<SchemaElementDecl*>* subsElements = fValidSubstitutionGroups->get(elemName, elemURI); - - if (subsElements) { - - unsigned subsElemSize = subsElements->size(); - - for (unsigned int j=0; j < subsElemSize; j++) { - - SchemaElementDecl* subsElem = subsElements->elementAt(j); - const XMLCh* subsElemName = subsElem->getBaseName(); - SchemaElementDecl* sameScopeElem = (SchemaElementDecl*) - fSchemaGrammar->getElemDecl(subsElem->getURI(), subsElemName, 0, elemScope); - - if (sameScopeElem - && (subsElem->getComplexTypeInfo() != sameScopeElem->getComplexTypeInfo() - || subsElem->getDatatypeValidator() != sameScopeElem->getDatatypeValidator())) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::DuplicateElementDeclaration, subsElemName); - } - } - } - } - } -} - -void -TraverseSchema::buildValidSubstitutionListB(SchemaElementDecl* const elemDecl, - SchemaElementDecl* const subsElemDecl) { - - SchemaElementDecl* tmpElemDecl = subsElemDecl; - - while (true) { - - int elemURI = tmpElemDecl->getURI(); - XMLCh* elemName = tmpElemDecl->getBaseName(); - SchemaElementDecl* chainElem = fSubstitutionGroups->get(elemName, elemURI); - - if (!chainElem || (chainElem == elemDecl)) { - break; - } - - int chainElemURI = chainElem->getURI(); - XMLCh* chainElemName = chainElem->getBaseName(); - ValueVectorOf<SchemaElementDecl*>* validSubsElements = - fValidSubstitutionGroups->get(chainElemName, chainElemURI); - - if (!validSubsElements) { - - if (fTargetNSURI == chainElemURI) { - break; // an error must have occured - } - - SchemaGrammar* aGrammar = (SchemaGrammar*) - fGrammarResolver->getGrammar(fURIStringPool->getValueForId(chainElemURI)); - - if (!aGrammar) - break; - - validSubsElements = aGrammar->getValidSubstitutionGroups()->get(chainElemName, chainElemURI); - - if (!validSubsElements) { - break; - } - - validSubsElements = new ValueVectorOf<SchemaElementDecl*>(*validSubsElements); - fValidSubstitutionGroups->put((void*) chainElemName, chainElemURI, validSubsElements); - } - - if (validSubsElements->containsElement(elemDecl) || - !isSubstitutionGroupValid(chainElem, elemDecl->getComplexTypeInfo(), - elemDecl->getDatatypeValidator(), 0, false)) { - break; - } - - validSubsElements->addElement(elemDecl); - - // update related subs. info in case of circular import - RefVectorEnumerator<SchemaInfo> importingEnum = fSchemaInfo->getImportingListEnumerator(); - - while (importingEnum.hasMoreElements()) { - - const SchemaInfo& curRef = importingEnum.nextElement(); - SchemaGrammar* aGrammar = (SchemaGrammar*) fGrammarResolver->getGrammar(curRef.getTargetNSURIString()); - ValueVectorOf<SchemaElementDecl*>* subsElemList = - aGrammar->getValidSubstitutionGroups()->get(chainElemName, chainElemURI); - - if (subsElemList && !subsElemList->containsElement(elemDecl)) { - subsElemList->addElement(elemDecl); - } - } - } -} - -void -TraverseSchema::buildValidSubstitutionListF(SchemaElementDecl* const elemDecl, - SchemaElementDecl* const subsElemDecl) { - - int elemURI = elemDecl->getURI(); - XMLCh* elemName = elemDecl->getBaseName(); - ValueVectorOf<SchemaElementDecl*>* validSubsElements =fValidSubstitutionGroups->get(elemName, elemURI); - - if (validSubsElements) { - - int subsElemURI = subsElemDecl->getURI(); - XMLCh* subsElemName = subsElemDecl->getBaseName(); - ValueVectorOf<SchemaElementDecl*>* validSubs = fValidSubstitutionGroups->get(subsElemName, subsElemURI); - - if (!validSubs) { - - if (fTargetNSURI == subsElemURI) { - return; // an error must have occured - } - - SchemaGrammar* aGrammar = (SchemaGrammar*) - fGrammarResolver->getGrammar(fURIStringPool->getValueForId(subsElemURI)); - - if (!aGrammar) - return; - - validSubs = aGrammar->getValidSubstitutionGroups()->get(subsElemName, subsElemURI); - - if (!validSubs) { - return; - } - - validSubs = new ValueVectorOf<SchemaElementDecl*>(*validSubs); - fValidSubstitutionGroups->put((void*) subsElemName, subsElemURI, validSubs); - } - - unsigned int elemSize = validSubsElements->size(); - for (unsigned int i=0; i<elemSize; i++) { - - SchemaElementDecl* chainElem = validSubsElements->elementAt(i); - - if (chainElem == subsElemDecl || - validSubs->containsElement(chainElem)) { - continue; - } - - if (isSubstitutionGroupValid(subsElemDecl, chainElem->getComplexTypeInfo(), - chainElem->getDatatypeValidator(), 0, false)) { - validSubs->addElement(chainElem); - buildValidSubstitutionListB(chainElem, subsElemDecl); - } - } - } -} - -void TraverseSchema::checkEnumerationRequiredNotation(const XMLCh* const name, - const XMLCh* const type) { - - const XMLCh* localPart = getLocalPart(type); - - if (!XMLString::compareString(localPart, SchemaSymbols::fgELT_NOTATION)) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::NoNotationType, name); - } -} - -XercesGroupInfo* TraverseSchema::processGroupRef(const DOM_Element& elem, - const XMLCh* const refName) { - - if (XUtil::getFirstChildElement(elem) != 0) { - reportSchemaError(XMLUni::fgValidityDomain, XMLValid::NoContentForRef, SchemaSymbols::fgELT_GROUP); - } - - const XMLCh* prefix = getPrefix(refName); - const XMLCh* localPart = getLocalPart(refName); - const XMLCh* uriStr = resolvePrefixToURI(prefix); - - fBuffer.set(uriStr); - fBuffer.append(chComma); - fBuffer.append(localPart); - - unsigned int nameIndex = fStringPool->addOrFind(fBuffer.getRawBuffer()); - - if (fCurrentGroupStack->containsElement(nameIndex)) { - - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::NoCircularDefinition, localPart); - return 0; - } - - XercesGroupInfo* groupInfo = 0; - SchemaInfo* saveInfo = fSchemaInfo; - SchemaInfo::ListType infoType = SchemaInfo::INCLUDE; - - //if from another schema - if (XMLString::compareString(uriStr, fTargetNSURIString) != 0) { - - Grammar* aGrammar = fGrammarResolver->getGrammar(uriStr); - - if (!aGrammar || aGrammar->getGrammarType() != Grammar::SchemaGrammarType) { - - reportSchemaError(XMLUni::fgValidityDomain, XMLValid::GrammarNotFound, uriStr); - return 0; - } - - groupInfo = ((SchemaGrammar*)aGrammar)->getGroupInfoRegistry()->get(fStringPool->getValueForId(nameIndex)); - - if (!groupInfo) { - - SchemaInfo* impInfo = fSchemaInfo->getImportInfo(fURIStringPool->addOrFind(uriStr)); - - if (!impInfo) { - - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::DeclarationNotFound, - SchemaSymbols::fgELT_GROUP, uriStr, localPart); - return 0; - } - - infoType = SchemaInfo::IMPORT; - fSchemaInfo->setCurrentScope(fCurrentScope); - fSchemaInfo->setScopeCount(fScopeCount); - restoreSchemaInfo(impInfo, infoType); - } - } - else { - groupInfo = fGroupRegistry->get(fStringPool->getValueForId(nameIndex)); - } - - if (!groupInfo) { - - DOM_Element groupElem = fSchemaInfo->getTopLevelComponent(SchemaSymbols::fgELT_GROUP, localPart, &fSchemaInfo); - - if (groupElem != 0) { - - groupInfo = traverseGroupDecl(groupElem); - - if (groupInfo && fCurrentGroupInfo - && groupInfo->getScope() == fCurrentGroupInfo->getScope()) { - copyGroupElements(groupInfo, fCurrentGroupInfo, 0); - } - - // restore schema information, if necessary - if (saveInfo != fSchemaInfo) { - restoreSchemaInfo(saveInfo, infoType); - } - - return groupInfo; - } - else { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::DeclarationNotFound, - SchemaSymbols::fgELT_GROUP, uriStr, localPart); - } - } - - if (groupInfo) { - copyGroupElements(groupInfo, fCurrentGroupInfo, fCurrentComplexType); - } - - // restore schema information, if necessary - if (saveInfo != fSchemaInfo) { - restoreSchemaInfo(saveInfo, infoType); - } - - return groupInfo; -} - - -XercesAttGroupInfo* -TraverseSchema::processAttributeGroupRef(const DOM_Element& elem, - const XMLCh* const refName, - ComplexTypeInfo* const typeInfo) { - - if (XUtil::getFirstChildElement(elem) != 0) { - reportSchemaError(XMLUni::fgValidityDomain, XMLValid::NoContentForRef, SchemaSymbols::fgELT_ATTRIBUTEGROUP); - } - - const XMLCh* prefix = getPrefix(refName); - const XMLCh* localPart = getLocalPart(refName); - const XMLCh* uriStr = resolvePrefixToURI(prefix); - XercesAttGroupInfo* attGroupInfo = 0; - SchemaInfo* saveInfo = fSchemaInfo; - SchemaInfo::ListType infoType = SchemaInfo::INCLUDE; - - if (XMLString::compareString(uriStr, fTargetNSURIString) != 0) { - - attGroupInfo = traverseAttributeGroupDeclNS(uriStr, localPart); - - if (!attGroupInfo) { - SchemaInfo* impInfo = fSchemaInfo->getImportInfo(fURIStringPool->addOrFind(uriStr)); - - if (!impInfo) { - - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::DeclarationNotFound, - SchemaSymbols::fgELT_ATTRIBUTEGROUP, uriStr, localPart); - return 0; - } - - infoType = SchemaInfo::IMPORT; - fSchemaInfo->setCurrentScope(fCurrentScope); - fSchemaInfo->setScopeCount(fScopeCount); - restoreSchemaInfo(impInfo, infoType); - } - } - else { - - // circular check - DOM_Node parentElem = elem.getParentNode(); - - if (parentElem.getLocalName().equals(SchemaSymbols::fgELT_ATTRIBUTEGROUP) - && ((DOM_Element&) parentElem).getAttribute(SchemaSymbols::fgATT_NAME).equals(localPart) - && !(parentElem.getParentNode().getLocalName().equals(SchemaSymbols::fgELT_REDEFINE))) { - - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::NoCircularAttGroup); - return 0; - } - - attGroupInfo = fAttGroupRegistry->get(localPart); - } - - if (!attGroupInfo) { - - // traverse top level attributeGroup - if found - DOM_Element attGroupElem = fSchemaInfo->getTopLevelComponent(SchemaSymbols::fgELT_ATTRIBUTEGROUP, localPart, &fSchemaInfo); - - if (attGroupElem != 0) { - - attGroupInfo = traverseAttributeGroupDecl(attGroupElem, typeInfo); - - if (attGroupInfo && fCurrentAttGroupInfo) { - copyAttGroupAttributes(attGroupInfo, fCurrentAttGroupInfo, 0); - } - - // restore schema information, if necessary - if (saveInfo != fSchemaInfo) { - restoreSchemaInfo(saveInfo, infoType); - } - - return attGroupInfo; - } - else { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::DeclarationNotFound, - SchemaSymbols::fgELT_ATTRIBUTEGROUP, uriStr, localPart); - } - } - - if (attGroupInfo) { - copyAttGroupAttributes(attGroupInfo, fCurrentAttGroupInfo, typeInfo); - } - - // restore schema information, if necessary - if (saveInfo != fSchemaInfo) { - restoreSchemaInfo(saveInfo, infoType); - } - - return attGroupInfo; -} - -bool TraverseSchema::hasAllContent(const ContentSpecNode* const specNode) { - - if (specNode) { - - const ContentSpecNode* tmpSpecNode = specNode; - - if (specNode->getType() == ContentSpecNode::ZeroOrOne) { - tmpSpecNode = specNode->getFirst(); - } - - return (tmpSpecNode->getType() == ContentSpecNode::All); - } - - return false; -} - -void TraverseSchema::processElements(ComplexTypeInfo* const baseTypeInfo, - ComplexTypeInfo* const newTypeInfo) { - - unsigned int elemCount = baseTypeInfo->elementCount(); - - if (elemCount) { - - int newTypeScope = newTypeInfo->getScopeDefined(); - int schemaURI = fURIStringPool->addOrFind(SchemaSymbols::fgURI_SCHEMAFORSCHEMA); - - for (unsigned int i=0; i < elemCount; i++) { - - SchemaGrammar* aGrammar = fSchemaGrammar; - SchemaElementDecl* elemDecl = baseTypeInfo->elementAt(i); - - if (!elemDecl) { - continue; - } - - int elemURI = elemDecl->getURI(); - - if (elemURI != fTargetNSURI && elemURI != schemaURI && elemURI != fEmptyNamespaceURI) { - - Grammar* aGrammar = - fGrammarResolver->getGrammar(fURIStringPool->getValueForId(elemURI)); - - if (!aGrammar || aGrammar->getGrammarType() != Grammar::SchemaGrammarType) { - continue; // REVISIT - error message - } - } - - const XMLCh* localPart = elemDecl->getBaseName(); - const SchemaElementDecl* other = (SchemaElementDecl*) - aGrammar->getElemDecl(elemURI, localPart, 0, newTypeScope); - - if (other) { - - if (elemDecl->getComplexTypeInfo() != other->getComplexTypeInfo() - || elemDecl->getDatatypeValidator() != other->getDatatypeValidator()) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::DuplicateElementDeclaration, localPart); - } - } - else { - - int elemScope = elemDecl->getEnclosingScope(); - - newTypeInfo->addElement(elemDecl); - elemDecl->setEnclosingScope(newTypeScope); - ((SchemaGrammar*) aGrammar)->putGroupElemDecl(elemDecl); - elemDecl->setEnclosingScope(elemScope); - } - } - } -} - - -void TraverseSchema::copyGroupElements(XercesGroupInfo* const fromGroup, - XercesGroupInfo* const toGroup, - ComplexTypeInfo* const typeInfo) { - - unsigned int elemCount = fromGroup->elementCount(); - int newScope = (typeInfo) ? typeInfo->getScopeDefined() : 0; - - for (unsigned int i = 0; i < elemCount; i++) { - - SchemaElementDecl* elemDecl = fromGroup->elementAt(i); - - if (typeInfo) { - int elemURI = elemDecl->getURI(); - const XMLCh* localPart = elemDecl->getBaseName(); - const SchemaElementDecl* other = (SchemaElementDecl*) - fSchemaGrammar->getElemDecl(elemURI, localPart, 0, fCurrentScope); - - if (other) { - - if (elemDecl->getComplexTypeInfo() != other->getComplexTypeInfo() - || elemDecl->getDatatypeValidator() != other->getDatatypeValidator()) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::DuplicateElementDeclaration, localPart); - } - - continue; - } - - int elemScope = elemDecl->getEnclosingScope(); - - elemDecl->setEnclosingScope(newScope); - typeInfo->addElement(elemDecl); - fSchemaGrammar->putGroupElemDecl(elemDecl); - elemDecl->setEnclosingScope(elemScope); - - if (toGroup) { - toGroup->addElement(elemDecl); - } - } - else { - if (!toGroup->containsElement(elemDecl)) { - toGroup->addElement(elemDecl); - } - } - } -} - -void TraverseSchema::copyAttGroupAttributes(XercesAttGroupInfo* const fromAttGroup, - XercesAttGroupInfo* const toAttGroup, - ComplexTypeInfo* const typeInfo) { - - unsigned int attCount = fromAttGroup->attributeCount(); - - for (unsigned int i=0; i < attCount; i++) { - - SchemaAttDef* attDef = fromAttGroup->attributeAt(i); - QName* attName = attDef->getAttName(); - const XMLCh* localPart = attName->getLocalPart(); - DatatypeValidator* attDV = attDef->getDatatypeValidator(); - - if (typeInfo) { - - if (typeInfo->getAttDef(localPart, attName->getURI())) { - - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::DuplicateAttribute, localPart); - continue; - } - - if (attDV && attDV->getType() == DatatypeValidator::ID) { - - if (typeInfo->containsAttWithTypeId()) { - - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::AttDeclPropCorrect5, localPart); - continue; - } - - typeInfo->setAttWithTypeId(true); - } - - typeInfo->addAttDef(new SchemaAttDef(attDef)); - - if (toAttGroup) { - toAttGroup->addAttDef(attDef, true); - } - } - else { - - if (toAttGroup->containsAttribute(localPart, attName->getURI())) { - - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::DuplicateAttribute, localPart); - continue; - } - - if (attDV && attDV->getType() == DatatypeValidator::ID) { - - if (toAttGroup->containsTypeWithId()) { - - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::AttGrpPropCorrect3, localPart); - continue; - } - - toAttGroup->setTypeWithId(true); - } - - toAttGroup->addAttDef(attDef, true); - } - } - - if (toAttGroup) { - unsigned int anyAttCount = fromAttGroup->anyAttributeCount(); - - for (unsigned int j=0; j < anyAttCount; j++) { - toAttGroup->addAnyAttDef(fromAttGroup->anyAttributeAt(j), true); - } - } -} - -void -TraverseSchema::attWildCardIntersection(SchemaAttDef* const resultWildCard, - const SchemaAttDef* const compareWildCard) { - - XMLAttDef::AttTypes typeR = resultWildCard->getType(); - XMLAttDef::AttTypes typeC = compareWildCard->getType(); - - //If either O1 or O2 is any, then the other must be the value. - if (typeC == XMLAttDef::Any_Any || - typeR == XMLAttDef::AttTypes_Unknown) { - return; - } - - if (typeR == XMLAttDef::Any_Any || - typeC == XMLAttDef::AttTypes_Unknown) { - - resultWildCard->resetNamespaceList(); - copyWildCardData(compareWildCard, resultWildCard); - return; - } - - // If either O1 or O2 is a pair of not and a namespace name and the other - // is a set, then that set, minus the negated namespace name if it was in - // is the value - if ((typeC == XMLAttDef::Any_Other && typeR == XMLAttDef::Any_List) || - (typeR == XMLAttDef::Any_Other && typeC == XMLAttDef::Any_List)) { - - unsigned int compareURI = 0; - ValueVectorOf<unsigned int>* nameURIList = 0; - - if (typeC == XMLAttDef::Any_List) { - nameURIList = compareWildCard->getNamespaceList(); - compareURI = resultWildCard->getAttName()->getURI(); - } - else { - nameURIList = resultWildCard->getNamespaceList(); - compareURI = compareWildCard->getAttName()->getURI(); - } - - unsigned int listSize = (nameURIList) ? nameURIList->size() : 0; - - if (listSize) { - - bool found = false; - ValueVectorOf<unsigned int> tmpURIList(listSize); - - for (unsigned int i=0; i < listSize; i++) { - - unsigned int nameURI = nameURIList->elementAt(i); - - if (nameURI != compareURI) { - tmpURIList.addElement(nameURI); - } - else { - found = true; - } - } - - if (found || typeC == XMLAttDef::Any_List) { - resultWildCard->setNamespaceList(&tmpURIList); - } - } - - if (typeC == XMLAttDef::Any_List) { - copyWildCardData(compareWildCard, resultWildCard); - } - - return; - } - - // If both O1 and O2 are sets, then the intersection of those sets must be - // the value. - if (typeR == XMLAttDef::Any_List && typeC == XMLAttDef::Any_List) { - - ValueVectorOf<unsigned int>* uriListR = resultWildCard->getNamespaceList(); - ValueVectorOf<unsigned int>* uriListC = compareWildCard->getNamespaceList(); - unsigned int listSize = (uriListC) ? uriListC->size() : 0; - - if (listSize) { - - ValueVectorOf<unsigned int> tmpURIList(listSize); - - for (unsigned int i=0; i < listSize; i++) { - - unsigned int uriName = uriListC->elementAt(i); - - if (uriListR && uriListR->containsElement(uriName)) { - tmpURIList.addElement(uriName); - } - } - - resultWildCard->setNamespaceList(&tmpURIList); - } - else { - resultWildCard->resetNamespaceList(); - } - - return; - } - - // If the two are negations of different namespace names, then the - // intersection is not expressible. - if (typeR == XMLAttDef::Any_Other && typeC == XMLAttDef::Any_Other) { - - QName* qnameR = resultWildCard->getAttName(); - - if (qnameR->getURI() != compareWildCard->getAttName()->getURI()) { - - qnameR->setURI(fEmptyNamespaceURI); - resultWildCard->setType(XMLAttDef::AttTypes_Unknown); - } - } -} - - -void -TraverseSchema::attWildCardUnion(SchemaAttDef* const resultWildCard, - const SchemaAttDef* const compareWildCard) { - - XMLAttDef::AttTypes typeR = resultWildCard->getType(); - XMLAttDef::AttTypes typeC = compareWildCard->getType(); - - //If either O1 or O2 is any, then the other must be the value. - if (typeR == XMLAttDef::Any_Any || - typeR == XMLAttDef::AttTypes_Unknown) { - return; - } - - if (typeC == XMLAttDef::Any_Any || - typeC == XMLAttDef::AttTypes_Unknown) { - - resultWildCard->resetNamespaceList(); - copyWildCardData(compareWildCard, resultWildCard); - return; - } - - // If both O1 and O2 are sets, then the union of those sets must be - // the value. - if (typeR == XMLAttDef::Any_List && typeC == XMLAttDef::Any_List) { - - ValueVectorOf<unsigned int>* uriListR = resultWildCard->getNamespaceList(); - ValueVectorOf<unsigned int>* uriListC = compareWildCard->getNamespaceList(); - unsigned int listSizeC = (uriListC) ? uriListC->size() : 0; - - if (listSizeC) { - - if (!uriListR || !uriListR->size()) { - - resultWildCard->setNamespaceList(uriListC); - return; - } - - ValueVectorOf<unsigned int> tmpURIList(*uriListR); - - for (unsigned int i = 0; i < listSizeC; i++) { - - unsigned int uriName = uriListC->elementAt(i); - - if (!uriListR->containsElement(uriName)) { - tmpURIList.addElement(uriName); - } - } - - resultWildCard->setNamespaceList(&tmpURIList); - } - - return; - } - - // If the two are negations of different namespace names, then any must - // be the value - if (typeR == XMLAttDef::Any_Other && typeC == XMLAttDef::Any_Other) { - - QName* qnameR = resultWildCard->getAttName(); - - if (qnameR->getURI() != compareWildCard->getAttName()->getURI()) { - - qnameR->setURI(fEmptyNamespaceURI); - resultWildCard->setType(XMLAttDef::Any_Any); - } - } - - // If either O1 or O2 is a pair of not and a namespace name and the other - // is a set, then: - // 1. If the set includes the negated namespace name, then any must be the value. - // 2. If the set does not include the negated namespace name, then whichever of O1 or O2 is a - // pair of not and a namespace name must be the value. - if ((typeC == XMLAttDef::Any_Other && typeR == XMLAttDef::Any_List) || - (typeR == XMLAttDef::Any_Other && typeC == XMLAttDef::Any_List)) { - - ValueVectorOf<unsigned int>* nameURIList = 0; - QName* attNameR = resultWildCard->getAttName(); - unsigned int compareURI = 0; - - if (typeC == XMLAttDef::Any_List) { - nameURIList = compareWildCard->getNamespaceList(); - compareURI = attNameR->getURI(); - } - else { - nameURIList = resultWildCard->getNamespaceList(); - compareURI = compareWildCard->getAttName()->getURI(); - } - - - if (nameURIList && nameURIList->containsElement(compareURI)) { - - resultWildCard->setType(XMLAttDef::Any_Any); - attNameR->setURI(fEmptyNamespaceURI); - } - else if (typeR == XMLAttDef::Any_List) { - - resultWildCard->setType(XMLAttDef::Any_Other); - attNameR->setURI(compareURI); - } - - resultWildCard->resetNamespaceList(); - } -} - - -void TraverseSchema::checkAttDerivationOK(const ComplexTypeInfo* const baseTypeInfo, - const ComplexTypeInfo* const childTypeInfo) { - - SchemaAttDefList& childAttList = (SchemaAttDefList&) childTypeInfo->getAttDefList(); - const SchemaAttDef* baseAttWildCard = baseTypeInfo->getAttWildCard(); - - while (childAttList.hasMoreElements()) { - - SchemaAttDef& childAttDef = (SchemaAttDef&) childAttList.nextElement(); - QName* childAttName = childAttDef.getAttName(); - const XMLCh* childLocalPart = childAttName->getLocalPart(); - const SchemaAttDef* baseAttDef = baseTypeInfo->getAttDef(childLocalPart, childAttName->getURI()); - - if (baseAttDef) { - - XMLAttDef::DefAttTypes baseAttDefType = baseAttDef->getDefaultType(); - XMLAttDef::DefAttTypes childAttDefType = childAttDef.getDefaultType(); - - // Constraint 2.1.1 & 3 + check for prohibited base attribute - if (baseAttDefType == XMLAttDef::Prohibited - && childAttDefType != XMLAttDef::Prohibited) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::BadAttDerivation_8, childLocalPart); - } - - if ((baseAttDefType & XMLAttDef::Required) - && !(childAttDefType & XMLAttDef::Required)) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::BadAttDerivation_2, childLocalPart); - } - - // Constraint 2.1.2 - DatatypeValidator* baseDV = baseAttDef->getDatatypeValidator(); - DatatypeValidator* childDV = childAttDef.getDatatypeValidator(); - if (!baseDV || !baseDV->isSubstitutableBy(childDV)) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::BadAttDerivation_3, childLocalPart); - } - - // Constraint 2.1.3 - if ((baseAttDefType & XMLAttDef::Fixed) && - (!(childAttDefType & XMLAttDef::Fixed) || - XMLString::compareString(baseAttDef->getValue(), childAttDef.getValue()))) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::BadAttDerivation_4, childLocalPart); - } - } - // Constraint 2.2 - else if (!baseAttWildCard || - !wildcardAllowsNamespace(baseAttWildCard, childAttName->getURI())) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::BadAttDerivation_5, childLocalPart); - } - } - - // Constraint 4 - const SchemaAttDef* childAttWildCard = childTypeInfo->getAttWildCard(); - - if (childAttWildCard) { - - if (!baseAttWildCard) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::BadAttDerivation_6); - } - else if (!isWildCardSubset(baseAttWildCard, childAttWildCard)) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::BadAttDerivation_7); - } - } -} - -void TraverseSchema::checkAttDerivationOK(const XercesAttGroupInfo* const baseAttGrpInfo, - const XercesAttGroupInfo* const childAttGrpInfo) { - - unsigned int baseAttCount = baseAttGrpInfo->attributeCount(); - unsigned int baseAnyAttCount = baseAttGrpInfo->anyAttributeCount(); - unsigned int childAttCount = childAttGrpInfo->attributeCount(); - unsigned int childAnyAttCount = childAttGrpInfo->anyAttributeCount(); - - if ((childAttCount || childAnyAttCount) && (!baseAttCount && !baseAnyAttCount)) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::BadAttDerivation_1); - } - - const SchemaAttDef* baseAttWildCard = (baseAnyAttCount) ? baseAttGrpInfo->anyAttributeAt(0) : 0; - - for (unsigned int i=0; i<childAttCount; i++) { - - const SchemaAttDef* childAttDef = childAttGrpInfo->attributeAt(i); - QName* childAttName = childAttDef->getAttName(); - const XMLCh* childLocalPart = childAttName->getLocalPart(); - const SchemaAttDef* baseAttDef = baseAttGrpInfo->getAttDef(childLocalPart, childAttName->getURI()); - - if (baseAttDef) { - - XMLAttDef::DefAttTypes baseAttDefType = baseAttDef->getDefaultType(); - XMLAttDef::DefAttTypes childAttDefType = childAttDef->getDefaultType(); - - // Constraint 2.1.1 & 3 + check for prohibited base attribute - if (baseAttDefType == XMLAttDef::Prohibited - && childAttDefType != XMLAttDef::Prohibited) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::BadAttDerivation_8, childLocalPart); - } - - if ((baseAttDefType & XMLAttDef::Required) - && !(childAttDefType & XMLAttDef::Required)) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::BadAttDerivation_2, childLocalPart); - } - - // Constraint 2.1.2 - DatatypeValidator* baseDV = baseAttDef->getDatatypeValidator(); - DatatypeValidator* childDV = childAttDef->getDatatypeValidator(); - if (!baseDV || !baseDV->isSubstitutableBy(childDV)) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::BadAttDerivation_3, childLocalPart); - } - - // Constraint 2.1.3 - if ((baseAttDefType & XMLAttDef::Fixed) && - (!(childAttDefType & XMLAttDef::Fixed) || - XMLString::compareString(baseAttDef->getValue(), childAttDef->getValue()))) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::BadAttDerivation_4, childLocalPart); - } - } - // Constraint 2.2 - else if (!baseAttWildCard || - !wildcardAllowsNamespace(baseAttWildCard, childAttName->getURI())) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::BadAttDerivation_5, childLocalPart); - } - } - - // Constraint 4 - const SchemaAttDef* childAttWildCard = (childAnyAttCount) ? childAttGrpInfo->anyAttributeAt(0) : 0; - - if (childAttWildCard) { - - if (!baseAttWildCard) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::BadAttDerivation_6); - } - else if (!isWildCardSubset(baseAttWildCard, childAttWildCard)) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::BadAttDerivation_7); - } - } -} - -bool TraverseSchema::wildcardAllowsNamespace(const SchemaAttDef* const wildCard, - const unsigned int nameURI) { - - XMLAttDef::AttTypes wildCardType = wildCard->getType(); - - // The constraint must be any - if (wildCardType == XMLAttDef::Any_Any) { - return true; - } - - // All of the following must be true: - // 2.1 The constraint is a pair of not and a namespace name or ·absent - // 2.2 The value must not be identical to the ·namespace test·. - // 2.3 The value must not be ·absent·. - if (wildCardType == XMLAttDef::Any_Other && - ((int) nameURI) != fEmptyNamespaceURI && - wildCard->getAttName()->getURI() != nameURI) { - return true; - } - - // The constraint is a set, and the value is identical to one of the - // members of the set - if (wildCardType == XMLAttDef::Any_List) { - - ValueVectorOf<unsigned int>* nameURIList = wildCard->getNamespaceList(); - - if (nameURIList->containsElement(nameURI)) { - return true; - } - } - - return false; -} - -bool TraverseSchema::isWildCardSubset(const SchemaAttDef* const baseAttWildCard, - const SchemaAttDef* const childAttWildCard) { - - XMLAttDef::AttTypes baseWildCardType = baseAttWildCard->getType(); - XMLAttDef::AttTypes childWildCardType = childAttWildCard->getType(); - - if (baseWildCardType == XMLAttDef::AttTypes_Unknown || - childWildCardType == XMLAttDef::AttTypes_Unknown) { - return false; - } - - // 1 super must be any. - if (baseWildCardType == XMLAttDef::Any_Any) { - return true; - } - - // 2 All of the following must be true: - // 2.1 sub must be a pair of not and a namespace name or ·absent·. - // 2.2 super must be a pair of not and the same value. - if (childWildCardType == XMLAttDef::Any_Other && baseWildCardType == XMLAttDef::Any_Other && - childAttWildCard->getAttName()->getURI() == baseAttWildCard->getAttName()->getURI()) { - return true; - } - - // 3 All of the following must be true: - // 3.1 sub must be a set whose members are either namespace names or ·absent·. - // 3.2 One of the following must be true: - // 3.2.1 super must be the same set or a superset thereof. - // 3.2.2 super must be a pair of not and a namespace name or ·absent· and - // that value must not be in sub's set. - if (childWildCardType == XMLAttDef::Any_List) { - - ValueVectorOf<unsigned int>* childURIList = childAttWildCard->getNamespaceList(); - - if (baseWildCardType == XMLAttDef::Any_List) { - - ValueVectorOf<unsigned int>* baseURIList = baseAttWildCard->getNamespaceList(); - unsigned int childListSize = (childURIList) ? childURIList->size() : 0; - - for (unsigned int i=0; i<childListSize; i++) { - if (!baseURIList->containsElement(childURIList->elementAt(i))) { - return false; - } - } - - return true; - } - else if (baseWildCardType == XMLAttDef::Any_Other) { - if (!childURIList->containsElement(baseAttWildCard->getAttName()->getURI())) { - return true; - } - } - } - - return false; -} - -bool TraverseSchema::openRedefinedSchema(const DOM_Element& redefineElem) { - - // ------------------------------------------------------------------ - // Get 'schemaLocation' attribute - // ------------------------------------------------------------------ - const XMLCh* schemaLocation = getElementAttValue(redefineElem, SchemaSymbols::fgATT_SCHEMALOCATION); - - if (XMLString::stringLen(schemaLocation) == 0) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::DeclarationNoSchemaLocation, SchemaSymbols::fgELT_REDEFINE); - return false; - } - - // ------------------------------------------------------------------ - // Resolve schema location - // ------------------------------------------------------------------ - InputSource* srcToFill = resolveSchemaLocation(schemaLocation); - Janitor<InputSource> janSrc(srcToFill); - - // Nothing to do - if (!srcToFill) { - return false; - } - - const XMLCh* includeURL = srcToFill->getSystemId(); - - if (!XMLString::compareString(includeURL, fSchemaInfo->getCurrentSchemaURL())) { - return false; - } - - SchemaInfo* redefSchemaInfo = fSchemaInfoList->get(includeURL, fTargetNSURI); - - if (redefSchemaInfo) { - - fSchemaInfo->addSchemaInfo(redefSchemaInfo, SchemaInfo::INCLUDE); - restoreSchemaInfo(redefSchemaInfo); - return true; - } - - // ------------------------------------------------------------------ - // Parse input source - // ------------------------------------------------------------------ - DOMParser parser; - XMLInternalErrorHandler internalErrorHandler(fErrorHandler); - - parser.setValidationScheme(DOMParser::Val_Never); - parser.setDoNamespaces(true); - parser.setErrorHandler((ErrorHandler*) &internalErrorHandler); - parser.setEntityResolver(fEntityResolver); - - // Should just issue warning if the schema is not found - const bool flag = srcToFill->getIssueFatalErrorIfNotFound(); - srcToFill->setIssueFatalErrorIfNotFound(false); - - parser.parse(*srcToFill) ; - - // Reset the InputSource - srcToFill->setIssueFatalErrorIfNotFound(flag); - - if (internalErrorHandler.getSawFatal() && fScanner->getExitOnFirstFatal()) - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::SchemaScanFatalError); - - // ------------------------------------------------------------------ - // Get root element - // ------------------------------------------------------------------ - DOM_Document document = parser.getDocument(); - - if (document.isNull()) { - return false; - } - else { - - DOM_Element root = document.getDocumentElement(); - - if (root.isNull()) { - return false; - } - - const XMLCh* targetNSURIString = getTargetNamespaceString(root); //getElementAttValue(root,SchemaSymbols::fgATT_TARGETNAMESPACE); - unsigned int targetNSLength = XMLString::stringLen(targetNSURIString); - - // check to see if targetNameSpace is right - if (targetNSLength != 0 - && XMLString::compareString(targetNSURIString,fTargetNSURIString) != 0){ - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::RedefineNamespaceDifference, - schemaLocation, targetNSURIString); - return false; - } - - // if targetNamespace is empty, change it to redefin'g schema - // targetNamespace - if (targetNSLength == 0 && root.getAttributeNode(XMLUni::fgXMLNSString) == 0 - && fTargetNSURI != fEmptyNamespaceURI) { - root.setAttribute(XMLUni::fgXMLNSString, fTargetNSURIString); - } - - // -------------------------------------------------------- - // Update schema information with redefined schema - // -------------------------------------------------------- - unsigned int namespaceDepth = fNamespaceScope->increaseDepth(); - fElemAttrDefaultQualified = 0; - traverseSchemaHeader(root); - - // and now we'd better save this stuff! - redefSchemaInfo = fSchemaInfo; - fSchemaInfo = new SchemaInfo(fElemAttrDefaultQualified, fBlockDefault, - fFinalDefault, fTargetNSURI, fCurrentScope, - fScopeCount, namespaceDepth, - XMLString::replicate(includeURL), - fTargetNSURIString, fStringPool, root); - - fSchemaInfoList->put((void*) fSchemaInfo->getCurrentSchemaURL(), fSchemaInfo->getTargetNSURI(), fSchemaInfo); - redefSchemaInfo->addSchemaInfo(fSchemaInfo, SchemaInfo::INCLUDE); - } - - return true; -} - -void TraverseSchema::renameRedefinedComponents(const DOM_Element& redefineElem, - SchemaInfo* const redefiningSchemaInfo, - SchemaInfo* const redefinedSchemaInfo) { - - DOM_Element child = XUtil::getFirstChildElement(redefineElem); - - for (; child != 0; child = XUtil::getNextSiblingElement(child)) { - - DOMString childName = child.getLocalName(); - - if (childName.equals(SchemaSymbols::fgELT_ANNOTATION)) { - continue; - } - - // if component already redefined skip - fBuffer.set(childName.rawBuffer(), childName.length()); - - unsigned int childNameId = fStringPool->addOrFind(fBuffer.getRawBuffer()); - const XMLCh* tmpChildName = fStringPool->getValueForId(childNameId); - const XMLCh* typeName = getElementAttValue(child, SchemaSymbols::fgATT_NAME); - - fBuffer.set(fTargetNSURIString); - fBuffer.append(chComma); - fBuffer.append(typeName); - - if (fRedefineComponents->containsKey(tmpChildName, fStringPool->addOrFind(fBuffer.getRawBuffer()))) { - continue; - } - - if (validateRedefineNameChange(child, tmpChildName, typeName, 1, redefiningSchemaInfo)) { - redefinedSchemaInfo->addRedefineInfo(tmpChildName, typeName, redefiningSchemaInfo); - fixRedefinedSchema(redefinedSchemaInfo, tmpChildName, typeName, 1); - } - } -} - -bool TraverseSchema::validateRedefineNameChange(const DOM_Element& redefineChildElem, - const XMLCh* const redefineChildComponentName, - const XMLCh* const redefineChildTypeName, - const int redefineNameCounter, - SchemaInfo* const redefiningSchemaInfo) { - - const XMLCh* baseTypeName = 0; - unsigned int typeNameId = fStringPool->addOrFind(redefineChildTypeName); - - fBuffer.set(fTargetNSURIString); - fBuffer.append(chComma); - fBuffer.append(redefineChildTypeName); - - int fullTypeNameId = fStringPool->addOrFind(fBuffer.getRawBuffer()); - const XMLCh* typeNameStr = fStringPool->getValueForId(fullTypeNameId); - - restoreSchemaInfo(redefiningSchemaInfo); - - if (!XMLString::compareString(redefineChildComponentName,SchemaSymbols::fgELT_SIMPLETYPE)) { - - if (fDatatypeRegistry->getDatatypeValidator(typeNameStr)) { - return false; - } - - DOM_Element grandKid = XUtil::getFirstChildElement(redefineChildElem); - - if (grandKid != 0 && grandKid.getLocalName().equals(SchemaSymbols::fgELT_ANNOTATION)) { - grandKid = XUtil::getNextSiblingElement(grandKid); - } - - if (grandKid == 0) { - - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::Redefine_InvalidSimpleType); - return false; - } - else if(!grandKid.getLocalName().equals(SchemaSymbols::fgELT_RESTRICTION)) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::Redefine_InvalidSimpleType); - return false; - } - - baseTypeName = getElementAttValue(grandKid, SchemaSymbols::fgATT_BASE); - const XMLCh* prefix = getPrefix(baseTypeName); - const XMLCh* localPart = getLocalPart(baseTypeName); - const XMLCh* uriStr = resolvePrefixToURI(prefix); - - if (fTargetNSURI != (int) fURIStringPool->addOrFind(uriStr) - || fStringPool->addOrFind(localPart) != typeNameId) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::Redefine_InvalidSimpleTypeBase); - return false; - } - - // now we have to do the renaming... - getRedefineNewTypeName(baseTypeName, redefineNameCounter, fBuffer); - grandKid.setAttribute(SchemaSymbols::fgATT_BASE, fBuffer.getRawBuffer()); - fRedefineComponents->put((void*) SchemaSymbols::fgELT_SIMPLETYPE, - fullTypeNameId, 0); - } - else if (!XMLString::compareString(redefineChildComponentName,SchemaSymbols::fgELT_COMPLEXTYPE)) { - - if (fComplexTypeRegistry->containsKey(typeNameStr)) { - return false; - } - - DOM_Element grandKid = XUtil::getFirstChildElement(redefineChildElem); - - if (grandKid != 0 && grandKid.getLocalName().equals(SchemaSymbols::fgELT_ANNOTATION)) { - grandKid = XUtil::getNextSiblingElement(grandKid); - } - - if (grandKid == 0) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::Redefine_InvalidComplexType); - return false; - } else { - - // have to go one more level down; let another pass worry whether complexType is valid. - DOM_Element greatGrandKid = XUtil::getFirstChildElement(grandKid); - - if (greatGrandKid != 0 && greatGrandKid.getLocalName().equals(SchemaSymbols::fgELT_ANNOTATION)) { - greatGrandKid = XUtil::getNextSiblingElement(greatGrandKid); - } - - if (greatGrandKid == 0) { - - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::Redefine_InvalidComplexType); - return false; - } else { - - DOMString greatGrandKidName = greatGrandKid.getLocalName(); - - if (!greatGrandKidName.equals(SchemaSymbols::fgELT_RESTRICTION) - && !greatGrandKidName.equals(SchemaSymbols::fgELT_EXTENSION)) { - - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::Redefine_InvalidComplexType); - return false; - } - - baseTypeName = getElementAttValue(greatGrandKid, SchemaSymbols::fgATT_BASE); - const XMLCh* prefix = getPrefix(baseTypeName); - const XMLCh* localPart = getLocalPart(baseTypeName); - const XMLCh* uriStr = resolvePrefixToURI(prefix); - - if (fTargetNSURI != (int) fURIStringPool->addOrFind(uriStr) - || fStringPool->addOrFind(localPart) != typeNameId) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::Redefine_InvalidComplexTypeBase); - return false; - } - - // now we have to do the renaming... - getRedefineNewTypeName(baseTypeName, redefineNameCounter, fBuffer); - greatGrandKid.setAttribute(SchemaSymbols::fgATT_BASE, fBuffer.getRawBuffer()); - fRedefineComponents->put((void*) SchemaSymbols::fgELT_COMPLEXTYPE, - fullTypeNameId, 0); - } - } - } - else if (!XMLString::compareString(redefineChildComponentName, SchemaSymbols::fgELT_GROUP)) { - - if (fGroupRegistry->containsKey(typeNameStr)) { - return false; - } - - int groupRefCount = changeRedefineGroup(redefineChildElem, redefineChildComponentName, - redefineChildTypeName, redefineNameCounter); - - if (groupRefCount > 1) { - - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::Redefine_GroupRefCount); - return false; - } - else if (groupRefCount == 0) { - // put a dummy value, default is null. - // when processing groups, we will check that table, if a value - // is found, we need to do a particle derivation check. - fRedefineComponents->put((void*) SchemaSymbols::fgELT_GROUP, - fullTypeNameId, fSchemaInfo->getCurrentSchemaURL()); - } - else { - fRedefineComponents->put((void*) SchemaSymbols::fgELT_GROUP, fullTypeNameId, 0); - } - } - else if (!XMLString::compareString(redefineChildComponentName, SchemaSymbols::fgELT_ATTRIBUTEGROUP)) { - - if (fAttGroupRegistry->containsKey(redefineChildTypeName)) { - return false; - } - - int attGroupRefCount = changeRedefineGroup(redefineChildElem, redefineChildComponentName, - redefineChildTypeName, redefineNameCounter); - - if (attGroupRefCount > 1) { - - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::Redefine_AttGroupRefCount); - return false; - } - else if (attGroupRefCount == 0) { - // put a dummy value, default is null. - // when processing attributeGroups, we will check that table, if - // a value is found, we need to check for attribute derivation ok - // (by restriction) - fRedefineComponents->put((void*) SchemaSymbols::fgELT_ATTRIBUTEGROUP, - fullTypeNameId, fSchemaInfo->getCurrentSchemaURL()); - } - else { - fRedefineComponents->put((void*) SchemaSymbols::fgELT_ATTRIBUTEGROUP, fullTypeNameId, 0); - } - } - - return true; -} - -int TraverseSchema::changeRedefineGroup(const DOM_Element& redefineChildElem, - const XMLCh* const redefineChildComponentName, - const XMLCh* const redefineChildTypeName, - const int redefineNameCounter) { - int result = 0; - DOM_Element child = XUtil::getFirstChildElement(redefineChildElem); - - for (; child != 0; child = XUtil::getNextSiblingElement(child)) { - - DOMString name = child.getLocalName(); - - if (name.equals(SchemaSymbols::fgELT_ANNOTATION)) { - continue; - } - - if (!name.equals(redefineChildComponentName)) { - result += changeRedefineGroup(child, redefineChildComponentName, redefineChildTypeName, redefineNameCounter); - } else { - const XMLCh* refName = getElementAttValue(child, SchemaSymbols::fgATT_REF); - - if (XMLString::stringLen(refName)) { - - const XMLCh* prefix = getPrefix(refName); - const XMLCh* localPart = getLocalPart(refName); - const XMLCh* uriStr = resolvePrefixToURI(prefix); - - if (fTargetNSURI == (int) fURIStringPool->addOrFind(uriStr) - && fStringPool->addOrFind(localPart) == fStringPool->addOrFind(redefineChildTypeName)) { - - // now we have to do the renaming... - getRedefineNewTypeName(refName, redefineNameCounter, fBuffer); - child.setAttribute(SchemaSymbols::fgATT_REF, fBuffer.getRawBuffer()); - result++; - - if(!XMLString::compareString(redefineChildComponentName, SchemaSymbols::fgELT_GROUP)) { - - const XMLCh* minOccurs = getElementAttValue(child, SchemaSymbols::fgATT_MINOCCURS); - const XMLCh* maxOccurs = getElementAttValue(child, SchemaSymbols::fgATT_MAXOCCURS); - - if ((XMLString::stringLen(maxOccurs) && XMLString::compareString(maxOccurs, fgValueOne)) - || (XMLString::stringLen(minOccurs) && XMLString::compareString(minOccurs, fgValueOne))) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::Redefine_InvalidGroupMinMax, redefineChildTypeName); - } - } - } - } // if ref was null some other stage of processing will flag the error - } - } - - return result; -} - - -void TraverseSchema::fixRedefinedSchema(SchemaInfo* const redefinedSchemaInfo, - const XMLCh* const redefineChildComponentName, - const XMLCh* const redefineChildTypeName, - const int redefineNameCounter) { - - bool foundIt = false; - DOM_Element child = XUtil::getFirstChildElement(redefinedSchemaInfo->getRoot()); - - restoreSchemaInfo(redefinedSchemaInfo); - - for (; child != 0; child = XUtil::getNextSiblingElement(child)) { - - DOMString name = child.getLocalName(); - - if (name.equals(redefineChildComponentName)) { - - const XMLCh* infoItemName = getElementAttValue(child, SchemaSymbols::fgATT_NAME); - - if(XMLString::compareString(infoItemName, redefineChildTypeName)) { - continue; - } - else { // found it! - - // now we have to do the renaming... - foundIt = true; - getRedefineNewTypeName(infoItemName, redefineNameCounter, fBuffer); - child.setAttribute(SchemaSymbols::fgATT_NAME, fBuffer.getRawBuffer()); - break; - } - } - else if(name.equals(SchemaSymbols::fgELT_REDEFINE)) { // need to search the redefine decl... - - for (DOM_Element redefChild = XUtil::getFirstChildElement(child); - redefChild != 0; - redefChild = XUtil::getNextSiblingElement(redefChild)) { - - DOMString redefName = redefChild.getLocalName(); - - if (redefName.equals(redefineChildComponentName)) { - - const XMLCh* infoItemName = getElementAttValue(redefChild, SchemaSymbols::fgATT_NAME); - - if(XMLString::compareString(infoItemName, redefineChildTypeName)) { - continue; - } - else { // found it! - - if (!openRedefinedSchema(child)) { - return; - } - - foundIt = true; - - SchemaInfo* reRedefinedSchemaInfo = fSchemaInfo; - - SchemaInfo* redefInfo = - redefinedSchemaInfo->getRedefInfo(redefineChildComponentName, redefineChildTypeName); - - reRedefinedSchemaInfo->addRedefineInfo(redefineChildComponentName, - redefineChildTypeName, redefInfo); - - if (validateRedefineNameChange(redefChild, redefineChildComponentName, redefineChildTypeName, redefineNameCounter + 1, redefinedSchemaInfo)) { - fixRedefinedSchema(reRedefinedSchemaInfo, redefineChildComponentName, redefineChildTypeName, redefineNameCounter + 1); - } - else { // rename it so that we do not end up with two global declarations of the same name - fixRedefinedSchema(reRedefinedSchemaInfo, redefineChildComponentName, redefineChildTypeName, redefineNameCounter + 2); - } - - // now we have to do the renaming... - getRedefineNewTypeName(infoItemName, redefineNameCounter, fBuffer); - const XMLCh* newInfoItemName = fStringPool->getValueForId(fStringPool->addOrFind(fBuffer.getRawBuffer())); - redefChild.setAttribute(SchemaSymbols::fgATT_NAME, newInfoItemName); - - // and we now know we will traverse this, so set fRedefineComponents appropriately... - fBuffer.set(fTargetNSURIString); - fBuffer.append(chComma); - fBuffer.append(newInfoItemName); - - unsigned int infoItemNameId = fStringPool->addOrFind(fBuffer.getRawBuffer()); - - if (!fRedefineComponents->containsKey(redefineChildComponentName, infoItemNameId)) { - fRedefineComponents->put((void*) redefineChildComponentName, infoItemNameId, 0); - } - - break; - } - } - } //for - - if (foundIt) { - break; - } - } - } //for - - if(!foundIt) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::Redefine_DeclarationNotFound, redefineChildTypeName); - } -} - -void TraverseSchema::checkParticleDerivation() { - - RefHashTableOfEnumerator<ComplexTypeInfo> complexTypeEnum(fComplexTypeRegistry); - - while (complexTypeEnum.hasMoreElements()) { - - ComplexTypeInfo& curTypeInfo = complexTypeEnum.nextElement(); - ComplexTypeInfo* baseTypeInfo = 0; - ContentSpecNode* curSpecNode = 0; - - if (curTypeInfo.getDerivedBy() == SchemaSymbols::RESTRICTION - && ((baseTypeInfo = curTypeInfo.getBaseComplexTypeInfo()) != 0) - && ((curSpecNode = curTypeInfo.getContentSpec()) != 0)) { - - try { - checkParticleDerivationOk(curSpecNode, curTypeInfo.getScopeDefined(), - baseTypeInfo->getContentSpec(), - baseTypeInfo->getScopeDefined(), baseTypeInfo); - } - catch (const XMLException& excep) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::DisplayErrorMessage, excep.getMessage()); - } - } - } -} - -void TraverseSchema::checkParticleDerivationOk(ContentSpecNode* const curNode, - const int derivedScope, - ContentSpecNode* const baseNode, - const int baseScope, - const ComplexTypeInfo* const baseInfo) { - - // Check for pointless occurrences of all, choice, sequence. The result is - // the contentspec which is not pointless. If the result is a non-pointless - // group, Vector is filled in with the children of interest - if (!curNode || !baseNode) - return; - - ContentSpecNode* curSpecNode = curNode; - ContentSpecNode* baseSpecNode = baseNode; - ValueVectorOf<ContentSpecNode*> curVector(8); - ValueVectorOf<ContentSpecNode*> baseVector(8); - ContentSpecNode::NodeTypes curNodeType = curSpecNode->getType(); - ContentSpecNode::NodeTypes baseNodeType = baseSpecNode->getType(); - - if (curNodeType == ContentSpecNode::Sequence || - curNodeType == ContentSpecNode::Choice || - curNodeType == ContentSpecNode::All) { - curSpecNode = checkForPointlessOccurrences(curSpecNode, curNodeType, &curVector); - } - - if (baseNodeType == ContentSpecNode::Sequence || - baseNodeType == ContentSpecNode::Choice || - baseNodeType == ContentSpecNode::All) { - baseSpecNode = checkForPointlessOccurrences(baseSpecNode, baseNodeType, &baseVector); - } - - curNodeType = curSpecNode->getType(); - baseNodeType = baseSpecNode->getType(); - - switch (curNodeType & 0x0f) { - case ContentSpecNode::Leaf: - { - switch (baseNodeType & 0x0f) { - case ContentSpecNode::Leaf: - { - checkNameAndTypeOK(curSpecNode, derivedScope, baseSpecNode, baseScope, baseInfo); - return; - } - case ContentSpecNode::Any: - case ContentSpecNode::Any_Other: - case ContentSpecNode::Any_NS: - { - checkNSCompat(curSpecNode, baseSpecNode); - return; - } - case ContentSpecNode::Choice: - case ContentSpecNode::Sequence: - case ContentSpecNode::All: - { - checkRecurseAsIfGroup(curSpecNode, derivedScope, baseSpecNode, baseScope, &baseVector, baseInfo); - return; - } - default: - { - ThrowXML(RuntimeException, XMLExcepts::PD_InvalidContentType); - } - } - } - case ContentSpecNode::Any: - case ContentSpecNode::Any_Other: - case ContentSpecNode::Any_NS: - { - switch (baseNodeType & 0x0f) { - case ContentSpecNode::Any: - case ContentSpecNode::Any_Other: - case ContentSpecNode::Any_NS: - { - checkNSSubset(curSpecNode, baseSpecNode); - return; - } - case ContentSpecNode::Choice: - case ContentSpecNode::Sequence: - case ContentSpecNode::All: - case ContentSpecNode::Leaf: - { - ThrowXML(RuntimeException, XMLExcepts::PD_ForbiddenRes1); - } - default: - { - ThrowXML(RuntimeException, XMLExcepts::PD_InvalidContentType); - } - } - } - case ContentSpecNode::All: - { - switch (baseNodeType & 0x0f) { - case ContentSpecNode::Any: - case ContentSpecNode::Any_Other: - case ContentSpecNode::Any_NS: - { - checkNSRecurseCheckCardinality(curSpecNode, &curVector, derivedScope, baseSpecNode); - return; - } - case ContentSpecNode::All: - { - checkRecurse(curSpecNode, derivedScope, &curVector, baseSpecNode, baseScope, &baseVector, baseInfo); - return; - } - case ContentSpecNode::Choice: - case ContentSpecNode::Sequence: - case ContentSpecNode::Leaf: - { - ThrowXML(RuntimeException, XMLExcepts::PD_ForbiddenRes2); - } - default: - { - ThrowXML(RuntimeException, XMLExcepts::PD_InvalidContentType); - } - } - } - case ContentSpecNode::Choice: - { - switch (baseNodeType & 0x0f) { - case ContentSpecNode::Any: - case ContentSpecNode::Any_Other: - case ContentSpecNode::Any_NS: - { - checkNSRecurseCheckCardinality(curSpecNode, &curVector, derivedScope, baseSpecNode); - return; - } - case ContentSpecNode::Choice: - { - checkRecurse(curSpecNode, derivedScope, &curVector, baseSpecNode, baseScope, &baseVector, baseInfo, true); - return; - } - case ContentSpecNode::All: - case ContentSpecNode::Sequence: - case ContentSpecNode::Leaf: - { - ThrowXML(RuntimeException, XMLExcepts::PD_ForbiddenRes3); - } - default: - { - ThrowXML(RuntimeException, XMLExcepts::PD_InvalidContentType); - } - } - } - case ContentSpecNode::Sequence: - { - switch (baseNodeType & 0x0f) { - case ContentSpecNode::Any: - case ContentSpecNode::Any_Other: - case ContentSpecNode::Any_NS: - { - checkNSRecurseCheckCardinality(curSpecNode, &curVector, derivedScope, baseSpecNode); - return; - } - case ContentSpecNode::All: - { - checkRecurseUnordered(curSpecNode, &curVector, derivedScope, baseSpecNode, &baseVector, baseScope, baseInfo); - return; - } - case ContentSpecNode::Sequence: - { - checkRecurse(curSpecNode, derivedScope, &curVector, baseSpecNode, baseScope, &baseVector, baseInfo); - return; - } - case ContentSpecNode::Choice: - { - checkMapAndSum(curSpecNode, &curVector, derivedScope, baseSpecNode, &baseVector, baseScope, baseInfo); - return; - } - case ContentSpecNode::Leaf: - { - ThrowXML(RuntimeException, XMLExcepts::PD_ForbiddenRes4); - } - default: - { - ThrowXML(RuntimeException, XMLExcepts::PD_InvalidContentType); - } - } - } - } -} - -ContentSpecNode* -TraverseSchema::checkForPointlessOccurrences(ContentSpecNode* const specNode, - const ContentSpecNode::NodeTypes nodeType, - ValueVectorOf<ContentSpecNode*>* const nodes) { - - ContentSpecNode* rightNode = specNode->getSecond(); - int min = specNode->getMinOccurs(); - int max = specNode->getMaxOccurs(); - - if (!rightNode) { - - gatherChildren(nodeType, specNode->getFirst(), nodes); - - if (nodes->size() == 1 && min == 1 && max == 1) { - return nodes->elementAt(0); - } - - return specNode; - } - - gatherChildren(nodeType, specNode->getFirst(), nodes); - gatherChildren(nodeType, rightNode, nodes); - - return specNode; -} - -void TraverseSchema::gatherChildren(const ContentSpecNode::NodeTypes parentNodeType, - ContentSpecNode* const specNode, - ValueVectorOf<ContentSpecNode*>* const nodes) { - - if (!specNode) { - return; - } - - int min = specNode->getMinOccurs(); - int max = specNode->getMaxOccurs(); - ContentSpecNode::NodeTypes nodeType = specNode->getType(); - ContentSpecNode* rightNode = specNode->getSecond(); - - if (nodeType == ContentSpecNode::Leaf || - (nodeType & 0x0f) == ContentSpecNode::Any || - (nodeType & 0x0f) == ContentSpecNode::Any_NS || - (nodeType & 0x0f) == ContentSpecNode::Any_Other) { - nodes->addElement(specNode); - } - else if (min !=1 || max != 1) { - nodes->addElement(specNode); - } - else if (!rightNode) { - gatherChildren(nodeType, specNode->getFirst(), nodes); - } - else if (parentNodeType == nodeType) { - - gatherChildren(nodeType, specNode->getFirst(), nodes); - gatherChildren(nodeType, rightNode, nodes); - } - else { - nodes->addElement(specNode); - } -} - -void -TraverseSchema::checkNSCompat(const ContentSpecNode* const derivedSpecNode, - const ContentSpecNode* const baseSpecNode) { - - // check Occurrence ranges - if (!isOccurrenceRangeOK(derivedSpecNode->getMinOccurs(), derivedSpecNode->getMaxOccurs(), - baseSpecNode->getMinOccurs(), baseSpecNode->getMaxOccurs())) { - ThrowXML1(RuntimeException, XMLExcepts::PD_OccurRangeE, - derivedSpecNode->getElement()->getLocalPart()); - } - - // check wildcard subset - if (!wildcardEltAllowsNamespace(baseSpecNode, derivedSpecNode->getElement()->getURI())) { - ThrowXML1(RuntimeException, XMLExcepts::PD_NSCompat1, - derivedSpecNode->getElement()->getLocalPart()); - } -} - -bool -TraverseSchema::wildcardEltAllowsNamespace(const ContentSpecNode* const baseSpecNode, - const unsigned int derivedURI) { - - ContentSpecNode::NodeTypes nodeType = baseSpecNode->getType(); - - if ((nodeType & 0x0f) == ContentSpecNode::Any) { - return true; - } - - unsigned int baseURI = baseSpecNode->getElement()->getURI(); - - if ((nodeType & 0x0f) == ContentSpecNode::Any_NS) { - if (derivedURI == baseURI) { - return true; - } - } - else { // must be ANY_OTHER - if (derivedURI != baseURI && derivedURI != (unsigned int) fEmptyNamespaceURI) { - return true; - } - } - - return false; -} - -void -TraverseSchema::checkNameAndTypeOK(const ContentSpecNode* const derivedSpecNode, - const int derivedScope, - const ContentSpecNode* const baseSpecNode, - const int baseScope, - const ComplexTypeInfo* const baseInfo) { - - unsigned int derivedURI = derivedSpecNode->getElement()->getURI(); - unsigned int baseURI = baseSpecNode->getElement()->getURI(); - const XMLCh* derivedName = derivedSpecNode->getElement()->getLocalPart(); - const XMLCh* baseName = baseSpecNode->getElement()->getLocalPart(); - - if (XMLString::compareString(derivedName, baseName) || derivedURI != baseURI) { - ThrowXML(RuntimeException, XMLExcepts::PD_NameTypeOK1); - } - - // case of mixed complex types with attributes only - if (derivedURI == XMLElementDecl::fgPCDataElemId) { - return; - } - - if (!isOccurrenceRangeOK(derivedSpecNode->getMinOccurs(), derivedSpecNode->getMaxOccurs(), - baseSpecNode->getMinOccurs(), baseSpecNode->getMaxOccurs())) { - ThrowXML1(RuntimeException, XMLExcepts::PD_OccurRangeE, derivedName); - } - - SchemaGrammar* aGrammar = fSchemaGrammar; - const XMLCh* schemaURI = fURIStringPool->getValueForId(derivedURI); - - if ((derivedURI != (unsigned int) fTargetNSURI) && - (derivedURI != (unsigned int) fEmptyNamespaceURI)) { - aGrammar= (SchemaGrammar*) fGrammarResolver->getGrammar(schemaURI); - } - - if (!aGrammar) { //something is wrong - return; - } - - SchemaElementDecl* derivedElemDecl = findElement(derivedScope, derivedURI, derivedName, aGrammar); - - if (!derivedElemDecl) { - return; - } - - SchemaElementDecl* baseElemDecl = - findElement(baseScope, baseURI, baseName, aGrammar, baseInfo); - - if (!baseElemDecl) { - return; - } - - int derivedFlags = derivedElemDecl->getMiscFlags(); - int baseFlags = baseElemDecl->getMiscFlags(); - - if (((baseFlags & SchemaSymbols::NILLABLE) == 0) && - ((derivedFlags & SchemaSymbols::NILLABLE) != 0)) { - ThrowXML1(RuntimeException, XMLExcepts::PD_NameTypeOK2, derivedName); - } - - const XMLCh* derivedDefVal = derivedElemDecl->getDefaultValue(); - const XMLCh* baseDefVal = baseElemDecl->getDefaultValue(); - - if (baseDefVal && (baseFlags & SchemaSymbols::FIXED) != 0 && - ((derivedFlags & SchemaSymbols::FIXED) == 0 || - XMLString::compareString(derivedDefVal, baseDefVal))) { - ThrowXML1(RuntimeException, XMLExcepts::PD_NameTypeOK3, derivedName); - } - - int derivedBlockSet = derivedElemDecl->getBlockSet(); - int baseBlockSet = baseElemDecl->getBlockSet(); - - if ((derivedBlockSet & baseBlockSet) != baseBlockSet) { - ThrowXML1(RuntimeException, XMLExcepts::PD_NameTypeOK4, derivedName); - } - - // check identity constraints - checkICRestriction(derivedElemDecl, baseElemDecl, derivedName, baseName); - - // check that the derived element's type is derived from the base's. - checkTypesOK(derivedElemDecl, baseElemDecl, derivedName); - -} - -SchemaElementDecl* -TraverseSchema::findElement(const int scope, const unsigned int uriIndex, - const XMLCh* const name, - SchemaGrammar* const grammar, - const ComplexTypeInfo* const typeInfo) { - - // check for element at given scope first - SchemaElementDecl* elemDecl = (SchemaElementDecl*) grammar->getElemDecl(uriIndex, name, 0, scope); - - // if not found, check at global scope - if (!elemDecl) { - - elemDecl = (SchemaElementDecl*) - grammar->getElemDecl(uriIndex, name, 0, Grammar::TOP_LEVEL_SCOPE); - - // if still not found, and base is specified, look it up there - if (!elemDecl && typeInfo) { - - const ComplexTypeInfo* baseInfo = typeInfo; - - while (baseInfo) { - - elemDecl = (SchemaElementDecl*) - grammar->getElemDecl(uriIndex, name, 0, baseInfo->getScopeDefined()); - - if (elemDecl) { - break; - } - - baseInfo = baseInfo->getBaseComplexTypeInfo(); - } - } - } - - return elemDecl; -} - -void -TraverseSchema::checkICRestriction(const SchemaElementDecl* const derivedElemDecl, - const SchemaElementDecl* const baseElemDecl, - const XMLCh* const derivedElemName, - const XMLCh* const baseElemName) { - - // REVIST - need to get more clarification - unsigned int derivedICCount = derivedElemDecl->getIdentityConstraintCount(); - unsigned int baseICCount = baseElemDecl->getIdentityConstraintCount(); - - if (derivedICCount > baseICCount) { - ThrowXML2(RuntimeException, XMLExcepts::PD_NameTypeOK6, derivedElemName, baseElemName); - } - - for (unsigned int i=0; i < derivedICCount; i++) { - - bool found = false; - IdentityConstraint* ic= derivedElemDecl->getIdentityConstraintAt(i); - - for (unsigned int j=0; j < baseICCount; j++) { - if (*ic == *(baseElemDecl->getIdentityConstraintAt(j))) { - - found = true; - break; - } - } - - if (!found) { - ThrowXML2(RuntimeException, XMLExcepts::PD_NameTypeOK7, derivedElemName, baseElemName); - } - } -} - -void -TraverseSchema::checkTypesOK(const SchemaElementDecl* const derivedElemDecl, - const SchemaElementDecl* const baseElemDecl, - const XMLCh* const derivedElemName) { - - SchemaElementDecl::ModelTypes baseType = baseElemDecl->getModelType(); - - if (baseType == SchemaElementDecl::Any) { - return; - } - - ComplexTypeInfo* rInfo = derivedElemDecl->getComplexTypeInfo(); - ComplexTypeInfo* bInfo = baseElemDecl->getComplexTypeInfo(); - - if (derivedElemDecl->getModelType() == SchemaElementDecl::Simple) { - - if (baseType != SchemaElementDecl::Simple) { - ThrowXML1(RuntimeException, XMLExcepts::PD_NameTypeOK5, derivedElemName); - } - - if (!rInfo) { - - DatatypeValidator* bDV = baseElemDecl->getDatatypeValidator(); - - if (bInfo || bDV == 0 || - !bDV->isSubstitutableBy(derivedElemDecl->getDatatypeValidator())) { - ThrowXML1(RuntimeException, XMLExcepts::PD_NameTypeOK5, derivedElemName); - } - - return; - } - } - - for (; rInfo && rInfo != bInfo; rInfo = rInfo->getBaseComplexTypeInfo()); - - if (rInfo == 0 || rInfo->getDerivedBy() != SchemaSymbols::RESTRICTION) { - ThrowXML1(RuntimeException, XMLExcepts::PD_NameTypeOK5, derivedElemName); - } -} - -void -TraverseSchema::checkRecurseAsIfGroup(ContentSpecNode* const derivedSpecNode, - const int derivedScope, - const ContentSpecNode* const baseSpecNode, - const int baseScope, - ValueVectorOf<ContentSpecNode*>* const baseNodes, - const ComplexTypeInfo* const baseInfo) { - - ContentSpecNode::NodeTypes baseType = baseSpecNode->getType(); - ValueVectorOf<ContentSpecNode*> derivedNodes(1); - bool toLax = false; - - //Treat the element as if it were in a group of the same variety as base - ContentSpecNode derivedGroupNode(baseType, derivedSpecNode, 0, false); - - derivedNodes.addElement(derivedSpecNode); - - if (baseSpecNode->getType() == ContentSpecNode::Choice) { - toLax = true; - } - - checkRecurse(&derivedGroupNode, derivedScope, &derivedNodes, - baseSpecNode, baseScope, baseNodes, baseInfo, toLax); -} - -void -TraverseSchema::checkRecurse(const ContentSpecNode* const derivedSpecNode, - const int derivedScope, - ValueVectorOf<ContentSpecNode*>* const derivedNodes, - const ContentSpecNode* const baseSpecNode, - const int baseScope, - ValueVectorOf<ContentSpecNode*>* const baseNodes, - const ComplexTypeInfo* const baseInfo, - const bool toLax) { - - if (!isOccurrenceRangeOK(derivedSpecNode->getMinOccurs(), derivedSpecNode->getMaxOccurs(), - baseSpecNode->getMinOccurs(), baseSpecNode->getMaxOccurs())) { - ThrowXML(RuntimeException, XMLExcepts::PD_Recurse1); - } - - // check for mapping of children - XMLExcepts::Codes codeToThrow = XMLExcepts::NoError; - unsigned int count1= derivedNodes->size(); - unsigned int count2= baseNodes->size(); - unsigned int current = 0; - - for (unsigned int i=0; i<count1; i++) { - - bool matched = false; - - for (unsigned int j = current; j < count2; j++) { - - ContentSpecNode* baseNode = baseNodes->elementAt(j); - current++; - - try { - - checkParticleDerivationOk(derivedNodes->elementAt(i), derivedScope, baseNode, baseScope, baseInfo); - matched = true; - break; - } - catch(const XMLException&) { - if (!toLax && !emptiableParticle(baseNode)) { - break; - } - } - } - - // did not find a match - if (!matched) { - - codeToThrow = XMLExcepts::PD_Recurse2; - break; - } - } - - // Now, see if there are some elements in the base we didn't match up - // in case of Sequence or All - if (!toLax && codeToThrow == XMLExcepts::NoError) { - for (unsigned int j = current; j < count2; j++) { - if (!emptiableParticle(baseNodes->elementAt(j))) { - - codeToThrow = XMLExcepts::PD_Recurse2; - break; - } - } - } - - if (codeToThrow != XMLExcepts::NoError) { - ThrowXML(RuntimeException, codeToThrow); - } -} - -void TraverseSchema::checkNSSubset(const ContentSpecNode* const derivedSpecNode, - const ContentSpecNode* const baseSpecNode) { - - // check Occurrence ranges - if (!isOccurrenceRangeOK(derivedSpecNode->getMinOccurs(), derivedSpecNode->getMaxOccurs(), - baseSpecNode->getMinOccurs(), baseSpecNode->getMaxOccurs())) { - ThrowXML(RuntimeException, XMLExcepts::PD_NSSubset1); - } - - if (!isWildCardEltSubset(derivedSpecNode, baseSpecNode)) { - ThrowXML(RuntimeException, XMLExcepts::PD_NSSubset2); - } -} - -bool -TraverseSchema::isWildCardEltSubset(const ContentSpecNode* const derivedSpecNode, - const ContentSpecNode* const baseSpecNode) { - - ContentSpecNode::NodeTypes baseType = baseSpecNode->getType(); - - if ((baseType & 0x0f) == ContentSpecNode::Any) { - return true; - } - - ContentSpecNode::NodeTypes derivedType = derivedSpecNode->getType(); - unsigned int baseURI = baseSpecNode->getElement()->getURI(); - unsigned int derivedURI = derivedSpecNode->getElement()->getURI(); - - if (((derivedType & 0x0f) == ContentSpecNode::Any_Other) && - ((baseType & 0x0f) == ContentSpecNode::Any_Other) && - baseURI == derivedURI) { - return true; - } - - if ((derivedType & 0x0f) == ContentSpecNode::Any_NS) { - - if (((baseType & 0x0f) == ContentSpecNode::Any_NS) && - baseURI == derivedURI) { - return true; - } - - if (((baseType & 0x0f) == ContentSpecNode::Any_Other) && - baseURI != derivedURI) { - return true; - } - } - - return false; -} - -void -TraverseSchema::checkNSRecurseCheckCardinality(const ContentSpecNode* const derivedSpecNode, - ValueVectorOf<ContentSpecNode*>* const derivedNodes, - const int derivedScope, - ContentSpecNode* const baseSpecNode) { - - // Implement total range check - int derivedMin = getMinTotalRange(derivedSpecNode); - int derivedMax = getMaxTotalRange(derivedSpecNode); - - // check Occurrence ranges - if (!isOccurrenceRangeOK(derivedMin, derivedMax, baseSpecNode->getMinOccurs(), - baseSpecNode->getMaxOccurs())) { - ThrowXML(RuntimeException, XMLExcepts::PD_NSRecurseCheckCardinality1); - } - - // Check that each member of the group is a valid restriction of the wildcard - unsigned int nodesCount = derivedNodes->size(); - - for (unsigned int i = 0; i < nodesCount; i++) { - checkParticleDerivationOk(derivedNodes->elementAt(i), derivedScope, baseSpecNode, -1); - } -} - -void -TraverseSchema::checkRecurseUnordered(const ContentSpecNode* const derivedSpecNode, - ValueVectorOf<ContentSpecNode*>* const derivedNodes, - const int derivedScope, - ContentSpecNode* const baseSpecNode, - ValueVectorOf<ContentSpecNode*>* const baseNodes, - const int baseScope, - const ComplexTypeInfo* const baseInfo) { - - // check Occurrence ranges - if (!isOccurrenceRangeOK(derivedSpecNode->getMinOccurs(), derivedSpecNode->getMaxOccurs(), - baseSpecNode->getMinOccurs(), baseSpecNode->getMaxOccurs())) { - ThrowXML(RuntimeException, XMLExcepts::PD_Recurse1); - } - - XMLExcepts::Codes codeToThrow = XMLExcepts::NoError; - unsigned int derivedCount= derivedNodes->size(); - unsigned int baseCount = baseNodes->size(); - bool* foundIt = new bool[baseCount]; - ArrayJanitor<bool> janFoundIt(foundIt); - - for (unsigned k=0; k < baseCount; k++) { - foundIt[k] = false; - } - - // check for mapping of children - for (unsigned int i = 0; i < derivedCount; i++) { - - ContentSpecNode* derivedNode = derivedNodes->elementAt(i); - bool matched = false; - - for (unsigned int j = 0; j < baseCount; j++) { - - try { - - checkParticleDerivationOk(derivedNode, derivedScope, baseNodes->elementAt(j), baseScope, baseInfo); - - if (foundIt[j]) { - break; - } - - foundIt[j] = true; - matched = true; - break; - } - catch (const XMLException&) { - } - } - - // didn't find a match. - if (!matched) { - - codeToThrow = XMLExcepts::PD_RecurseUnordered; - break; - } - } - - // For all unmapped particles in base, check to see it it's emptiable or not - if (codeToThrow == XMLExcepts::NoError) { - for (unsigned int j=0; j < baseCount; j++) { - if (!foundIt[j] && !emptiableParticle(baseNodes->elementAt(j))) { - - codeToThrow = XMLExcepts::PD_RecurseUnordered; - break; - } - } - } - - if (codeToThrow != XMLExcepts::NoError) { - ThrowXML(RuntimeException, codeToThrow); - } -} - -void -TraverseSchema::checkMapAndSum(const ContentSpecNode* const derivedSpecNode, - ValueVectorOf<ContentSpecNode*>* const derivedNodes, - const int derivedScope, - ContentSpecNode* const baseSpecNode, - ValueVectorOf<ContentSpecNode*>* const baseNodes, - const int baseScope, - const ComplexTypeInfo* const baseInfo) { - - // check Occurrence ranges - int derivedCount = derivedNodes->size(); - int baseCount = baseNodes->size(); - int derivedMin = derivedSpecNode->getMinOccurs() * derivedCount; - int derivedMax = derivedSpecNode->getMaxOccurs(); - - if (derivedMax != SchemaSymbols::UNBOUNDED) { - derivedMax *= derivedCount; - } - - if (!isOccurrenceRangeOK(derivedMin, derivedMax, baseSpecNode->getMinOccurs(), - baseSpecNode->getMaxOccurs())) { - ThrowXML(RuntimeException, XMLExcepts::PD_Recurse1); - } - - // check for mapping of children - for (int i = 0; i < derivedCount; i++) { - - ContentSpecNode* derivedNode = derivedNodes->elementAt(i); - bool matched = false; - - for (int j = 0; j < baseCount && !matched; j++) { - - try { - - checkParticleDerivationOk(derivedNode, derivedScope, baseNodes->elementAt(j), baseScope, baseInfo); - matched = true; - } - catch (const XMLException&) { - } - } - - // didn't find a match. - if (!matched) { - ThrowXML(RuntimeException, XMLExcepts::PD_MapAndSum); - } - } - -} - -// --------------------------------------------------------------------------- -// TraverseSchema: Error reporting methods -// --------------------------------------------------------------------------- -void TraverseSchema::reportSchemaError(const XMLCh* const msgDomain, - const int errorCode) { - - if (fScanner && XMLString::compareString(msgDomain, XMLUni::fgXMLErrDomain) == 0) { - fScanner->emitError((XMLErrs::Codes) errorCode); - } - else if (fValidator && fScanner && fScanner->getDoValidation() - && XMLString::compareString(msgDomain, XMLUni::fgValidityDomain) == 0) { - fValidator->emitError((XMLValid::Codes) errorCode); - } -} - -void TraverseSchema::reportSchemaError(const XMLCh* const msgDomain, - const int errorCode, - const XMLCh* const text1, - const XMLCh* const text2, - const XMLCh* const text3, - const XMLCh* const text4) { - - if (fScanner && XMLString::compareString(msgDomain, XMLUni::fgXMLErrDomain) == 0) { - fScanner->emitError((XMLErrs::Codes) errorCode,text1,text2,text3,text4); - } - else if (fValidator && fScanner && fScanner->getDoValidation() - && XMLString::compareString(msgDomain, XMLUni::fgValidityDomain) == 0) { - fValidator->emitError((XMLValid::Codes) errorCode,text1,text2,text3,text4); - } -} - -// --------------------------------------------------------------------------- -// TraverseSchema: Init/CleanUp methods -// --------------------------------------------------------------------------- -void TraverseSchema::init() { - - if (fScanner && fScanner->getValidationSchemaFullChecking()) { - fFullConstraintChecking = true; - } - - fDatatypeRegistry = fGrammarResolver->getDatatypeRegistry(); - fDatatypeRegistry->expandRegistryToFullSchemaSet(); - fStringPool = fGrammarResolver->getStringPool(); - fEmptyNamespaceURI = fScanner->getEmptyNamespaceId(); - fCurrentTypeNameStack = new ValueVectorOf<unsigned int>(8); - fCurrentGroupStack = new ValueVectorOf<unsigned int>(8); - fGlobalDeclarations = new RefHash2KeysTableOf<XMLCh>(29, false); - fNotationRegistry = new RefHash2KeysTableOf<XMLCh>(13, false); - fSubstitutionGroups = new RefHash2KeysTableOf<SchemaElementDecl>(29, false); - fSchemaInfoList = new RefHash2KeysTableOf<SchemaInfo>(29); -} - -void TraverseSchema::cleanUp() { - - delete fSchemaInfoList; - delete fCurrentTypeNameStack; - delete fCurrentGroupStack; - delete fGlobalDeclarations; - delete fNotationRegistry; - delete fRedefineComponents; - delete fIdentityConstraintNames; - delete fSubstitutionGroups; - delete fRefElements; - delete fRefElemScope; - delete fIC_ElementsNS; - delete fIC_NamespaceDepthNS; - delete fIC_NodeListNS; - delete fRecursingAnonTypes; - delete fRecursingTypeNames; -} - -/** - * End of file TraverseSchema.cpp - */ - diff --git a/src/validators/schema/TraverseSchema.hpp b/src/validators/schema/TraverseSchema.hpp deleted file mode 100644 index 2222edd5f687c633a090f732d3b7ff123e215293..0000000000000000000000000000000000000000 --- a/src/validators/schema/TraverseSchema.hpp +++ /dev/null @@ -1,1016 +0,0 @@ -/* - * 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$ - */ - -#if !defined(TRAVERSESCHEMA_HPP) -#define TRAVERSESCHEMA_HPP - -/** - * Instances of this class get delegated to Traverse the Schema and - * to populate the SchemaGrammar internal representation. - */ - -// --------------------------------------------------------------------------- -// Includes -// --------------------------------------------------------------------------- -#include <util/XMLUniDefs.hpp> -#include <dom/DOM_Element.hpp> -#include <dom/DOM_Attr.hpp> -#include <framework/XMLBuffer.hpp> -#include <framework/XMLErrorCodes.hpp> -#include <validators/schema/SchemaSymbols.hpp> -#include <util/ValueVectorOf.hpp> -#include <util/RefHash2KeysTableOf.hpp> -#include <validators/common/ContentSpecNode.hpp> -#include <validators/schema/SchemaGrammar.hpp> -#include <validators/schema/SchemaInfo.hpp> -#include <validators/schema/GeneralAttributeCheck.hpp> - -// --------------------------------------------------------------------------- -// Forward Declarations -// --------------------------------------------------------------------------- -class GrammarResolver; -class EntityResolver; -class XMLValidator; -class XMLScanner; -class DatatypeValidator; -class DatatypeValidatorFactory; -class QName; -class ComplexTypeInfo; -class XMLAttDef; -class ContentSpecNode; -class NamespaceScope; -class SchemaAttDef; -class InputSource; -class ErrorHandler; -class XercesGroupInfo; -class XercesAttGroupInfo; -class IdentityConstraint; - - -class VALIDATORS_EXPORT TraverseSchema -{ -public: - // ----------------------------------------------------------------------- - // Public Constructors/Destructor - // ----------------------------------------------------------------------- - TraverseSchema - ( - const DOM_Element& schemaRoot - , XMLStringPool* const uriStringPool - , SchemaGrammar* const schemaGrammar - , GrammarResolver* const grammarResolver - , XMLScanner* const xmlScanner - , XMLValidator* const xmlValidator - , const XMLCh* const schemaURL - , EntityResolver* const entityResolver - , ErrorHandler* const errorHandler - ); - - ~TraverseSchema(); - -private: - // This enumeration is defined here for compatibility with the CodeWarrior - // compiler, which apparently doesn't like to accept default parameter - // arguments that it hasn't yet seen. The Not_All_Context argument is - // used in the declaration of checkMinMax, below. - // - // Flags indicate any special restrictions on minOccurs and maxOccurs - // relating to "all". - // Not_All_Context - not processing an <all> - // All_Element - processing an <element> in an <all> - // Group_Ref_With_All - processing <group> reference that contained <all> - // All_Group - processing an <all> group itself - enum - { - Not_All_Context = 0 - , All_Element = 1 - , Group_Ref_With_All = 2 - , All_Group = 4 - }; - - // ----------------------------------------------------------------------- - // Unimplemented constructors and operators - // ----------------------------------------------------------------------- - TraverseSchema(const TraverseSchema&); - void operator=(const TraverseSchema&); - - // ----------------------------------------------------------------------- - // Init/CleanUp methods - // ----------------------------------------------------------------------- - void init(); - void cleanUp(); - - // ----------------------------------------------------------------------- - // Traversal methods - // ----------------------------------------------------------------------- - /** - * Traverse the Schema DOM tree - */ - void doTraverseSchema(const DOM_Element& schemaRoot, - const XMLCh* const schemaURL); - void traverseSchemaHeader(const DOM_Element& schemaRoot); - void traverseAnnotationDecl(const DOM_Element& childElem); - void traverseInclude(const DOM_Element& childElem); - void traverseImport(const DOM_Element& childElem); - void traverseRedefine(const DOM_Element& childElem); - void traverseAttributeDecl(const DOM_Element& childElem, - ComplexTypeInfo* const typeInfo); - void traverseSimpleContentDecl(const XMLCh* const typeName, - const DOM_Element& contentDecl, - ComplexTypeInfo* const typeInfo); - void traverseComplexContentDecl(const XMLCh* const typeName, - const DOM_Element& contentDecl, - ComplexTypeInfo* const typeInfo, - const bool isMixed); - int traverseSimpleTypeDecl(const DOM_Element& childElem, - int baseRefContext = SchemaSymbols::EMPTY_SET); - int traverseComplexTypeDecl(const DOM_Element& childElem, const XMLCh* const recursingTypeName = 0); - int traverseByList(const DOM_Element& rootElem, - const DOM_Element& contentElem, - const int typeNameIndex, - const int finalSet); - int traverseByRestriction(const DOM_Element& rootElem, - const DOM_Element& contentElem, - const int typeNameIndex, - const int finalSet); - int traverseByUnion(const DOM_Element& rootElem, - const DOM_Element& contentElem, - const int typeNameIndex, - const int finalSet, - int baseRefContext); - QName* traverseElementDecl(const DOM_Element& childElem, bool& toDelete); - const XMLCh* traverseNotationDecl(const DOM_Element& childElem); - const XMLCh* traverseNotationDecl(const XMLCh* const name, - const XMLCh* const uriStr); - ContentSpecNode* traverseChoiceSequence(const DOM_Element& elemDecl, - const int modelGroupType); - ContentSpecNode* traverseAny(const DOM_Element& anyDecl); - ContentSpecNode* traverseAll(const DOM_Element& allElem); - XercesGroupInfo* traverseGroupDecl(const DOM_Element& childElem); - XercesAttGroupInfo* traverseAttributeGroupDecl(const DOM_Element& elem, - ComplexTypeInfo* const typeInfo); - XercesAttGroupInfo* traverseAttributeGroupDeclNS(const XMLCh* const uriStr, - const XMLCh* const name); - SchemaAttDef* traverseAnyAttribute(const DOM_Element& elem); - void traverseKey(const DOM_Element& icElem, - SchemaElementDecl* const elemDecl); - void traverseUnique(const DOM_Element& icElem, - SchemaElementDecl* const elemDecl); - void traverseKeyRef(const DOM_Element& icElem, - SchemaElementDecl* const elemDecl, - const unsigned int namespaceDepth); - bool traverseIdentityConstraint(IdentityConstraint* const ic, - const DOM_Element& icElem); - - // ----------------------------------------------------------------------- - // Error Reporting methods - // ----------------------------------------------------------------------- - void reportSchemaError(const XMLCh* const msgDomain, const int errorCode); - void reportSchemaError(const XMLCh* const msgDomain, - const int errorCode, - const XMLCh* const text1, - const XMLCh* const text2 = 0, - const XMLCh* const text3 = 0, - const XMLCh* const text4 = 0); - - // ----------------------------------------------------------------------- - // Private Helper methods - // ----------------------------------------------------------------------- - /** - * Retrived the Namespace mapping from the schema element - */ - void retrieveNamespaceMapping(const DOM_Element& schemaRoot); - - /** - * Loop through the children, and traverse the corresponding schema type - * type declaration (simpleType, complexType, import, ....) - */ - void processChildren(const DOM_Element& root); - - /** - * Parameters: - * rootElem - top element for a given type declaration - * contentElem - content must be annotation? or some other simple content - * isEmpty: - true if (annotation?, smth_else), false if (annotation?) - * - * Check for Annotation if it is present, traverse it. If a sibling is - * found and it is not an annotation return it, otherwise return 0. - * Used by traverseSimpleTypeDecl. - */ - DOM_Element checkContent(const DOM_Element& rootElem, - const DOM_Element& contentElem, - const bool isEmpty); - - /** - * Parameters: - * contentElem - content element to check - * - * Check for identity constraints content. - */ - DOM_Element checkIdentityConstraintContent(const DOM_Element& contentElem); - - DatatypeValidator* getDatatypeValidator(const XMLCh* const uriStr, - const XMLCh* const localPartStr); - - /** - * Return qualified name of a given type name index from the string pool - * If a target name space exist, it is returned as part of the name - * - * The allocation will be handled internally, and the caller should not - * delete the returned pointer. - */ - XMLCh* getQualifiedName(const int typeNameIndex); - - /** - * Process simpleType content of a list|restriction|union - * Return a dataype validator if valid type, otherwise 0. - */ - DatatypeValidator* checkForSimpleTypeValidator(const DOM_Element& content, - int baseRefContext = SchemaSymbols::EMPTY_SET); - - /** - * Process complexType content of an element - * Return a ComplexTypeInfo if valid type, otherwise 0. - */ - ComplexTypeInfo* checkForComplexTypeInfo(const DOM_Element& content); - - /** - * Return DatatypeValidator available for the baseTypeStr. - */ - DatatypeValidator* findDTValidator(const DOM_Element& rootElem, - const XMLCh* const baseTypeStr, - const int baseRefContext); - - const XMLCh* resolvePrefixToURI(const XMLCh* const prefix); - const XMLCh* resolvePrefixToURI(const XMLCh* const prefix, - const unsigned int namespaceDepth); - - /** - * Return whether an element is defined as a top level schema component - * or not. - */ - bool isTopLevelComponent(const DOM_Element& elem); - - /** - * Return the prefix for a given rawname string - * - * Function allocated, caller managed (facm) - pointer to be deleted by - * caller. - */ - const XMLCh* getPrefix(const XMLCh* const rawName); - - /** - * Return the local for a given rawname string - * - * caller allocated, caller managed (cacm) - */ - const XMLCh* getLocalPart(const XMLCh* const rawName); - - /** - * Process a 'ref' of an Element declaration - */ - QName* processElementDeclRef(const DOM_Element& elem, - const XMLCh* const refName, - bool& toDelete); - - /** - * Process a 'ref' of an Attribute declaration - */ - void processAttributeDeclRef(const DOM_Element& elem, - ComplexTypeInfo* const typeInfo, - const XMLCh* const refName, - const XMLCh* const useVal, - const XMLCh* const defaultVal, - const XMLCh* const fixedVal); - - /** - * Process a 'ref' on a group - */ - XercesGroupInfo* processGroupRef(const DOM_Element& elem, - const XMLCh* const refName); - - /** - * Process a 'ref' on a attributeGroup - */ - XercesAttGroupInfo* processAttributeGroupRef(const DOM_Element& elem, - const XMLCh* const refName, - ComplexTypeInfo* const typeInfo); - - /** - * Parse block & final items - */ - int parseBlockSet(const XMLCh* const blockStr, const int blockType); - int parseFinalSet(const XMLCh* const finalStr, const int finalType); - - /** - * Return true if a name is an identity constraint, otherwise false - */ - bool isIdentityConstraintName(const XMLCh* const constraintName); - - /** - * Check a 'ref' declaration representation constraint - */ - bool isValidRefDeclaration(const DOM_Element& elem); - - /** - * If 'typeStr' belongs to a different schema, return that schema URI, - * otherwise return 0; - */ - const XMLCh* checkTypeFromAnotherSchema(const XMLCh* const typeStr); - - /** - * Return the datatype validator for a given element type attribute if - * the type is a simple type - */ - DatatypeValidator* getElementTypeValidator(const XMLCh* const typeStr, - bool& noErrorDetected, - const XMLCh* const otherSchemaURI, - bool errorCheck = false); - - /** - * Return the complexType info for a given element type attribute if - * the type is a complex type - */ - ComplexTypeInfo* getElementComplexTypeInfo(const XMLCh* const typeStr, - bool& noErrorDetected, - const XMLCh* const otherSchemaURI); - - /** - * Return schema element declaration for a given substituteGroup element - * name - */ - SchemaElementDecl* getSubstituteGroupElemDecl(const XMLCh* const name, - bool& noErrorDetected); - - /** - * Check validity constraint of a substitutionGroup attribute in - * an element declaration - */ - bool isSubstitutionGroupValid(const SchemaElementDecl* const elemDecl, - const ComplexTypeInfo* const typeInfo, - const DatatypeValidator* const validator, - const XMLCh* const elemName, - const bool toEmit = true); - - /** - * Create a 'SchemaElementDecl' object and add it to SchemaGrammar - */ - SchemaElementDecl* createSchemaElementDecl(const DOM_Element& elem, - const bool topLevel, - const unsigned short elemType, - bool& isDuplicate, - const bool isFixedValue); - - /** - * Return the value of a given attribute name from an element node - */ - const XMLCh* getElementAttValue(const DOM_Element& elem, - const XMLCh* const attName, - const bool toTrim = false); - - void checkMinMax(ContentSpecNode* const specNode, - const DOM_Element& elem, - const int allContext = Not_All_Context); - - /** - * Process complex content for a complexType - */ - void processComplexContent(const XMLCh* const typeName, - const DOM_Element& childElem, - ComplexTypeInfo* const typeInfo, - const XMLCh* const baseRawName, - const XMLCh* const baseLocalPart, - const XMLCh* const baseURI, - const bool isMixed, - const bool isBaseAnyType = false); - - /** - * Process "base" information for a complexType - */ - void processBaseTypeInfo(const XMLCh* const baseName, - const XMLCh* const localPart, - const XMLCh* const uriStr, - ComplexTypeInfo* const typeInfo); - - /** - * Check if base is from another schema - */ - bool isBaseFromAnotherSchema(const XMLCh* const baseURI); - - /** - * Get complexType infp from another schema - */ - ComplexTypeInfo* getTypeInfoFromNS(const XMLCh* const uriStr, - const XMLCh* const localPart); - - /** - * Returns true if 'name' is a valid facet for a given 'component', - * otherwise false - */ - bool isValidFacet(const XMLCh* const component, const XMLCh* const name); - - bool isAttrOrAttrGroup(const DOM_Element& elem); - - /** - * Process attributes of a complex type - */ - void processAttributes(const DOM_Element& elem, - const XMLCh* const baseRawName, - const XMLCh* const baseLocalPart, - const XMLCh* const baseURI, - ComplexTypeInfo* const typeInfo); - - /** - * Generate a name for an anonymous type - */ - const XMLCh* genAnonTypeName(const XMLCh* const prefix); - - void defaultComplexTypeInfo(ComplexTypeInfo* const typeInfo); - - /** - * Resolve a schema location attribute value to an input source. - * Caller to delete the returned object. - */ - InputSource* resolveSchemaLocation(const XMLCh* const loc); - - void restoreSchemaInfo(SchemaInfo* const toRestore, - SchemaInfo::ListType const aListType = SchemaInfo::INCLUDE); - int resetCurrentTypeNameStack(const int); - - /** - * Check whether a mixed content is emptiable or not. - * Needed to validate element constraint values (defualt, fixed) - */ - bool emptiableParticle(const ContentSpecNode* const specNode); - - /** - * Used by emptiableMixedContent to get the 'particle' - * minimum/maximum total range. - */ - int getMinTotalRange(const ContentSpecNode* const specNode); - int getMaxTotalRange(const ContentSpecNode* const specNode); - - - void checkFixedFacet(const DOM_Element&, const XMLCh* const, - const DatatypeValidator* const, unsigned int&); - void checkRefElementConsistency(); - void buildValidSubstitutionListF(SchemaElementDecl* const, - SchemaElementDecl* const); - void buildValidSubstitutionListB(SchemaElementDecl* const, - SchemaElementDecl* const); - - void checkEnumerationRequiredNotation(const XMLCh* const name, - const XMLCh* const typeStr); - - bool hasAllContent(const ContentSpecNode* const specNode); - - void processElements(ComplexTypeInfo* const baseTypeInfo, - ComplexTypeInfo* const newTypeInfo); - - void copyGroupElements(XercesGroupInfo* const fromGroup, - XercesGroupInfo* const toGroup, - ComplexTypeInfo* const typeInfo); - - void copyAttGroupAttributes(XercesAttGroupInfo* const fromAttGroup, - XercesAttGroupInfo* const toAttGroup, - ComplexTypeInfo* const typeInfo); - - const XMLCh* getTargetNamespaceString(const DOM_Element& elem); - - /** - * Attribute wild card intersection. - * - * Note: - * The first parameter will be the result of the intersection, so - * we need to make sure that first parameter is a copy of the - * actual attribute definition we need to intersect with. - * - * What we need to wory about is: type, defaultType, namespace, - * and URI. All remaining data members should be the same. - */ - void attWildCardIntersection(SchemaAttDef* const resultWildCart, - const SchemaAttDef* const toCompareWildCard); - - /** - * Attribute wild card union. - * - * Note: - * The first parameter will be the result of the union, so - * we need to make sure that first parameter is a copy of the - * actual attribute definition we need to intersect with. - * - * What we need to wory about is: type, defaultType, namespace, - * and URI. All remaining data members should be the same. - */ - void attWildCardUnion(SchemaAttDef* const resultWildCart, - const SchemaAttDef* const toCompareWildCard); - - void copyWildCardData(const SchemaAttDef* const srcWildCard, - SchemaAttDef* const destWildCard); - - /** - * Check that the attributes of a type derived by restriction satisfy - * the constraints of derivation valid restriction - */ - void checkAttDerivationOK(const ComplexTypeInfo* const baseTypeInfo, - const ComplexTypeInfo* const childTypeInfo); - void checkAttDerivationOK(const XercesAttGroupInfo* const baseAttGrpInfo, - const XercesAttGroupInfo* const childAttGrpInfo); - - /** - * Check whether a namespace value is valid with respect to wildcard - * constraint - */ - bool wildcardAllowsNamespace(const SchemaAttDef* const baseAttWildCard, - const unsigned int nameURI); - - /** - * Check whether a namespace constraint is an intensional subset of - * another namespace constraint - */ - bool isWildCardSubset(const SchemaAttDef* const baseAttWildCard, - const SchemaAttDef* const childAttWildCard); - - bool isAnyType(const XMLCh* const typeName); - - bool openRedefinedSchema(const DOM_Element& redefineElem); - - /** - * The purpose of this method is twofold: - * 1. To find and appropriately modify all information items - * in redefinedSchema with names that are redefined by children of - * redefineElem. - * 2. To make sure the redefine element represented by - * redefineElem is valid as far as content goes and with regard to - * properly referencing components to be redefined. - * - * No traversing is done here! - * This method also takes actions to find and, if necessary, modify - * the names of elements in <redefine>'s in the schema that's being - * redefined. - */ - void renameRedefinedComponents(const DOM_Element& redefineElem, - SchemaInfo* const redefiningSchemaInfo, - SchemaInfo* const redefinedSchemaInfo); - - /** - * This method returns true if the redefine component is valid, and if - * it was possible to revise it correctly. - */ - bool validateRedefineNameChange(const DOM_Element& redefineChildElem, - const XMLCh* const redefineChildElemName, - const XMLCh* const redefineChildDeclName, - const int redefineNameCounter, - SchemaInfo* const redefiningSchemaInfo); - - /** - * This function looks among the children of 'redefineChildElem' for a - * component of type 'redefineChildComponentName'. If it finds one, it - * evaluates whether its ref attribute contains a reference to - * 'refChildTypeName'. If it does, it returns 1 + the value returned by - * calls to itself on all other children. In all other cases it returns - * 0 plus the sum of the values returned by calls to itself on - * redefineChildElem's children. It also resets the value of ref so that - * it will refer to the renamed type from the schema being redefined. - */ - int changeRedefineGroup(const DOM_Element& redefineChildElem, - const XMLCh* const redefineChildComponentName, - const XMLCh* const redefineChildTypeName, - const int redefineNameCounter); - - /** This simple function looks for the first occurrence of a - * 'redefineChildTypeName' item in the redefined schema and appropriately - * changes the value of its name. If it turns out that what we're looking - * for is in a <redefine> though, then we just rename it--and it's - * reference--to be the same. - */ - void fixRedefinedSchema(SchemaInfo* const redefinedSchemaInfo, - const XMLCh* const redefineChildComponentName, - const XMLCh* const redefineChildTypeName, - const int redefineNameCounter); - - void getRedefineNewTypeName(const XMLCh* const oldTypeName, - const int redefineCounter, - XMLBuffer& newTypeName); - - /** - * This purpose of this method is threefold: - * 1. To extract the schema information of included/redefined schema. - * 2. Rename redefined components. - * 3. Process components of included/redefined schemas - */ - void preprocessRedefineInclude(SchemaInfo* const currSchemaInfo); - - /** - * Update the list of valid substitution groups in the case of circular - * import. - */ - void updateCircularSubstitutionList(SchemaInfo* const aSchemaInfo); - - void processKeyRefFor(SchemaInfo* const aSchemaInfo, - ValueVectorOf<SchemaInfo*>* const infoList); - - // ----------------------------------------------------------------------- - // Particle Derivation Checking methods - // ----------------------------------------------------------------------- - void checkParticleDerivation(); - void checkParticleDerivationOk(ContentSpecNode* const curNode, - const int derivedScope, - ContentSpecNode* const baseNode, - const int baseScope, - const ComplexTypeInfo* const baseInfo = 0); - ContentSpecNode* checkForPointlessOccurrences(ContentSpecNode* const specNode, - const ContentSpecNode::NodeTypes nodeType, - ValueVectorOf<ContentSpecNode*>* const nodes); - void gatherChildren(const ContentSpecNode::NodeTypes parentNodeType, - ContentSpecNode* const specNode, - ValueVectorOf<ContentSpecNode*>* const nodes); - bool isOccurrenceRangeOK(const int min1, const int max1, const int min2, const int max2); - void checkNSCompat(const ContentSpecNode* const derivedSpecNode, - const ContentSpecNode* const baseSpecNode); - bool wildcardEltAllowsNamespace(const ContentSpecNode* const baseSpecNode, - const unsigned int derivedURI); - void checkNameAndTypeOK(const ContentSpecNode* const derivedSpecNode, - const int derivedScope, - const ContentSpecNode* const baseSpecNode, - const int baseScope, - const ComplexTypeInfo* const baseInfo = 0); - SchemaElementDecl* findElement(const int scope, - const unsigned int uriIndex, - const XMLCh* const name, - SchemaGrammar* const grammar, - const ComplexTypeInfo* const typeInfo = 0); - void checkICRestriction(const SchemaElementDecl* const derivedElemDecl, - const SchemaElementDecl* const baseElemDecl, - const XMLCh* const derivedElemName, - const XMLCh* const baseElemName); - void checkTypesOK(const SchemaElementDecl* const derivedElemDecl, - const SchemaElementDecl* const baseElemDecl, - const XMLCh* const derivedElemName); - void checkRecurseAsIfGroup(ContentSpecNode* const derivedSpecNode, - const int derivedScope, - const ContentSpecNode* const baseSpecNode, - const int baseScope, - ValueVectorOf<ContentSpecNode*>* const nodes, - const ComplexTypeInfo* const baseInfo); - void checkRecurse(const ContentSpecNode* const derivedSpecNode, - const int derivedScope, - ValueVectorOf<ContentSpecNode*>* const derivedNodes, - const ContentSpecNode* const baseSpecNode, - const int baseScope, - ValueVectorOf<ContentSpecNode*>* const baseNodes, - const ComplexTypeInfo* const baseInfo, - const bool toLax = false); - void checkNSSubset(const ContentSpecNode* const derivedSpecNode, - const ContentSpecNode* const baseSpecNode); - bool isWildCardEltSubset(const ContentSpecNode* const derivedSpecNode, - const ContentSpecNode* const baseSpecNode); - void checkNSRecurseCheckCardinality(const ContentSpecNode* const derivedSpecNode, - ValueVectorOf<ContentSpecNode*>* const derivedNodes, - const int derivedScope, - ContentSpecNode* const baseSpecNode); - void checkRecurseUnordered(const ContentSpecNode* const derivedSpecNode, - ValueVectorOf<ContentSpecNode*>* const derivedNodes, - const int derivedScope, - ContentSpecNode* const baseSpecNode, - ValueVectorOf<ContentSpecNode*>* const baseNodes, - const int baseScope, - const ComplexTypeInfo* const baseInfo); - void checkMapAndSum(const ContentSpecNode* const derivedSpecNode, - ValueVectorOf<ContentSpecNode*>* const derivedNodes, - const int derivedScope, - ContentSpecNode* const baseSpecNode, - ValueVectorOf<ContentSpecNode*>* const baseNodes, - const int baseScope, - const ComplexTypeInfo* const baseInfo); - - // ----------------------------------------------------------------------- - // Private constants - // ----------------------------------------------------------------------- - enum - { - ES_Block - , C_Block - , S_Final - , EC_Final - , ECS_Final - }; - - enum ExceptionCodes - { - NoException = 0, - InvalidComplexTypeInfo = 1, - RecursingElement = 2 - }; - - enum - { - Elem_Def_Qualified = 1, - Attr_Def_Qualified = 2 - }; - - // ----------------------------------------------------------------------- - // Private data members - // ----------------------------------------------------------------------- - bool fFullConstraintChecking; - unsigned short fElemAttrDefaultQualified; - int fTargetNSURI; - int fEmptyNamespaceURI; - int fCurrentScope; - int fFinalDefault; - int fBlockDefault; - int fScopeCount; - int fRecursingElemIndex; - unsigned int fAnonXSTypeCount; - unsigned int fCircularCheckIndex; - const XMLCh* fTargetNSURIString; - DatatypeValidatorFactory* fDatatypeRegistry; - GrammarResolver* fGrammarResolver; - SchemaGrammar* fSchemaGrammar; - EntityResolver* fEntityResolver; - ErrorHandler* fErrorHandler; - XMLStringPool* fURIStringPool; - XMLStringPool* fStringPool; - XMLBuffer fBuffer; - XMLValidator* fValidator; - XMLScanner* fScanner; - NamespaceScope* fNamespaceScope; - RefHashTableOf<XMLAttDef>* fAttributeDeclRegistry; - RefHashTableOf<ComplexTypeInfo>* fComplexTypeRegistry; - RefHashTableOf<XercesGroupInfo>* fGroupRegistry; - RefHashTableOf<XercesAttGroupInfo>* fAttGroupRegistry; - RefHash2KeysTableOf<SchemaInfo>* fSchemaInfoList; - SchemaInfo* fSchemaInfo; - XercesGroupInfo* fCurrentGroupInfo; - XercesAttGroupInfo* fCurrentAttGroupInfo; - ComplexTypeInfo* fCurrentComplexType; - ValueVectorOf<unsigned int>* fCurrentTypeNameStack; - ValueVectorOf<unsigned int>* fCurrentGroupStack; - ValueVectorOf<unsigned int>* fIC_NamespaceDepth; - ValueVectorOf<SchemaElementDecl*>* fIC_Elements; - GeneralAttributeCheck fAttributeCheck; - RefHash2KeysTableOf<XMLCh>* fGlobalDeclarations; - RefHash2KeysTableOf<XMLCh>* fNotationRegistry; - RefHash2KeysTableOf<XMLCh>* fRedefineComponents; - RefHash2KeysTableOf<IdentityConstraint>* fIdentityConstraintNames; - RefHash2KeysTableOf<SchemaElementDecl>* fSubstitutionGroups; - RefHash2KeysTableOf<ElemVector>* fValidSubstitutionGroups; - RefVectorOf<QName>* fRefElements; - ValueVectorOf<int>* fRefElemScope; - RefHashTableOf<ValueVectorOf<DOM_Element> >* fIC_NodeListNS; - RefHashTableOf<ElemVector>* fIC_ElementsNS; - RefHashTableOf<ValueVectorOf<unsigned int> >* fIC_NamespaceDepthNS; - ValueVectorOf<DOM_Element>* fRecursingAnonTypes; - ValueVectorOf<const XMLCh*>* fRecursingTypeNames; - - friend class GeneralAttributeCheck; -}; - - -// --------------------------------------------------------------------------- -// TraverseSchema: Helper methods -// --------------------------------------------------------------------------- -inline const XMLCh* TraverseSchema::getPrefix(const XMLCh* const rawName) { - - int colonIndex = XMLString::indexOf(rawName, chColon); - - if (colonIndex == -1 || colonIndex == 0) { - return XMLUni::fgZeroLenString; - } - - fBuffer.set(rawName, colonIndex); - - return fStringPool->getValueForId(fStringPool->addOrFind(fBuffer.getRawBuffer())); -} - -inline const XMLCh* TraverseSchema::getLocalPart(const XMLCh* const rawName) { - - int colonIndex = XMLString::indexOf(rawName, chColon); - int rawNameLen = XMLString::stringLen(rawName); - - if (colonIndex + 1 == rawNameLen) { - return XMLUni::fgZeroLenString; - } - - if (colonIndex == -1) { - fBuffer.set(rawName, rawNameLen); - } - else { - - fBuffer.set(rawName + colonIndex + 1, rawNameLen - colonIndex - 1); - } - - return fStringPool->getValueForId(fStringPool->addOrFind(fBuffer.getRawBuffer())); -} - -inline bool -TraverseSchema::isValidRefDeclaration(const DOM_Element& elem) { - - return !(elem.getAttribute(SchemaSymbols::fgATT_ABSTRACT).length() != 0 - || elem.getAttribute(SchemaSymbols::fgATT_NILLABLE).length() != 0 - || elem.getAttribute(SchemaSymbols::fgATT_BLOCK).length() != 0 - || elem.getAttribute(SchemaSymbols::fgATT_FINAL).length() != 0 - || elem.getAttribute(SchemaSymbols::fgATT_TYPE).length() != 0 - || elem.getAttribute(SchemaSymbols::fgATT_DEFAULT).length() != 0 - || elem.getAttribute(SchemaSymbols::fgATT_FIXED).length() != 0 - || elem.getAttribute(SchemaSymbols::fgATT_SUBSTITUTIONGROUP).length() != 0); -} - -inline -const XMLCh* TraverseSchema::getElementAttValue(const DOM_Element& elem, - const XMLCh* const attName, - const bool toTrim) { - - DOM_Attr attNode = elem.getAttributeNode(attName); - - if (attNode == 0) { - return 0; - } - - DOMString attValue = attNode.getValue(); - - if (attValue.length() > 0) { - - fBuffer.set(attValue.rawBuffer(), attValue.length()); - XMLCh* bufValue = fBuffer.getRawBuffer(); - - if (toTrim) { - - XMLString::trim(bufValue); - - if (!XMLString::stringLen(bufValue)) { - return 0; - } - } - - return fStringPool->getValueForId(fStringPool->addOrFind(bufValue)); - } - - return XMLUni::fgZeroLenString; -} - -inline const XMLCh* -TraverseSchema::getTargetNamespaceString(const DOM_Element& elem) { - - const XMLCh* targetNS = getElementAttValue(elem, SchemaSymbols::fgATT_TARGETNAMESPACE); - - if (targetNS && XMLString::stringLen(targetNS) == 0) { - reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::InvalidTargetNSValue); - } - - return targetNS; -} - -inline bool TraverseSchema::isBaseFromAnotherSchema(const XMLCh* const baseURI) -{ - if (XMLString::compareString(baseURI,fTargetNSURIString) != 0 - && XMLString::compareString(baseURI, SchemaSymbols::fgURI_SCHEMAFORSCHEMA) != 0 - && XMLString::stringLen(baseURI) != 0) { - //REVISIT, !!!! a hack: for schema that has no - //target namespace, e.g. personal-schema.xml - return true; - } - - return false; -} - -inline bool TraverseSchema::isAttrOrAttrGroup(const DOM_Element& elem) { - - DOMString elementName = elem.getLocalName(); - - if (elementName.equals(SchemaSymbols::fgELT_ATTRIBUTE) || - elementName.equals(SchemaSymbols::fgELT_ATTRIBUTEGROUP) || - elementName.equals(SchemaSymbols::fgELT_ANYATTRIBUTE)) { - return true; - } - - return false; -} - -inline const XMLCh* TraverseSchema::genAnonTypeName(const XMLCh* const prefix) { - - XMLCh anonCountStr[16]; // a count of 15 digits should be enough - - XMLString::binToText(fAnonXSTypeCount++, anonCountStr, 15, 10); - fBuffer.set(prefix); - fBuffer.append(anonCountStr); - - return fStringPool->getValueForId(fStringPool->addOrFind(fBuffer.getRawBuffer())); -} - -inline int TraverseSchema::resetCurrentTypeNameStack(const int value) { - - unsigned int stackSize = fCurrentTypeNameStack->size(); - - if (stackSize != 0) { - fCurrentTypeNameStack->removeElementAt(stackSize - 1); - } - - return value; -} - -inline void -TraverseSchema::copyWildCardData(const SchemaAttDef* const srcWildCard, - SchemaAttDef* const destWildCard) { - - destWildCard->getAttName()->setURI(srcWildCard->getAttName()->getURI()); - destWildCard->setType(srcWildCard->getType()); - destWildCard->setDefaultType(srcWildCard->getDefaultType()); -} - -inline bool -TraverseSchema::isAnyType(const XMLCh* const typeName) { - - const XMLCh* const localPart = getLocalPart(typeName); - const XMLCh* const uri = resolvePrefixToURI(getPrefix(typeName)); - - return (!XMLString::compareString(uri, SchemaSymbols::fgURI_SCHEMAFORSCHEMA) - && !XMLString::compareString(localPart, SchemaSymbols::fgATTVAL_ANYTYPE)); -} - -inline void TraverseSchema::getRedefineNewTypeName(const XMLCh* const oldTypeName, - const int redefineCounter, - XMLBuffer& newTypeName) { - - newTypeName.set(oldTypeName); - - for (int i=0; i < redefineCounter; i++) { - newTypeName.append(SchemaSymbols::fgRedefIdentifier); - } -} - -inline bool -TraverseSchema::isOccurrenceRangeOK(const int min1, const int max1, - const int min2, const int max2) { - - if (min1 >= min2 && - (max2 == SchemaSymbols::UNBOUNDED || - (max1 != SchemaSymbols::UNBOUNDED && max1 <= max2))) { - return true; - } - return false; -} - -#endif - -/** - * End of file TraverseSchema.hpp - */ - diff --git a/src/validators/schema/XUtil.cpp b/src/validators/schema/XUtil.cpp deleted file mode 100644 index 90a0f9294667f32cf6af7c48dab97910dc796b82..0000000000000000000000000000000000000000 --- a/src/validators/schema/XUtil.cpp +++ /dev/null @@ -1,529 +0,0 @@ -/* - * 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$ - * Revision 1.6 2001/12/05 20:12:30 knoaman - * Use getLocalName instead of getNodeName. - * - * Revision 1.5 2001/11/02 14:13:45 knoaman - * Add support for identity constraints. - * - * Revision 1.4 2001/05/11 13:27:39 tng - * Copyright update. - * - * Revision 1.3 2001/05/03 21:02:40 tng - * Schema: Add SubstitutionGroupComparator and update exception messages. By Pei Yong Zhang. - * - * Revision 1.2 2001/04/04 18:02:04 tng - * Schema: include failure on Unix for XUtil.cpp. Fixed by Pei Yong Zhang. - * - * Revision 1.1 2001/03/30 16:06:00 tng - * Schema: XUtil, added by Pei Yong Zhang - * - */ - - -// --------------------------------------------------------------------------- -// Includes -// --------------------------------------------------------------------------- -#include <validators/schema/XUtil.hpp> -#include <util/XMLString.hpp> -#include <framework/XMLBuffer.hpp> -#include <dom/AttrImpl.hpp> -#include <dom/ElementImpl.hpp> -#include <dom/DocumentImpl.hpp> -#include <util/IllegalArgumentException.hpp> - -void XUtil::copyInto(const DOM_Node &src, DOM_Node &dest) -{ - // get node factory - DOM_Document factory = dest.getOwnerDocument(); - - // placement variables - DOM_Node start = src; - DOM_Node parent = src; - DOM_Node place = src; - - // traverse source tree - while (place != 0) - { - // copy this node - DOM_Node node; - short type = place.getNodeType(); - switch (type) - { - case DOM_Node::CDATA_SECTION_NODE: - { - node = factory.createCDATASection(place.getNodeValue()); - break; - } - case DOM_Node::COMMENT_NODE: - { - node = factory.createComment(place.getNodeValue()); - break; - } - case DOM_Node::ELEMENT_NODE: - { - DOM_Element element = factory.createElement(place.getNodeName()); - node = element; - ElementImpl *elemImpl = (ElementImpl*)element.fImpl; - DOM_NamedNodeMap attrs = place.getAttributes(); - unsigned int attrCount = attrs.getLength(); - for (unsigned int i = 0; i < attrCount; i++) - { - if (attrs.item(i).getNodeType() == DOM_Node::ATTRIBUTE_NODE) - { - DOM_Node tmpNode = attrs.item(i); - DOM_Attr attr = (DOM_Attr&)tmpNode; - AttrImpl *attrImpl = elemImpl->setAttribute(attr.getNodeName(), attr.getNodeValue()); - if ((factory.getNodeType() == DOM_Node::DOCUMENT_NODE) && !attr.getSpecified()) - attrImpl->setSpecified(false); - } - }//for - break; - } - case DOM_Node::ENTITY_REFERENCE_NODE: - { - node = factory.createEntityReference(place.getNodeName()); - break; - } - case DOM_Node::PROCESSING_INSTRUCTION_NODE: - { - node = factory.createProcessingInstruction(place.getNodeName(), place.getNodeValue()); - break; - } - case DOM_Node::TEXT_NODE: - { - node = factory.createTextNode(place.getNodeValue()); - break; - } - default: - { - ThrowXML1(IllegalArgumentException - , XMLExcepts::XUTIL_UnCopyableNodeType - , node.getNodeName().rawBuffer()); - } - }//switch - - dest.appendChild(node); - - // iterate over children - if (place.hasChildNodes()) - { - parent = place; - place = place.getFirstChild(); - dest = node; - } - // advance - else - { - place = place.getNextSibling(); - while (place == null && parent != start) - { - place = parent.getNextSibling(); - parent = parent.getParentNode(); - dest = dest.getParentNode(); - } - } - }//while - -} - - -/* - * Returns the concatenated child text of the specified node. - * This method only looks at the immediate children of type - * <code>Node.TEXT_NODE</code> or the children of any child - * node that is of type <code>Node.CDATA_SECTION_NODE</code> - * for the concatenation. - * - * @param node The node to look at. -*/ - -DOMString XUtil::getChildText(const DOM_Node &node) -{ - // is there anything to do? - if (node == 0) - return 0; - - // concatenate children text - DOMString bufToFill; - DOM_Node child = node.getFirstChild(); - while (child != 0) - { - short type = child.getNodeType(); - if (type == DOM_Node::TEXT_NODE) - bufToFill.appendData(child.getNodeValue()); - else if (type == DOM_Node::CDATA_SECTION_NODE) - bufToFill.appendData(getChildText(child)); - - child = child.getNextSibling(); - } - - // return text value - return bufToFill; -} - -// Finds and returns the first child element node. -DOM_Element XUtil::getFirstChildElement(const DOM_Node &parent) -{ - // search for node - DOM_Node child = parent.getFirstChild(); - while (child != 0) - { - if (child.getNodeType() == DOM_Node::ELEMENT_NODE) - return (DOM_Element&)child; - - child = child.getNextSibling(); - } - - // not found - return DOM_Element(); -} - -// Finds and returns the first child node with the given name. -DOM_Element XUtil::getFirstChildElement(const DOM_Node &parent - , const XMLCh* const elemName) -{ - // search for node - DOM_Node child = parent.getFirstChild(); - while (child != 0) - { - if ((child.getNodeType() == DOM_Node::ELEMENT_NODE) && - (XMLString::compareString(child.getNodeName().rawBuffer(), elemName) ==0)) - return (DOM_Element&)child; - - child = child.getNextSibling(); - } - - // not found - return DOM_Element(); -} - -// Finds and returns the first child node with the given name. -DOM_Element XUtil::getFirstChildElement(const DOM_Node &parent - , const XMLCh** const elemNames - , unsigned int length) -{ - // search for node - DOM_Node child = parent.getFirstChild(); - while (child != 0) - { - if (child.getNodeType() == DOM_Node::ELEMENT_NODE) - { - for (unsigned int i = 0; i < length; i++) - { - if (XMLString::compareString(child.getNodeName().rawBuffer(), elemNames[i]) ==0) - return (DOM_Element&)child; - } - } - child = child.getNextSibling(); - } - - // not found - return DOM_Element(); -} - -// Finds and returns the first child node with the given name and -// attribute name, value pair. -DOM_Element XUtil::getFirstChildElement(const DOM_Node &parent - , const XMLCh* const elemName - , const XMLCh* const attrName - , const XMLCh* const attrValue) -{ - // search for node - DOM_Node child = parent.getFirstChild(); - while (child != 0) - { - if (child.getNodeType() == DOM_Node::ELEMENT_NODE) - { - DOM_Element element = (DOM_Element&)child; - if ((XMLString::compareString(element.getNodeName().rawBuffer(), elemName) ==0) && - (XMLString::compareString(element.getAttribute(attrName).rawBuffer(), attrValue) ==0)) - return element; - } - child = child.getNextSibling(); - } - - // not found - return DOM_Element(); -} - - -// Finds and returns the first child node with the given qualified name. -DOM_Element XUtil::getFirstChildElementNS(const DOM_Node &parent - , const XMLCh** const elemNames - , const XMLCh* const uriStr - , unsigned int length) -{ - // search for node - DOM_Node child = parent.getFirstChild(); - while (child != 0) - { - if (child.getNodeType() == DOM_Node::ELEMENT_NODE) - { - for (unsigned int i = 0; i < length; i++) - { - if (child.getNamespaceURI().equals(uriStr) && - XMLString::compareString(child.getLocalName().rawBuffer(), elemNames[i]) ==0) - return (DOM_Element&)child; - } - } - child = child.getNextSibling(); - } - - // not found - return DOM_Element(); -} - -// Finds and returns the last child element node. -DOM_Element XUtil::getLastChildElement(const DOM_Node &parent) { - - // search for node - DOM_Node child = parent.getLastChild(); - while (child != 0) - { - if (child.getNodeType() == DOM_Node::ELEMENT_NODE) - return (DOM_Element&)child; - - child = child.getPreviousSibling(); - } - - // not found - return DOM_Element(); - -} // getLastChildElement(Node):Element - -// Finds and returns the last child node with the given name. -DOM_Element XUtil::getLastChildElement(const DOM_Node &parent - , const XMLCh* const elemName) -{ - // search for node - DOM_Node child = parent.getLastChild(); - while (child != 0) - { - if ((child.getNodeType() == DOM_Node::ELEMENT_NODE) && - (XMLString::compareString(child.getNodeName().rawBuffer(), elemName) ==0)) - return (DOM_Element&)child; - - child = child.getPreviousSibling(); - } - - // not found - return DOM_Element(); -} - -// Finds and returns the last child node with the given name. -DOM_Element XUtil::getLastChildElement(const DOM_Node &parent - , const XMLCh** const elemNames - , unsigned int length) -{ - // search for node - DOM_Node child = parent.getLastChild(); - while (child != 0) - { - if (child.getNodeType() == DOM_Node::ELEMENT_NODE) - { - for (unsigned int i = 0; i < length; i++) - { - if (XMLString::compareString(child.getNodeName().rawBuffer(), elemNames[i]) ==0) - return (DOM_Element&)child; - } - } - child = child.getPreviousSibling(); - } - - // not found - return DOM_Element(); -} - -// Finds and returns the last child node with the given name and -// attribute name, value pair. -DOM_Element XUtil::getLastChildElement(const DOM_Node &parent - , const XMLCh* const elemName - , const XMLCh* const attrName - , const XMLCh* const attrValue) -{ - // search for node - DOM_Node child = parent.getLastChild(); - while (child != 0) - { - if (child.getNodeType() == DOM_Node::ELEMENT_NODE) - { - DOM_Element element = (DOM_Element&)child; - if ((XMLString::compareString(element.getNodeName().rawBuffer(), elemName) ==0) && - (XMLString::compareString(element.getAttribute(attrName).rawBuffer(), attrValue) ==0)) - return element; - } - child = child.getPreviousSibling(); - } - - // not found - return DOM_Element(); -} - -// Finds and returns the next sibling element node. -DOM_Element XUtil::getNextSiblingElement(const DOM_Node &node) -{ - // search for node - DOM_Node sibling = node.getNextSibling(); - while (sibling != 0) - { - if (sibling.getNodeType() == DOM_Node::ELEMENT_NODE) - return (DOM_Element&)sibling; - - sibling = sibling.getNextSibling(); - } - - // not found - return DOM_Element(); -} - -// Finds and returns the next sibling element node with the give name. -DOM_Element XUtil::getNextSiblingElement(const DOM_Node &node - , const XMLCh* const elemName) -{ - // search for node - DOM_Node sibling = node.getNextSibling(); - while (sibling != 0) - { - if ((sibling.getNodeType() == DOM_Node::ELEMENT_NODE) && - (XMLString::compareString(sibling.getNodeName().rawBuffer(), elemName) ==0)) - return (DOM_Element&)sibling; - - sibling = sibling.getNextSibling(); - } - - // not found - return DOM_Element(); -} - -// Finds and returns the next sibling element node with the give name. -DOM_Element XUtil::getNextSiblingElement(const DOM_Node &node - , const XMLCh** const elemNames - , unsigned int length) -{ - // search for node - DOM_Node sibling = node.getNextSibling(); - while (sibling != 0) - { - if (sibling.getNodeType() == DOM_Node::ELEMENT_NODE) - { - for (unsigned int i = 0; i < length; i++) - { - if (XMLString::compareString(sibling.getNodeName().rawBuffer(), elemNames[i]) ==0) - return (DOM_Element&)sibling; - } - } - sibling = sibling.getNextSibling(); - } - - // not found - return DOM_Element(); -} - -// Finds and returns the next sibling element node with the given name and -// attribute name, value pair. -DOM_Element XUtil::getNextSiblingElement(const DOM_Node &node - , const XMLCh* const elemName - , const XMLCh* const attrName - , const XMLCh* const attrValue) -{ - // search for node - DOM_Node sibling = node.getNextSibling(); - while (sibling != 0) - { - if (sibling.getNodeType() == DOM_Node::ELEMENT_NODE) - { - DOM_Element element = (DOM_Element&)sibling; - if ((XMLString::compareString(element.getNodeName().rawBuffer(), elemName) ==0) && - (XMLString::compareString(element.getAttribute(attrName).rawBuffer(), attrValue) ==0)) - return element; - } - sibling = sibling.getNextSibling(); - } - - // not found - return DOM_Element(); -} - -// Finds and returns the next sibling element node with the qualified name. -DOM_Element XUtil::getNextSiblingElementNS(const DOM_Node &node - , const XMLCh** const elemNames - , const XMLCh* const uriStr - , unsigned int length) -{ - // search for node - DOM_Node sibling = node.getNextSibling(); - while (sibling != 0) - { - if (sibling.getNodeType() == DOM_Node::ELEMENT_NODE) - { - for (unsigned int i = 0; i < length; i++) - { - if (sibling.getNamespaceURI().equals(uriStr) && - XMLString::compareString(sibling.getLocalName().rawBuffer(), elemNames[i]) ==0) - return (DOM_Element&)sibling; - } - } - sibling = sibling.getNextSibling(); - } - - // not found - return DOM_Element(); -} - diff --git a/src/validators/schema/XUtil.hpp b/src/validators/schema/XUtil.hpp deleted file mode 100644 index c769f572f36df024870ac0e21211cdc24ce91c22..0000000000000000000000000000000000000000 --- a/src/validators/schema/XUtil.hpp +++ /dev/null @@ -1,177 +0,0 @@ -/* - * 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$ - * Revision 1.3 2001/11/02 14:13:45 knoaman - * Add support for identity constraints. - * - * Revision 1.2 2001/05/11 13:27:39 tng - * Copyright update. - * - * Revision 1.1 2001/03/30 16:06:00 tng - * Schema: XUtil, added by Pei Yong Zhang - * - */ - -#if !defined(XUTIL_HPP) -#define XUTIL_HPP - -#include <dom/DOM_Element.hpp> -#include <dom/DOM_Document.hpp> -#include <dom/DOM_NamedNodeMap.hpp> -#include <dom/DOM_Node.hpp> - -/** - * Some useful utility methods. - */ -class VALIDATORS_EXPORT XUtil -{ -public: - - // - // Copies the source tree into the specified place in a destination - // tree. The source node and its children are appended as children - // of the destination node. - // <p> - // <em>Note:</em> This is an iterative implementation. - // - static void copyInto(const DOM_Node &src, DOM_Node &dest); - - /* - * Returns the concatenated child text of the specified node. - * This method only looks at the immediate children of type - * <code>Node.TEXT_NODE</code> or the children of any child - * node that is of type <code>Node.CDATA_SECTION_NODE</code> - * for the concatenation. - * - * @param node The node to look at. - */ - static DOMString getChildText(const DOM_Node &node); - - // Finds and returns the first child element node. - static DOM_Element getFirstChildElement(const DOM_Node &parent); - // Finds and returns the first child element node with the given name. - static DOM_Element getFirstChildElement(const DOM_Node &parent - , const XMLCh* const elemName); - // Finds and returns the first child node with the given name. - static DOM_Element getFirstChildElement(const DOM_Node &parent - , const XMLCh** const elemNames - , unsigned int length); - // Finds and returns the first child node with the given name and - // attribute name, value pair. - static DOM_Element getFirstChildElement(const DOM_Node &parent - , const XMLCh* const elemName - , const XMLCh* const attrName - , const XMLCh* const attrValue); - - // Finds and returns the first child node with the given qualifiedname. - static DOM_Element getFirstChildElementNS(const DOM_Node &parent - , const XMLCh** const elemNames - , const XMLCh* const uriStr - , unsigned int length); - - // Finds and returns the last child element node. - static DOM_Element getLastChildElement(const DOM_Node &parent); - // Finds and returns the last child element node with the given name. - static DOM_Element getLastChildElement(const DOM_Node &parent - , const XMLCh* const elemName); - // Finds and returns the last child node with the given name. - static DOM_Element getLastChildElement(const DOM_Node &parent - , const XMLCh** const elemNames - , unsigned int length); - // Finds and returns the last child node with the given name and - // attribute name, value pair. - static DOM_Element getLastChildElement(const DOM_Node &parent - , const XMLCh* const elemName - , const XMLCh* const attrName - , const XMLCh* const attrValue); - - // Finds and returns the next sibling element node. - static DOM_Element getNextSiblingElement(const DOM_Node &node); - // Finds and returns the next sibling element node with the given name. - static DOM_Element getNextSiblingElement(const DOM_Node &node - , const XMLCh* const elemName); - // Finds and returns the next sibling node with the given name. - static DOM_Element getNextSiblingElement(const DOM_Node &node - , const XMLCh** const elemNames - , unsigned int length); - // Finds and returns the next sibling node with the given name and - // attribute name, value pair. Since only elements have attributes, - // the node returned will be of type Node.ELEMENT_NODE. - static DOM_Element getNextSiblingElement(const DOM_Node &parent - , const XMLCh* const elemName - , const XMLCh* const attrName - , const XMLCh* const attrValue); - - // Finds and returns the next sibling node with the given qualified name. - static DOM_Element getNextSiblingElementNS(const DOM_Node &node - , const XMLCh** const elemNames - , const XMLCh* const uriStr - , unsigned int length); - -protected: - // ----------------------------------------------------------------------- - // Constructors and Destructor - // ----------------------------------------------------------------------- - - // This class cannot be instantiated. - XUtil() {}; - ~XUtil() {}; - -}; - -#endif diff --git a/src/validators/schema/XercesAttGroupInfo.cpp b/src/validators/schema/XercesAttGroupInfo.cpp deleted file mode 100644 index 539e63966cf3acc6f21b31e1798b6691e284710a..0000000000000000000000000000000000000000 --- a/src/validators/schema/XercesAttGroupInfo.cpp +++ /dev/null @@ -1,154 +0,0 @@ -/* - * 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$ - * Revision 1.4 2001/11/20 20:21:49 knoaman - * Add check for attribute derviation ok when redefining attribute group by restriction. - * - * Revision 1.3 2001/11/20 15:57:04 knoaman - * Add check for multiple attributes with type derived from ID. - * - * Revision 1.2 2001/08/09 15:23:17 knoaman - * add support for <anyAttribute> declaration. - * - * Revision 1.1 2001/07/31 15:26:54 knoaman - * Added support for <attributeGroup>. - * - */ - -// --------------------------------------------------------------------------- -// Includes -// --------------------------------------------------------------------------- -#include <validators/schema/XercesAttGroupInfo.hpp> -#include <util/QName.hpp> - -// --------------------------------------------------------------------------- -// XercesAttGroupInfo: Constructors and Destructor -// --------------------------------------------------------------------------- -XercesAttGroupInfo::XercesAttGroupInfo() - : fTypeWithId(false) - , fAttributes(0) - , fAnyAttributes(0) - , fCompleteWildCard(0) -{ - -} - - -XercesAttGroupInfo::~XercesAttGroupInfo() -{ - delete fAttributes; - delete fAnyAttributes; - delete fCompleteWildCard; -} - -bool XercesAttGroupInfo::containsAttribute(const XMLCh* const name, - const unsigned int uri) { - - if (fAttributes) { - - unsigned int attCount = fAttributes->size(); - - if (attCount) { - - for (unsigned int i=0; i < attCount; i++) { - - QName* attName = fAttributes->elementAt(i)->getAttName(); - - if (attName->getURI() == uri && - !XMLString::compareString(attName->getLocalPart(),name)) { - return true; - } - } - } - } - - return false; -} - -// --------------------------------------------------------------------------- -// XercesAttGroupInfo: Getter methods -// --------------------------------------------------------------------------- -const SchemaAttDef* XercesAttGroupInfo::getAttDef(const XMLCh* const baseName, - const int uriId) const { - - // If no list, then return a null - if (!fAttributes) - return 0; - - unsigned int attSize = fAttributes->size(); - - for (unsigned int i=0; i<attSize; i++) { - - const SchemaAttDef* attDef = fAttributes->elementAt(i); - QName* attName = attDef->getAttName(); - - if (uriId == (int) attName->getURI() && - !XMLString::compareString(baseName, attName->getLocalPart())) { - - return attDef; - } - } - - return 0; -} - -/** - * End of file XercesAttGroupInfo.cpp - */ - - diff --git a/src/validators/schema/XercesAttGroupInfo.hpp b/src/validators/schema/XercesAttGroupInfo.hpp deleted file mode 100644 index 22a4a747673b363ba74e4204705d6ca754d1d0b1..0000000000000000000000000000000000000000 --- a/src/validators/schema/XercesAttGroupInfo.hpp +++ /dev/null @@ -1,256 +0,0 @@ -/* - * 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$ - */ - -#if !defined(XERCESATTGROUPINFO_HPP) -#define XERCESATTGROUPINFO_HPP - - -/** - * The class act as a place holder to store attributeGroup information. - * - * The class is intended for internal use. - */ - -// --------------------------------------------------------------------------- -// Includes -// --------------------------------------------------------------------------- -#include <util/RefVectorOf.hpp> -#include <validators/schema/SchemaAttDef.hpp> - - - -class VALIDATORS_EXPORT XercesAttGroupInfo -{ -public: - // ----------------------------------------------------------------------- - // Public Constructors/Destructor - // ----------------------------------------------------------------------- - XercesAttGroupInfo(); - ~XercesAttGroupInfo(); - - // ----------------------------------------------------------------------- - // Getter methods - // ----------------------------------------------------------------------- - bool containsTypeWithId() const; - unsigned int attributeCount() const; - unsigned int anyAttributeCount() const; - SchemaAttDef* attributeAt(const unsigned int index); - const SchemaAttDef* attributeAt(const unsigned int index) const; - SchemaAttDef* anyAttributeAt(const unsigned int index); - const SchemaAttDef* anyAttributeAt(const unsigned int index) const; - SchemaAttDef* getCompleteWildCard() const; - const SchemaAttDef* getAttDef(const XMLCh* const baseName, - const int uriId) const; - - // ----------------------------------------------------------------------- - // Setter methods - // ----------------------------------------------------------------------- - void setTypeWithId(const bool other); - void addAttDef(SchemaAttDef* const toAdd, const bool toClone = false); - void addAnyAttDef(SchemaAttDef* const toAdd, const bool toClone = false); - void setCompleteWildCard(SchemaAttDef* const toSet); - - // ----------------------------------------------------------------------- - // Query methods - // ----------------------------------------------------------------------- - bool containsAttribute(const XMLCh* const name, const unsigned int uri); - -private: - // ----------------------------------------------------------------------- - // Unimplemented contstructors and operators - // ----------------------------------------------------------------------- - XercesAttGroupInfo(const XercesAttGroupInfo& elemInfo); - XercesAttGroupInfo& operator= (const XercesAttGroupInfo& other); - - // ----------------------------------------------------------------------- - // Private data members - // ----------------------------------------------------------------------- - bool fTypeWithId; - RefVectorOf<SchemaAttDef>* fAttributes; - RefVectorOf<SchemaAttDef>* fAnyAttributes; - SchemaAttDef* fCompleteWildCard; -}; - -// --------------------------------------------------------------------------- -// XercesAttGroupInfo: Getter methods -// --------------------------------------------------------------------------- -inline bool XercesAttGroupInfo::containsTypeWithId() const { - - return fTypeWithId; -} - -inline unsigned int XercesAttGroupInfo::attributeCount() const { - - if (fAttributes) { - return fAttributes->size(); - } - - return 0; -} - -inline unsigned int XercesAttGroupInfo::anyAttributeCount() const { - - if (fAnyAttributes) { - return fAnyAttributes->size(); - } - - return 0; -} - -inline SchemaAttDef* -XercesAttGroupInfo::attributeAt(const unsigned int index) { - - if (fAttributes) { - return fAttributes->elementAt(index); - } - - return 0; -} - -inline const SchemaAttDef* -XercesAttGroupInfo::attributeAt(const unsigned int index) const { - - if (fAttributes) { - return fAttributes->elementAt(index); - } - - return 0; -} - -inline SchemaAttDef* -XercesAttGroupInfo::anyAttributeAt(const unsigned int index) { - - if (fAnyAttributes) { - return fAnyAttributes->elementAt(index); - } - - return 0; -} - -inline const SchemaAttDef* -XercesAttGroupInfo::anyAttributeAt(const unsigned int index) const { - - if (fAnyAttributes) { - return fAnyAttributes->elementAt(index); - } - - return 0; -} - -inline SchemaAttDef* -XercesAttGroupInfo::getCompleteWildCard() const { - - return fCompleteWildCard; -} - -// --------------------------------------------------------------------------- -// XercesAttGroupInfo: Setter methods -// --------------------------------------------------------------------------- -inline void XercesAttGroupInfo::setTypeWithId(const bool other) { - - fTypeWithId = other; -} - -inline void XercesAttGroupInfo::addAttDef(SchemaAttDef* const toAdd, - const bool toClone) { - - if (!fAttributes) { - fAttributes = new RefVectorOf<SchemaAttDef>(4); - } - - if (toClone) { - fAttributes->addElement(new SchemaAttDef(toAdd)); - } - else { - fAttributes->addElement(toAdd); - } -} - -inline void XercesAttGroupInfo::addAnyAttDef(SchemaAttDef* const toAdd, - const bool toClone) { - - if (!fAnyAttributes) { - fAnyAttributes = new RefVectorOf<SchemaAttDef>(2); - } - - if (toClone) { - fAnyAttributes->addElement(new SchemaAttDef(toAdd)); - } - else { - fAnyAttributes->addElement(toAdd); - } -} - -inline void -XercesAttGroupInfo::setCompleteWildCard(SchemaAttDef* const toSet) { - - if (fCompleteWildCard) { - delete fCompleteWildCard; - } - - fCompleteWildCard = toSet; -} - -#endif - -/** - * End of file XercesAttGroupInfo.hpp - */ - diff --git a/src/validators/schema/XercesElementWildcard.cpp b/src/validators/schema/XercesElementWildcard.cpp deleted file mode 100644 index 27bf5338f4ae210308d5d8883127bd8a79cf91db..0000000000000000000000000000000000000000 --- a/src/validators/schema/XercesElementWildcard.cpp +++ /dev/null @@ -1,162 +0,0 @@ -/* - * 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$ - * Revision 1.3 2001/11/21 14:30:13 knoaman - * Fix for UPA checking. - * - * Revision 1.2 2001/08/22 16:58:27 tng - * typo: the type should be t1/t2, not w1/w2. - * - * Revision 1.1 2001/08/21 15:58:42 tng - * Schema: New files XercesElementWildCard. - * - */ - - -// --------------------------------------------------------------------------- -// Includes -// --------------------------------------------------------------------------- -#include <validators/schema/XercesElementWildcard.hpp> - - -// --------------------------------------------------------------------------- -// Local methods -// --------------------------------------------------------------------------- - -/** - * XercesElementWildcard is used to check whether two element declarations conflict - */ -/** - * Check whether two element declarations conflict - */ -bool XercesElementWildcard::conflict(SchemaGrammar* const pGrammar, - ContentSpecNode::NodeTypes type1, - QName* q1, - ContentSpecNode::NodeTypes type2, - QName* q2, - SubstitutionGroupComparator* comparator) -{ - if (type1 == ContentSpecNode::Leaf && - type2 == ContentSpecNode::Leaf) { - if (comparator->isEquivalentTo(q1, q2) || comparator->isEquivalentTo(q2, q1)) - return true; - } - else if (type1 == ContentSpecNode::Leaf) { - return uriInWildcard(pGrammar, q1, q2->getURI(), type2, comparator); - } - else if (type2 == ContentSpecNode::Leaf) { - return uriInWildcard(pGrammar, q2, q1->getURI(), type1, comparator); - } - else { - return wildcardIntersect(type1, q1->getURI(), type2, q2->getURI()); - } - return false; -} - -bool XercesElementWildcard::uriInWildcard(SchemaGrammar* const pGrammar, - QName* qname, - unsigned int wildcard, - ContentSpecNode::NodeTypes wtype, - SubstitutionGroupComparator* comparator) -{ - if ((wtype & 0x0f)== ContentSpecNode::Any) { - return true; - } - else if ((wtype & 0x0f)== ContentSpecNode::Any_NS) { - // substitution of "uri" satisfies "wtype:wildcard" - return comparator->isAllowedByWildcard(pGrammar, qname, wildcard, false); - } - else if ((wtype & 0x0f)== ContentSpecNode::Any_Other) { - // substitution of "uri" satisfies "wtype:wildcard" - return comparator->isAllowedByWildcard(pGrammar, qname, wildcard, true); - } - - return false; -} - -bool XercesElementWildcard::wildcardIntersect(ContentSpecNode::NodeTypes t1, - unsigned int w1, - ContentSpecNode::NodeTypes t2, - unsigned int w2) -{ - if (((t1 & 0x0f) == ContentSpecNode::Any) || - ((t2 & 0x0f) == ContentSpecNode::Any)) { - // if either one is "##any", then intersects - return true; - } - else if (((t1 & 0x0f) == ContentSpecNode::Any_NS) && - ((t2 & 0x0f) == ContentSpecNode::Any_NS) && - (w1 == w2)) { - // if both are "some_namespace" and equal, then intersects - return true; - } - else if (((t1 & 0x0f) == ContentSpecNode::Any_Other) && - ((t2 & 0x0f) == ContentSpecNode::Any_Other)) { - // if both are "##other", and equal, then intersects - return true; - } - else if (((((t1 & 0x0f) == ContentSpecNode::Any_NS) && - ((t2 & 0x0f) == ContentSpecNode::Any_Other)) || - (((t1 & 0x0f) == ContentSpecNode::Any_Other) && - ((t2 & 0x0f) == ContentSpecNode::Any_NS))) && - (w1 != w2)) { - return true; - } - return false; -} - diff --git a/src/validators/schema/XercesElementWildcard.hpp b/src/validators/schema/XercesElementWildcard.hpp deleted file mode 100644 index 170a069e688885153907fa638300259ce655ae3d..0000000000000000000000000000000000000000 --- a/src/validators/schema/XercesElementWildcard.hpp +++ /dev/null @@ -1,124 +0,0 @@ -/* - * 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$ - * Revision 1.2 2001/11/21 14:30:13 knoaman - * Fix for UPA checking. - * - * Revision 1.1 2001/08/21 15:58:42 tng - * Schema: New files XercesElementWildCard. - * - -*/ - - -#if !defined(XERCESELEMENTWILDCARD_HPP) -#define XERCESELEMENTWILDCARD_HPP - -#include <util/QName.hpp> -#include <validators/common/ContentSpecNode.hpp> -#include <validators/schema/SubstitutionGroupComparator.hpp> - -// --------------------------------------------------------------------------- -// Forward declarations -// --------------------------------------------------------------------------- -class SchemaGrammar; - - -class VALIDATORS_EXPORT XercesElementWildcard -{ - -public : - - // ----------------------------------------------------------------------- - // Class static methods - // ----------------------------------------------------------------------- - /* - * check whether two elements are in conflict - */ - static bool conflict(SchemaGrammar* const pGrammar, - ContentSpecNode::NodeTypes type1, - QName* q1, - ContentSpecNode::NodeTypes type2, - QName* q2, - SubstitutionGroupComparator* comparator); - -private: - - // ----------------------------------------------------------------------- - // private helper methods - // ----------------------------------------------------------------------- - static bool uriInWildcard(SchemaGrammar* const pGrammar, - QName* qname, - unsigned int wildcard, - ContentSpecNode::NodeTypes wtype, - SubstitutionGroupComparator* comparator); - - static bool wildcardIntersect(ContentSpecNode::NodeTypes t1, - unsigned int w1, - ContentSpecNode::NodeTypes t2, - unsigned int w2); - - // ----------------------------------------------------------------------- - // Unimplemented constructors and operators - // ----------------------------------------------------------------------- - XercesElementWildcard(); - ~XercesElementWildcard(); -}; - -#endif // XERCESELEMENTWILDCARD_HPP - diff --git a/src/validators/schema/XercesGroupInfo.cpp b/src/validators/schema/XercesGroupInfo.cpp deleted file mode 100644 index 7f3d86803905bf3987c4de78cc4be6d14d310095..0000000000000000000000000000000000000000 --- a/src/validators/schema/XercesGroupInfo.cpp +++ /dev/null @@ -1,95 +0,0 @@ -/* - * 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$ - * Revision 1.2 2001/08/24 20:36:37 knoaman - * Add support for <redefine>. - * - * Revision 1.1 2001/07/24 18:33:46 knoaman - * Added support for <group> + extra constraint checking for complexType - * - */ - -// --------------------------------------------------------------------------- -// Includes -// --------------------------------------------------------------------------- -#include <validators/schema/XercesGroupInfo.hpp> -#include <validators/common/ContentSpecNode.hpp> - -// --------------------------------------------------------------------------- -// XercesGroupInfo: Constructors and Destructor -// --------------------------------------------------------------------------- -XercesGroupInfo::XercesGroupInfo() - : fScope(-1) - , fContentSpec(0) - , fElements(0) -{ - fElements = new RefVectorOf<SchemaElementDecl>(4, false); -} - - -XercesGroupInfo::~XercesGroupInfo() -{ - delete fElements; - delete fContentSpec; -} - -/** - * End of file XercesGroupInfo.cpp - */ - - diff --git a/src/validators/schema/XercesGroupInfo.hpp b/src/validators/schema/XercesGroupInfo.hpp deleted file mode 100644 index 6edb07209bff35c02fc5770b1d84ea301bc81a23..0000000000000000000000000000000000000000 --- a/src/validators/schema/XercesGroupInfo.hpp +++ /dev/null @@ -1,199 +0,0 @@ -/* - * 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$ - */ - -#if !defined(XERCESGROUPINFO_HPP) -#define XERCESGROUPINFO_HPP - - -/** - * The class act as a place holder to store group information. - * - * The class is intended for internal use. - */ - -// --------------------------------------------------------------------------- -// Includes -// --------------------------------------------------------------------------- -#include <util/RefVectorOf.hpp> -#include <validators/schema/SchemaElementDecl.hpp> - - -// --------------------------------------------------------------------------- -// Forward Declarations -// --------------------------------------------------------------------------- -class ContentSpecNode; - - -class VALIDATORS_EXPORT XercesGroupInfo -{ -public: - // ----------------------------------------------------------------------- - // Public Constructors/Destructor - // ----------------------------------------------------------------------- - XercesGroupInfo(); - ~XercesGroupInfo(); - - // ----------------------------------------------------------------------- - // Getter methods - // ----------------------------------------------------------------------- - int getScope() const; - unsigned int elementCount() const; - ContentSpecNode* getContentSpec() const; - SchemaElementDecl* elementAt(const unsigned int index); - const SchemaElementDecl* elementAt(const unsigned int index) const; - - // ----------------------------------------------------------------------- - // Setter methods - // ----------------------------------------------------------------------- - void setScope(const int other); - void setContentSpec(ContentSpecNode* const other); - void addElement(SchemaElementDecl* const toAdd); - - // ----------------------------------------------------------------------- - // Query methods - // ----------------------------------------------------------------------- - bool containsElement(const SchemaElementDecl* const elem); - -private: - // ----------------------------------------------------------------------- - // Unimplemented contstructors and operators - // ----------------------------------------------------------------------- - XercesGroupInfo(const XercesGroupInfo& elemInfo); - XercesGroupInfo& operator= (const XercesGroupInfo& other); - - // ----------------------------------------------------------------------- - // Private data members - // ----------------------------------------------------------------------- - int fScope; - ContentSpecNode* fContentSpec; - RefVectorOf<SchemaElementDecl>* fElements; -}; - -// --------------------------------------------------------------------------- -// XercesGroupInfo: Getter methods -// --------------------------------------------------------------------------- -inline int XercesGroupInfo::getScope() const { - - return fScope; -} - -inline unsigned int XercesGroupInfo::elementCount() const { - - return fElements->size(); -} - -inline ContentSpecNode* XercesGroupInfo::getContentSpec() const { - - return fContentSpec; -} - -inline SchemaElementDecl* -XercesGroupInfo::elementAt(const unsigned int index) { - - return fElements->elementAt(index); -} - -inline const SchemaElementDecl* -XercesGroupInfo::elementAt(const unsigned int index) const { - - return fElements->elementAt(index); -} - -// --------------------------------------------------------------------------- -// XercesGroupInfo: Setter methods -// ---------------------------------------------------------------------------} -inline void XercesGroupInfo::setScope(const int other) { - - fScope = other; -} - -inline void XercesGroupInfo::setContentSpec(ContentSpecNode* const other) { - - fContentSpec = other; -} - -inline void XercesGroupInfo::addElement(SchemaElementDecl* const elem) { - - fElements->addElement(elem); -} - - -// --------------------------------------------------------------------------- -// XercesGroupInfo: Query methods -// ---------------------------------------------------------------------------} -inline bool XercesGroupInfo::containsElement(const SchemaElementDecl* const elem) { - - unsigned int elemSize = fElements->size(); - - for (unsigned int i=0; i < elemSize; i++) { - if (fElements->elementAt(i) == elem) { - return true; - } - } - - return false; -} - -#endif - -/** - * End of file XercesGroupInfo.hpp - */ - diff --git a/src/validators/schema/identity/FieldActivator.cpp b/src/validators/schema/identity/FieldActivator.cpp deleted file mode 100644 index 868fa74b63b9d45160d67e1acd088bf1fa81fb46..0000000000000000000000000000000000000000 --- a/src/validators/schema/identity/FieldActivator.cpp +++ /dev/null @@ -1,145 +0,0 @@ -/* - * 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$ - * 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 - */ - diff --git a/src/validators/schema/identity/FieldActivator.hpp b/src/validators/schema/identity/FieldActivator.hpp deleted file mode 100644 index ca7c2a84a011e194897e9ff723e3e1338f7aa494..0000000000000000000000000000000000000000 --- a/src/validators/schema/identity/FieldActivator.hpp +++ /dev/null @@ -1,155 +0,0 @@ -/* - * 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$ - */ - -#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 - */ - diff --git a/src/validators/schema/identity/FieldValueMap.cpp b/src/validators/schema/identity/FieldValueMap.cpp deleted file mode 100644 index b8d697850a701461b3a6407e5ae892449577a972..0000000000000000000000000000000000000000 --- a/src/validators/schema/identity/FieldValueMap.cpp +++ /dev/null @@ -1,136 +0,0 @@ -/* - * 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$ - * 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 - */ - diff --git a/src/validators/schema/identity/FieldValueMap.hpp b/src/validators/schema/identity/FieldValueMap.hpp deleted file mode 100644 index cfb9a44d50423d6286b81f47d1d42921743a7092..0000000000000000000000000000000000000000 --- a/src/validators/schema/identity/FieldValueMap.hpp +++ /dev/null @@ -1,224 +0,0 @@ -/* - * 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$ - */ - -#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 - */ - diff --git a/src/validators/schema/identity/IC_Field.cpp b/src/validators/schema/identity/IC_Field.cpp deleted file mode 100644 index d74264948b6559496e85cc9e8ab39898e137a9a9..0000000000000000000000000000000000000000 --- a/src/validators/schema/identity/IC_Field.cpp +++ /dev/null @@ -1,145 +0,0 @@ -/* - * 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$ - * Revision 1.2 2001/11/15 17:10:19 knoaman - * Particle derivation checking support. - * - * 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: operators -// --------------------------------------------------------------------------- -bool IC_Field::operator== (const IC_Field& other) const { - - return (*fXPath == *(other.fXPath)); -} - -bool IC_Field::operator!= (const IC_Field& other) const { - - return !operator==(other); -} - -// --------------------------------------------------------------------------- -// IC_Field: Factory methods -// --------------------------------------------------------------------------- -XPathMatcher* IC_Field::createMatcher(ValueStore* const valueStore) { - - return new FieldMatcher(fXPath, this, valueStore); -} - -/** - * End of file IC_Field.cpp - */ - diff --git a/src/validators/schema/identity/IC_Field.hpp b/src/validators/schema/identity/IC_Field.hpp deleted file mode 100644 index 8e753d7cec6967c24a9b12d550cf22357581e975..0000000000000000000000000000000000000000 --- a/src/validators/schema/identity/IC_Field.hpp +++ /dev/null @@ -1,175 +0,0 @@ -/* - * 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$ - */ - -#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(); - - // ----------------------------------------------------------------------- - // operators - // ----------------------------------------------------------------------- - bool operator== (const IC_Field& other) const; - bool operator!= (const IC_Field& other) const; - - // ----------------------------------------------------------------------- - // 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 - */ - diff --git a/src/validators/schema/identity/IC_Key.cpp b/src/validators/schema/identity/IC_Key.cpp deleted file mode 100644 index 8176c090cf313dbb69bf3cdb0bdd925511164bf0..0000000000000000000000000000000000000000 --- a/src/validators/schema/identity/IC_Key.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/* - * 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$ - * 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 - */ - diff --git a/src/validators/schema/identity/IC_Key.hpp b/src/validators/schema/identity/IC_Key.hpp deleted file mode 100644 index 34ad7970eda05ad65e824e8d939634ab5a1e81cf..0000000000000000000000000000000000000000 --- a/src/validators/schema/identity/IC_Key.hpp +++ /dev/null @@ -1,109 +0,0 @@ -/* - * 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$ - */ - -#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 - */ - diff --git a/src/validators/schema/identity/IC_KeyRef.cpp b/src/validators/schema/identity/IC_KeyRef.cpp deleted file mode 100644 index bb872df4ee08428b97ff6483d2254cf6e9f28fce..0000000000000000000000000000000000000000 --- a/src/validators/schema/identity/IC_KeyRef.cpp +++ /dev/null @@ -1,89 +0,0 @@ -/* - * 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$ - * 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 - */ - - diff --git a/src/validators/schema/identity/IC_KeyRef.hpp b/src/validators/schema/identity/IC_KeyRef.hpp deleted file mode 100644 index 6216fa4aa1935288cdbdaed0305841d70000d0c9..0000000000000000000000000000000000000000 --- a/src/validators/schema/identity/IC_KeyRef.hpp +++ /dev/null @@ -1,121 +0,0 @@ -/* - * 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$ - */ - -#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 - */ - diff --git a/src/validators/schema/identity/IC_Selector.cpp b/src/validators/schema/identity/IC_Selector.cpp deleted file mode 100644 index 6eda6b3ad4ebafe8c97c9928812c45d6f8320d35..0000000000000000000000000000000000000000 --- a/src/validators/schema/identity/IC_Selector.cpp +++ /dev/null @@ -1,182 +0,0 @@ -/* - * 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$ - * Revision 1.3 2001/11/23 18:35:33 tng - * Eliminate Warning from AIX xlC 3.6:1540-399: (W) "XMLAttr" is undefined. The delete operator will not call a destructor. - * - * Revision 1.2 2001/11/15 17:10:19 knoaman - * Particle derivation checking support. - * - * Revision 1.1 2001/11/02 14:08:40 knoaman - * Add support for identity constraints. - * - */ - -// --------------------------------------------------------------------------- -// Includes -// --------------------------------------------------------------------------- -#include <framework/XMLAttr.hpp> -#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 unsigned int urlId, - const XMLCh* const elemPrefix, - const RefVectorOf<XMLAttr>& attrList, - const unsigned int attrCount) { - - XPathMatcher::startElement(elemDecl, urlId, elemPrefix, 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, urlId, elemPrefix, 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: operators -// --------------------------------------------------------------------------- -bool IC_Selector::operator ==(const IC_Selector& other) const { - - return (*fXPath == *(other.fXPath)); -} - -bool IC_Selector::operator !=(const IC_Selector& other) const { - - return !operator==(other); -} - -// --------------------------------------------------------------------------- -// IC_Selector: Factory methods -// --------------------------------------------------------------------------- -XPathMatcher* IC_Selector::createMatcher(FieldActivator* const fieldActivator) { - - return new SelectorMatcher(fXPath, this, fieldActivator); -} - -/** - * End of file IC_Selector.cpp - */ - diff --git a/src/validators/schema/identity/IC_Selector.hpp b/src/validators/schema/identity/IC_Selector.hpp deleted file mode 100644 index 20c116ee293df4c25304ca53b3661849d7580b5a..0000000000000000000000000000000000000000 --- a/src/validators/schema/identity/IC_Selector.hpp +++ /dev/null @@ -1,169 +0,0 @@ -/* - * 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$ - */ - -#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(); - - // ----------------------------------------------------------------------- - // operators - // ----------------------------------------------------------------------- - bool operator== (const IC_Selector& other) const; - bool operator!= (const IC_Selector& other) const; - - // ----------------------------------------------------------------------- - // Getter methods - // ----------------------------------------------------------------------- - XercesXPath* getXPath() const { return fXPath; } - IdentityConstraint* getIdentityConstraint() const { return fIdentityConstraint; } - - // ----------------------------------------------------------------------- - // Factory methods - // ----------------------------------------------------------------------- - XPathMatcher* createMatcher(FieldActivator* const fieldActivator); - -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 unsigned int urlId, - const XMLCh* const elemPrefix, - 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 - */ - diff --git a/src/validators/schema/identity/IC_Unique.cpp b/src/validators/schema/identity/IC_Unique.cpp deleted file mode 100644 index a01d8c3061f325ea3dd996017d9e0bf9ba017013..0000000000000000000000000000000000000000 --- a/src/validators/schema/identity/IC_Unique.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/* - * 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$ - * 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 - */ - - diff --git a/src/validators/schema/identity/IC_Unique.hpp b/src/validators/schema/identity/IC_Unique.hpp deleted file mode 100644 index 2eb699ca8c410c410af6a4fbd44d23b21b1f35d4..0000000000000000000000000000000000000000 --- a/src/validators/schema/identity/IC_Unique.hpp +++ /dev/null @@ -1,113 +0,0 @@ -/* - * 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$ - */ - -#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 - */ - diff --git a/src/validators/schema/identity/IdentityConstraint.cpp b/src/validators/schema/identity/IdentityConstraint.cpp deleted file mode 100644 index b97b9471460f667e91193396e2ecce12e336ec2a..0000000000000000000000000000000000000000 --- a/src/validators/schema/identity/IdentityConstraint.cpp +++ /dev/null @@ -1,162 +0,0 @@ -/* - * 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$ - * Revision 1.2 2001/11/15 17:10:19 knoaman - * Particle derivation checking support. - * - * 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: operators -// --------------------------------------------------------------------------- -bool IdentityConstraint::operator ==(const IdentityConstraint& other) const { - - if (getType() != other.getType()) - return false; - - if (XMLString::compareString(fIdentityConstraintName, other.fIdentityConstraintName)) - return false; - - if (*fSelector != *(other.fSelector)) - return false; - - unsigned int fieldCount = fFields->size(); - - if (fieldCount != other.fFields->size()) - return false; - - for (unsigned int i = 0; i < fieldCount; i++) { - if (*(fFields->elementAt(i)) != *(other.fFields->elementAt(i))) - return false; - } - - return true; -} - -bool IdentityConstraint::operator !=(const IdentityConstraint& other) const { - - return !operator==(other); -} - -// --------------------------------------------------------------------------- -// IdentityConstraint: Setter methods -// --------------------------------------------------------------------------- -void IdentityConstraint::setSelector(IC_Selector* const selector) { - - if (fSelector) { - delete fSelector; - } - - fSelector = selector; -} - - -// --------------------------------------------------------------------------- -// IdentityConstraint: cleanUp methods -// --------------------------------------------------------------------------- -void IdentityConstraint::cleanUp() { - - delete [] fIdentityConstraintName; - delete [] fElemName; - delete fFields; - delete fSelector; -} - - - -/** - * End of file IdentityConstraint.cpp - */ - diff --git a/src/validators/schema/identity/IdentityConstraint.hpp b/src/validators/schema/identity/IdentityConstraint.hpp deleted file mode 100644 index eb8c0617f03c573929b452ac5e0e7f44920c0184..0000000000000000000000000000000000000000 --- a/src/validators/schema/identity/IdentityConstraint.hpp +++ /dev/null @@ -1,227 +0,0 @@ -/* - * 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$ - */ - -#if !defined(IDENTITYCONSTRAINT_HPP) -#define IDENTITYCONSTRAINT_HPP - - -/** - * The class act as a base class for schema identity constraints. - */ - -// --------------------------------------------------------------------------- -// Includes -// --------------------------------------------------------------------------- -#include <util/RefVectorOf.hpp> -#include <validators/schema/identity/IC_Field.hpp> - -// --------------------------------------------------------------------------- -// Forward Declarations -// --------------------------------------------------------------------------- -class IC_Selector; - -class VALIDATORS_EXPORT IdentityConstraint -{ -public: - // ----------------------------------------------------------------------- - // Constants - // ----------------------------------------------------------------------- - enum { - UNIQUE = 0, - KEY = 1, - KEYREF = 2 - }; - - // ----------------------------------------------------------------------- - // Constructors/Destructor - // ----------------------------------------------------------------------- - virtual ~IdentityConstraint(); - - // ----------------------------------------------------------------------- - // operators - // ----------------------------------------------------------------------- - bool operator== (const IdentityConstraint& other) const; - bool operator!= (const IdentityConstraint& other) const; - - // ----------------------------------------------------------------------- - // 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 - */ - diff --git a/src/validators/schema/identity/Makefile.in b/src/validators/schema/identity/Makefile.in deleted file mode 100644 index f98fd929bfda73568adea64768478e2564330485..0000000000000000000000000000000000000000 --- a/src/validators/schema/identity/Makefile.in +++ /dev/null @@ -1,144 +0,0 @@ -# -# 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$ -# 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) diff --git a/src/validators/schema/identity/ValueStore.cpp b/src/validators/schema/identity/ValueStore.cpp deleted file mode 100644 index 8a4d04a17b81cd22f3529c314c783240b41c3928..0000000000000000000000000000000000000000 --- a/src/validators/schema/identity/ValueStore.cpp +++ /dev/null @@ -1,373 +0,0 @@ -/* - * 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$ - * Revision 1.3 2001/12/06 17:03:37 knoaman - * Identity Constraint: fix for xpath expressions containing union operator(s). - * - * Revision 1.2 2001/11/20 20:32:52 knoaman - * Bypass validating element's simple content if it's empty and element is nillable. - * - * 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)) { - - if (!fValueTuples) { - fValueTuples = new RefVectorOf<FieldValueMap>(4); - } - - 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); - } - - unsigned int val1Len = XMLString::stringLen(val1); - unsigned int val2Len = XMLString::stringLen(val2); - - if (!val1Len && !val2Len) { - - if (dv1 == dv2) { - return true; - } - - return false; - } - - if (!val1Len || !val2Len) { - return false; - } - - // 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 - */ - diff --git a/src/validators/schema/identity/ValueStore.hpp b/src/validators/schema/identity/ValueStore.hpp deleted file mode 100644 index ee401298d32b13320f25f5e647f59cbab71fa2d1..0000000000000000000000000000000000000000 --- a/src/validators/schema/identity/ValueStore.hpp +++ /dev/null @@ -1,165 +0,0 @@ -/* - * 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$ - */ - -#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 - */ - diff --git a/src/validators/schema/identity/ValueStoreCache.cpp b/src/validators/schema/identity/ValueStoreCache.cpp deleted file mode 100644 index 82d9f1524395b24310407509ad137027240f5ec6..0000000000000000000000000000000000000000 --- a/src/validators/schema/identity/ValueStoreCache.cpp +++ /dev/null @@ -1,199 +0,0 @@ -/* - * 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$ - * 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 - */ - diff --git a/src/validators/schema/identity/ValueStoreCache.hpp b/src/validators/schema/identity/ValueStoreCache.hpp deleted file mode 100644 index f4adcffbcdbc5755be710d860f0f80b76d168e03..0000000000000000000000000000000000000000 --- a/src/validators/schema/identity/ValueStoreCache.hpp +++ /dev/null @@ -1,207 +0,0 @@ -/* - * 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$ - */ - -#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 - */ - diff --git a/src/validators/schema/identity/XPathException.hpp b/src/validators/schema/identity/XPathException.hpp deleted file mode 100644 index fe137d195410a3341de6a23ec7f19dcb52653f24..0000000000000000000000000000000000000000 --- a/src/validators/schema/identity/XPathException.hpp +++ /dev/null @@ -1,71 +0,0 @@ -/* - * 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$ - */ - - -#if !defined(XPATHEXCEPTION_HPP) -#define XPATHEXCEPTION_HPP - -#include <util/XercesDefs.hpp> -#include <util/XMLException.hpp> - - -MakeXMLException(XPathException, VALIDATORS_EXPORT) - -#endif diff --git a/src/validators/schema/identity/XPathMatcher.cpp b/src/validators/schema/identity/XPathMatcher.cpp deleted file mode 100644 index 37f4a37ecb4d4f048febe035b7dbdacc2b56fc1a..0000000000000000000000000000000000000000 --- a/src/validators/schema/identity/XPathMatcher.cpp +++ /dev/null @@ -1,407 +0,0 @@ -/* - * 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$ - * Revision 1.2 2001/11/15 17:10:19 knoaman - * Particle derivation checking support. - * - * 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 unsigned int urlId, - const XMLCh* const elemPrefix, - 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])->getAxisType() == XercesStep::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])->getAxisType() == XercesStep::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])->getAxisType() == XercesStep::CHILD) { - - XercesStep* step = locPath->getStep(fCurrentStep[i]); - XercesNodeTest* nodeTest = step->getNodeTest(); - - if (nodeTest->getType() == XercesNodeTest::QNAME) { - - QName elemQName(elemPrefix, elemDecl.getElementName()->getLocalPart(), urlId); - -// if (!(*(nodeTest->getName()) == *(elemDecl.getElementName()))) { - if (!(*(nodeTest->getName()) == elemQName)) { - - 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])->getAxisType() == XercesStep::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 - */ - diff --git a/src/validators/schema/identity/XPathMatcher.hpp b/src/validators/schema/identity/XPathMatcher.hpp deleted file mode 100644 index 36478ce26518b789ed7b31b66d1034ea6f2da61a..0000000000000000000000000000000000000000 --- a/src/validators/schema/identity/XPathMatcher.hpp +++ /dev/null @@ -1,206 +0,0 @@ -/* - * 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$ - */ - -#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 unsigned int urlId, - const XMLCh* const elemPrefix, - 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 - */ - diff --git a/src/validators/schema/identity/XPathMatcherStack.cpp b/src/validators/schema/identity/XPathMatcherStack.cpp deleted file mode 100644 index 2146e944f0fe7c4365956aafe04285107af2e10c..0000000000000000000000000000000000000000 --- a/src/validators/schema/identity/XPathMatcherStack.cpp +++ /dev/null @@ -1,108 +0,0 @@ -/* - * 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$ - * 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 - */ - diff --git a/src/validators/schema/identity/XPathMatcherStack.hpp b/src/validators/schema/identity/XPathMatcherStack.hpp deleted file mode 100644 index 06943c11dee671cce73499c058c497dd9b48be00..0000000000000000000000000000000000000000 --- a/src/validators/schema/identity/XPathMatcherStack.hpp +++ /dev/null @@ -1,170 +0,0 @@ -/* - * 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$ - */ - -#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 - */ - diff --git a/src/validators/schema/identity/XPathSymbols.cpp b/src/validators/schema/identity/XPathSymbols.cpp deleted file mode 100644 index 166bae2e99ba7d92ed45c37e8742bbe47e52d412..0000000000000000000000000000000000000000 --- a/src/validators/schema/identity/XPathSymbols.cpp +++ /dev/null @@ -1,199 +0,0 @@ -/* - * 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$ - * 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 - */ - diff --git a/src/validators/schema/identity/XPathSymbols.hpp b/src/validators/schema/identity/XPathSymbols.hpp deleted file mode 100644 index cb9ff8c2352199b04bc86c6ef17ec1ed22ef206f..0000000000000000000000000000000000000000 --- a/src/validators/schema/identity/XPathSymbols.hpp +++ /dev/null @@ -1,105 +0,0 @@ -/* - * 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$ - */ - -#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 - */ - diff --git a/src/validators/schema/identity/XercesXPath.cpp b/src/validators/schema/identity/XercesXPath.cpp deleted file mode 100644 index 689eabe985a363d2e254cad3f1ba8794819fdd5a..0000000000000000000000000000000000000000 --- a/src/validators/schema/identity/XercesXPath.cpp +++ /dev/null @@ -1,1307 +0,0 @@ -/* - * 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$ - * Revision 1.3 2001/11/15 17:10:19 knoaman - * Particle derivation checking support. - * - * Revision 1.2 2001/11/07 14:25:36 knoaman - * Fix compliation error on Unix. - * - * 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 -}; - - -// --------------------------------------------------------------------------- -// 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; -} - -bool XercesNodeTest::operator ==(const XercesNodeTest& other) const { - - if (this == &other) - return true; - - if (fType != other.fType) - return false; - - return (*fName == *(other.fName)); -} - - -bool XercesNodeTest::operator !=(const XercesNodeTest& other) const { - - return !operator==(other); -} - -// --------------------------------------------------------------------------- -// XercesStep: Constructors and Destructor -// --------------------------------------------------------------------------- -XercesStep::XercesStep(const unsigned short axisType, XercesNodeTest* const nodeTest) - : fAxisType(axisType) - , fNodeTest(nodeTest) -{ -} - -XercesStep::XercesStep(const XercesStep& other) - : fAxisType(other.fAxisType) - , fNodeTest(0) -{ - fNodeTest = new XercesNodeTest(*(other.fNodeTest)); -} - - -// --------------------------------------------------------------------------- -// XercesStep: Operators -// --------------------------------------------------------------------------- -XercesStep& XercesStep::operator=(const XercesStep& other) -{ - if (this == &other) - return *this; - - fAxisType = other.fAxisType; - *fNodeTest = *(other.fNodeTest); - return *this; -} - -bool XercesStep::operator==(const XercesStep& other) const { - - if (this == &other) - return true; - - if (fAxisType != other.fAxisType) - return false; - - if (fAxisType == XercesStep::CHILD || - fAxisType == XercesStep::ATTRIBUTE) { - return (*fNodeTest == *(other.fNodeTest)); - } - - return true; -} - -bool XercesStep::operator!=(const XercesStep& other) const { - - return !operator==(other); -} - -// --------------------------------------------------------------------------- -// XercesLocationPath: Constructors and Destructor -// --------------------------------------------------------------------------- -XercesLocationPath::XercesLocationPath() - : fSteps(0) -{ -} - -XercesLocationPath::XercesLocationPath(RefVectorOf<XercesStep>* const steps) - : fSteps(steps) -{ -} - -// --------------------------------------------------------------------------- -// XercesLocationPath: Operators -// --------------------------------------------------------------------------- -bool XercesLocationPath::operator==(const XercesLocationPath& other) const { - - unsigned int stepsSize = fSteps->size(); - - if (stepsSize != other.fSteps->size()) - return false; - - for (unsigned int i=0; i < stepsSize; i++) { - if (*(fSteps->elementAt(i)) != *(other.fSteps->elementAt(i))) - return false; - } - - return true; -} - -bool XercesLocationPath::operator!=(const XercesLocationPath& other) const { - - return !operator==(other); -} - -// --------------------------------------------------------------------------- -// 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(); -} - - -// --------------------------------------------------------------------------- -// XercesXPath: Operators -// --------------------------------------------------------------------------- -bool XercesXPath::operator==(const XercesXPath& other) const { - - unsigned int locPathSize = fLocationPaths->size(); - - if (locPathSize != other.fLocationPaths->size()) - return false; - - for (unsigned int i=0; i < locPathSize; i++) { - if (*(fLocationPaths->elementAt(i)) != *(other.fLocationPaths->elementAt(i))) - return false; - } - - return true; -} - -bool XercesXPath::operator!=(const XercesXPath& other) const { - - return !operator==(other); -} - -// --------------------------------------------------------------------------- -// 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) { - if (locPath->getStep(stepSize - 1)->getAxisType() == XercesStep::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: - { - XercesNodeTest* nodeTest = new XercesNodeTest(XercesNodeTest::WILDCARD); - XercesStep* step = new XercesStep(XercesStep::ATTRIBUTE, 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 - XercesNodeTest* nodeTest = new XercesNodeTest(prefix, uri); - XercesStep* step = new XercesStep(XercesStep::ATTRIBUTE, nodeTest); - stepsVector->addElement(step); - break; - } - - aToken = tokens.elementAt(++i); - - const XMLCh* localPart = stringPool->getValueForId(aToken); - QName aQName(prefix, localPart, uri); - - // build step - XercesNodeTest* nodeTest = new XercesNodeTest(&aQName); - XercesStep* step = new XercesStep(XercesStep::ATTRIBUTE, 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: - { - XercesNodeTest* nodeTest = new XercesNodeTest(XercesNodeTest::WILDCARD); - XercesStep* step = new XercesStep(XercesStep::CHILD, 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 - XercesNodeTest* nodeTest = new XercesNodeTest(prefix, uri); - XercesStep* step = new XercesStep(XercesStep::CHILD, nodeTest); - stepsVector->addElement(step); - break; - } - - aToken = tokens.elementAt(++i); - const XMLCh* localPart = stringPool->getValueForId(aToken); - QName aQName(prefix, localPart, uri); - - // build step - XercesNodeTest* nodeTest = new XercesNodeTest(&aQName); - XercesStep* step = new XercesStep(XercesStep::CHILD, nodeTest); - stepsVector->addElement(step); - firstTokenOfLocationPath = false; - break; - } - case XercesXPath::EXPRTOKEN_PERIOD: - { - // build step - XercesNodeTest* nodeTest = new XercesNodeTest(XercesNodeTest::NODE); - XercesStep* step = new XercesStep(XercesStep::SELF, 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 - nodeTest = new XercesNodeTest(XercesNodeTest::NODE); - step = new XercesStep(XercesStep::DESCENDANT, 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>* const 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 (ch == chColon || !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 - */ - diff --git a/src/validators/schema/identity/XercesXPath.hpp b/src/validators/schema/identity/XercesXPath.hpp deleted file mode 100644 index 09dc7971eff67727a9b44ae70da27974aa4f1112..0000000000000000000000000000000000000000 --- a/src/validators/schema/identity/XercesXPath.hpp +++ /dev/null @@ -1,498 +0,0 @@ -/* - * 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$ - */ - -#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 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); - bool operator== (const XercesNodeTest& other) const; - bool operator!= (const XercesNodeTest& other) const; - - // ----------------------------------------------------------------------- - // 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: - // ----------------------------------------------------------------------- - // Constants - // ----------------------------------------------------------------------- - enum { // Axis type - CHILD = 1, - ATTRIBUTE = 2, - SELF = 3, - DESCENDANT = 4 - }; - - // ----------------------------------------------------------------------- - // Constructors/Destructor - // ----------------------------------------------------------------------- - XercesStep(const unsigned short axisType, XercesNodeTest* const nodeTest); - XercesStep(const XercesStep& other); - ~XercesStep() { delete fNodeTest; } - - // ----------------------------------------------------------------------- - // Operators - // ----------------------------------------------------------------------- - XercesStep& operator= (const XercesStep& other); - bool operator== (const XercesStep& other) const; - bool operator!= (const XercesStep& other) const; - - // ----------------------------------------------------------------------- - // Getter methods - // ----------------------------------------------------------------------- - unsigned short getAxisType() const { return fAxisType; } - XercesNodeTest* getNodeTest() const { return fNodeTest; } - -private: - // ----------------------------------------------------------------------- - // Data members - // ----------------------------------------------------------------------- - unsigned short fAxisType; - 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; } - - // ----------------------------------------------------------------------- - // Operators - // ----------------------------------------------------------------------- - bool operator== (const XercesLocationPath& other) const; - bool operator!= (const XercesLocationPath& other) const; - - // ----------------------------------------------------------------------- - // Access methods - // ----------------------------------------------------------------------- - unsigned int getStepSize() const; - void addStep(XercesStep* const aStep); - XercesStep* getStep(const 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(); - - // ----------------------------------------------------------------------- - // Operators - // ----------------------------------------------------------------------- - bool operator== (const XercesXPath& other) const; - bool operator!= (const XercesXPath& other) const; - - // ----------------------------------------------------------------------- - // 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 - */ -