Class CoercionRules

java.lang.Object
net.sf.saxon.type.coercion.CoercionRules

public class CoercionRules extends Object
Implementation of the coercion rules (3.0: function conversion rules) for dynamic function calls. Converts a value supplied as an argument in a function call to the required type. This is used primarily for dynamic function calls; for static calls see the TypeChecker class, which converts expressions rather than values. The class is also used for converting external parameters to the required type.

There are separate versions of this class for XPath 3.1 and XPath 4.0.

  • Constructor Details

    • CoercionRules

      public CoercionRules(Configuration config, int version)
  • Method Details

    • forVersion

      public static CoercionRules forVersion(Configuration config, int version)
    • coerce

      public Sequence coerce(Sequence value, SequenceType requiredType, SequenceType knownType, Configuration config, Supplier<RoleDiagnostic> roleSupplier, Location locator) throws XPathException
      Apply the coercion rules (function conversion rules) to a value, given a required type.
      Parameters:
      value - a value to be converted
      requiredType - the required type
      knownType - the item type of the supplied value, to the extent this is known
      config - the Saxon configuration
      roleSupplier - identifies the value to be converted in error messages
      locator - identifies the location for error messages
      Returns:
      the converted value (possibly as a lazily-evaluated sequence)
      Throws:
      XPathException - if the value cannot be converted to the required type