00001 00002 00003 00004 00005 00006 00007 00008 00009 00010 00011 00012 00013 00014 00015 00016 00017 00018 00019 00020 00021 00022 00023 00024 00025 00026 00027 00028 00029 00030 00031 00032 00033 00034 00035 00036 00037 00038 00039 00040 00041 00042 00043 00044 00045 00046 00047 00048 00049 00050 00051 00052 00053 00054 00055
00056
00057 00058 00059 00060 00061 00062 00063 00064 00065 00066 00067 00068 00069 00070 00071 00072 00073 00074 00075 00076 00077 00078 00079 00080 00081 00082
00083
00084 #if !defined(XMLELEMENTDECL_HPP)
00085 #define XMLELEMENTDECL_HPP
00086
00087 #include <util/XMLString.hpp>
00088 #include <framework/XMLAttr.hpp>
00089 #include <framework/XMLAttDefList.hpp>
00090 #include <framework/XMLContentModel.hpp>
00091
00092 class XMLValidator;
00093
00116 class XMLElementDecl
00117 {
00118 public:
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134 enum CreateReasons
00135 {
00136 NoReason
00137 , Declared
00138 , AttList
00139 , InContentModel
00140 , AsRootElem
00141 };
00142
00143 enum LookupOpts
00144 {
00145 AddIfNotFound
00146 , FailIfNotFound
00147 };
00148
00149 enum CharDataOpts
00150 {
00151 NoCharData
00152 , SpacesOk
00153 , AllCharData
00154 };
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171 static const unsigned int fgInvalidElemId;
00172 static const unsigned int fgPCDataElemId;
00173 static const XMLCh fgPCDataElemName[];
00174
00175
00176
00177
00178
00179
00181
00182 virtual ~XMLElementDecl();
00183
00184
00185
00186
00187
00188
00189
00191
00192
00218 virtual XMLAttDef* findAttr
00219 (
00220 const XMLCh* const qName
00221 , const unsigned int uriId
00222 , const XMLCh* const baseName
00223 , const LookupOpts options
00224 , bool& wasAdded
00225 ) const = 0;
00226
00238 virtual XMLAttDefList& getAttDefList() const = 0;
00239
00248 virtual const XMLCh* getBaseName() const = 0;
00249
00257 virtual CharDataOpts getCharDataOpts() const = 0;
00258
00267 virtual const XMLCh* getFullName() const = 0;
00268
00275 virtual bool hasAttDefs() const = 0;
00276
00284 virtual bool resetDefs() = 0;
00285
00286
00287
00288
00289
00290
00291
00292
00294
00295
00307 const XMLContentModel* getContentModel() const;
00308
00314 XMLContentModel* getContentModel();
00315
00326 CreateReasons getCreateReason() const;
00327
00337 unsigned int getId() const;
00338
00348 bool isDeclared() const;
00349
00357
00358 bool isExternal() const;
00359
00360
00361
00362
00363
00364
00365
00366
00368
00369
00381 void setContentModel(XMLContentModel* const newModelToAdopt);
00382
00393 void setCreateReason(const CreateReasons newReason);
00394
00401 void setId(const unsigned int newId);
00402
00403
00407 void setExternalElemDeclaration();
00408
00409
00410
00411
00412
00413
00414
00415
00417
00418
00438 const XMLCh* getFormattedContentModel
00439 (
00440 const XMLValidator& validator
00441 ) const;
00442
00451 const XMLCh* getKey() const;
00452
00453
00454
00455
00456 protected :
00457
00458
00459
00460 XMLElementDecl();
00461
00462
00463
00464
00465
00466 virtual XMLContentModel* makeContentModel() const = 0;
00467 virtual XMLCh* formatContentModel
00468 (
00469 const XMLValidator& validator
00470 ) const = 0;
00471
00472
00473 private :
00474
00475
00476
00477 XMLElementDecl(const XMLElementDecl&);
00478 void operator=(const XMLElementDecl&);
00479
00480
00481
00482
00483
00484
00485
00486
00487
00488
00489
00490
00491
00492
00493
00494
00495
00496
00497
00498
00499
00500
00501
00502
00503
00504
00505
00506
00507
00508
00509
00510 XMLContentModel* fContentModel;
00511 CreateReasons fCreateReason;
00512 XMLCh* fFormattedModel;
00513 unsigned int fId;
00514 bool fExternalElement;
00515 };
00516
00517
00518
00519
00520
00521 inline const XMLCh* XMLElementDecl::getKey() const
00522 {
00523
00524
00525
00526
00527 return getFullName();
00528 }
00529
00530
00531
00532
00533
00534 inline XMLContentModel* XMLElementDecl::getContentModel()
00535 {
00536 if (!fContentModel)
00537 fContentModel = makeContentModel();
00538 return fContentModel;
00539 }
00540
00541 inline const XMLContentModel* XMLElementDecl::getContentModel() const
00542 {
00543
00544 if (!fContentModel)
00545 ((XMLElementDecl*)this)->fContentModel = makeContentModel();
00546 return fContentModel;
00547 }
00548
00549 inline XMLElementDecl::CreateReasons XMLElementDecl::getCreateReason() const
00550 {
00551 return fCreateReason;
00552 }
00553
00554 inline unsigned int XMLElementDecl::getId() const
00555 {
00556 return fId;
00557 }
00558
00559 inline bool XMLElementDecl::isDeclared() const
00560 {
00561 return (fCreateReason == Declared);
00562 }
00563
00564
00565 inline bool XMLElementDecl::isExternal() const
00566 {
00567 return fExternalElement;
00568 }
00569
00570
00571
00572
00573
00574 inline void
00575 XMLElementDecl::setContentModel(XMLContentModel* const newModelToAdopt)
00576 {
00577 delete fContentModel;
00578 fContentModel = newModelToAdopt;
00579 }
00580
00581 inline void
00582 XMLElementDecl::setCreateReason(const XMLElementDecl::CreateReasons newReason)
00583 {
00584 fCreateReason = newReason;
00585 }
00586
00587 inline void XMLElementDecl::setId(const unsigned int newId)
00588 {
00589 fId = newId;
00590 }
00591
00592
00593 inline void XMLElementDecl::setExternalElemDeclaration()
00594 {
00595 fExternalElement = true;
00596 }
00597
00598 #endif