Elm
2
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
|
#include <elm/xom/Element.h>
Protected Member Functions | |
Element (void *node) | |
virtual Element * | shallowCopy (void) |
Protected Member Functions inherited from ParentNode | |
ParentNode (void *node) | |
void | internSetBaseURI (String URI) |
Protected Member Functions inherited from Node | |
Node (void *_node) | |
void | setNode (void *_node) |
Node * | make (void *node) |
Node * | get (void *node) |
Node * | internCopy (void) |
Node * | internGetChild (int index) |
int | internGetChildCount (void) |
String | internGetValue (void) |
String | internToXML (void) |
Static Protected Member Functions | |
static void * | makeNS (String name, String uri) |
Static Protected Member Functions inherited from Node | |
static void | freeNode (void *node) |
Additional Inherited Members | |
Public Types inherited from Node | |
enum | kind_t { NONE = 0, ELEMENT, DOCUMENT, TEXT, COMMENT, ATTRIBUTE, PROCESSING_INSTRUCTION, DOCTYPE, NAMESPACE } |
typedef enum elm::xom::Node::kind_t | kind_t |
Protected Attributes inherited from Node | |
void * | node |
Represents an XML element.
Build an element from the parser representation.
node | Node in the parser representation. |
References Node::node.
Referenced by Element::shallowCopy().
Creates a new element in no namespace.
name | the name of the element |
IllegalNameException | if name is not a legal XML 1.0 non-colonized name. |
Creates a new element in a namespace.
name | the qualified name of the element |
uri | the namespace URI of the element |
IllegalNameException | if name is not a legal XML 1.0 name |
NamespaceConflictException | if name's prefix cannot be used with uri |
MalformedURIException | if uri is not an RFC 3986 absolute URI reference |
Creates a deep copy of an element. The copy is disconnected from the tree, and does not have a parent.
element | the element to copy |
References Node::getNode(), and Node::node.
Adds an attribute to this element, replacing any existing attribute with the same local name and namespace URI.
attribute | the attribute to add |
MultipleParentException | if the attribute is already attached to an element |
NamespaceConflictException | - if the attribute's prefix is mapped to a different namespace URI than the same prefix is mapped to by this element, another attribute of this element, or an additional namespace declaration of this element. |
References Attribute::getLocalName(), Node::getNode(), Attribute::getValue(), Node::node, and Node::setNode().
Declares a namespace prefix. This is only necessary when prefixes are used in element content and attribute values, as in XSLT and the W3C XML Schema Language. Do not use this method to declare prefixes for element and attribute names.
prefix | the prefix to declare. |
uri | the absolute URI reference to map the prefix to. |
MalformedURIException | if URI is not an RFC 3986 URI reference |
IllegalNameException | if prefix is not a legal XML non-colonized name |
NamespaceConflictException | if the mapping conflicts with an existing element, attribute, or additional namespace declaration |
References Node::node.
Appends a node to the children of this node.
child | node to append to this node |
Reimplemented from ParentNode.
References ParentNode::appendChild(), and Node::node.
Converts a string to a text node and appends that node to the children of this node.
text | String to add to this node. |
IllegalAddException | if this node cannot have children of this type. |
References Node::node.
|
virtual |
Selects an attribute by index. The index is purely for convenience and has no particular meaning. In particular, it is not necessarily the position of this attribute in the original document from which this Element object was read. As with most lists in Java, attributes are numbered from 0 to one less than the length of the list.
index | the attribute to return. |
References Node::get(), and Node::node.
Referenced by Serializer::writeAttributes().
Returns the attribute with the specified name and namespace URI, or null if this element does not have an attribute with that name in that namespace.
localName | the local name of the attribute. |
namespaceURI | the namespace of the attribute. |
References Node::get(), and Node::node.
Returns the attribute with the specified name in no namespace, or null if this element does not have an attribute with that name in no namespace.
name | the name of the attribute . |
References Node::get(), and Node::node.
|
virtual |
Returns the number of attributes of this Element, not counting namespace declarations. This is always a non-negative number.
References Node::node.
Referenced by Serializer::writeAttributes().
Returns the value of the attribute with the specified name and namespace URI, or null if this element does not have such an attribute.
localName | the name of the attribute. |
namespaceURI | the namespace of the attribute. |
References Node::node, elm::none, and elm::some().
Returns the value of the attribute with the specified name in no namespace, or none if this element does not have an attribute with that name.
name | the name of the attribute. |
References Node::node, elm::none, and elm::some().
Referenced by XOMUnserializer::flush().
Returns a list of the immediate child elements of this element with the specified local name and namespace URI. Passing the empty string or null as the local name returns all elements in the specified namespace. Passing null or the empty string as the namespace URI returns elements with the specified name in no namespace. The elements returned are in document order.
localName | The name of the elements included in the list. |
namespaceURI | The namespace URI of the elements included in the list. |
References Node::Elements, Node::make(), and Node::node.
Returns a list of the child elements of this element with the specified name in no namespace. The elements returned are in document order.
name | The name of the elements included in the list . |
References Node::Elements, Node::make(), and Node::node.
Returns a list of all the child elements of this element in document order.
References Node::Elements, Node::make(), and Node::node.
Returns the first child element with the specified local name and namespace URI. If there is no such element, it returns null.
localName | The local name of the element to return. |
namespaceURI | The namespace URI of the element to return. |
References Node::make(), and Node::node.
Returns the first child element with the specified name in no namespace. If there is no such element, it returns null.
name | The name of the element to return. |
References Node::make(), and Node::node.
Returns the local name of this element, not including the namespace prefix or colon.
References Node::node.
Referenced by Element::parse(), and Serializer::writeEmptyElementTag().
|
virtual |
Returns the number of namespace declarations on this element. This counts the namespace of the element itself (which may be the empty string), the namespace of each attribute, and each namespace added by addNamespaceDeclaration. However, prefixes used multiple times are only counted once; and the xml prefix used for xml:base, xml:lang, and xml:space is not counted even if one of these attributes is present on the element.
References Node::node.
Referenced by Serializer::writeStartTag().
|
virtual |
Returns the indexth namespace prefix declared on this element. Namespaces inherited from ancestors are not included. The index is purely for convenience, and has no meaning in itself. This includes the namespaces of the element name and of all attributes' names (except for those with the prefix xml such as xml:space) as well as additional declarations made for attribute values and element content. However, prefixes used multiple times (e.g. on several attribute values) are only reported once. The default namespace is reported with an empty string prefix if present. Like most lists in Java, the first prefix is at index 0.
index | The prefix to return. |
References Node::node.
Returns the prefix of this element, or the empty string if this element does not have a prefix.
References Node::node.
Referenced by Serializer::writeStartTag().
Returns the namespace URI mapped to the specified prefix within this element. Returns null if this prefix is not associated with a URI.
prefix | The namespace prefix whose URI is desired. |
References Node::node.
Returns the namespace URI of this element, or the empty string if this element is not in a namespace.
References Node::node.
Referenced by Serializer::writeStartTag().
Returns the complete name of this element, including the namespace prefix if this element has one.
References Node::node.
Referenced by Serializer::writeEndTag(), and Serializer::writeStartTag().
Get the node as a string with markup removed.
Implements Node.
References Node::internGetValue().
Insert a node at the given position.
position | Where to insert the child. |
node | Node to insert. |
Reimplemented from ParentNode.
References ParentNode::insertChild(), and Node::node.
Converts a string to a text node and inserts that node at the specified position.
position | Where to insert the child. |
text | The string to convert to a text node and insert. |
References ParentNode::insertChild().
Build an element with a namespace.
name | Qualified element name. |
uri | URI of the namespace. |
References CString::chars(), and Node::node.
Removes an attribute from this element.
attribute | The attribute to remove. |
NoSuchAttributeException | If this element is not the parent of attribute. |
Implements ParentNode.
Creates a very shallow copy of the element with the same name and namespace URI, but no children, attributes, base URI, or namespace declaration. This method is invoked as necessary by the copy method and the copy constructor.
References Element::Element().