Interface XMQNode
- All Known Subinterfaces:
XMQAttr, XMQDoc, XMQDtd, XMQElement, XMQEntityDecl
public interface XMQNode
Base of all nodes in the xmq DOM: documents, elements, attributes, text,
comments, dtds and so on. The DOM is modelled after libxml2, the nodes are
linked with parent/children/next/prev pointers, entity references are kept
as nodes, and adding a text node next to another text node merges them.
Like XMQNode in xmq.h.
-
Method Summary
Modifier and TypeMethodDescriptionAdd a child like xmqAddChild.Insert a sibling after this node, like xmqAddNextSibling (but without text merging).Insert a sibling before this node, like xmqAddPrevSibling (but without text merging).Append a child without merging adjacent text nodes.children()Returns a new list with the children of this node.content()Returns the text content of text like nodes (text, cdata, comment, pi).doc()Returns the document owning this node.Returns the first child.fullName()Returns the full name, ie prefix:name if the node has a namespace with a prefix.Returns the last child.intline()Returns the source line of the node, like xmqGetLineNumber: elements get the line where their start tag ends, text the line where its first chunk was read, comments, processing instructions and cdata sections the line where they end.name()Returns the name of the node.next()Returns the next sibling.intReturns the number of children.parent()Returns the parent node.prev()Returns the previous sibling.voidReplace this node with another node, like xmqReplaceNode.voidsetContent(String content) Set the content of a text like node.voidsetLine(int line) Set the source line of the node.voidSet the name of the node.Returns the string value of the node, like xmqGetString.type()Returns the type of this node.voidunlink()Remove this node from its parent and siblings, like xmqUnlinkNode.
-
Method Details
-
type
-
name
String name()Returns the name of the node. For an element or attribute this is the local name (without namespace prefix). For a pi it is the target, for an entity reference or declaration it is the entity name.- Returns:
- The name or null.
-
setName
-
line
int line()Returns the source line of the node, like xmqGetLineNumber: elements get the line where their start tag ends, text the line where its first chunk was read, comments, processing instructions and cdata sections the line where they end.- Returns:
- The line, 0 if unknown.
-
setLine
void setLine(int line) Set the source line of the node.- Parameters:
line- The line.
-
parent
-
next
-
prev
-
doc
-
firstChild
-
lastChild
-
children
-
numChildren
int numChildren()Returns the number of children.- Returns:
- The number of children.
-
content
String content()Returns the text content of text like nodes (text, cdata, comment, pi). Returns null for other nodes, use textContent() for the concatenated text of an element.- Returns:
- The content or null.
-
setContent
Set the content of a text like node. For an element, all children are replaced with a single text node, like xmqSetNodeContent.- Parameters:
content- The new content.
-
textContent
String textContent()Returns the string value of the node, like xmqGetString. For an element this is the concatenation of all descendant text, where entity references contribute nothing (entities are never expanded implicitly) and character references kept as nodes their character.- Returns:
- The text content, never null.
-
appendRaw
-
addChild
Add a child like xmqAddChild. If the child is a text node and the current last child is also a text node, then the text is merged into the existing last child, and the existing node is returned.- Parameters:
child- The child to add.- Returns:
- The node holding the child content.
-
addPrevSibling
-
addNextSibling
-
unlink
void unlink()Remove this node from its parent and siblings, like xmqUnlinkNode. -
replaceWith
Replace this node with another node, like xmqReplaceNode.- Parameters:
n- The replacement.
-
fullName
String fullName()Returns the full name, ie prefix:name if the node has a namespace with a prefix.- Returns:
- The full name.
-