Xerces-C++: XMLAttr Class Reference

Xerces-C++ 3.3.0

List of all members
XMLAttr Class Reference

This class defines the information about an attribute that will come out of the scanner during parsing. More...

`#include <xercesc/framework/XMLAttr.hpp>`

Inheritance diagram for XMLAttr:

## Public Member Functions
Constructors
| XMLAttr (MemoryManager *const manager=XMLPlatformUtils::fgMemoryManager)
| The default constructor just setsup an empty attribute to be filled in the later.
| XMLAttr (const unsigned int uriId, const XMLCh *const attrName, const XMLCh *const attrPrefix, const XMLCh *const attrValue, const XMLAttDef::AttTypes type=XMLAttDef::CData, const bool specified=true, MemoryManager *const manager=XMLPlatformUtils::fgMemoryManager, DatatypeValidator *datatypeValidator=0, const bool isSchema=false)
| This is the primary constructor which takes all of the information required to construct a complete attribute object.
| XMLAttr (const unsigned int uriId, const XMLCh *const rawName, const XMLCh *const attrValue, const XMLAttDef::AttTypes type=XMLAttDef::CData, const bool specified=true, MemoryManager *const manager=XMLPlatformUtils::fgMemoryManager, DatatypeValidator *datatypeValidator=0, const bool isSchema=false)
| This is the primary constructor which takes all of the information required to construct a complete attribute object.
Destructor
| ~XMLAttr ()
Getter methods
QName * | getAttName () const
| This method returns the attribute name in a QName format.
const XMLCh * | getName () const
| This method gets a const pointer to the name of the attribute.
const XMLCh * | getPrefix () const
| This method will get a const pointer to the prefix string of this attribute.
const XMLCh * | getQName () const
| This method will get the QName of this attribute, which will be the prefix if any, then a colon, then the base name.
bool | getSpecified () const
| This method will get the specified flag, which indicates whether the attribute was explicitly specified or just faulted in.
XMLAttDef::AttTypes | getType () const
| This method will get the type of the attribute.
const XMLCh * | getValue () const
| This method will get the value of the attribute.
unsigned int | getURIId () const
| This method will get the id of the URI that this attribute's prefix mapped to.
Public Member Functions inherited from XMemory
void * | operator new (size_t size)
| This method overrides operator new.
void * | operator new (size_t size, MemoryManager *memMgr)
| This method defines a custom operator new, that will use the provided memory manager to perform the allocation.
void * | operator new (size_t size, void *ptr)
| This method overrides placement operator new.
void | operator delete (void *p)
| This method overrides operator delete.
void | operator delete (void *p, MemoryManager *memMgr)
| This method provides a matching delete for the custom operator new.
void | operator delete (void *p, void *ptr)
| This method provides a matching delete for the placement new.

## Setter methods
void | set (const unsigned int uriId, const XMLCh *const attrName, const XMLCh *const attrPrefix, const XMLCh *const attrValue, const XMLAttDef::AttTypes type=XMLAttDef::CData, DatatypeValidator *datatypeValidator=0, const bool isSchema=false)
| This method is called to set up a default constructed object after the fact, or to reuse a previously used object.
void | set (const unsigned int uriId, const XMLCh *const attrRawName, const XMLCh *const attrValue, const XMLAttDef::AttTypes type=XMLAttDef::CData, DatatypeValidator *datatypeValidator=0, const bool isSchema=false)
| This method is called to set up a default constructed object after the fact, or to reuse a previously used object.
void | setName (const unsigned int uriId, const XMLCh *const attrName, const XMLCh *const attrPrefix)
| This method will update just the name related fields of the attribute object.
void | setSpecified (const bool newValue)
| This method will update the specified state of the object.
void | setType (const XMLAttDef::AttTypes newType)
| This method will update the attribute type of the object.
void | setValue (const XMLCh *const newValue)
| This method will update the value field of the attribute.
void | setURIId (const unsigned int uriId)
| This method will set the URI id field of this attribute.

## Additional Inherited Members
Protected Member Functions inherited from XMemory
| XMemory ()
| Protected default constructor.

## Detailed Description

This class defines the information about an attribute that will come out of the scanner during parsing.

This information does not depend upon the type of validator because it is not tied to any scheme/DTD type info. Its just the raw XML 1.0 information that will be reported about an attribute in the startElement() callback method of the XMLDocumentHandler class. Hence it is not intended to be extended or derived from. Its designed to be used as is.

The 'specified' field of this class indicates whether the attribute was actually present or whether it was faulted in because it had a fixed or default value.

