Package net.sf.saxon.tree.wrapper

## Class RebasedDocument

- java.lang.Object
- - net.sf.saxon.om.GenericTreeInfo
  - - net.sf.saxon.tree.wrapper.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.

  Since:
    9.9.0.2

- - ### Field Summary

    - ### Fields inherited from class net.sf.saxon.om.GenericTreeInfo

      `root`

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `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

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `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
    `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
    `TreeInfo` | `getUnderlyingTree()` | Get the underlying tree (the one whose nodes are being mapped to a new base URI and system ID)
    `boolean` | `isTyped()` | Ask whether the document contains any nodes whose type annotation is anything other than UNTYPED.
    `NodeInfo` | `selectID​(java.lang.String id, boolean getParent)` | Get the element with a given ID, if any
    `RebasedNode` | `wrap​(NodeInfo node)` | Create a wrapped node within this document

    - ### Methods inherited from class net.sf.saxon.om.GenericTreeInfo

      `getConfiguration, getDocumentNumber, getPublicId, getRootNode, getSpaceStrippingRule, getSystemId, getUnparsedEntity, getUnparsedEntityNames, getUserData, isStreamed, setConfiguration, setDocumentNumber, setRootNode, setSpaceStrippingRule, setSystemId, setUserData`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface javax.xml.transform.Source

      `isEmpty`

    - ### Methods inherited from interface net.sf.saxon.om.TreeInfo

      `isMutable`

- - ### 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
      Parameters:
        `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
      Parameters:
        `node` - the node to be wrapped - must be a node in the base document

    - #### 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.

      Returns:
        true if the document contains elements whose type is other than UNTYPED

    - #### 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`
      Overrides:
        `selectID` in class `GenericTreeInfo`
      Parameters:
        `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
      Returns:
        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)
      Returns:
        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
      Returns:
        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
      Returns:
        the system ID mapping function