Class XmlDocument
java.lang.Object
org.libxmq.imp.xml.XmlNode
org.libxmq.imp.xml.XmlDocument
A document. The children are the top level nodes: the dtd (if any),
comments, processing instructions and the root element. Unlike many
java DOMs, a document can also have text and multiple elements at the
top level, which xmq needs to represent xmq content with multiple roots.
-
Constructor Summary
ConstructorsConstructorDescriptionCreate an empty xml document.XmlDocument(boolean html) Create an empty xml or html document. -
Method Summary
Modifier and TypeMethodDescriptionencoding()Returns the declared encoding.fullName()Returns the full name, ie prefix:name if the node has a namespace with a prefix.Find a general entity declared in the internal subset.Returns the internal subset dtd.booleanisHtml()Returns true if this is an html document.Returns the root element, ie the first top level element.voidSet the declared encoding.voidsetHtml(boolean html) Mark the document as html or xml.voidsetIntSubset(XMQDtd dtd) Set the dtd, like libxml2 xmlCreateIntSubset.voidsetIntSubsetRef(XmlDtd dtd) Remember the dtd without adding it as a child, used when the caller places the dtd node itself.voidSet the root element, replacing any existing root element, like libxml2 xmlDocSetRootElement.voidsetStandalone(int s) Set the standalone declaration.voidSet the source url/name of the document.voidsetVersion(String v) Set the xml version.intReturns the standalone declaration, -1 if not declared, 0 for no, 1 for yes.type()Returns the type of this node.url()Returns the source url/name of the document.version()Returns the xml version.Methods inherited from class XmlNode
addChild, addNextSibling, addPrevSibling, appendRaw, children, content, doc, firstChild, hasChildren, lastChild, line, name, next, numChildren, parent, prev, replaceWith, setContent, setLine, setName, textContent, toString, unlinkModifier and TypeMethodDescriptionAdd a child like libxml2 xmlAddChild.Insert a sibling after this node, like libxml2 xmlAddNextSibling (but without text merging).Insert a sibling before this node, like libxml2 xmlAddPrevSibling (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.booleanReturns true if this node has children.Returns the last child.intline()Returns the source line of the node, like libxml2 xmlGetLineNo: 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.intCount the children.parent()Returns the parent node.prev()Returns the previous sibling.voidReplace this node with another node, like libxml2 xmlReplaceNode.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 libxml2 xmlNodeGetContent.toString()voidunlink()Remove this node from its parent and siblings, like libxml2 xmlUnlinkNode.
-
Constructor Details
-
XmlDocument
public XmlDocument()Create an empty xml document. -
XmlDocument
public XmlDocument(boolean html) Create an empty xml or html document.- Parameters:
html- True for an html document.
-
-
Method Details
-
type
-
isHtml
public boolean isHtml()Returns true if this is an html document.- Returns:
- True if html.
-
setHtml
public void setHtml(boolean html) Mark the document as html or xml.- Parameters:
html- True for html.
-
rootElement
Returns the root element, ie the first top level element.- Specified by:
rootElementin interfaceXMQDoc- Returns:
- The root element or null.
-
setRootElement
Set the root element, replacing any existing root element, like libxml2 xmlDocSetRootElement.- Specified by:
setRootElementin interfaceXMQDoc- Parameters:
e- The new root.
-
intSubset
-
setIntSubset
Set the dtd, like libxml2 xmlCreateIntSubset. Unless the dtd is already a child, it is added as the first child of an html document, and before the first element of an xml document (or last if there is no element).- Specified by:
setIntSubsetin interfaceXMQDoc- Parameters:
dtd- The dtd.
-
setIntSubsetRef
Remember the dtd without adding it as a child, used when the caller places the dtd node itself.- Parameters:
dtd- The dtd.
-
getEntity
Find a general entity declared in the internal subset. -
version
-
setVersion
-
encoding
-
setEncoding
-
standalone
public int standalone()Returns the standalone declaration, -1 if not declared, 0 for no, 1 for yes.- Returns:
- The standalone value.
-
setStandalone
public void setStandalone(int s) Set the standalone declaration.- Parameters:
s- -1 if not declared, 0 for no, 1 for yes.
-
url
-
setUrl
-
fullName
-