00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #if !defined(XMLATTR_HPP)
00022 #define XMLATTR_HPP
00023
00024 #include <xercesc/util/PlatformUtils.hpp>
00025 #include <xercesc/util/QName.hpp>
00026 #include <xercesc/framework/XMLAttDef.hpp>
00027 #include <xercesc/validators/datatype/DatatypeValidator.hpp>
00028
00029 XERCES_CPP_NAMESPACE_BEGIN
00030
00052 class XMLAttr : public XMemory
00053 {
00054 public:
00055
00056
00057
00060
00068 XMLAttr(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
00069
00102 XMLAttr
00103 (
00104 const unsigned int uriId
00105 , const XMLCh* const attrName
00106 , const XMLCh* const attrPrefix
00107 , const XMLCh* const attrValue
00108 , const XMLAttDef::AttTypes type = XMLAttDef::CData
00109 , const bool specified = true
00110 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
00111 , DatatypeValidator * datatypeValidator = 0
00112 , const bool isSchema = false
00113 );
00114
00143 XMLAttr
00144 (
00145 const unsigned int uriId
00146 , const XMLCh* const rawName
00147 , const XMLCh* const attrValue
00148 , const XMLAttDef::AttTypes type = XMLAttDef::CData
00149 , const bool specified = true
00150 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
00151 , DatatypeValidator * datatypeValidator = 0
00152 , const bool isSchema = false
00153 );
00154
00156
00159 ~XMLAttr();
00161
00162
00163
00164
00165
00166
00169
00173 QName* getAttName() const;
00174
00179 const XMLCh* getName() const;
00180
00185 const XMLCh* getPrefix() const;
00186
00192 const XMLCh* getQName() const;
00193
00198 bool getSpecified() const;
00199
00204 XMLAttDef::AttTypes getType() const;
00205
00211 const XMLCh* getValue() const;
00212
00217 unsigned int getURIId() const;
00218
00223 const XMLCh* getValidatingTypeURI() const;
00224
00229 const XMLCh* getValidatingTypeName() const;
00230
00232
00233
00234
00235
00236
00237
00240
00269 void set
00270 (
00271 const unsigned int uriId
00272 , const XMLCh* const attrName
00273 , const XMLCh* const attrPrefix
00274 , const XMLCh* const attrValue
00275 , const XMLAttDef::AttTypes type = XMLAttDef::CData
00276 , DatatypeValidator * datatypeValidator = 0
00277 , const bool isSchema = false
00278 );
00279
00303 void set
00304 (
00305 const unsigned int uriId
00306 , const XMLCh* const attrRawName
00307 , const XMLCh* const attrValue
00308 , const XMLAttDef::AttTypes type = XMLAttDef::CData
00309 , DatatypeValidator * datatypeValidator = 0
00310 , const bool isSchema = false
00311 );
00312
00327 void setName
00328 (
00329 const unsigned int uriId
00330 , const XMLCh* const attrName
00331 , const XMLCh* const attrPrefix
00332 );
00333
00341 void setSpecified(const bool newValue);
00342
00351 void setType(const XMLAttDef::AttTypes newType);
00352
00360 void setValue(const XMLCh* const newValue);
00361
00369 void setURIId(const unsigned int uriId);
00370
00378 void setDatatypeValidator(DatatypeValidator * datatypeValidator);
00379
00387 void setSchemaValidated(const bool isSchema);
00388
00390
00391
00392
00393 private :
00394
00395
00396
00397 XMLAttr(const XMLAttr&);
00398 XMLAttr& operator=(const XMLAttr&);
00399
00400
00401
00402
00403
00404 void cleanUp();
00405
00406
00407
00408
00409
00410
00411
00412
00413
00414
00415
00416
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426
00427
00428
00429
00430
00431
00432
00433
00434
00435
00436 bool fSpecified;
00437 XMLAttDef::AttTypes fType;
00438 unsigned int fValueBufSz;
00439 XMLCh* fValue;
00440 QName* fAttName;
00441 MemoryManager* fMemoryManager;
00442 DatatypeValidator * fDatatypeValidator;
00443 bool fIsSchemaValidated;
00444 };
00445
00446
00447
00448
00449 inline XMLAttr::~XMLAttr()
00450 {
00451 cleanUp();
00452 }
00453
00454
00455
00456
00457
00458 inline QName* XMLAttr::getAttName() const
00459 {
00460 return fAttName;
00461 }
00462
00463 inline const XMLCh* XMLAttr::getName() const
00464 {
00465 return fAttName->getLocalPart();
00466 }
00467
00468 inline const XMLCh* XMLAttr::getPrefix() const
00469 {
00470 return fAttName->getPrefix();
00471 }
00472
00473 inline bool XMLAttr::getSpecified() const
00474 {
00475 return fSpecified;
00476 }
00477
00478 inline XMLAttDef::AttTypes XMLAttr::getType() const
00479 {
00480 return fType;
00481 }
00482
00483 inline const XMLCh* XMLAttr::getValue() const
00484 {
00485 return fValue;
00486 }
00487
00488 inline unsigned int XMLAttr::getURIId() const
00489 {
00490 return fAttName->getURI();
00491 }
00492
00493 inline const XMLCh* XMLAttr::getValidatingTypeName() const
00494 {
00495 if(fIsSchemaValidated)
00496 {
00497 if(!fDatatypeValidator || fDatatypeValidator->getAnonymous())
00498 return 0;
00499 return fDatatypeValidator->getTypeLocalName();
00500 }
00501 else
00502 {
00503 return XMLAttDef::getAttTypeString(fType, fMemoryManager);
00504 }
00505 }
00506
00507 inline const XMLCh* XMLAttr::getValidatingTypeURI() const
00508 {
00509 if(fIsSchemaValidated)
00510 {
00511 if(!fDatatypeValidator || fDatatypeValidator->getAnonymous())
00512 return 0;
00513 return fDatatypeValidator->getTypeUri();
00514 }
00515 else
00516 {
00517 return 0;
00518 }
00519 }
00520
00521
00522
00523
00524 inline void XMLAttr::set(const unsigned int uriId
00525 , const XMLCh* const attrName
00526 , const XMLCh* const attrPrefix
00527 , const XMLCh* const attrValue
00528 , const XMLAttDef::AttTypes type
00529 , DatatypeValidator * datatypeValidator
00530 , const bool isSchema )
00531 {
00532
00533 fAttName->setName(attrPrefix, attrName, uriId);
00534 setValue(attrValue);
00535
00536
00537 fType = type;
00538
00539
00540 fIsSchemaValidated = isSchema;
00541 fDatatypeValidator = datatypeValidator;
00542 }
00543
00544 inline void XMLAttr::set(const unsigned int uriId
00545 , const XMLCh* const attrRawName
00546 , const XMLCh* const attrValue
00547 , const XMLAttDef::AttTypes type
00548 , DatatypeValidator * datatypeValidator
00549 , const bool isSchema )
00550 {
00551
00552 fAttName->setName(attrRawName, uriId);
00553 setValue(attrValue);
00554
00555
00556 fType = type;
00557
00558
00559 fIsSchemaValidated = isSchema;
00560 fDatatypeValidator = datatypeValidator;
00561 }
00562
00563 inline void XMLAttr::setType(const XMLAttDef::AttTypes newValue)
00564 {
00565 fType = newValue;
00566 }
00567
00568 inline void XMLAttr::setSpecified(const bool newValue)
00569 {
00570 fSpecified = newValue;
00571 }
00572
00573 inline void XMLAttr::setDatatypeValidator(DatatypeValidator *datatypeValidator)
00574 {
00575 fDatatypeValidator = datatypeValidator;
00576 }
00577
00578 inline void XMLAttr::setSchemaValidated(const bool isSchema)
00579 {
00580 fIsSchemaValidated = isSchema;
00581 }
00582
00583 XERCES_CPP_NAMESPACE_END
00584
00585 #endif