Class RebasedDocument

  • All Implemented Interfaces:
    javax.xml.transform.Source, TreeInfo

    public class RebasedDocument
    extends GenericTreeInfo
    A RebasedDocument represents a view of a real Document in which all nodes are mapped to a different base URI and/or system ID using supplied mapping functions.

    It is possible to map either base URIs or system IDs or both.

    All properties of the nodes other than the base URI and system ID are unchanged.

    The user-supplied functions supplied to compute the base URI and system ID will be applied to the underlying node in the "real" document. It is of course possible to supply a function that ignores the supplied input.

    • Constructor Detail

      • RebasedDocument

        public RebasedDocument​(TreeInfo doc,
                               java.util.function.Function<NodeInfo,​java.lang.String> baseUriMapper,
                               java.util.function.Function<NodeInfo,​java.lang.String> systemIdMapper)
        Create a rebased view of a document
        doc - the underlying document
        baseUriMapper - a function that is applied to a node in the original document to deliver the base URI of the corresponding node in the rebased document
        systemIdMapper - a function that is applied to a node in the original document to deliver the system ID of the corresponding node in the rebased document
    • Method Detail

      • wrap

        public RebasedNode wrap​(NodeInfo node)
        Create a wrapped node within this document
        node - the node to be wrapped - must be a node in the base document
        the wrapped node
      • isTyped

        public boolean isTyped()
        Ask whether the document contains any nodes whose type annotation is anything other than UNTYPED. (This will be true if and only if the underlying document is untyped).

        Note: in XSD 1.1 it is possible to define assertions such that the validity of a node depends on its base URI. This class assumes that no-one would be quite so perverse. The validity and type annotation of a virtual node are therefore the same as the validity and type annotation of its underlying node.

        true if the document contains elements whose type is other than UNTYPED
      • getDurability

        public Durability getDurability()
        Description copied from interface: TreeInfo
        Get the durability of nodes in the tree. This affects how they are handled in a memo function cache, to optimize memory and garbage collection. By default, all nodes are considered durable unless otherwise specified
        Specified by:
        getDurability in interface TreeInfo
        getDurability in class GenericTreeInfo
        the durability property of this node tree
      • selectID

        public NodeInfo selectID​(java.lang.String id,
                                 boolean getParent)
        Get the element with a given ID, if any
        Specified by:
        selectID in interface TreeInfo
        selectID in class GenericTreeInfo
        id - the required ID value
        getParent - true if the required element is the parent of an element annotated as xs:ID, false if the required node is the element itself
        the element with the given ID value, or null if there is none.
      • getUnderlyingTree

        public TreeInfo getUnderlyingTree()
        Get the underlying tree (the one whose nodes are being mapped to a new base URI and system ID)
        the underlying tree
      • getBaseUriMapper

        public java.util.function.Function<NodeInfo,​java.lang.String> getBaseUriMapper()
        Get the function that is used to map nodes in the underlying tree to a new base URI
        the base URI mapping function
      • getSystemIdMapper

        public java.util.function.Function<NodeInfo,​java.lang.String> getSystemIdMapper()
        Get the function that is used to map nodes in the underlying tree to a new system ID
        the system ID mapping function