The code receiving this information can ask its validator for more info about the attribute, i.e. get its declaration from the DTD/Schema info.

Because of the heavy use (and reuse) of instances of this class, and the number of string members it has, this class takes pains to not reallocate string members unless it has to. It keeps up with how long each buffer is and only reallocates if the new value won't fit.

## Constructor & Destructor Documentation

## ◆ XMLAttr() [1/3]

XMLAttr::XMLAttr | ( | MemoryManager *const | manager = XMLPlatformUtils::fgMemoryManager | ) |

The default constructor just setsup an empty attribute to be filled in the later.

Though the initial state is a reasonable one, it is not documented because it should not be depended on.

Parameters

  manager | The configurable memory manager

## ◆ XMLAttr() [2/3]

XMLAttr::XMLAttr | ( | const unsigned int | uriId,
|  | const XMLCh *const | attrName,
|  | const XMLCh *const | attrPrefix,
|  | const XMLCh *const | attrValue,
|  | const XMLAttDef::AttTypes | type = XMLAttDef::CData,
|  | const bool | specified = true,
|  | MemoryManager *const | manager = XMLPlatformUtils::fgMemoryManager,
|  | DatatypeValidator * | datatypeValidator = 0,
|  | const bool | isSchema = false )

This is the primary constructor which takes all of the information required to construct a complete attribute object.

Parameters

  uriId | The id into the validator's URI pool of the URI that the prefix mapped to. Only used if namespaces are enabled/supported.
  attrName | The base name of the attribute, i.e. the part after any prefix.
  attrPrefix | The prefix, if any, of this attribute's name. If this is empty, then uriID is meaningless as well.
  attrValue | The value string of the attribute, which should be fully normalized by XML rules!
  type | The type of the attribute. This will indicate the type of normalization done and constrains the value content. Make sure that the value set meets the constraints!
  specified | Indicates whether the attribute was explicitly specified or not. If not, then it was faulted in from a FIXED or DEFAULT value.
  manager | The configurable memory manager
  datatypeValidator | type used to validate the attribute, if it was validated by an XML Schema
  isSchema | true if and only if this attribute was validated by an XML Schema

## ◆ XMLAttr() [3/3]

XMLAttr::XMLAttr | ( | const unsigned int | uriId,
|  | const XMLCh *const | rawName,
|  | const XMLCh *const | attrValue,
|  | const XMLAttDef::AttTypes | type = XMLAttDef::CData,
|  | const bool | specified = true,
|  | MemoryManager *const | manager = XMLPlatformUtils::fgMemoryManager,
|  | DatatypeValidator * | datatypeValidator = 0,
|  | const bool | isSchema = false )

This is the primary constructor which takes all of the information required to construct a complete attribute object.

Parameters

  uriId | The id into the validator's URI pool of the URI that the prefix mapped to. Only used if namespaces are enabled/supported.
  rawName | The raw name of the attribute.
  attrValue | The value string of the attribute, which should be fully normalized by XML rules!
  type | The type of the attribute. This will indicate the type of normalization done and constrains the value content. Make sure that the value set meets the constraints!
  specified | Indicates whether the attribute was explicitly specified or not. If not, then it was faulted in from a FIXED or DEFAULT value.
  manager | The configurable memory manager
  datatypeValidator | type used to validate the attribute, if it was validated by an XML Schema
  isSchema | true if and only if this attribute was validated by an XML Schema

## ◆ ~XMLAttr()

XMLAttr::~XMLAttr | ( |  | ) |

## Member Function Documentation

## ◆ getAttName()

QName * XMLAttr::getAttName | ( |  | ) | const

This method returns the attribute name in a QName format.

## ◆ getName()

const XMLCh * XMLAttr::getName | ( |  | ) | const

This method gets a const pointer to the name of the attribute.

The form of this name is defined by the validator in use.

References QName::getLocalPart().

## ◆ getPrefix()

const XMLCh * XMLAttr::getPrefix | ( |  | ) | const

This method will get a const pointer to the prefix string of this attribute.

Since prefixes are optional, it may be zero.

References QName::getPrefix().

## ◆ getQName()

const XMLCh * XMLAttr::getQName | ( |  | ) | const

This method will get the QName of this attribute, which will be the prefix if any, then a colon, then the base name.

If there was no prefix, its the same as the getName() method.

## ◆ getSpecified()

bool XMLAttr::getSpecified | ( |  | ) | const

This method will get the specified flag, which indicates whether the attribute was explicitly specified or just faulted in.

