[188] | 1 | /*
|
---|
| 2 | * The Apache Software License, Version 1.1
|
---|
| 3 | *
|
---|
| 4 | * Copyright (c) 1999-2003 The Apache Software Foundation. All rights
|
---|
| 5 | * reserved.
|
---|
| 6 | *
|
---|
| 7 | * Redistribution and use in source and binary forms, with or without
|
---|
| 8 | * modification, are permitted provided that the following conditions
|
---|
| 9 | * are met:
|
---|
| 10 | *
|
---|
| 11 | * 1. Redistributions of source code must retain the above copyright
|
---|
| 12 | * notice, this list of conditions and the following disclaimer.
|
---|
| 13 | *
|
---|
| 14 | * 2. Redistributions in binary form must reproduce the above copyright
|
---|
| 15 | * notice, this list of conditions and the following disclaimer in
|
---|
| 16 | * the documentation and/or other materials provided with the
|
---|
| 17 | * distribution.
|
---|
| 18 | *
|
---|
| 19 | * 3. The end-user documentation included with the redistribution,
|
---|
| 20 | * if any, must include the following acknowledgment:
|
---|
| 21 | * "This product includes software developed by the
|
---|
| 22 | * Apache Software Foundation (http://www.apache.org/)."
|
---|
| 23 | * Alternately, this acknowledgment may appear in the software itself,
|
---|
| 24 | * if and wherever such third-party acknowledgments normally appear.
|
---|
| 25 | *
|
---|
| 26 | * 4. The names "Xerces" and "Apache Software Foundation" must
|
---|
| 27 | * not be used to endorse or promote products derived from this
|
---|
| 28 | * software without prior written permission. For written
|
---|
| 29 | * permission, please contact apache\@apache.org.
|
---|
| 30 | *
|
---|
| 31 | * 5. Products derived from this software may not be called "Apache",
|
---|
| 32 | * nor may "Apache" appear in their name, without prior written
|
---|
| 33 | * permission of the Apache Software Foundation.
|
---|
| 34 | *
|
---|
| 35 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
|
---|
| 36 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
| 37 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
---|
| 38 | * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
|
---|
| 39 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
---|
| 40 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
---|
| 41 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
---|
| 42 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
---|
| 43 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
---|
| 44 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
---|
| 45 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
---|
| 46 | * SUCH DAMAGE.
|
---|
| 47 | * ====================================================================
|
---|
| 48 | *
|
---|
| 49 | * This software consists of voluntary contributions made by many
|
---|
| 50 | * individuals on behalf of the Apache Software Foundation, and was
|
---|
| 51 | * originally based on software copyright (c) 1999, International
|
---|
| 52 | * Business Machines, Inc., http://www.ibm.com . For more information
|
---|
| 53 | * on the Apache Software Foundation, please see
|
---|
| 54 | * <http://www.apache.org/>.
|
---|
| 55 | */
|
---|
| 56 |
|
---|
| 57 | /*
|
---|
| 58 | * $Log: XMLAttDef.hpp,v $
|
---|
| 59 | * Revision 1.12 2003/12/17 00:18:33 cargilld
|
---|
| 60 | * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data.
|
---|
| 61 | *
|
---|
| 62 | * Revision 1.11 2003/11/24 05:19:15 neilg
|
---|
| 63 | * update method documentation
|
---|
| 64 | *
|
---|
| 65 | * Revision 1.10 2003/10/10 16:23:29 peiyongz
|
---|
| 66 | * Implementation of Serialization/Deserialization
|
---|
| 67 | *
|
---|
| 68 | * Revision 1.9 2003/05/16 21:36:55 knoaman
|
---|
| 69 | * Memory manager implementation: Modify constructors to pass in the memory manager.
|
---|
| 70 | *
|
---|
| 71 | * Revision 1.8 2003/05/15 18:26:07 knoaman
|
---|
| 72 | * Partial implementation of the configurable memory manager.
|
---|
| 73 | *
|
---|
| 74 | * Revision 1.7 2003/04/21 20:46:01 knoaman
|
---|
| 75 | * Use XMLString::release to prepare for configurable memory manager.
|
---|
| 76 | *
|
---|
| 77 | * Revision 1.6 2003/03/07 18:08:10 tng
|
---|
| 78 | * Return a reference instead of void for operator=
|
---|
| 79 | *
|
---|
| 80 | * Revision 1.5 2003/01/29 19:45:35 gareth
|
---|
| 81 | * added api for DOMTypeInfo
|
---|
| 82 | *
|
---|
| 83 | * Revision 1.4 2002/12/10 02:15:55 knoaman
|
---|
| 84 | * Schema Errata: E1-21.
|
---|
| 85 | *
|
---|
| 86 | * Revision 1.3 2002/11/04 15:00:21 tng
|
---|
| 87 | * C++ Namespace Support.
|
---|
| 88 | *
|
---|
| 89 | * Revision 1.2 2002/02/20 18:17:01 tng
|
---|
| 90 | * [Bug 5977] Warnings on generating apiDocs.
|
---|
| 91 | *
|
---|
| 92 | * Revision 1.1.1.1 2002/02/01 22:21:50 peiyongz
|
---|
| 93 | * sane_include
|
---|
| 94 | *
|
---|
| 95 | * Revision 1.13 2001/11/15 16:36:36 knoaman
|
---|
| 96 | * Re-organize constant values.
|
---|
| 97 | *
|
---|
| 98 | * Revision 1.12 2001/08/09 15:23:37 knoaman
|
---|
| 99 | * add support for <anyAttribute> declaration.
|
---|
| 100 | *
|
---|
| 101 | * Revision 1.11 2001/06/21 14:25:26 knoaman
|
---|
| 102 | * Fix for bug 1946
|
---|
| 103 | *
|
---|
| 104 | * Revision 1.10 2001/05/11 13:25:31 tng
|
---|
| 105 | * Copyright update.
|
---|
| 106 | *
|
---|
| 107 | * Revision 1.9 2001/02/27 18:48:20 tng
|
---|
| 108 | * Schema: Add SchemaAttDef, SchemaElementDecl, SchemaAttDefList.
|
---|
| 109 | *
|
---|
| 110 | * Revision 1.8 2000/12/14 18:49:56 tng
|
---|
| 111 | * Fix API document generation warning: "Warning: end of member group without matching begin"
|
---|
| 112 | *
|
---|
| 113 | * Revision 1.7 2000/11/30 18:22:38 andyh
|
---|
| 114 | * reuseValidator - fix bugs (spurious errors) that occured on reuse due to
|
---|
| 115 | * pools already containing some items. Fixed by Tinny Ng.
|
---|
| 116 | *
|
---|
| 117 | * Revision 1.6 2000/07/07 22:23:38 jpolast
|
---|
| 118 | * remove useless getKey() functions.
|
---|
| 119 | *
|
---|
| 120 | * Revision 1.5 2000/02/24 20:00:22 abagchi
|
---|
| 121 | * Swat for removing Log from API docs
|
---|
| 122 | *
|
---|
| 123 | * Revision 1.4 2000/02/16 23:03:48 roddey
|
---|
| 124 | * More documentation updates
|
---|
| 125 | *
|
---|
| 126 | * Revision 1.3 2000/02/15 01:21:30 roddey
|
---|
| 127 | * Some initial documentation improvements. More to come...
|
---|
| 128 | *
|
---|
| 129 | * Revision 1.2 2000/02/06 07:47:46 rahulj
|
---|
| 130 | * Year 2K copyright swat.
|
---|
| 131 | *
|
---|
| 132 | * Revision 1.1.1.1 1999/11/09 01:08:27 twl
|
---|
| 133 | * Initial checkin
|
---|
| 134 | *
|
---|
| 135 | * Revision 1.2 1999/11/08 20:44:34 rahul
|
---|
| 136 | * Swat for adding in Product name and CVS comment log variable.
|
---|
| 137 | *
|
---|
| 138 | */
|
---|
| 139 |
|
---|
| 140 | #if !defined(ATTDEF_HPP)
|
---|
| 141 | #define ATTDEF_HPP
|
---|
| 142 |
|
---|
| 143 | #include <xercesc/util/PlatformUtils.hpp>
|
---|
| 144 | #include <xercesc/util/XMLString.hpp>
|
---|
| 145 | #include <xercesc/util/XMemory.hpp>
|
---|
| 146 | #include <xercesc/internal/XSerializable.hpp>
|
---|
| 147 |
|
---|
| 148 | XERCES_CPP_NAMESPACE_BEGIN
|
---|
| 149 |
|
---|
| 150 | class XMLAttr;
|
---|
| 151 |
|
---|
| 152 | /** Represents the core information of an atribute definition
|
---|
| 153 | *
|
---|
| 154 | * This class defines the basic characteristics of an attribute, no matter
|
---|
| 155 | * what type of validator is used. If a particular schema associates more
|
---|
| 156 | * information with an attribute it will create a derivative of this class.
|
---|
| 157 | * So this class provides an abstract way to get basic information on
|
---|
| 158 | * attributes from any type of validator.
|
---|
| 159 | *
|
---|
| 160 | * This class supports keyed collection semantics on the fully qualified
|
---|
| 161 | * attribute name, by providing a getKey() method to extract the key string.
|
---|
| 162 | * getKey(), in this case, just calls the virtual method getFullName() to
|
---|
| 163 | * get the fully qualified name, as defined by the derived class.
|
---|
| 164 | *
|
---|
| 165 | * Note that the 'value' of an attribute type definition is the default or
|
---|
| 166 | * of fixed value given to it in its definition. If the attribute is of the
|
---|
| 167 | * enumerated or notation type, it will have an 'enumeration value' as well
|
---|
| 168 | * which is a space separated list of its possible vlaues.
|
---|
| 169 | */
|
---|
| 170 | class XMLPARSER_EXPORT XMLAttDef : public XSerializable, public XMemory
|
---|
| 171 | {
|
---|
| 172 | public:
|
---|
| 173 | // -----------------------------------------------------------------------
|
---|
| 174 | // Class specific types
|
---|
| 175 | //
|
---|
| 176 | // AttTypes
|
---|
| 177 | // The list of possible types that an attribute can have, according
|
---|
| 178 | // to the XML 1.0 spec and schema.
|
---|
| 179 | //
|
---|
| 180 | // DefAttTypes
|
---|
| 181 | // The modifiers that an attribute decl can have, which indicates
|
---|
| 182 | // whether instances of that attributes are required, implied, etc..
|
---|
| 183 | //
|
---|
| 184 | // CreateReasons
|
---|
| 185 | // This type is used to store how an attribute declaration got into
|
---|
| 186 | // the elementdecl's attribute pool.
|
---|
| 187 | //
|
---|
| 188 | // -----------------------------------------------------------------------
|
---|
| 189 | enum AttTypes
|
---|
| 190 | {
|
---|
| 191 | CData = 0
|
---|
| 192 | , ID = 1
|
---|
| 193 | , IDRef = 2
|
---|
| 194 | , IDRefs = 3
|
---|
| 195 | , Entity = 4
|
---|
| 196 | , Entities = 5
|
---|
| 197 | , NmToken = 6
|
---|
| 198 | , NmTokens = 7
|
---|
| 199 | , Notation = 8
|
---|
| 200 | , Enumeration = 9
|
---|
| 201 | , Simple = 10
|
---|
| 202 | , Any_Any = 11
|
---|
| 203 | , Any_Other = 12
|
---|
| 204 | , Any_List = 13
|
---|
| 205 |
|
---|
| 206 | , AttTypes_Count
|
---|
| 207 | , AttTypes_Min = 0
|
---|
| 208 | , AttTypes_Max = 13
|
---|
| 209 | , AttTypes_Unknown = -1
|
---|
| 210 | };
|
---|
| 211 |
|
---|
| 212 | enum DefAttTypes
|
---|
| 213 | {
|
---|
| 214 | Default = 0
|
---|
| 215 | , Fixed = 1
|
---|
| 216 | , Required = 2
|
---|
| 217 | , Required_And_Fixed = 3
|
---|
| 218 | , Implied = 4
|
---|
| 219 | , ProcessContents_Skip = 5
|
---|
| 220 | , ProcessContents_Lax = 6
|
---|
| 221 | , ProcessContents_Strict = 7
|
---|
| 222 | , Prohibited = 8
|
---|
| 223 |
|
---|
| 224 | , DefAttTypes_Count
|
---|
| 225 | , DefAttTypes_Min = 0
|
---|
| 226 | , DefAttTypes_Max = 8
|
---|
| 227 | , DefAttTypes_Unknown = -1
|
---|
| 228 | };
|
---|
| 229 |
|
---|
| 230 | enum CreateReasons
|
---|
| 231 | {
|
---|
| 232 | NoReason
|
---|
| 233 | , JustFaultIn
|
---|
| 234 | };
|
---|
| 235 |
|
---|
| 236 | // -----------------------------------------------------------------------
|
---|
| 237 | // Public static data members
|
---|
| 238 | // -----------------------------------------------------------------------
|
---|
| 239 | static const unsigned int fgInvalidAttrId;
|
---|
| 240 |
|
---|
| 241 |
|
---|
| 242 | // -----------------------------------------------------------------------
|
---|
| 243 | // Public, static methods
|
---|
| 244 | // -----------------------------------------------------------------------
|
---|
| 245 |
|
---|
| 246 | /** @name Public, static methods */
|
---|
| 247 | //@{
|
---|
| 248 |
|
---|
| 249 | /** Get a string representation of the passed attribute type enum
|
---|
| 250 | *
|
---|
| 251 | * This method allows you to get a textual representation of an attriubte
|
---|
| 252 | * type, mostly for debug or display.
|
---|
| 253 | *
|
---|
| 254 | * @param attrType The attribute type value to get the string for.
|
---|
| 255 | *
|
---|
| 256 | * @return A const pointer to the static string that holds the text
|
---|
| 257 | * description of the passed type.
|
---|
| 258 | */
|
---|
| 259 | static const XMLCh* getAttTypeString(const AttTypes attrType
|
---|
| 260 | , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
|
---|
| 261 |
|
---|
| 262 | /** Get a string representation of the passed def attribute type enum
|
---|
| 263 | *
|
---|
| 264 | * This method allows you to get a textual representation of an default
|
---|
| 265 | * attributetype, mostly for debug or display.
|
---|
| 266 | *
|
---|
| 267 | * @param attrType The default attribute type value to get the string for.
|
---|
| 268 | *
|
---|
| 269 | * @return A const pointer to the static string that holds the text
|
---|
| 270 | * description of the passed default type.
|
---|
| 271 | */
|
---|
| 272 | static const XMLCh* getDefAttTypeString(const DefAttTypes attrType
|
---|
| 273 | , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
|
---|
| 274 |
|
---|
| 275 | //@}
|
---|
| 276 |
|
---|
| 277 |
|
---|
| 278 | // -----------------------------------------------------------------------
|
---|
| 279 | // Destructor
|
---|
| 280 | // -----------------------------------------------------------------------
|
---|
| 281 |
|
---|
| 282 | /** @name Destructor */
|
---|
| 283 | //@{
|
---|
| 284 |
|
---|
| 285 | /**
|
---|
| 286 | * Destructor
|
---|
| 287 | */
|
---|
| 288 | virtual ~XMLAttDef();
|
---|
| 289 | //@}
|
---|
| 290 |
|
---|
| 291 |
|
---|
| 292 | // -----------------------------------------------------------------------
|
---|
| 293 | // The virtual attribute def interface
|
---|
| 294 | // -----------------------------------------------------------------------
|
---|
| 295 |
|
---|
| 296 | /** @name Virtual interface */
|
---|
| 297 | //@{
|
---|
| 298 |
|
---|
| 299 | /** Get the full name of this attribute type
|
---|
| 300 | *
|
---|
| 301 | * The derived class should return a const pointer to the full name of
|
---|
| 302 | * this attribute. This will vary depending on the type of validator in
|
---|
| 303 | * use.
|
---|
| 304 | *
|
---|
| 305 | * @return A const pointer to the full name of this attribute type.
|
---|
| 306 | */
|
---|
| 307 | virtual const XMLCh* getFullName() const = 0;
|
---|
| 308 |
|
---|
| 309 | /**
|
---|
| 310 | * The derived class should implement any cleaning up required between
|
---|
| 311 | * each use of an instance of this class for validation
|
---|
| 312 | */
|
---|
| 313 | virtual void reset() = 0;
|
---|
| 314 |
|
---|
| 315 | //@}
|
---|
| 316 |
|
---|
| 317 |
|
---|
| 318 | // -----------------------------------------------------------------------
|
---|
| 319 | // Getter methods
|
---|
| 320 | // -----------------------------------------------------------------------
|
---|
| 321 |
|
---|
| 322 | /** @name Getter methods */
|
---|
| 323 | //@{
|
---|
| 324 |
|
---|
| 325 | /** Get the default type of this attribute type
|
---|
| 326 | *
|
---|
| 327 | * This method returns the 'default type' of the attribute. Default
|
---|
| 328 | * type in this case refers to the XML concept of a default type for
|
---|
| 329 | * an attribute, i.e. #FIXED, #IMPLIED, etc...
|
---|
| 330 | *
|
---|
| 331 | * @return The default type enum for this attribute type.
|
---|
| 332 | */
|
---|
| 333 | DefAttTypes getDefaultType() const;
|
---|
| 334 |
|
---|
| 335 | /** Get the enumeration value (if any) of this attribute type
|
---|
| 336 | *
|
---|
| 337 | * If the attribute is of an enumeration or notatin type, then this
|
---|
| 338 | * method will return a const reference to a string that contains the
|
---|
| 339 | * space separated values that can the attribute can have.
|
---|
| 340 | *
|
---|
| 341 | * @return A const pointer to a string that contains the space separated
|
---|
| 342 | * legal values for this attribute.
|
---|
| 343 | */
|
---|
| 344 | const XMLCh* getEnumeration() const;
|
---|
| 345 |
|
---|
| 346 | /** Get the pool id of this attribute type
|
---|
| 347 | *
|
---|
| 348 | * This method will return the id of this attribute in the validator's
|
---|
| 349 | * attribute pool. It was set by the validator when this attribute was
|
---|
| 350 | * created.
|
---|
| 351 | *
|
---|
| 352 | * @return The pool id of this attribute type.
|
---|
| 353 | */
|
---|
| 354 | unsigned int getId() const;
|
---|
| 355 |
|
---|
| 356 | /** Query whether the attribute was explicitly provided.
|
---|
| 357 | *
|
---|
| 358 | * When the scanner scans a start tag, it will ask the element decl
|
---|
| 359 | * object of the element type of that start tag to clear the 'provided'
|
---|
| 360 | * flag on all its attributes. As the scanner sees explicitly provided
|
---|
| 361 | * attributes, its turns on this flag to indicate that this attribute
|
---|
| 362 | * has been provided. In this way, the scanner can catch duplicated
|
---|
| 363 | * attributes and required attributes that aren't provided, and default
|
---|
| 364 | * in fixed/default valued attributes that are not explicitly provided.
|
---|
| 365 | *
|
---|
| 366 | * @return Returns a boolean value that indicates whether this attribute
|
---|
| 367 | * was explicitly provided.
|
---|
| 368 | * @deprecated
|
---|
| 369 | */
|
---|
| 370 | bool getProvided() const;
|
---|
| 371 |
|
---|
| 372 | /** Get the type of this attribute
|
---|
| 373 | *
|
---|
| 374 | * Gets the type of this attribute. This type is represented by an enum
|
---|
| 375 | * that convers the types of attributes allowed by XML, e.g. CDATA, NMTOKEN,
|
---|
| 376 | * NOTATION, etc...
|
---|
| 377 | *
|
---|
| 378 | * @return The attribute type enumeration value for this type of
|
---|
| 379 | * attribute.
|
---|
| 380 | */
|
---|
| 381 | AttTypes getType() const;
|
---|
| 382 |
|
---|
| 383 | /** Get the default/fixed value of this attribute (if any.)
|
---|
| 384 | *
|
---|
| 385 | * If the attribute defined a default/fixed value, then it is stored
|
---|
| 386 | * and this method will retrieve it. If it has non, then a null pointer
|
---|
| 387 | * is returned.
|
---|
| 388 | *
|
---|
| 389 | * @return A const pointer to the default/fixed value for this attribute
|
---|
| 390 | * type.
|
---|
| 391 | */
|
---|
| 392 | const XMLCh* getValue() const;
|
---|
| 393 |
|
---|
| 394 | /** Get the create reason for this attribute
|
---|
| 395 | *
|
---|
| 396 | * This method returns an enumeration which indicates why this attribute
|
---|
| 397 | * declaration exists.
|
---|
| 398 | *
|
---|
| 399 | * @return An enumerated value that indicates the reason why this attribute
|
---|
| 400 | * was added to the attribute table.
|
---|
| 401 | */
|
---|
| 402 | CreateReasons getCreateReason() const;
|
---|
| 403 |
|
---|
| 404 | /** Indicate whether this attribute has been declared externally
|
---|
| 405 | *
|
---|
| 406 | * This method returns a boolean that indicates whether this attribute
|
---|
| 407 | * has been declared externally.
|
---|
| 408 | *
|
---|
| 409 | * @return true if this attribute has been declared externally, else false.
|
---|
| 410 | */
|
---|
| 411 | bool isExternal() const;
|
---|
| 412 |
|
---|
| 413 | /** Get the plugged-in memory manager
|
---|
| 414 | *
|
---|
| 415 | * This method returns the plugged-in memory manager user for dynamic
|
---|
| 416 | * memory allocation/deallocation.
|
---|
| 417 | *
|
---|
| 418 | * @return the plugged-in memory manager
|
---|
| 419 | */
|
---|
| 420 | MemoryManager* getMemoryManager() const;
|
---|
| 421 |
|
---|
| 422 |
|
---|
| 423 | /**
|
---|
| 424 | * @return the uri part of DOM Level 3 TypeInfo
|
---|
| 425 | * @deprecated
|
---|
| 426 | */
|
---|
| 427 | virtual const XMLCh* getDOMTypeInfoUri() const = 0;
|
---|
| 428 |
|
---|
| 429 | /**
|
---|
| 430 | * @return the name part of DOM Level 3 TypeInfo
|
---|
| 431 | * @deprecated
|
---|
| 432 | */
|
---|
| 433 | virtual const XMLCh* getDOMTypeInfoName() const = 0;
|
---|
| 434 |
|
---|
| 435 | //@}
|
---|
| 436 |
|
---|
| 437 |
|
---|
| 438 | // -----------------------------------------------------------------------
|
---|
| 439 | // Setter methods
|
---|
| 440 | // -----------------------------------------------------------------------
|
---|
| 441 |
|
---|
| 442 | /** @name Setter methods */
|
---|
| 443 | //@{
|
---|
| 444 |
|
---|
| 445 | /** Set the default attribute type
|
---|
| 446 | *
|
---|
| 447 | * This method sets the default attribute type for this attribute.
|
---|
| 448 | * This setting controls whether the attribute is required, fixed,
|
---|
| 449 | * implied, etc...
|
---|
| 450 | *
|
---|
| 451 | * @param newValue The new default attribute to set
|
---|
| 452 | */
|
---|
| 453 | void setDefaultType(const XMLAttDef::DefAttTypes newValue);
|
---|
| 454 |
|
---|
| 455 | /** Set the pool id for this attribute type.
|
---|
| 456 | *
|
---|
| 457 | * This method sets the pool id of this attribute type. This is usually
|
---|
| 458 | * called by the validator that creates the actual instance (which is of
|
---|
| 459 | * a derived type known only by the validator.)
|
---|
| 460 | *
|
---|
| 461 | * @param newId The new pool id to set.
|
---|
| 462 | */
|
---|
| 463 | void setId(const unsigned int newId);
|
---|
| 464 |
|
---|
| 465 | /** Set or clear the 'provided' flag.
|
---|
| 466 | *
|
---|
| 467 | * This method will set or clear the 'provided' flag. This is called
|
---|
| 468 | * by the scanner as it is scanning a start tag and marking off the
|
---|
| 469 | * attributes that have been explicitly provided.
|
---|
| 470 | *
|
---|
| 471 | * @param newValue The new provided state to set
|
---|
| 472 | * @deprecated
|
---|
| 473 | */
|
---|
| 474 | void setProvided(const bool newValue);
|
---|
| 475 |
|
---|
| 476 | /** Set the type of this attribute type.
|
---|
| 477 | *
|
---|
| 478 | * This method will set the type of the attribute. The type of an attribute
|
---|
| 479 | * controls how it is normalized and what kinds of characters it can hold.
|
---|
| 480 | *
|
---|
| 481 | * @param newValue The new attribute type to set
|
---|
| 482 | */
|
---|
| 483 | void setType(const XMLAttDef::AttTypes newValue);
|
---|
| 484 |
|
---|
| 485 | /** Set the default/fixed value of this attribute type.
|
---|
| 486 | *
|
---|
| 487 | * This method set the fixed/default value for the attribute. This value
|
---|
| 488 | * will be used when instances of this attribute type are faulted in. It
|
---|
| 489 | * <b>must</b> be a valid value for the type set by setType(). If the
|
---|
| 490 | * type is enumeration or notation, this must be one of the valid values
|
---|
| 491 | * set in the setEnumeration() call.
|
---|
| 492 | *
|
---|
| 493 | * @param newValue The new fixed/default value to set.
|
---|
| 494 | */
|
---|
| 495 | void setValue(const XMLCh* const newValue);
|
---|
| 496 |
|
---|
| 497 | /** Set the enumerated value of this attribute type.
|
---|
| 498 | *
|
---|
| 499 | * This method sets the enumerated/notation value list for this attribute
|
---|
| 500 | * type. It is a space separated set of possible values. These values must
|
---|
| 501 | * meet the constrains of the XML spec for such values of this type of
|
---|
| 502 | * attribute. This should only be set if the setType() method is used to
|
---|
| 503 | * set the type to the enumeration or notation types.
|
---|
| 504 | *
|
---|
| 505 | * @param newValue The new enumerated/notation value list to set.
|
---|
| 506 | */
|
---|
| 507 | void setEnumeration(const XMLCh* const newValue);
|
---|
| 508 |
|
---|
| 509 | /** Update the create reason for this attribute type.
|
---|
| 510 | *
|
---|
| 511 | * This method will update the 'create reason' field for this attribute
|
---|
| 512 | * decl object.
|
---|
| 513 | *
|
---|
| 514 | * @param newReason The new create reason.
|
---|
| 515 | */
|
---|
| 516 | void setCreateReason(const CreateReasons newReason);
|
---|
| 517 |
|
---|
| 518 | /**
|
---|
| 519 | * Set the attribute decl to indicate external declaration
|
---|
| 520 | *
|
---|
| 521 | * @param aValue The new value to indicate external declaration.
|
---|
| 522 | */
|
---|
| 523 | void setExternalAttDeclaration(const bool aValue);
|
---|
| 524 |
|
---|
| 525 | //@}
|
---|
| 526 |
|
---|
| 527 | /***
|
---|
| 528 | * Support for Serialization/De-serialization
|
---|
| 529 | ***/
|
---|
| 530 | DECL_XSERIALIZABLE(XMLAttDef)
|
---|
| 531 |
|
---|
| 532 | protected :
|
---|
| 533 | // -----------------------------------------------------------------------
|
---|
| 534 | // Hidden constructors
|
---|
| 535 | // -----------------------------------------------------------------------
|
---|
| 536 | XMLAttDef
|
---|
| 537 | (
|
---|
| 538 | const AttTypes type = CData
|
---|
| 539 | , const DefAttTypes defType= Implied
|
---|
| 540 | , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
|
---|
| 541 | );
|
---|
| 542 | XMLAttDef
|
---|
| 543 | (
|
---|
| 544 | const XMLCh* const attValue
|
---|
| 545 | , const AttTypes type
|
---|
| 546 | , const DefAttTypes defType
|
---|
| 547 | , const XMLCh* const enumValues = 0
|
---|
| 548 | , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
|
---|
| 549 | );
|
---|
| 550 |
|
---|
| 551 |
|
---|
| 552 | private :
|
---|
| 553 | // -----------------------------------------------------------------------
|
---|
| 554 | // Unimplemented constructors and operators
|
---|
| 555 | // -----------------------------------------------------------------------
|
---|
| 556 | XMLAttDef(const XMLAttDef&);
|
---|
| 557 | XMLAttDef& operator=(const XMLAttDef&);
|
---|
| 558 |
|
---|
| 559 |
|
---|
| 560 | // -----------------------------------------------------------------------
|
---|
| 561 | // Private helper methods
|
---|
| 562 | // -----------------------------------------------------------------------
|
---|
| 563 | void cleanUp();
|
---|
| 564 |
|
---|
| 565 |
|
---|
| 566 | // -----------------------------------------------------------------------
|
---|
| 567 | // Private data members
|
---|
| 568 | //
|
---|
| 569 | // fDefaultType
|
---|
| 570 | // Indicates what, if any, default stuff this attribute has.
|
---|
| 571 | //
|
---|
| 572 | // fEnumeration
|
---|
| 573 | // If its an enumeration, this is the list of values as space
|
---|
| 574 | // separated values.
|
---|
| 575 | //
|
---|
| 576 | // fId
|
---|
| 577 | // This is the unique id of this attribute, given to it when its put
|
---|
| 578 | // into the validator's attribute decl pool. It defaults to the
|
---|
| 579 | // special value XMLAttrDef::fgInvalidAttrId.
|
---|
| 580 | //
|
---|
| 581 | // fProvided
|
---|
| 582 | // This field is really for use by the scanner. It is used to track
|
---|
| 583 | // which of the attributes of an element were provided. Any marked
|
---|
| 584 | // as not provided (after scanning the start tag) and having a
|
---|
| 585 | // default type of Required, is in error.
|
---|
| 586 | //
|
---|
| 587 | // fType
|
---|
| 588 | // The type of attribute, which is one of the AttTypes values.
|
---|
| 589 | //
|
---|
| 590 | // fValue
|
---|
| 591 | // This is the value of the attribute, which is the default value
|
---|
| 592 | // given in the attribute declaration.
|
---|
| 593 | //
|
---|
| 594 | // fCreateReason
|
---|
| 595 | // This flag tells us how this attribute got created. Sometimes even
|
---|
| 596 | // the attribute was not declared for the element, we want to fault
|
---|
| 597 | // fault it into the pool to avoid lots of redundant errors.
|
---|
| 598 | //
|
---|
| 599 | // fExternalAttribute
|
---|
| 600 | // This flag indicates whether or not the attribute was declared externally.
|
---|
| 601 | // -----------------------------------------------------------------------
|
---|
| 602 | DefAttTypes fDefaultType;
|
---|
| 603 | AttTypes fType;
|
---|
| 604 | CreateReasons fCreateReason;
|
---|
| 605 | bool fProvided;
|
---|
| 606 | bool fExternalAttribute;
|
---|
| 607 | unsigned int fId;
|
---|
| 608 | XMLCh* fValue;
|
---|
| 609 | XMLCh* fEnumeration;
|
---|
| 610 | MemoryManager* fMemoryManager;
|
---|
| 611 | };
|
---|
| 612 |
|
---|
| 613 |
|
---|
| 614 | // ---------------------------------------------------------------------------
|
---|
| 615 | // Getter methods
|
---|
| 616 | // ---------------------------------------------------------------------------
|
---|
| 617 | inline XMLAttDef::DefAttTypes XMLAttDef::getDefaultType() const
|
---|
| 618 | {
|
---|
| 619 | return fDefaultType;
|
---|
| 620 | }
|
---|
| 621 |
|
---|
| 622 | inline const XMLCh* XMLAttDef::getEnumeration() const
|
---|
| 623 | {
|
---|
| 624 | return fEnumeration;
|
---|
| 625 | }
|
---|
| 626 |
|
---|
| 627 | inline unsigned int XMLAttDef::getId() const
|
---|
| 628 | {
|
---|
| 629 | return fId;
|
---|
| 630 | }
|
---|
| 631 |
|
---|
| 632 | inline bool XMLAttDef::getProvided() const
|
---|
| 633 | {
|
---|
| 634 | return fProvided;
|
---|
| 635 | }
|
---|
| 636 |
|
---|
| 637 | inline XMLAttDef::AttTypes XMLAttDef::getType() const
|
---|
| 638 | {
|
---|
| 639 | return fType;
|
---|
| 640 | }
|
---|
| 641 |
|
---|
| 642 | inline const XMLCh* XMLAttDef::getValue() const
|
---|
| 643 | {
|
---|
| 644 | return fValue;
|
---|
| 645 | }
|
---|
| 646 |
|
---|
| 647 | inline XMLAttDef::CreateReasons XMLAttDef::getCreateReason() const
|
---|
| 648 | {
|
---|
| 649 | return fCreateReason;
|
---|
| 650 | }
|
---|
| 651 |
|
---|
| 652 | inline bool XMLAttDef::isExternal() const
|
---|
| 653 | {
|
---|
| 654 | return fExternalAttribute;
|
---|
| 655 | }
|
---|
| 656 |
|
---|
| 657 | inline MemoryManager* XMLAttDef::getMemoryManager() const
|
---|
| 658 | {
|
---|
| 659 | return fMemoryManager;
|
---|
| 660 | }
|
---|
| 661 |
|
---|
| 662 | // ---------------------------------------------------------------------------
|
---|
| 663 | // XMLAttDef: Setter methods
|
---|
| 664 | // ---------------------------------------------------------------------------
|
---|
| 665 | inline void XMLAttDef::setDefaultType(const XMLAttDef::DefAttTypes newValue)
|
---|
| 666 | {
|
---|
| 667 | fDefaultType = newValue;
|
---|
| 668 | }
|
---|
| 669 |
|
---|
| 670 | inline void XMLAttDef::setEnumeration(const XMLCh* const newValue)
|
---|
| 671 | {
|
---|
| 672 | if (fEnumeration)
|
---|
| 673 | fMemoryManager->deallocate(fEnumeration);
|
---|
| 674 |
|
---|
| 675 | fEnumeration = XMLString::replicate(newValue, fMemoryManager);
|
---|
| 676 | }
|
---|
| 677 |
|
---|
| 678 | inline void XMLAttDef::setId(const unsigned int newId)
|
---|
| 679 | {
|
---|
| 680 | fId = newId;
|
---|
| 681 | }
|
---|
| 682 |
|
---|
| 683 | inline void XMLAttDef::setProvided(const bool newValue)
|
---|
| 684 | {
|
---|
| 685 | fProvided = newValue;
|
---|
| 686 | }
|
---|
| 687 |
|
---|
| 688 | inline void XMLAttDef::setType(const XMLAttDef::AttTypes newValue)
|
---|
| 689 | {
|
---|
| 690 | fType = newValue;
|
---|
| 691 | }
|
---|
| 692 |
|
---|
| 693 | inline void XMLAttDef::setValue(const XMLCh* const newValue)
|
---|
| 694 | {
|
---|
| 695 | if (fValue)
|
---|
| 696 | fMemoryManager->deallocate(fValue);
|
---|
| 697 |
|
---|
| 698 | fValue = XMLString::replicate(newValue, fMemoryManager);
|
---|
| 699 | }
|
---|
| 700 |
|
---|
| 701 | inline void
|
---|
| 702 | XMLAttDef::setCreateReason(const XMLAttDef::CreateReasons newReason)
|
---|
| 703 | {
|
---|
| 704 | fCreateReason = newReason;
|
---|
| 705 | }
|
---|
| 706 |
|
---|
| 707 | inline void XMLAttDef::setExternalAttDeclaration(const bool aValue)
|
---|
| 708 | {
|
---|
| 709 | fExternalAttribute = aValue;
|
---|
| 710 | }
|
---|
| 711 |
|
---|
| 712 | XERCES_CPP_NAMESPACE_END
|
---|
| 713 |
|
---|
| 714 | #endif
|
---|