Class DocumentFn

All Implemented Interfaces:
Callable, FunctionItem, GroundedValue, Item, Sequence

public class DocumentFn extends SystemFunction implements Callable
Implements the XSLT document() function
  • Constructor Details

    • DocumentFn

      public DocumentFn()
  • Method Details

    • getCardinality

      public int getCardinality(Expression[] arguments)
      Determine the static cardinality
      Overrides:
      getCardinality in class SystemFunction
      Parameters:
      arguments - the actual arguments supplied
      Returns:
      the most precise available cardinality that the function will return
    • getSpecialProperties

      public int getSpecialProperties(Expression[] arguments)
      Get the static properties of this expression (other than its type). The result is bit-signficant. These properties are used for optimizations. In general, if property bit is set, it is true, but if it is unset, the value is unknown.
      Overrides:
      getSpecialProperties in class SystemFunction
      Parameters:
      arguments - the expressions supplied as arguments to the function call
      Returns:
      the properties
    • makeFunctionCall

      public Expression makeFunctionCall(Expression... arguments)
      Description copied from class: SystemFunction
      Make an expression that either calls this function, or that is equivalent to a call on this function
      Overrides:
      makeFunctionCall in class SystemFunction
      Parameters:
      arguments - the supplied arguments to the function call
      Returns:
      either a function call on this function, or an expression that delivers the same result
    • sourceIsTree

      public static boolean sourceIsTree(Source source)
    • call

      public Sequence call(XPathContext context, Sequence[] arguments) throws XPathException
      Evaluate the expression
      Specified by:
      call in interface Callable
      Parameters:
      context - the dynamic evaluation context
      arguments - the values of the arguments, supplied as SequenceIterators
      Returns:
      the result of the evaluation, in the form of a SequenceIterator
      Throws:
      XPathException - if a dynamic error occurs during the evaluation of the expression
    • makeDoc

      public static NodeInfo makeDoc(String href, String baseURI, PackageData packageData, ParseOptions options, XPathContext c, Location locator, boolean silent) throws XPathException
      Supporting routine to load one external document given a URI (href) and a baseURI. This is used in the normal case when a document is loaded at run-time (that is, when a Controller is available)
      Parameters:
      href - the relative URI
      baseURI - the base URI
      packageData - the stylesheet (or other) package in which the call appears
      options - parse options to be used. May be null.
      c - the dynamic XPath context
      locator - used to identify the location of the instruction in event of error
      silent - if true, errors should not be notified to the ErrorListener
      Returns:
      the root of the constructed document, or the selected element within the document if a fragment identifier was supplied, or null if the URIResolver returns an instance of EmptySource;
      Throws:
      XPathException - if reading or parsing the document fails
    • resolveURI

      public static Source resolveURI(String href, String baseURI, String documentKey, XPathContext context) throws XPathException
      Call the URIResolver to resolve a URI
      Parameters:
      href - the supplied relative URI, stripped of any fragment identifier
      baseURI - the base URI
      documentKey - the absolute URI if already available, or null otherwise
      context - the dynamic context
      Returns:
      a Source representing the document to be read
      Throws:
      XPathException - if the relative URI cannot be resolved
    • computeDocumentKey

      protected static DocumentKey computeDocumentKey(String href, String baseURI, PackageData packageData, XPathContext c) throws XPathException
      Compute a document key
      Throws:
      XPathException
    • computeDocumentKey

      public static DocumentKey computeDocumentKey(String href, String baseURI, PackageData packageData, boolean strip)
      Compute a document key (an absolute URI that can be used to see if a document is already loaded)
      Parameters:
      href - the relative URI
      baseURI - the base URI
      packageData - the package in which the call to doc() or document() appears (affects options such as strip-space)
      strip - true if the document is subject to whitespace stripping (typically a source document), otherwise false
    • preLoadDoc

      public static NodeInfo preLoadDoc(String href, String baseURI, PackageData packageData, Configuration config, SourceLocator locator) throws XPathException
      Supporting routine to load one external document given a URI (href) and a baseURI. This is used when the document is pre-loaded at compile time.
      Parameters:
      href - the relative URI. This must not contain a fragment identifier
      baseURI - the base URI
      config - the Saxon configuration
      locator - used to identify the location of the instruction in event of error. May be null.
      Returns:
      the root of the constructed document, or the selected element within the document if a fragment identifier was supplied
      Throws:
      XPathException
    • sendDoc

      public static void sendDoc(String href, String baseURI, PackageData packageData, XPathContext context, Location locator, Receiver out, ParseOptions parseOptions) throws XPathException
      Supporting routine to push one external document given a URI (href) and a baseURI to a given Receiver. This method cannot handle fragment identifiers
      Parameters:
      href - the relative URI
      baseURI - the base URI
      packageData - the containing XSLT package
      context - the XPath dynamic context
      locator - used to identify the location of the instruction in case of error
      out - the destination where the document is to be sent
      Throws:
      XPathException