Class XQueryAsXPathFunctionConverter

java.lang.Object
com.helger.schematron.pure.xpath.XQueryAsXPathFunctionConverter

public class XQueryAsXPathFunctionConverter extends Object
This class loads XQuery modules and provides a list of XPath functions. This class can only be used, if Saxon is on the classpath!
Author:
Philip Helger
  • Constructor Details

    • XQueryAsXPathFunctionConverter

      public XQueryAsXPathFunctionConverter() throws MalformedURLException
      Default ctor using the current working directory as the base URL for the XQuery resource resolver.
      Throws:
      MalformedURLException - In case the conversion to URL failed
    • XQueryAsXPathFunctionConverter

      public XQueryAsXPathFunctionConverter(@Nonnull File aBasePath) throws MalformedURLException
      Constructor using the passed file as a working directory as the base URL for the XQuery resource resolver.
      Parameters:
      aBasePath - Base path for XQuery resource resolving. May not be null.
      Throws:
      MalformedURLException - In case the conversion to URL failed
    • XQueryAsXPathFunctionConverter

      public XQueryAsXPathFunctionConverter(@Nonnull @Nonempty String sBaseURL)
      Constructor using the passed URL as a working directory as the base URL for the XQuery resource resolver.
      Parameters:
      sBaseURL - Base URL for XQuery resource resolving. May neither be null nor empty.
  • Method Details

    • getBaseURL

      @Nonnull @Nonempty public String getBaseURL()
      Returns:
      The base URL provided in the constructor. Neither null nor empty.
    • loadXQuery

      @Nonnull public com.helger.xml.xpath.MapBasedXPathFunctionResolver loadXQuery(@Nonnull @WillClose InputStream aXQueryIS) throws net.sf.saxon.trans.XPathException, IOException
      Load XQuery functions from an input stream. As this function is supposed to work with Saxon HE, this method allows only for loading full XQuery modules and not for XQuery libraries.
      Parameters:
      aXQueryIS - The Input Stream to read from. May not be null. Will be closed automatically in this method.
      Returns:
      A non-null MapBasedXPathFunctionResolver containing all loaded functions.
      Throws:
      net.sf.saxon.trans.XPathException - if the syntax of the expression is wrong, or if it references namespaces, variables, or functions that have not been declared, or any other static error is reported.
      IOException - if a failure occurs reading the supplied input.