http://xml.apache.org/http://www.apache.org/http://www.w3.org/

Home

Readme
Download
Installation
Build

API Docs
Samples
Schema

FAQs
Programming
Migration

Releases
Bug-Reporting
Feedback

Y2K Compliance
PDF Document

CVS Repository
Mail Archive

API Docs for SAX and DOM
 

Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

XMLAttDef.hpp

Go to the documentation of this file.
00001 /*
00002  * The Apache Software License, Version 1.1
00003  *
00004  * Copyright (c) 1999-2001 The Apache Software Foundation.  All rights
00005  * reserved.
00006  *
00007  * Redistribution and use in source and binary forms, with or without
00008  * modification, are permitted provided that the following conditions
00009  * are met:
00010  *
00011  * 1. Redistributions of source code must retain the above copyright
00012  *    notice, this list of conditions and the following disclaimer.
00013  *
00014  * 2. Redistributions in binary form must reproduce the above copyright
00015  *    notice, this list of conditions and the following disclaimer in
00016  *    the documentation and/or other materials provided with the
00017  *    distribution.
00018  *
00019  * 3. The end-user documentation included with the redistribution,
00020  *    if any, must include the following acknowledgment:
00021  *       "This product includes software developed by the
00022  *        Apache Software Foundation (http://www.apache.org/)."
00023  *    Alternately, this acknowledgment may appear in the software itself,
00024  *    if and wherever such third-party acknowledgments normally appear.
00025  *
00026  * 4. The names "Xerces" and "Apache Software Foundation" must
00027  *    not be used to endorse or promote products derived from this
00028  *    software without prior written permission. For written
00029  *    permission, please contact apache\@apache.org.
00030  *
00031  * 5. Products derived from this software may not be called "Apache",
00032  *    nor may "Apache" appear in their name, without prior written
00033  *    permission of the Apache Software Foundation.
00034  *
00035  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
00036  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00037  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00038  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
00039  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00040  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00041  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
00042  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00043  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00044  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
00045  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00046  * SUCH DAMAGE.
00047  * ====================================================================
00048  *
00049  * This software consists of voluntary contributions made by many
00050  * individuals on behalf of the Apache Software Foundation, and was
00051  * originally based on software copyright (c) 1999, International
00052  * Business Machines, Inc., http://www.ibm.com .  For more information
00053  * on the Apache Software Foundation, please see
00054  * <http://www.apache.org/>.
00055  */
00056 
00057 /*
00058  * $Log: XMLAttDef.hpp,v $
00059  * Revision 1.11  2001/06/21 14:25:26  knoaman
00060  * Fix for bug 1946
00061  *
00062  * Revision 1.10  2001/05/11 13:25:31  tng
00063  * Copyright update.
00064  *
00065  * Revision 1.9  2001/02/27 18:48:20  tng
00066  * Schema: Add SchemaAttDef, SchemaElementDecl, SchemaAttDefList.
00067  *
00068  * Revision 1.8  2000/12/14 18:49:56  tng
00069  * Fix API document generation warning: "Warning: end of member group without matching begin"
00070  *
00071  * Revision 1.7  2000/11/30 18:22:38  andyh
00072  * reuseValidator - fix bugs (spurious errors) that occured on reuse due to
00073  * pools already containing some items.  Fixed by Tinny Ng.
00074  *
00075  * Revision 1.6  2000/07/07 22:23:38  jpolast
00076  * remove useless getKey() functions.
00077  *
00078  * Revision 1.5  2000/02/24 20:00:22  abagchi
00079  * Swat for removing Log from API docs
00080  *
00081  * Revision 1.4  2000/02/16 23:03:48  roddey
00082  * More documentation updates
00083  *
00084  * Revision 1.3  2000/02/15 01:21:30  roddey
00085  * Some initial documentation improvements. More to come...
00086  *
00087  * Revision 1.2  2000/02/06 07:47:46  rahulj
00088  * Year 2K copyright swat.
00089  *
00090  * Revision 1.1.1.1  1999/11/09 01:08:27  twl
00091  * Initial checkin
00092  *
00093  * Revision 1.2  1999/11/08 20:44:34  rahul
00094  * Swat for adding in Product name and CVS comment log variable.
00095  *
00096  */
00097 
00098 #if !defined(ATTDEF_HPP)
00099 #define ATTDEF_HPP
00100 
00101 #include <util/XMLString.hpp>
00102 
00103 class XMLAttr;
00104 
00123 class  XMLAttDef
00124 {
00125 public:
00126     // -----------------------------------------------------------------------
00127     //  Class specific types
00128     //
00129     //  AttTypes
00130     //      The list of possible types that an attribute can have, according
00131     //      to the XML 1.0 spec and schema.
00132     //
00133     //  DefAttTypes
00134     //      The modifiers that an attribute decl can have, which indicates
00135     //      whether instances of that attributes are required, implied, etc..
00136     //
00137     //  CreateReasons
00138     //      This type is used to store how an attribute declaration got into
00139     //      the elementdecl's attribute pool.
00140     //
00141     // -----------------------------------------------------------------------
00142     enum AttTypes
00143     {
00144         CData               = 0
00145         , ID                = 1
00146         , IDRef             = 2
00147         , IDRefs            = 3
00148         , Entity            = 4
00149         , Entities          = 5
00150         , NmToken           = 6
00151         , NmTokens          = 7
00152         , Notation          = 8
00153         , Enumeration       = 9
00154         , Simple            = 10
00155         , Any_Any           = 11
00156         , Any_Other         = 12
00157         , Any_Local         = 13
00158         , Any_List          = 14
00159 
00160         , AttTypes_Count
00161         , AttTypes_Min      = 0
00162         , AttTypes_Max      = 14
00163         , AttTypes_Unknown  = -1
00164     };
00165 
00166     enum DefAttTypes
00167     {
00168         Default                  = 0
00169         , Required               = 1
00170         , Implied                = 2
00171         , Fixed                  = 3
00172         , Prohibited             = 4
00173         , Required_And_Fixed     = 5
00174         , ProcessContents_Strict = 6
00175         , ProcessContents_Lax    = 7
00176         , ProcessContents_Skip   = 8
00177 
00178         , DefAttTypes_Count
00179         , DefAttTypes_Min   = 0
00180         , DefAttTypes_Max   = 8
00181         , DefAttTypes_Unknown = -1
00182     };
00183 
00184     enum CreateReasons
00185     {
00186         NoReason
00187         , JustFaultIn
00188     };
00189 
00190     // -----------------------------------------------------------------------
00191     //  Public static data members
00192     // -----------------------------------------------------------------------
00193     static const unsigned int fgInvalidAttrId;
00194 
00195 
00196     // -----------------------------------------------------------------------
00197     //  Public, static methods
00198     // -----------------------------------------------------------------------
00199 
00202 
00213     static const XMLCh* getAttTypeString(const AttTypes attrType);
00214 
00225     static const XMLCh* getDefAttTypeString(const DefAttTypes attrType);
00226 
00228 
00229 
00230     // -----------------------------------------------------------------------
00231     //  Destructor
00232     // -----------------------------------------------------------------------
00233 
00236 
00240     virtual ~XMLAttDef();
00242 
00243 
00244     // -----------------------------------------------------------------------
00245     //  The virtual attribute def interface
00246     // -----------------------------------------------------------------------
00247 
00250 
00259     virtual const XMLCh* getFullName() const = 0;
00260 
00262 
00263 
00264     // -----------------------------------------------------------------------
00265     //  Getter methods
00266     // -----------------------------------------------------------------------
00267 
00270 
00279     DefAttTypes getDefaultType() const;
00280 
00290     const XMLCh* getEnumeration() const;
00291 
00300     unsigned int getId() const;
00301 
00315     bool getProvided() const;
00316 
00326     AttTypes getType() const;
00327 
00337     const XMLCh* getValue() const;
00338 
00347     CreateReasons getCreateReason() const;
00348 
00356     bool isExternal() const;
00357 
00359 
00360 
00361     // -----------------------------------------------------------------------
00362     //  Setter methods
00363     // -----------------------------------------------------------------------
00364 
00367 
00376     void setDefaultType(const XMLAttDef::DefAttTypes newValue);
00377 
00386     void setId(const unsigned int newId);
00387 
00396     void setProvided(const bool newValue);
00397 
00405     void setType(const XMLAttDef::AttTypes newValue);
00406 
00417     void setValue(const XMLCh* const newValue);
00418 
00429     void setEnumeration(const XMLCh* const newValue);
00430 
00436     void setCreateReason(const CreateReasons newReason);
00437 
00441     void setExternalAttDeclaration(const bool aValue);
00442 
00444 
00445 protected :
00446     // -----------------------------------------------------------------------
00447     //  Hidden constructors
00448     // -----------------------------------------------------------------------
00449     XMLAttDef
00450     (
00451         const   AttTypes            type = CData
00452         , const DefAttTypes         defType = Implied
00453     );
00454     XMLAttDef
00455     (
00456         const   XMLCh* const        attValue
00457         , const AttTypes            type
00458         , const DefAttTypes         defType
00459         , const XMLCh* const        enumValues = 0
00460     );
00461 
00462 
00463 private :
00464     // -----------------------------------------------------------------------
00465     //  Unimplemented constructors and operators
00466     // -----------------------------------------------------------------------
00467     XMLAttDef(const XMLAttDef&);
00468     void operator=(const XMLAttDef&);
00469 
00470 
00471     // -----------------------------------------------------------------------
00472     //  Private helper methods
00473     // -----------------------------------------------------------------------
00474     void cleanUp();
00475 
00476 
00477     // -----------------------------------------------------------------------
00478     //  Private data members
00479     //
00480     //  fDefaultType
00481     //      Indicates what, if any, default stuff this attribute has.
00482     //
00483     //  fEnumeration
00484     //      If its an enumeration, this is the list of values as space
00485     //      separated values.
00486     //
00487     //  fId
00488     //      This is the unique id of this attribute, given to it when its put
00489     //      into the validator's attribute decl pool. It defaults to the
00490     //      special value XMLAttrDef::fgInvalidAttrId.
00491     //
00492     //  fProvided
00493     //      This field is really for use by the scanner. It is used to track
00494     //      which of the attributes of an element were provided. Any marked
00495     //      as not provided (after scanning the start tag) and having a
00496     //      default type of Required, is in error.
00497     //
00498     //  fType
00499     //      The type of attribute, which is one of the AttTypes values.
00500     //
00501     //  fValue
00502     //      This is the value of the attribute, which is the default value
00503     //      given in the attribute declaration.
00504     //
00505     //  fCreateReason
00506     //      This flag tells us how this attribute got created.  Sometimes even
00507     //      the attribute was not declared for the element, we want to fault
00508     //      fault it into the pool to avoid lots of redundant errors.
00509     //
00510     //  fExternalAttribute
00511     //      This flag indicates whether or not the attribute was declared externally.
00512     // -----------------------------------------------------------------------
00513     DefAttTypes     fDefaultType;
00514     XMLCh*          fEnumeration;
00515     unsigned int    fId;
00516     bool            fProvided;
00517     AttTypes        fType;
00518     XMLCh*          fValue;
00519     CreateReasons   fCreateReason;
00520     bool            fExternalAttribute;
00521 };
00522 
00523 
00524 
00525 // ---------------------------------------------------------------------------
00526 //  Getter methods
00527 // ---------------------------------------------------------------------------
00528 inline XMLAttDef::DefAttTypes XMLAttDef::getDefaultType() const
00529 {
00530     return fDefaultType;
00531 }
00532 
00533 inline const XMLCh* XMLAttDef::getEnumeration() const
00534 {
00535     return fEnumeration;
00536 }
00537 
00538 inline unsigned int XMLAttDef::getId() const
00539 {
00540     return fId;
00541 }
00542 
00543 inline bool XMLAttDef::getProvided() const
00544 {
00545     return fProvided;
00546 }
00547 
00548 inline XMLAttDef::AttTypes XMLAttDef::getType() const
00549 {
00550     return fType;
00551 }
00552 
00553 inline const XMLCh* XMLAttDef::getValue() const
00554 {
00555     return fValue;
00556 }
00557 
00558 inline XMLAttDef::CreateReasons XMLAttDef::getCreateReason() const
00559 {
00560     return fCreateReason;
00561 }
00562 
00563 inline bool XMLAttDef::isExternal() const
00564 {
00565     return fExternalAttribute;
00566 }
00567 
00568 
00569 // ---------------------------------------------------------------------------
00570 //  XMLAttDef: Setter methods
00571 // ---------------------------------------------------------------------------
00572 inline void XMLAttDef::setDefaultType(const XMLAttDef::DefAttTypes newValue)
00573 {
00574     fDefaultType = newValue;
00575 }
00576 
00577 inline void XMLAttDef::setEnumeration(const XMLCh* const newValue)
00578 {
00579     delete [] fEnumeration;
00580     fEnumeration = XMLString::replicate(newValue);
00581 }
00582 
00583 inline void XMLAttDef::setId(const unsigned int newId)
00584 {
00585     fId = newId;
00586 }
00587 
00588 inline void XMLAttDef::setProvided(const bool newValue)
00589 {
00590     fProvided = newValue;
00591 }
00592 
00593 inline void XMLAttDef::setType(const XMLAttDef::AttTypes newValue)
00594 {
00595     fType = newValue;
00596 }
00597 
00598 inline void XMLAttDef::setValue(const XMLCh* const newValue)
00599 {
00600     delete [] fValue;
00601     fValue = XMLString::replicate(newValue);
00602 }
00603 
00604 inline void
00605 XMLAttDef::setCreateReason(const XMLAttDef::CreateReasons newReason)
00606 {
00607     fCreateReason = newReason;
00608 }
00609 
00610 inline void XMLAttDef::setExternalAttDeclaration(const bool aValue)
00611 {
00612     fExternalAttribute = aValue;
00613 }
00614 
00615 #endif


Copyright © 2000 The Apache Software Foundation. All Rights Reserved.