Class XmlDomApi
java.lang.Object
org.libxmq.imp.xml.XmlDomApi
The C dom api (src/main/c/parts/xml_dom.h) on the java dom, with the same semantics, so
that C code using it can be ported line by line (eg the xslt engine). The C name
xml_node_first_child is nodeFirstChild here, XmlDom is XmlDocument, XMQNode is XmlNode,
XMQAttr is XmlAttr (attributes are nodes) and XmlNs is XmlNs.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intAn attribute.static final intAn attribute declaration in a DTD.static final intA CDATA section.static final intA comment.static final intThe document.static final intA document type declaration.static final intAn element.static final intAn element declaration in a DTD.static final intAn entity declaration in a DTD.static final intAn entity reference.static final intA namespace declaration.static final intA notation declaration in a DTD.static final intUse a namespace declared on an ancestor, declare it on the top element if not found.static final intDeclare the namespace on the element itself.static final intThe namespace actions of the C XMQNSAction: no namespace.static final intUse the namespace of the parent.static final intA parameter entity reference in a DTD.static final intA processing instruction.static final intA text node.static final StringThe xml namespace uri. -
Method Summary
Modifier and TypeMethodDescriptionstatic StringThe name of an attribute.static XmlAttrThe next attribute.static XmlNodeThe attribute as a node, the same object in java.static XmlNodeThe element of an attribute.static XmlNodedomDocument(XmlDocument dom) The document node of a dom, the same object in java.static XmlNodedomDtd(XmlDocument dom) The internal subset.static StringdomEncoding(XmlDocument dom) The encoding of the xml declaration.static XmlNodedomGetEntity(XmlDocument dom, String name) A general entity declared in the internal subset.static XmlDocumentdomNew()A new empty document (xml_dom_new).static XmlNodeThe root element.static XmlNodedomSetDtd(XmlDocument dom, String name, String public_id, String system_id) Replace the dtd with a new one without declarations, before the root element (xml_dom_set_dtd).static voiddomSetEncoding(XmlDocument dom, String e) Set the encoding.static voiddomSetRootElement(XmlDocument dom, XmlNode root) Replace the root element (or add it).static voiddomSetStandalone(XmlDocument dom, int s) Set the standalone flag.static voiddomSetUrl(XmlDocument dom, String url) Set the url.static voiddomSetVersion(XmlDocument dom, String v) Set the version.static intdomStandalone(XmlDocument dom) The standalone flag: -1 not given, 0 no, 1 yes.static StringdomUrl(XmlDocument dom) Where the document was loaded from (libxml2 doc->URL).static StringdomVersion(XmlDocument dom) The version of the xml declaration.static StringdtdPublicId(XmlNode dtd) The public id of a dtd.static StringdtdSystemId(XmlNode dtd) The system id of a dtd.static StringentityDeclSystemId(XmlNode decl) The system id of an entity declaration.static XmlNodenodeAddChild(XmlNode parent, XmlNode child) Append a child, text is merged into a last text child (xml_node_add_child), then the child is dropped and the last child returned.static XmlNodenodeAddNextSibling(XmlNode node, XmlNode n) Insert n after node.static XmlNodenodeAddPrevSibling(XmlNode node, XmlNode n) Insert n before node.static XmlAttrnodeAppendAttr(XmlNode e, String name, XmlNs ns, String value) Append an attribute (without checking for an existing one).static XmlNodenodeAppendChild(XmlNode parent, XmlNode child) Append a child without merging text (xml_node_append_child), the child is unlinked first.static voidnodeAppendContent(XmlNode n, String content) Append to the content of a text like node.static booleannodeApplyXmqns(XmlNode element, int action, String puri) Set the namespace of an element added to the dom, as the C xmqAddElement does with an XMQNS (xml_node_apply_xmqns).static XmlAttrThe node as an attribute.The attributes of an element (the live list, copy it to change attributes while iterating).static intnodeCompareOrder(XmlNode a, XmlNode b) Compare two nodes in document order (xml_node_compare_order): -1, 0 or 1.static StringThe content of text, cdata, comments, pis (the data) and namespace nodes (the uri), null for other nodes.static XmlNodenodeCopy(XmlDocument dom, XmlNode node, boolean deep) Copy a node (not a document) into dom, deep with the children, the namespaces used are the copies of the declarations copied with it or the original ones (xml_node_copy).static XmlDocumentThe dom of a node.static XmlAttrThe first attribute.static XmlNodeThe first child.static voidUnlink a node (the garbage collector frees it).static XmlAttrnodeGetAttr(XmlNode e, String name, String ns_uri) The attribute with this name and namespace uri (null or "" for none).static intThe kind of a node, the C XmlNodeKind values.static XmlNodeThe last child.static intThe source line.static XmlAttrnodeMoveAttr(XmlNode e, XmlAttr a) Move an attribute to element, an attribute with the same name and namespace is replaced (xml_node_move_attr).static StringThe name: local name of elements and attributes, the target of a pi, the entity name of a reference, the prefix of a namespace node, null for text ("textnoenc" for text written without escaping), comments and documents.static XmlNodenodeNewCdata(XmlDocument dom, String text) A new cdata section.static XmlNodenodeNewComment(XmlDocument dom, String text) A new comment.static XmlNodenodeNewElement(XmlDocument dom, String name, XmlNs ns) A new element (xml_node_new_element).static XmlNodenodeNewEntityRef(XmlDocument dom, String name) A new entity reference.static XmlNodenodeNewNamespaceNode(XmlNode element, String prefix, String href, int index) An xpath namespace node of element, not linked into the element.static XmlNodenodeNewPi(XmlDocument dom, String target, String data) A new processing instruction.static XmlNodenodeNewText(XmlDocument dom, String text) A new text node.static XmlNodeThe next sibling (for an attribute the next attribute).static XmlNsThe namespace of an element or attribute.The namespace declarations of an element (the live list, copy it to change it while iterating).static StringThe prefix of the namespace of the node.static StringThe namespace uri of the node, null if none (or "").static intThe number of children.static XmlNodeThe parent (the owner element of an attribute or namespace node).static XmlNodeThe previous sibling (for an attribute the previous attribute).static voidnodeReconcileNs(XmlNode node) Make every namespace used in the subtree of node declared in scope (xml_node_reconcile_ns).static booleannodeRemoveAttr(XmlNode e, String name, String ns_uri) Remove the attribute with this name and namespace uri.static XmlNodenodeReplace(XmlNode node, XmlNode n) Replace node with n.static XmlAttrnodeSetAttr(XmlNode e, String name, XmlNs ns, String value) Set an attribute, replacing the value (and namespace) of an existing one.static voidnodeSetContent(XmlNode n, String content) Set the content, for elements and attributes the children are replaced with one text node (none for "").static voidnodeSetLine(XmlNode n, int line) Set the source line.static voidnodeSetName(XmlNode n, String name) Set the name.static voidSet the namespace of an element or attribute.static voidnodeSetUserData(XmlNode n, Object data) Set the user data.static StringThe string value: text content of elements, attributes and documents, the character of a character reference (other entity references contribute nothing).static voidUnlink a node from its parent (an attribute from its element).static ObjectThe user data.static XmlNsDeclare a namespace on element, null if the prefix is already declared there (xml_ns_declare).static StringThe uri of a namespace, "" for an undeclaration, null for a prefix declared without uri.static XmlNsnsLookupHref(XmlNode node, String href) Find a declaration of href in scope of node whose prefix is not shadowed (xmlSearchNsByHref).static XmlNsnsLookupPrefix(XmlNode node, String prefix) Find the declaration of prefix in scope of node (xmlSearchNs), the xml prefix is always declared.static voidnsMoveDeclLast(XmlNode e, XmlNs ns) Move the declaration ns last among the declarations of element.static voidnsMoveDeclTo(XmlNode from, XmlNs ns, XmlNode to) Move the declaration ns from element from to the front of the declarations of to.static StringThe prefix of a namespace.static voidnsRemoveDecl(XmlNode e, XmlNs ns, XmlNs replacement) Remove the declaration ns from element, the nodes of the subtree using it use replacement instead (xml_ns_remove_decl).static voidSet the uri.static String[]nsSplitPuri(String puri) Split a namespace written as {prefix}uri into the prefix and the uri (xml_ns_split_puri).
-
Field Details
-
ELEMENT
public static final int ELEMENTAn element.- See Also:
-
ATTRIBUTE
public static final int ATTRIBUTEAn attribute.- See Also:
-
TEXT
public static final int TEXTA text node.- See Also:
-
CDATA
public static final int CDATAA CDATA section.- See Also:
-
ENTITY_REF
public static final int ENTITY_REFAn entity reference.- See Also:
-
PI
public static final int PIA processing instruction.- See Also:
-
COMMENT
public static final int COMMENTA comment.- See Also:
-
DOCUMENT
public static final int DOCUMENTThe document.- See Also:
-
DTD
public static final int DTDA document type declaration.- See Also:
-
ELEMENT_DECL
public static final int ELEMENT_DECLAn element declaration in a DTD.- See Also:
-
ATTRIBUTE_DECL
public static final int ATTRIBUTE_DECLAn attribute declaration in a DTD.- See Also:
-
ENTITY_DECL
public static final int ENTITY_DECLAn entity declaration in a DTD.- See Also:
-
NAMESPACE
public static final int NAMESPACEA namespace declaration.- See Also:
-
NOTATION_DECL
public static final int NOTATION_DECLA notation declaration in a DTD.- See Also:
-
PE_REF
public static final int PE_REFA parameter entity reference in a DTD.- See Also:
-
XML_NAMESPACE
-
NS_NONE
public static final int NS_NONEThe namespace actions of the C XMQNSAction: no namespace.- See Also:
-
NS_PARENT
public static final int NS_PARENTUse the namespace of the parent.- See Also:
-
NS_HERE
public static final int NS_HEREDeclare the namespace on the element itself.- See Also:
-
NS_ANCESTOR
public static final int NS_ANCESTORUse a namespace declared on an ancestor, declare it on the top element if not found.- See Also:
-
-
Method Details
-
domNew
-
domDocument
The document node of a dom, the same object in java.- Parameters:
dom- The dom.- Returns:
- The document node.
-
domRootElement
The root element.- Parameters:
dom- The dom.- Returns:
- The root element or null.
-
domSetRootElement
Replace the root element (or add it).- Parameters:
dom- The dom.root- The new root element.
-
domVersion
The version of the xml declaration.- Parameters:
dom- The dom.- Returns:
- The version or null.
-
domSetVersion
Set the version.- Parameters:
dom- The dom.v- The version.
-
domEncoding
The encoding of the xml declaration.- Parameters:
dom- The dom.- Returns:
- The encoding or null.
-
domSetEncoding
Set the encoding.- Parameters:
dom- The dom.e- The encoding.
-
domUrl
Where the document was loaded from (libxml2 doc->URL).- Parameters:
dom- The dom.- Returns:
- The url or null.
-
domSetUrl
Set the url.- Parameters:
dom- The dom.url- The url.
-
domStandalone
The standalone flag: -1 not given, 0 no, 1 yes.- Parameters:
dom- The dom.- Returns:
- The flag.
-
domSetStandalone
Set the standalone flag.- Parameters:
dom- The dom.s- The flag.
-
domDtd
The internal subset.- Parameters:
dom- The dom.- Returns:
- The dtd or null.
-
domSetDtd
Replace the dtd with a new one without declarations, before the root element (xml_dom_set_dtd).- Parameters:
dom- The dom.name- The name.public_id- The public id or null.system_id- The system id or null.- Returns:
- The dtd.
-
dtdPublicId
-
dtdSystemId
-
domGetEntity
A general entity declared in the internal subset.- Parameters:
dom- The dom.name- The name.- Returns:
- The declaration or null.
-
entityDeclSystemId
-
nodeNewElement
A new element (xml_node_new_element).- Parameters:
dom- The dom.name- The local name.ns- The namespace or null.- Returns:
- The element.
-
nodeNewText
A new text node.- Parameters:
dom- The dom.text- The text, null is "".- Returns:
- The node.
-
nodeNewCdata
A new cdata section.- Parameters:
dom- The dom.text- The content.- Returns:
- The node.
-
nodeNewComment
A new comment.- Parameters:
dom- The dom.text- The content.- Returns:
- The node.
-
nodeNewPi
A new processing instruction.- Parameters:
dom- The dom.target- The target.data- The data or null.- Returns:
- The node.
-
nodeNewEntityRef
A new entity reference.- Parameters:
dom- The dom.name- The entity name.- Returns:
- The node.
-
nodeNewNamespaceNode
An xpath namespace node of element, not linked into the element.- Parameters:
element- The element.prefix- The prefix or null.href- The uri.index- The position on the namespace axis (stored as its line in C).- Returns:
- The node.
-
nodeFree
Unlink a node (the garbage collector frees it).- Parameters:
n- The node.
-
nodeKind
The kind of a node, the C XmlNodeKind values.- Parameters:
n- The node.- Returns:
- The kind.
-
nodeDom
The dom of a node.- Parameters:
n- The node.- Returns:
- The document.
-
nodeParent
-
nodeFirstChild
-
nodeLastChild
-
nodeNext
-
nodePrev
-
nodeName
The name: local name of elements and attributes, the target of a pi, the entity name of a reference, the prefix of a namespace node, null for text ("textnoenc" for text written without escaping), comments and documents.- Parameters:
n- The node.- Returns:
- The name or null.
-
nodeSetName
-
nodeContent
-
nodeSetContent
-
nodeAppendContent
-
nodeStringValue
-
nodeNs
-
nodeNsUri
-
nodeNsPrefix
-
nodeSetNs
-
nodeLine
-
nodeSetLine
Set the source line.- Parameters:
n- The node.line- The line.
-
nodeUserData
-
nodeSetUserData
-
nodeAppendChild
-
nodeAddChild
-
nodeAddPrevSibling
-
nodeAddNextSibling
-
nodeUnlink
Unlink a node from its parent (an attribute from its element).- Parameters:
n- The node.
-
nodeReplace
-
nodeNumChildren
The number of children.- Parameters:
n- The node.- Returns:
- The count.
-
nodeCopy
Copy a node (not a document) into dom, deep with the children, the namespaces used are the copies of the declarations copied with it or the original ones (xml_node_copy).- Parameters:
dom- The dom of the copy.node- The node.deep- Copy the children too.- Returns:
- The copy.
-
nodeCompareOrder
-
nodeAttrs
-
nodeFirstAttr
-
attrNext
-
attrName
-
attrOwner
-
attrNode
-
nodeAsAttr
-
nodeGetAttr
-
nodeAppendAttr
-
nodeSetAttr
-
nodeMoveAttr
-
nodeRemoveAttr
-
nsPrefix
-
nsHref
-
nsSetHref
-
nodeNsDecls
-
nsDeclare
-
nsMoveDeclTo
-
nsMoveDeclLast
-
nsRemoveDecl
-
nsLookupPrefix
-
nsLookupHref
-
nsSplitPuri
-
nodeApplyXmqns
Set the namespace of an element added to the dom, as the C xmqAddElement does with an XMQNS (xml_node_apply_xmqns).- Parameters:
element- The element, already added to its parent.action- NS_NONE, NS_PARENT, NS_HERE or NS_ANCESTOR.puri- The uri for NS_HERE and NS_ANCESTOR, optionally with a {prefix} first.- Returns:
- True if ok, false if the uri is malformed or the prefix is already declared on the element for another uri.
-
nodeReconcileNs
Make every namespace used in the subtree of node declared in scope (xml_node_reconcile_ns).- Parameters:
node- The element.
-