Class ExperimentalXPathCompiler

java.lang.Object
com.saxonica.ee.extfn.ExperimentalXPathCompiler

public class ExperimentalXPathCompiler extends Object
This class provides support to the XX (xslt-in-xslt) compiler. The XSLT compiler obtains a single instance of the ExperimentalXPathCompiler for a compilation episode, initializes it with global context information that applies to the package-being-compiled as a whole, and then invokes its compileXPath() method to compile each XPath expression encountered. Note that this code is essentially dormant, because we currently use the XX compiler only with a Javascript XPath compiler; but we don't want to drop the capability to potentially use it in the Java world.
  • Method Details

    • make

      public static ExperimentalXPathCompiler make(XPathContext context, MapItem globalFunctions, MapItem globalVariables)
    • withUniformStaticContext

      public ExperimentalXPathCompiler withUniformStaticContext(XPathContext context, NodeInfo sefElement, NodeInfo nsAttribute)
    • compileXPath

      public MapItem compileXPath(XPathContext context, String exprText, NodeInfo sefElement, MapItem localVariableMap, NodeInfo nsAttribute) throws XPathException
      Compile an XPath expression on behalf of the XX XSLT compiler
      Parameters:
      context - the evaluation context
      exprText - the text of the XPath expression
      sefElement - the element node in the SEF tree containing the XPath expression
      localVariableMap - map containing information about local variables in the static context. The key of the map is the name of the variable as a QName. The associated value is a sequence of three items: the declaring element in the SEF tree, the slot number, and the declared type of the variable.
      nsAttribute - the nearest in-scope ns attribute, containing a whitespace-separated list of prefix=uri namespace bindings
      Returns:
      a map representing the compiled expression, with two entries: "expr" for the SEF tree of the expression, and "type" for the static type of the expression.
      Throws:
      XPathException - if XPath parsing fails with a static error
    • allocateSlots

      public static int allocateSlots(Expression exp, int nextFree, SlotManager frame)
      Allocate slot numbers to range variables. This is a variant of ExpressionTool.allocateSlots(Expression, int, SlotManager), which takes into account that variable references may have no target binding, and that some variables will already have slot numbers.

      This method is only concerned with allocating slot numbers to variables that are declared within the expression itself.

      Parameters:
      exp - the expression whose range variables need to have slot numbers assigned
      nextFree - the next slot number that is available for allocation
      frame - a SlotManager object that is used to track the mapping of slot numbers to variable names for debugging purposes. May be null.
      Returns:
      the next unallocated slot number.
    • breakpoint

      public static void breakpoint(String s)
      Method that can be called from the XSLT code to trigger a debugger breakpoint
      Parameters:
      s - an identifying string
    • stackTrace

      public static void stackTrace(XPathContext context)
      Method to output a stack trace
    • parseSequenceType

      public static MapItem parseSequenceType(XPathContext context, String input, NodeInfo nsContext, NamespaceUri xpathDefaultNamespace) throws XPathException
      Parse a SequenceType
      Throws:
      XPathException
    • makeMap

      public static MapItem makeMap(SequenceType st)
    • fromMap

      public static SequenceType fromMap(MapItem typeAsMap)