public interface XmlNode extends SortedTree<XmlNode>
SortedTree.listChildren()
:
isTextNode()
to differ it.
getAttributes()
.
Modifier and Type | Field and Description |
---|---|
static int |
version
Version, history and license.
|
Modifier and Type | Method and Description |
---|---|
XmlNode |
addContent(java.lang.String text)
Adds textual content.
|
XmlNode |
addContent(XmlNode node)
Adds a child node.
|
void |
addNamespaceDeclaration(java.lang.String name,
java.lang.String value)
Adds namespace declaration on the specified node.
|
XmlNode |
addNewNode(java.lang.String name)
adds and returns a new child node.
|
XmlNode |
addNewNode(java.lang.String name,
java.lang.String namespaceKey)
adds and returns a new child node.
|
XmlNode |
createNode(java.lang.String name,
java.lang.String namespaceKey)
creates a XmlNode from the same implementation type as this, but without adding to the XML-tree.
|
java.lang.String |
getAttribute(java.lang.String name)
returns the requested attribute or null if it is not existing.
|
java.util.List<java.lang.String[]> |
getAttributeList()
Returns a list of attributes in its given order.
|
java.util.Map<java.lang.String,java.lang.String> |
getAttributes()
returns all attributes Sorted by "namespace:name" or "name".
|
java.lang.String |
getName()
Returns the tagname of the node.
|
java.lang.String |
getNamespaceKey()
returns the alias or key of the namespace.
|
java.util.Map<java.lang.String,java.lang.String> |
getNamespaces()
Gets all namespace declaration at this node.
|
boolean |
isTextNode()
returns true if the node is a text, not a XML element.
|
java.lang.String |
removeAttribute(java.lang.String name)
removes the requested attribute.
|
void |
removeChildren()
removes all children, also textual content, but not attributes.
|
XmlNode |
setAttribute(java.lang.String name,
java.lang.String value)
Sets an attribute by name.
|
void |
setAttribute(java.lang.String name,
java.lang.String namespaceKey,
java.lang.String value)
Sets an attribute by name.
|
java.lang.String |
text()
Returns the text of the node.
|
getChild, getParent, iterChildren, iterChildren, listChildren, listChildren
static final int version
setAttribute(String, String, String)
with namespace
text()
instead getText(). It is compatible with XPATH-expressions.
XmlNodeSimple
is removed as dependency, so this class is the same like in the past.
XmlNodeSimple
is derived from
TreeNodeBase
yet. Because both inherit from SortedTree
,
the generic type have to be the same. Up to now it is not possible to use
a indirect related type, the XmlNodeSimple
is used here. It is not able yet
to mix different implementations of XmlNode in one tree (is it necessary?)
XmlNode createNode(java.lang.String name, java.lang.String namespaceKey) throws XmlException
addContent(XmlNode)
, because it may be necessary to built
a sub tree with the new node first, and than add, if there are multi threads.name
- namespaceKey
- The this-node should know the key, otherwise an XmlException is thrown.XmlException
XmlNode setAttribute(java.lang.String name, java.lang.String value)
name
- value
- void setAttribute(java.lang.String name, java.lang.String namespaceKey, java.lang.String value) throws XmlException
name
- value
- XmlException
void addNamespaceDeclaration(java.lang.String name, java.lang.String value)
name
- namespace alias (key)value
- namespace uri.java.util.Map<java.lang.String,java.lang.String> getNamespaces()
XmlNode addContent(java.lang.String text)
XmlNode addContent(XmlNode node) throws XmlException
getName()
starts with "@", it is added as an attribute to this with the text()
as attribute value. This opens the possibility to create a XmlNode independent of a parent and independent of checking
whether it should be an attribute, and convert it to an attribute later.node
- to addXmlException
XmlNode addNewNode(java.lang.String name, java.lang.String namespaceKey) throws XmlException
name
- namespaceKey
- XmlException
XmlNode addNewNode(java.lang.String name) throws XmlException
name
- namespaceKey
- XmlException
void removeChildren()
boolean isTextNode()
java.lang.String text()
java.lang.String getName()
isTextNode()
.
java.lang.String getNamespaceKey()
java.lang.String getAttribute(java.lang.String name)
java.util.Map<java.lang.String,java.lang.String> getAttributes()
java.util.List<java.lang.String[]> getAttributeList()
java.lang.String removeAttribute(java.lang.String name)