Elm
1.0
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
|
#include <elm/xom/Element.h>
Public Member Functions | |
Element (String name) | |
Element (String name, String uri) | |
Element (const Element *element) | |
virtual void | addAttribute (Attribute *attribute) |
virtual void | addNamespaceDeclaration (String prefix, String uri) |
virtual void | appendChild (String text) |
virtual void | appendChild (Node *node) |
virtual Node * | copy (void) |
virtual Attribute * | getAttribute (int index) |
virtual Attribute * | getAttribute (String name) |
virtual Attribute * | getAttribute (String localName, String ns) |
virtual int | getAttributeCount (void) |
virtual Option< String > | getAttributeValue (String name) |
virtual Option< String > | getAttributeValue (String localName, String ns) |
virtual Elements * | getChildElements (void) |
virtual Elements * | getChildElements (String name) |
virtual Elements * | getChildElements (String localName, String ns) |
virtual Element * | getFirstChildElement (String name) |
virtual Element * | getFirstChildElement (String localName, String ns) |
virtual String | getLocalName (void) |
virtual int | getNamespaceDeclarationCount (void) |
virtual String | getNamespacePrefix (void) |
virtual String | getNamespacePrefix (int index) |
virtual String | getNamespaceURI (void) |
virtual String | getNamespaceURI (String prefix) |
virtual String | getQualifiedName (void) |
virtual String | getValue (void) |
virtual void | insertChild (String text, int position) |
virtual void | insertChild (Node *node, int position) |
virtual Attribute * | removeAttribute (Attribute *attribute) |
virtual Nodes * | removeChildren (void) |
virtual void | removeNamespaceDeclaration (String prefix) |
virtual void | setBaseURI (String uri) |
virtual void | setLocalName (String local_name) |
virtual void | setNamespacePrefix (String prefix) |
virtual void | setNamespaceURI (String uri) |
virtual String | toString (void) |
virtual String | toXML (void) |
Public Member Functions inherited from elm::xom::ParentNode | |
virtual int | indexOf (Node *child) |
virtual Node * | removeChild (int position) |
virtual Node * | removeChild (Node *child) |
virtual void | replaceChild (Node *old_child, Node *new_child) |
virtual Node * | getChild (int index) |
virtual int | getChildCount (void) |
Public Member Functions inherited from elm::xom::Node | |
virtual | ~Node (void) |
void * | getNode (void) const |
kind_t | kind (void) const |
void | detach (void) |
bool | equals (const Node *node) const |
virtual String | getBaseURI (void) |
virtual Document * | getDocument (void) |
virtual ParentNode * | getParent (void) |
virtual Nodes * | query (const String &xpath) |
virtual Nodes * | query (const String &xpath, XPathContext *context) |
int | line (void) const |
Protected Member Functions | |
Element (void *node) | |
virtual Element * | shallowCopy (void) |
Protected Member Functions inherited from elm::xom::ParentNode | |
ParentNode (void *node) | |
void | internSetBaseURI (String URI) |
Protected Member Functions inherited from elm::xom::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 elm::xom::Node | |
static void | freeNode (void *node) |
Additional Inherited Members | |
Public Types inherited from elm::xom::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 elm::xom::Node | |
void * | node |
Represents an XML element.
|
protected |
Build an element from the parser representation.
node | Node in the parser representation. |
Referenced by shallowCopy().
elm::xom::Element::Element | ( | String | name | ) |
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 |
elm::xom::Element::Element | ( | const Element * | element | ) |
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 elm::xom::Node::getNode(), and elm::xom::Node::node.
|
virtual |
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 elm::xom::Attribute::getLocalName(), elm::xom::Node::getNode(), elm::xom::Attribute::getValue(), elm::xom::Node::node, and elm::xom::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 elm::xom::Node::node.
|
virtual |
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 elm::xom::Node::node.
|
virtual |
Appends a node to the children of this node.
child | node to append to this node |
Reimplemented from elm::xom::ParentNode.
References elm::xom::ParentNode::appendChild().
|
virtual |
Implements elm::xom::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 elm::xom::Node::node.
Referenced by elm::xom::Serializer::writeAttributes().
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 elm::xom::Node::node.
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 elm::xom::Node::node.
|
virtual |
Returns the number of attributes of this Element, not counting namespace declarations. This is always a non-negative number.
References elm::xom::Node::node.
Referenced by elm::xom::Serializer::writeAttributes().
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 elm::xom::Node::node, elm::none, and elm::some().
Referenced by elm::serial2::XOMUnserializer::flush().
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 elm::xom::Node::node, elm::none, and elm::some().
|
virtual |
Returns a list of all the child elements of this element in document order.
References elm::xom::Node::Elements, elm::xom::Node::make(), and elm::xom::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 elm::xom::Node::Elements, elm::xom::Node::make(), and elm::xom::Node::node.
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 elm::xom::Node::Elements, elm::xom::Node::make(), and elm::xom::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 elm::xom::Node::make(), and elm::xom::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 elm::xom::Node::make(), and elm::xom::Node::node.
|
virtual |
Returns the local name of this element, not including the namespace prefix or colon.
References elm::xom::Node::node.
Referenced by elm::xom::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 elm::xom::Node::node.
Referenced by elm::xom::Serializer::writeStartTag().
|
virtual |
Returns the prefix of this element, or the empty string if this element does not have a prefix.
References elm::xom::Node::node.
Referenced by elm::xom::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 elm::xom::Node::node.
|
virtual |
Returns the namespace URI of this element, or the empty string if this element is not in a namespace.
References elm::xom::Node::node.
Referenced by elm::xom::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 elm::xom::Node::node.
|
virtual |
Returns the complete name of this element, including the namespace prefix if this element has one.
References elm::xom::Node::node.
Referenced by elm::xom::Serializer::writeEndTag(), and elm::xom::Serializer::writeStartTag().
|
virtual |
Get the node as a string with markup removed.
Implements elm::xom::Node.
References elm::xom::Node::internGetValue().
|
virtual |
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 elm::xom::ParentNode::insertChild().
|
virtual |
Insert a node at the given position.
position | Where to insert the child. |
node | Node to insert. |
Reimplemented from elm::xom::ParentNode.
References elm::xom::ParentNode::insertChild().
Build an element with a namespace.
name | Qualified element name. |
uri | URI of the namespace. |
References elm::xom::Node::node.
Removes an attribute from this element.
attribute | The attribute to remove. |
NoSuchAttributeException | If this element is not the parent of attribute. |
|
virtual |
|
virtual |
|
virtual |
Implements elm::xom::ParentNode.
|
virtual |
|
virtual |
|
virtual |
|
protectedvirtual |
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().
|
virtual |
|
virtual |
Implements elm::xom::Node.