Class XmlDocument

java.lang.Object
org.libxmq.imp.xml.XmlNode
org.libxmq.imp.xml.XmlDocument
All Implemented Interfaces:
XMQDoc, XMQNode

public class XmlDocument extends XmlNode implements XMQDoc
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 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

      public XMQNodeType type()
      Description copied from class: XmlNode
      Returns the type of this node.
      Specified by:
      type in interface XMQNode
      Specified by:
      type in class XmlNode
      Returns:
      The node 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

      public XmlElement rootElement()
      Returns the root element, ie the first top level element.
      Specified by:
      rootElement in interface XMQDoc
      Returns:
      The root element or null.
    • setRootElement

      public void setRootElement(XMQElement e)
      Set the root element, replacing any existing root element, like libxml2 xmlDocSetRootElement.
      Specified by:
      setRootElement in interface XMQDoc
      Parameters:
      e - The new root.
    • intSubset

      public XmlDtd intSubset()
      Returns the internal subset dtd.
      Specified by:
      intSubset in interface XMQDoc
      Returns:
      The dtd or null.
    • setIntSubset

      public void setIntSubset(XMQDtd dtd)
      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:
      setIntSubset in interface XMQDoc
      Parameters:
      dtd - The dtd.
    • setIntSubsetRef

      public void setIntSubsetRef(XmlDtd dtd)
      Remember the dtd without adding it as a child, used when the caller places the dtd node itself.
      Parameters:
      dtd - The dtd.
    • getEntity

      public XmlEntityDecl getEntity(String name)
      Find a general entity declared in the internal subset.
      Specified by:
      getEntity in interface XMQDoc
      Parameters:
      name - The entity name.
      Returns:
      The declaration or null.
    • version

      public String version()
      Returns the xml version.
      Returns:
      The version, eg 1.0.
    • setVersion

      public void setVersion(String v)
      Set the xml version.
      Parameters:
      v - The version.
    • encoding

      public String encoding()
      Returns the declared encoding.
      Returns:
      The encoding or null.
    • setEncoding

      public void setEncoding(String e)
      Set the declared encoding.
      Parameters:
      e - The encoding.
    • 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

      public String url()
      Returns the source url/name of the document.
      Returns:
      The url or null.
    • setUrl

      public void setUrl(String url)
      Set the source url/name of the document.
      Parameters:
      url - The url.
    • fullName

      public String fullName()
      Description copied from class: XmlNode
      Returns the full name, ie prefix:name if the node has a namespace with a prefix.
      Specified by:
      fullName in interface XMQNode
      Overrides:
      fullName in class XmlNode
      Returns:
      The full name.