## ◆ getType()

XMLAttDef::AttTypes XMLAttr::getType | ( |  | ) | const

This method will get the type of the attribute.

The available types are defined by the XML specification.

## ◆ getURIId()

unsigned int XMLAttr::getURIId | ( |  | ) | const

This method will get the id of the URI that this attribute's prefix mapped to.

If namespaces are not on, then its value is meaningless.

References QName::getURI().

## ◆ getValue()

const XMLCh * XMLAttr::getValue | ( |  | ) | const

This method will get the value of the attribute.

The value can be be an empty string, but never null if the object is correctly set up.

## ◆ set() [1/2]

void XMLAttr::set | ( | const unsigned int | uriId,
|  | const XMLCh *const | attrName,
|  | const XMLCh *const | attrPrefix,
|  | const XMLCh *const | attrValue,
|  | const XMLAttDef::AttTypes | type = XMLAttDef::CData,
|  | DatatypeValidator * | datatypeValidator = 0,
|  | const bool | isSchema = false )

This method is called to set up a default constructed object after the fact, or to reuse a previously used object.

Parameters

  uriId | The id into the validator's URI pool of the URI that the prefix mapped to. Only used if namespaces are enabled/supported.
  attrName | The base name of the attribute, i.e. the part after any prefix.
  attrPrefix | The prefix, if any, of this attribute's name. If this is empty, then uriID is meaningless as well.
  attrValue | The value string of the attribute, which should be fully normalized by XML rules according to the attribute type.
  type | The type of the attribute. This will indicate the type of normalization done and constrains the value content. Make sure that the value set meets the constraints!
  datatypeValidator | type used to validate the attribute, if it was validated by an XML Schema
  isSchema | true if and only if this attribute was validated by an XML Schema

References QName::setName(), and setValue().

## ◆ set() [2/2]

void XMLAttr::set | ( | const unsigned int | uriId,
|  | const XMLCh *const | attrRawName,
|  | const XMLCh *const | attrValue,
|  | const XMLAttDef::AttTypes | type = XMLAttDef::CData,
|  | DatatypeValidator * | datatypeValidator = 0,
|  | const bool | isSchema = false )

This method is called to set up a default constructed object after the fact, or to reuse a previously used object.

Parameters

  uriId | The id into the validator's URI pool of the URI that the prefix mapped to. Only used if namespaces are enabled/supported.
  attrRawName | The raw name of the attribute.
  attrValue | The value string of the attribute, which should be fully normalized by XML rules according to the attribute type.
  type | The type of the attribute. This will indicate the type of normalization done and constrains the value content. Make sure that the value set meets the constraints!
  datatypeValidator | type used to validate the attribute, if it was validated by an XML Schema
  isSchema | true if and only if this attribute was validated by an XML Schema

References QName::setName(), and setValue().

## ◆ setName()

void XMLAttr::setName | ( | const unsigned int | uriId,
|  | const XMLCh *const | attrName,
|  | const XMLCh *const | attrPrefix )

This method will update just the name related fields of the attribute object.

The other fields are left as is.

Parameters

  uriId | The id into the validator's URI pool of the URI that the prefix mapped to. Only used if namespaces are enabled/supported.
  attrName | The base name of the attribute, i.e. the part after any prefix.
  attrPrefix | The prefix, if any, of this attribute's name. If this is empty, then uriID is meaningless as well.

## ◆ setSpecified()

void XMLAttr::setSpecified | ( | const bool | newValue | ) |

This method will update the specified state of the object.

Parameters

  newValue | Indicates whether the attribute was explicitly specified or not. If not, then it was faulted in from a FIXED or DEFAULT value.

## ◆ setType()

void XMLAttr::setType | ( | const XMLAttDef::AttTypes | newType | ) |

This method will update the attribute type of the object.

Parameters

  newType | The type of the attribute. This will indicate the type of normalization done and constrains the value content. Make sure that the value set meets the constraints!

## ◆ setURIId()

void XMLAttr::setURIId | ( | const unsigned int | uriId | ) |

This method will set the URI id field of this attribute.

This is generally only ever called internally by the parser itself during the parsing process.

Parameters

  uriId | The uriId of the attribute.

## ◆ setValue()

void XMLAttr::setValue | ( | const XMLCh *const | newValue | ) |

This method will update the value field of the attribute.

Parameters

  newValue | The value string of the attribute, which should be fully normalized by XML rules according to the attribute type.

Referenced by set(), and set().

The documentation for this class was generated from the following file:

- XMLAttr.hpp