| 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.5  2003/01/29 19:45:35  gareth
    00060  * added api for DOMTypeInfo
    00061  *
    00062  * Revision 1.4  2002/12/10 02:15:55  knoaman
    00063  * Schema Errata: E1-21.
    00064  *
    00065  * Revision 1.3  2002/11/04 15:00:21  tng
    00066  * C++ Namespace Support.
    00067  *
    00068  * Revision 1.2  2002/02/20 18:17:01  tng
    00069  * [Bug 5977] Warnings on generating apiDocs.
    00070  *
    00071  * Revision 1.1.1.1  2002/02/01 22:21:50  peiyongz
    00072  * sane_include
    00073  *
    00074  * Revision 1.13  2001/11/15 16:36:36  knoaman
    00075  * Re-organize constant values.
    00076  *
    00077  * Revision 1.12  2001/08/09 15:23:37  knoaman
    00078  * add support for <anyAttribute> declaration.
    00079  *
    00080  * Revision 1.11  2001/06/21 14:25:26  knoaman
    00081  * Fix for bug 1946
    00082  *
    00083  * Revision 1.10  2001/05/11 13:25:31  tng
    00084  * Copyright update.
    00085  *
    00086  * Revision 1.9  2001/02/27 18:48:20  tng
    00087  * Schema: Add SchemaAttDef, SchemaElementDecl, SchemaAttDefList.
    00088  *
    00089  * Revision 1.8  2000/12/14 18:49:56  tng
    00090  * Fix API document generation warning: "Warning: end of member group without matching begin"
    00091  *
    00092  * Revision 1.7  2000/11/30 18:22:38  andyh
    00093  * reuseValidator - fix bugs (spurious errors) that occured on reuse due to
    00094  * pools already containing some items.  Fixed by Tinny Ng.
    00095  *
    00096  * Revision 1.6  2000/07/07 22:23:38  jpolast
    00097  * remove useless getKey() functions.
    00098  *
    00099  * Revision 1.5  2000/02/24 20:00:22  abagchi
    00100  * Swat for removing Log from API docs
    00101  *
    00102  * Revision 1.4  2000/02/16 23:03:48  roddey
    00103  * More documentation updates
    00104  *
    00105  * Revision 1.3  2000/02/15 01:21:30  roddey
    00106  * Some initial documentation improvements. More to come...
    00107  *
    00108  * Revision 1.2  2000/02/06 07:47:46  rahulj
    00109  * Year 2K copyright swat.
    00110  *
    00111  * Revision 1.1.1.1  1999/11/09 01:08:27  twl
    00112  * Initial checkin
    00113  *
    00114  * Revision 1.2  1999/11/08 20:44:34  rahul
    00115  * Swat for adding in Product name and CVS comment log variable.
    00116  *
    00117  */
    00118
    00119 #if !defined(ATTDEF_HPP)
    00120 #define ATTDEF_HPP
    00121
    00122 #include <xercesc/util/XMLString.hpp>
    00123
    00124 XERCES_CPP_NAMESPACE_BEGIN
    00125
    00126 class XMLAttr;
    00127
    00146 class  XMLAttDef
    00147 {
    00148 public:
    00149     // -----------------------------------------------------------------------
    00150     //  Class specific types
    00151     //
    00152     //  AttTypes
    00153     //      The list of possible types that an attribute can have, according
    00154     //      to the XML 1.0 spec and schema.
    00155     //
    00156     //  DefAttTypes
    00157     //      The modifiers that an attribute decl can have, which indicates
    00158     //      whether instances of that attributes are required, implied, etc..
    00159     //
    00160     //  CreateReasons
    00161     //      This type is used to store how an attribute declaration got into
    00162     //      the elementdecl's attribute pool.
    00163     //
    00164     // -----------------------------------------------------------------------
    00165     enum AttTypes
    00166     {
    00167         CData               = 0
    00168         , ID                = 1
    00169         , IDRef             = 2
    00170         , IDRefs            = 3
    00171         , Entity            = 4
    00172         , Entities          = 5
    00173         , NmToken           = 6
    00174         , NmTokens          = 7
    00175         , Notation          = 8
    00176         , Enumeration       = 9
    00177         , Simple            = 10
    00178         , Any_Any           = 11
    00179         , Any_Other         = 12
    00180         , Any_List          = 13
    00181
    00182         , AttTypes_Count
    00183         , AttTypes_Min      = 0
    00184         , AttTypes_Max      = 13
    00185         , AttTypes_Unknown  = -1
    00186     };
    00187
    00188     enum DefAttTypes
    00189     {
    00190         Default                  = 0
    00191         , Fixed                  = 1
    00192         , Required               = 2
    00193         , Required_And_Fixed     = 3
    00194         , Implied                = 4
    00195         , ProcessContents_Skip   = 5
    00196         , ProcessContents_Lax    = 6
    00197         , ProcessContents_Strict = 7
    00198         , Prohibited             = 8
    00199
    00200         , DefAttTypes_Count
    00201         , DefAttTypes_Min   = 0
    00202         , DefAttTypes_Max   = 8
    00203         , DefAttTypes_Unknown = -1
    00204     };
    00205
    00206     enum CreateReasons
    00207     {
    00208         NoReason
    00209         , JustFaultIn
    00210     };
    00211
    00212     // -----------------------------------------------------------------------
    00213     //  Public static data members
    00214     // -----------------------------------------------------------------------
    00215     static const unsigned int fgInvalidAttrId;
    00216
    00217
    00218     // -----------------------------------------------------------------------
    00219     //  Public, static methods
    00220     // -----------------------------------------------------------------------
    00221
    00224
    00235     static const XMLCh* getAttTypeString(const AttTypes attrType);
    00236
    00247     static const XMLCh* getDefAttTypeString(const DefAttTypes attrType);
    00248
    00250
    00251
    00252     // -----------------------------------------------------------------------
    00253     //  Destructor
    00254     // -----------------------------------------------------------------------
    00255
    00258
    00262     virtual ~XMLAttDef();
    00264
    00265
    00266     // -----------------------------------------------------------------------
    00267     //  The virtual attribute def interface
    00268     // -----------------------------------------------------------------------
    00269
    00272
    00281     virtual const XMLCh* getFullName() const = 0;
    00282
    00287     virtual void reset() = 0;
    00288
    00290
    00291
    00292     // -----------------------------------------------------------------------
    00293     //  Getter methods
    00294     // -----------------------------------------------------------------------
    00295
    00298
    00307     DefAttTypes getDefaultType() const;
    00308
    00318     const XMLCh* getEnumeration() const;
    00319
    00328     unsigned int getId() const;
    00329
    00343     bool getProvided() const;
    00344
    00354     AttTypes getType() const;
    00355
    00365     const XMLCh* getValue() const;
    00366
    00375     CreateReasons getCreateReason() const;
    00376
    00384     bool isExternal() const;
    00385
    00386
    00390     virtual const XMLCh* getDOMTypeInfoUri() const = 0;
    00391
    00395     virtual const XMLCh* getDOMTypeInfoName() const = 0;
    00396
    00398
    00399
    00400     // -----------------------------------------------------------------------
    00401     //  Setter methods
    00402     // -----------------------------------------------------------------------
    00403
    00406
    00415     void setDefaultType(const XMLAttDef::DefAttTypes newValue);
    00416
    00425     void setId(const unsigned int newId);
    00426
    00435     void setProvided(const bool newValue);
    00436
    00444     void setType(const XMLAttDef::AttTypes newValue);
    00445
    00456     void setValue(const XMLCh* const newValue);
    00457
    00468     void setEnumeration(const XMLCh* const newValue);
    00469
    00477     void setCreateReason(const CreateReasons newReason);
    00478
    00484     void setExternalAttDeclaration(const bool aValue);
    00485
    00487
    00488 protected :
    00489     // -----------------------------------------------------------------------
    00490     //  Hidden constructors
    00491     // -----------------------------------------------------------------------
    00492     XMLAttDef
    00493     (
    00494         const   AttTypes            type = CData
    00495         , const DefAttTypes         defType = Implied
    00496     );
    00497     XMLAttDef
    00498     (
    00499         const   XMLCh* const        attValue
    00500         , const AttTypes            type
    00501         , const DefAttTypes         defType
    00502         , const XMLCh* const        enumValues = 0
    00503     );
    00504
    00505
    00506 private :
    00507     // -----------------------------------------------------------------------
    00508     //  Unimplemented constructors and operators
    00509     // -----------------------------------------------------------------------
    00510     XMLAttDef(const XMLAttDef&);
    00511     void operator=(const XMLAttDef&);
    00512
    00513
    00514     // -----------------------------------------------------------------------
    00515     //  Private helper methods
    00516     // -----------------------------------------------------------------------
    00517     void cleanUp();
    00518
    00519
    00520     // -----------------------------------------------------------------------
    00521     //  Private data members
    00522     //
    00523     //  fDefaultType
    00524     //      Indicates what, if any, default stuff this attribute has.
    00525     //
    00526     //  fEnumeration
    00527     //      If its an enumeration, this is the list of values as space
    00528     //      separated values.
    00529     //
    00530     //  fId
    00531     //      This is the unique id of this attribute, given to it when its put
    00532     //      into the validator's attribute decl pool. It defaults to the
    00533     //      special value XMLAttrDef::fgInvalidAttrId.
    00534     //
    00535     //  fProvided
    00536     //      This field is really for use by the scanner. It is used to track
    00537     //      which of the attributes of an element were provided. Any marked
    00538     //      as not provided (after scanning the start tag) and having a
    00539     //      default type of Required, is in error.
    00540     //
    00541     //  fType
    00542     //      The type of attribute, which is one of the AttTypes values.
    00543     //
    00544     //  fValue
    00545     //      This is the value of the attribute, which is the default value
    00546     //      given in the attribute declaration.
    00547     //
    00548     //  fCreateReason
    00549     //      This flag tells us how this attribute got created.  Sometimes even
    00550     //      the attribute was not declared for the element, we want to fault
    00551     //      fault it into the pool to avoid lots of redundant errors.
    00552     //
    00553     //  fExternalAttribute
    00554     //      This flag indicates whether or not the attribute was declared externally.
    00555     // -----------------------------------------------------------------------
    00556     DefAttTypes     fDefaultType;
    00557     XMLCh*          fEnumeration;
    00558     unsigned int    fId;
    00559     bool            fProvided;
    00560     AttTypes        fType;
    00561     XMLCh*          fValue;
    00562     CreateReasons   fCreateReason;
    00563     bool            fExternalAttribute;
    00564 };
    00565
    00566
    00567
    00568 // ---------------------------------------------------------------------------
    00569 //  Getter methods
    00570 // ---------------------------------------------------------------------------
    00571 inline XMLAttDef::DefAttTypes XMLAttDef::getDefaultType() const
    00572 {
    00573     return fDefaultType;
    00574 }
    00575
    00576 inline const XMLCh* XMLAttDef::getEnumeration() const
    00577 {
    00578     return fEnumeration;
    00579 }
    00580
    00581 inline unsigned int XMLAttDef::getId() const
    00582 {
    00583     return fId;
    00584 }
    00585
    00586 inline bool XMLAttDef::getProvided() const
    00587 {
    00588     return fProvided;
    00589 }
    00590
    00591 inline XMLAttDef::AttTypes XMLAttDef::getType() const
    00592 {
    00593     return fType;
    00594 }
    00595
    00596 inline const XMLCh* XMLAttDef::getValue() const
    00597 {
    00598     return fValue;
    00599 }
    00600
    00601 inline XMLAttDef::CreateReasons XMLAttDef::getCreateReason() const
    00602 {
    00603     return fCreateReason;
    00604 }
    00605
    00606 inline bool XMLAttDef::isExternal() const
    00607 {
    00608     return fExternalAttribute;
    00609 }
    00610
    00611
    00612 // ---------------------------------------------------------------------------
    00613 //  XMLAttDef: Setter methods
    00614 // ---------------------------------------------------------------------------
    00615 inline void XMLAttDef::setDefaultType(const XMLAttDef::DefAttTypes newValue)
    00616 {
    00617     fDefaultType = newValue;
    00618 }
    00619
    00620 inline void XMLAttDef::setEnumeration(const XMLCh* const newValue)
    00621 {
    00622     delete [] fEnumeration;
    00623
    00624     if (newValue) {
    00625         fEnumeration = XMLString::replicate(newValue);
    00626     }
    00627     else {
    00628         fEnumeration = 0;
    00629     }
    00630 }
    00631
    00632 inline void XMLAttDef::setId(const unsigned int newId)
    00633 {
    00634     fId = newId;
    00635 }
    00636
    00637 inline void XMLAttDef::setProvided(const bool newValue)
    00638 {
    00639     fProvided = newValue;
    00640 }
    00641
    00642 inline void XMLAttDef::setType(const XMLAttDef::AttTypes newValue)
    00643 {
    00644     fType = newValue;
    00645 }
    00646
    00647 inline void XMLAttDef::setValue(const XMLCh* const newValue)
    00648 {
    00649     delete [] fValue;
    00650     fValue = XMLString::replicate(newValue);
    00651 }
    00652
    00653 inline void
    00654 XMLAttDef::setCreateReason(const XMLAttDef::CreateReasons newReason)
    00655 {
    00656     fCreateReason = newReason;
    00657 }
    00658
    00659 inline void XMLAttDef::setExternalAttDeclaration(const bool aValue)
    00660 {
    00661     fExternalAttribute = aValue;
    00662 }
    00663
    00664 XERCES_CPP_NAMESPACE_END
    00665
    00666 #endif

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