ot::sax
class Attributes (abstract)
#include "ot/sax/Attributes.h"
Interface to a list of XML attributes.
This interface allows access to a list of attributes in three different ways:-
by attribute index;
-
by Namespace-qualified name; or
-
by qualified (prefixed) name.
The list will not contain attributes that were declared #IMPLIED but not specified in the start tag. It will also not contain attributes used as Namespace declarations (xmlns*) unless the http://xml.org/sax/features/namespace-prefixes feature is set to true (it is false by default).
The order of attributes in the list is unspecified by the SAX specification, but in the OpenTop implementation attributes occur in document order.
Method Summary
|
virtual int |
getIndex(const String& qName) const=0
Look up the index of an attribute by XML 1.0 qualified name. |
virtual int |
getIndex(const String& uri, const String& localName) const=0
Look up the index of an attribute by Namespace name. |
virtual size_t |
getLength() const=0
Returns the number of attributes in the list. |
virtual String |
getLocalName(size_t index) const=0
Look up an attribute's local name by index. |
virtual String |
getQName(size_t index) const=0
Look up an attribute's XML 1.0 qualified name by index. |
virtual String |
getType(size_t index) const=0
Look up an attribute's type by index. |
virtual String |
getType(const String& qName) const=0
Look up an attribute's type by XML 1.0 qualified name. |
virtual String |
getType(const String& uri, const String& localName) const=0
Look up an attribute's type by Namespace name. |
virtual String |
getURI(size_t index) const=0
Look up an attribute's Namespace URI by index. |
virtual String |
getValue(size_t index) const=0
Look up an attribute's value by index. |
virtual String |
getValue(const String& qName) const=0
Look up an attribute's value by XML 1.0 qualified name. |
virtual String |
getValue(const String& uri, const String& localName) const=0
Look up an attribute's value by Namespace name. |
getIndex
virtual int getIndex(const String& qName) const=0
-
Look up the index of an attribute by XML 1.0 qualified name.
- Parameters:
qName
-
The qualified (prefixed) name.
- Returns:
-
The index of the attribute, or -1 if it does not appear in the list.
getIndex
virtual int getIndex(const String& uri,
const String& localName) const=0
-
Look up the index of an attribute by Namespace name.
- Parameters:
uri
-
The Namespace URI, or the empty String if the name has no Namespace URI.
localName
-
The attribute's local name.
- Returns:
-
The index of the attribute, or -1 if it does not appear in the list.
getLength
virtual size_t getLength() const=0
-
Returns the number of attributes in the list.
Once you know the number of attributes, you can iterate through the list.
- Returns:
-
The number of attributes in the list.
- See also:
-
getURI(size_t) , getLocalName(size_t) , getQName(size_t) , getType(size_t) , getValue(size_t)
getLocalName
virtual String getLocalName(size_t index) const=0
-
Look up an attribute's local name by index.
- Parameters:
index
-
The attribute index (zero-based).
- Returns:
-
The local name, or the empty String if Namespace processing is not being performed or the index is out of range.
- See also:
-
getLength
getQName
virtual String getQName(size_t index) const=0
-
Look up an attribute's XML 1.0 qualified name by index.
- Parameters:
index
-
The attribute index (zero-based).
- Returns:
-
The XML 1.0 qualified name, or the empty String if none is available or the index is out of range.
- See also:
-
getLength
getType
virtual String getType(size_t index) const=0
-
Look up an attribute's type by index.
The attribute type is one of the strings "CDATA", "ID", "IDREF", "IDREFS", "NMTOKEN", "NMTOKENS", "ENTITY", "ENTITIES", or "NOTATION" (always in upper case).
If the parser has not read a declaration for the attribute then it will return the value "CDATA" as stated in the XML 1.0 Recommendation (clause 3.3.3, "Attribute-Value Normalization").
For an enumerated attribute that is not a notation, the parser will report the type as "NMTOKEN".
- Parameters:
index
-
The attribute index (zero-based).
- Returns:
-
The attribute's type as a String or the empty String if the index is out of range.
- See also:
-
getLength
getType
virtual String getType(const String& qName) const=0
-
Look up an attribute's type by XML 1.0 qualified name.
See getType(size_t) for a description of the possible types.
- Parameters:
qName
-
The XML 1.0 qualified name.
- Returns:
-
The attribute type as a String or the empty String if the attribute is not in the list.
getType
virtual String getType(const String& uri,
const String& localName) const=0
-
Look up an attribute's type by Namespace name.
See getType(size_t) for a description of the possible types.
- Parameters:
uri
-
The Namespace URI, or the empty String if the name has no Namespace URI.
localName
-
The local name of the attribute.
- Returns:
-
The attribute type as a String or the empty String if the attribute is not in the list or if Namespace processing is not being performed.
getURI
virtual String getURI(size_t index) const=0
-
Look up an attribute's Namespace URI by index.
- Parameters:
index
-
The attribute index (zero-based).
- Returns:
-
The Namespace URI, or the empty String if none is available or if the index is out of range.
- See also:
-
getLength
getValue
virtual String getValue(size_t index) const=0
-
Look up an attribute's value by index.
If the attribute value is a list of tokens (IDREFS, ENTITIES, or NMTOKENS), the tokens will be concatenated into a single String with each token separated by a single space.
- Parameters:
index
-
The attribute index (zero-based).
- Returns:
-
The attribute's value as a String or the empty String if the index is out of range.
- See also:
-
getLength
getValue
virtual String getValue(const String& qName) const=0
-
Look up an attribute's value by XML 1.0 qualified name.
See getValue(size_t) for a description of the possible values.
- Parameters:
qName
-
The XML 1.0 qualified name.
- Returns:
-
The attribute value as a String or the empty String if the attribute is not in the list.
getValue
virtual String getValue(const String& uri,
const String& localName) const=0
-
Look up an attribute's value by Namespace name.
See getValue(size_t) for a description of the possible values.
- Parameters:
uri
-
The Namespace URI, or the empty String if the name has no Namespace URI.
localName
-
The local name of the attribute.
- Returns:
-
The attribute value as a String or the empty String if the attribute is not in the list.
Found a bug or missing feature? Please email us at support@elcel.com