Class DocumentImpl

    • Constructor Detail

      • DocumentImpl

        public DocumentImpl()
        Create a DocumentImpl
    • Method Detail

      • getRootNode

        public NodeInfo getRootNode()
        Get the NodeInfo object representing the document node at the root of the tree
        Specified by:
        getRootNode in interface TreeInfo
        Returns:
        the document node
      • setConfiguration

        public void setConfiguration​(Configuration config)
        Set the Configuration that contains this document
        Parameters:
        config - the Saxon configuration
      • getNamePool

        public NamePool getNamePool()
        Get the name pool used for the names in this document
        Overrides:
        getNamePool in class NodeImpl
      • setImaginary

        public void setImaginary​(boolean imaginary)
        Set whether this is an imaginary document node
        Parameters:
        imaginary - if true, this is an imaginary node - the tree is really rooted at the topmost element
      • isImaginary

        public boolean isImaginary()
        Ask whether this is an imaginary document node
        Returns:
        true if this is an imaginary node - the tree is really rooted at the topmost element
      • isTyped

        public boolean isTyped()
        Ask whether the document contains any nodes whose type annotation is anything other than UNTYPED
        Specified by:
        isTyped in interface TreeInfo
        Returns:
        true if the document contains elements whose type is other than UNTYPED
      • getDocumentNumber

        public long getDocumentNumber()
        Get the unique document number
        Specified by:
        getDocumentNumber in interface TreeInfo
        Returns:
        the document number
      • setDocumentElement

        public 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
      • graftLocationMap

        public void graftLocationMap​(DocumentImpl original)
        Copy the system ID and line number map from another document (used when grafting a simplified stylesheet)
        Parameters:
        original - the document whose system ID and line number maps are to be grafted onto this tree
      • setSystemId

        public void setSystemId​(java.lang.String uri)
        Set the system id (base URI) of this node
        Specified by:
        setSystemId in interface javax.xml.transform.Source
        Overrides:
        setSystemId in class NodeImpl
      • getSystemId

        public java.lang.String getSystemId()
        Get the system id of this root node
        Specified by:
        getSystemId in interface Location
        Specified by:
        getSystemId in interface org.xml.sax.Locator
        Specified by:
        getSystemId in interface NodeInfo
        Specified by:
        getSystemId in interface javax.xml.transform.Source
        Specified by:
        getSystemId in interface javax.xml.transform.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​(java.lang.String uri)
        Set the base URI of this document node
        Parameters:
        uri - the new base URI
      • getBaseURI

        public java.lang.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
      • setLineNumbering

        public void setLineNumbering()
        Set line numbering on
      • addNilledElement

        public void addNilledElement​(ElementImpl element)
        Add a nilled element. Nilled elements are unusual, so we avoid allocating a boolean in the element node; instead we keep a list of nilled elements at the document level
        Parameters:
        element - a nilled element
      • markTopWithinEntity

        public void markTopWithinEntity​(ElementImpl element)
      • isTopWithinEntity

        public boolean isTopWithinEntity​(ElementImpl element)
      • getLineNumber

        public int getLineNumber()
        Get the line number of this root node.
        Specified by:
        getLineNumber in interface Location
        Specified by:
        getLineNumber in interface org.xml.sax.Locator
        Specified by:
        getLineNumber in interface NodeInfo
        Specified by:
        getLineNumber in interface javax.xml.transform.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:
        Type
      • getDocumentElement

        public ElementImpl getDocumentElement()
        Get the root (outermost) element.
        Returns:
        the Element node for the outermost element of the document. May return null if the document node contains no element node.
      • 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
      • getPhysicalRoot

        public DocumentImpl getPhysicalRoot()
        Get the physical root of the tree. This may be an imaginary document node: this method should be used only when control information held at the physical root is required
        Overrides:
        getPhysicalRoot in class NodeImpl
        Returns:
        the document node, which may be imaginary
      • 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
      • deIndex

        public void deIndex​(NodeImpl node)
        Remove a node from any indexes when it is detached from the tree
        Parameters:
        node - the node to be removed from all indexes
      • registerID

        protected void registerID​(NodeInfo e,
                                  java.lang.String id)
        Register a unique element ID. Does nothing if there is already an element with that ID.
        Parameters:
        e - The Element having a particular unique ID value
        id - The unique ID value
      • selectID

        public NodeInfo selectID​(java.lang.String id,
                                 boolean getParent)
        Get the element with a given ID.
        Specified by:
        selectID in interface TreeInfo
        Parameters:
        id - The unique ID of the required element, previously registered using registerID()
        getParent - true if the requirement is for the parent of the node with the given ID, not the node itself.
        Returns:
        The NodeInfo for the given ID if one has been registered, otherwise null.
      • deregisterID

        protected void deregisterID​(java.lang.String id)
        Remove the entry for a given ID (when nodes are deleted). Does nothing if the id value is not present in the index.
        Parameters:
        id - The id value
      • setUnparsedEntity

        public void setUnparsedEntity​(java.lang.String name,
                                      java.lang.String uri,
                                      java.lang.String publicId)
        Set an unparsed entity URI associated with this document. For system use only, while building the document.
        Parameters:
        name - the entity name
        uri - the system identifier of the unparsed entity
        publicId - the public identifier of the unparsed entity
      • getUnparsedEntityNames

        public java.util.Iterator<java.lang.String> getUnparsedEntityNames()
        Get the list of unparsed entities defined in this document
        Specified by:
        getUnparsedEntityNames in interface TreeInfo
        Returns:
        an Iterator, whose items are of type String, containing the names of all unparsed entities defined in this document. If there are no unparsed entities or if the information is not available then an empty iterator is returned
      • getUnparsedEntity

        public java.lang.String[] getUnparsedEntity​(java.lang.String name)
        Get the unparsed entity with a given name
        Specified by:
        getUnparsedEntity in interface TreeInfo
        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.
      • copy

        public void copy​(Receiver out,
                         int copyOptions,
                         Location 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. It is the caller's responsibility to ensure that this Receiver is open before the method is called (or that it is self-opening), and that it is closed after use.
        copyOptions - a selection of the options defined in CopyOptions
        locationId - If non-null, identifies the location of the instruction that requested this copy. If zero, indicates that the location information is not available
        Throws:
        XPathException - if any downstream error occurs
      • replaceStringValue

        public void replaceStringValue​(java.lang.CharSequence stringValue)
        Replace the string-value of this node
        Specified by:
        replaceStringValue in interface MutableNodeInfo
        Parameters:
        stringValue - the new string value
      • resetIndexes

        public void resetIndexes()
        This method is called before performing a batch of updates; it allows all cached data that might be invalidated by such updates to be cleared
        Specified by:
        resetIndexes in interface MutableDocumentInfo
      • setSpaceStrippingRule

        public void setSpaceStrippingRule​(SpaceStrippingRule rule)
        Set details of space stripping action that was applied to this document during construction. This ensures that space stripping is not applied twice to the same document.
        Specified by:
        setSpaceStrippingRule in interface TreeInfo
        Parameters:
        rule - details of the space stripping rules that have been applied to this document during its construction.
        Since:
        9.9
      • getSpaceStrippingRule

        public SpaceStrippingRule getSpaceStrippingRule()
        Get details of space stripping action that was applied to this document during construction. This ensures that space stripping is not applied twice to the same document.
        Specified by:
        getSpaceStrippingRule in interface TreeInfo
        Returns:
        details of the space stripping rules that have been applied to this document during its construction. By default, returns NoElementsSpaceStrippingRule, indicating that no space stripping has been applied
        Since:
        9.9
      • setUserData

        public void setUserData​(java.lang.String key,
                                java.lang.Object value)
        Set user data on the document node. The user data can be retrieved subsequently using getUserData(java.lang.String)
        Specified by:
        setUserData in interface TreeInfo
        Parameters:
        key - A string giving the name of the property to be set. Clients are responsible for choosing a key that is likely to be unique. Must not be null. Keys used internally by Saxon are prefixed "saxon:".
        value - The value to be set for the property. May be null, which effectively removes the existing value for the property.
      • getUserData

        public java.lang.Object getUserData​(java.lang.String key)
        Get user data held in the document node. This retrieves properties previously set using setUserData(java.lang.String, java.lang.Object)
        Specified by:
        getUserData in interface TreeInfo
        Parameters:
        key - A string giving the name of the property to be retrieved.
        Returns:
        the value of the property, or null if the property has not been defined.