Class DocumentImpl

All Implemented Interfaces:
Source, SourceLocator, DocumentInfo, FingerprintedNode, Item, NodeInfo, ValueRepresentation

public final class DocumentImpl extends ParentNodeImpl implements DocumentInfo
A node in the XML parse tree representing the Document itself (or equivalently, the root node of the Document).

Author:
Michael H. Kay
  • Constructor Details

    • DocumentImpl

      public DocumentImpl()
  • Method Details

    • setConfiguration

      public void setConfiguration(Configuration config)
      Set the Configuration that contains this document
    • getConfiguration

      public Configuration getConfiguration()
      Get the configuration previously set using setConfiguration
      Specified by:
      getConfiguration in interface NodeInfo
      Overrides:
      getConfiguration in class NodeImpl
      Returns:
      the Configuration
    • getNamePool

      public NamePool getNamePool()
      Get the name pool used for the names in this document
      Specified by:
      getNamePool in interface NodeInfo
      Overrides:
      getNamePool in class NodeImpl
      Returns:
      the namepool
    • getDocumentNumber

      public int getDocumentNumber()
      Get the unique document number
      Specified by:
      getDocumentNumber in interface NodeInfo
      Overrides:
      getDocumentNumber in class NodeImpl
    • setDocumentElement

      void setDocumentElement(ElementImpl e)
      Set the top-level element of the document (variously called the root element or the document element). Note that a DocumentImpl may represent the root of a result tree fragment, in which case there is no document element.
      Parameters:
      e - the top-level element
    • setSystemId

      public void setSystemId(String uri)
      Set the system id of this node
      Specified by:
      setSystemId in interface Source
      Overrides:
      setSystemId in class NodeImpl
    • getSystemId

      public String getSystemId()
      Get the system id of this root node
      Specified by:
      getSystemId in interface NodeInfo
      Specified by:
      getSystemId in interface Source
      Specified by:
      getSystemId in interface SourceLocator
      Overrides:
      getSystemId in class NodeImpl
      Returns:
      the System Identifier of the entity in the source document containing the node, or null if not known or not applicable.
    • setBaseURI

      public void setBaseURI(String uri)
      Set the base URI of this document node
    • getBaseURI

      public String getBaseURI()
      Get the base URI of this root node.
      Specified by:
      getBaseURI in interface NodeInfo
      Overrides:
      getBaseURI in class NodeImpl
      Returns:
      the base URI of the node. This may be null if the base URI is unknown.
    • setSystemId

      void setSystemId(int seq, String uri)
      Set the system id of an element in the document
    • getSystemId

      String getSystemId(int seq)
      Get the system id of an element in the document
    • setLineNumbering

      public void setLineNumbering()
      Set line numbering on
    • setLineNumber

      void setLineNumber(int sequence, int line)
      Set the line number for an element. Ignored if line numbering is off.
    • getLineNumber

      int getLineNumber(int sequence)
      Get the line number for an element. Return -1 if line numbering is off.
    • getLineNumber

      public int getLineNumber()
      Get the line number of this root node.
      Specified by:
      getLineNumber in interface NodeInfo
      Specified by:
      getLineNumber in interface SourceLocator
      Overrides:
      getLineNumber in class NodeImpl
      Returns:
      0 always
    • getNodeKind

      public final int getNodeKind()
      Return the type of node.
      Specified by:
      getNodeKind in interface NodeInfo
      Returns:
      Type.DOCUMENT (always)
      See Also:
    • getNextSibling

      public final NodeInfo getNextSibling()
      Get next sibling - always null
      Overrides:
      getNextSibling in class NodeImpl
      Returns:
      null
    • getPreviousSibling

      public final NodeInfo getPreviousSibling()
      Get previous sibling - always null
      Overrides:
      getPreviousSibling in class NodeImpl
      Returns:
      null
    • getDocumentElement

      public ElementImpl getDocumentElement()
      Get the root (outermost) element.
      Returns:
      the Element node for the outermost element of the document.
    • getRoot

      public NodeInfo getRoot()
      Get the root node
      Specified by:
      getRoot in interface NodeInfo
      Overrides:
      getRoot in class NodeImpl
      Returns:
      the NodeInfo representing the root of this tree
    • getDocumentRoot

      public DocumentInfo getDocumentRoot()
      Get the root (document) node
      Specified by:
      getDocumentRoot in interface NodeInfo
      Overrides:
      getDocumentRoot in class NodeImpl
      Returns:
      the DocumentInfo representing this document
    • generateId

      public void generateId(FastStringBuffer buffer)
      Get a character string that uniquely identifies this node
      Specified by:
      generateId in interface NodeInfo
      Overrides:
      generateId in class NodeImpl
      Parameters:
      buffer - a buffer into which will be placed a string based on the document number
    • getAllElements

      AxisIterator getAllElements(int fingerprint)
      Get a list of all elements with a given name fingerprint
    • selectID

      public NodeInfo selectID(String id)
      Get the element with a given ID.
      Specified by:
      selectID in interface DocumentInfo
      Parameters:
      id - The unique ID of the required element, previously registered using registerID()
      Returns:
      The NodeInfo for the given ID if one has been registered, otherwise null.
    • setUnparsedEntity

      void setUnparsedEntity(String name, String uri, String publicId)
      Set an unparsed entity URI associated with this document. For system use only, while building the document.
    • getUnparsedEntity

      public String[] getUnparsedEntity(String name)
      Get the unparsed entity with a given name
      Specified by:
      getUnparsedEntity in interface DocumentInfo
      Parameters:
      name - the name of the entity
      Returns:
      if the entity exists, return an array of two Strings, the first holding the system ID of the entity, the second holding the public ID if there is one, or null if not. If the entity does not exist, return null. * @return the URI of the entity if there is one, or empty string if not
    • copy

      public void copy(Receiver out, int whichNamespaces, boolean copyAnnotations, int locationId) throws XPathException
      Copy this node to a given outputter
      Specified by:
      copy in interface NodeInfo
      Parameters:
      out - the Receiver to which the node should be copied
      whichNamespaces - in the case of an element, controls which namespace nodes should be copied. Values are NodeInfo.NO_NAMESPACES, NodeInfo.LOCAL_NAMESPACES, NodeInfo.ALL_NAMESPACES
      copyAnnotations - indicates whether the type annotations of element and attribute nodes should be copied
      locationId - If non-zero, identifies the location of the instruction that requested this copy. If zero, indicates that the location information for the original node is to be copied; in this case the Receiver must be a LocationCopier
      Throws:
      XPathException