org.apache.xalan.lib

## Class ExsltDynamic

- java.lang.Object
- - org.apache.xalan.lib.ExsltBase
  - - org.apache.xalan.lib.ExsltDynamic

-     public class ExsltDynamic
      extends ExsltBase

  This class contains EXSLT dynamic extension functions. It is accessed by specifying a namespace URI as follows:

          xmlns:dyn="http://exslt.org/dynamic"

  The documentation for each function has been copied from the relevant EXSLT Implementer page.
  See Also:
    EXSLT
  Usage:

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.lang.String` | `EXSL_URI`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ExsltDynamic()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static org.w3c.dom.NodeList` | `closure(ExpressionContext myContext, org.w3c.dom.NodeList nl, java.lang.String expr)` The dyn:closure function creates a node set resulting from transitive closure of evaluating the expression passed as the second argument on each of the nodes passed as the first argument, then on the node set resulting from that and so on until no more nodes are found.
    `static XObject` | `evaluate(ExpressionContext myContext, java.lang.String xpathExpr)` The dyn:evaluate function evaluates a string as an XPath expression and returns the resulting value, which might be a boolean, number, string, node set, result tree fragment or external object.
    `static org.w3c.dom.NodeList` | `map(ExpressionContext myContext, org.w3c.dom.NodeList nl, java.lang.String expr)` The dyn:map function evaluates the expression passed as the second argument for each of the nodes passed as the first argument, and returns a node set of those values.
    `static double` | `max(ExpressionContext myContext, org.w3c.dom.NodeList nl, java.lang.String expr)` The dyn:max function calculates the maximum value for the nodes passed as the first argument, where the value of each node is calculated dynamically using an XPath expression passed as a string as the second argument.
    `static double` | `min(ExpressionContext myContext, org.w3c.dom.NodeList nl, java.lang.String expr)` The dyn:min function calculates the minimum value for the nodes passed as the first argument, where the value of each node is calculated dynamically using an XPath expression passed as a string as the second argument.
    `static double` | `sum(ExpressionContext myContext, org.w3c.dom.NodeList nl, java.lang.String expr)` The dyn:sum function calculates the sum for the nodes passed as the first argument, where the value of each node is calculated dynamically using an XPath expression passed as a string as the second argument.

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

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

- - ### Field Detail

    - #### EXSL_URI

          public static final java.lang.String EXSL_URI

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### ExsltDynamic

          public ExsltDynamic()

  - ### Method Detail

    - #### max

          public static double max(ExpressionContext myContext,
                                   org.w3c.dom.NodeList nl,
                                   java.lang.String expr)
                            throws org.xml.sax.SAXNotSupportedException

      The dyn:max function calculates the maximum value for the nodes passed as the first argument, where the value of each node is calculated dynamically using an XPath expression passed as a string as the second argument.

      The expressions are evaluated relative to the nodes passed as the first argument. In other words, the value for each node is calculated by evaluating the XPath expression with all context information being the same as that for the call to the dyn:max function itself, except for the following:

      - the context node is the node whose value is being calculated.
      - the context position is the position of the node within the node set passed as the first argument to the dyn:max function, arranged in document order.
      - the context size is the number of nodes passed as the first argument to the dyn:max function.

      The dyn:max function returns the maximum of these values, calculated in exactly the same way as for math:max.

      If the expression string passed as the second argument is an invalid XPath expression (including an empty string), this function returns NaN.

      This function must take a second argument. To calculate the maximum of a set of nodes based on their string values, you should use the math:max function.

      Parameters:
        `myContext` - The ExpressionContext passed by the extension processor
        `nl` - The node set
        `expr` - The expression string
      Returns:
        The maximum evaluation value
      Throws:
        `org.xml.sax.SAXNotSupportedException`

    - #### min

          public static double min(ExpressionContext myContext,
                                   org.w3c.dom.NodeList nl,
                                   java.lang.String expr)
                            throws org.xml.sax.SAXNotSupportedException

      The dyn:min function calculates the minimum value for the nodes passed as the first argument, where the value of each node is calculated dynamically using an XPath expression passed as a string as the second argument.

      The expressions are evaluated relative to the nodes passed as the first argument. In other words, the value for each node is calculated by evaluating the XPath expression with all context information being the same as that for the call to the dyn:min function itself, except for the following:

      - the context node is the node whose value is being calculated.
      - the context position is the position of the node within the node set passed as the first argument to the dyn:min function, arranged in document order.
      - the context size is the number of nodes passed as the first argument to the dyn:min function.

      The dyn:min function returns the minimum of these values, calculated in exactly the same way as for math:min.

      If the expression string passed as the second argument is an invalid XPath expression (including an empty string), this function returns NaN.

      This function must take a second argument. To calculate the minimum of a set of nodes based on their string values, you should use the math:min function.

      Parameters:
        `myContext` - The ExpressionContext passed by the extension processor
        `nl` - The node set
        `expr` - The expression string
      Returns:
        The minimum evaluation value
      Throws:
        `org.xml.sax.SAXNotSupportedException`

    - #### sum

          public static double sum(ExpressionContext myContext,
                                   org.w3c.dom.NodeList nl,
                                   java.lang.String expr)
                            throws org.xml.sax.SAXNotSupportedException

      The dyn:sum function calculates the sum for the nodes passed as the first argument, where the value of each node is calculated dynamically using an XPath expression passed as a string as the second argument.

      The expressions are evaluated relative to the nodes passed as the first argument. In other words, the value for each node is calculated by evaluating the XPath expression with all context information being the same as that for the call to the dyn:sum function itself, except for the following:

      - the context node is the node whose value is being calculated.
      - the context position is the position of the node within the node set passed as the first argument to the dyn:sum function, arranged in document order.
      - the context size is the number of nodes passed as the first argument to the dyn:sum function.

      The dyn:sum function returns the sumimum of these values, calculated in exactly the same way as for sum.

      If the expression string passed as the second argument is an invalid XPath expression (including an empty string), this function returns NaN.

      This function must take a second argument. To calculate the sumimum of a set of nodes based on their string values, you should use the sum function.

      Parameters:
        `myContext` - The ExpressionContext passed by the extension processor
        `nl` - The node set
        `expr` - The expression string
      Returns:
        The sum of the evaluation value on each node
      Throws:
        `org.xml.sax.SAXNotSupportedException`

    - #### map

          public static org.w3c.dom.NodeList map(ExpressionContext myContext,
                                                 org.w3c.dom.NodeList nl,
                                                 java.lang.String expr)
                                          throws org.xml.sax.SAXNotSupportedException

      The dyn:map function evaluates the expression passed as the second argument for each of the nodes passed as the first argument, and returns a node set of those values.

      The expressions are evaluated relative to the nodes passed as the first argument. In other words, the value for each node is calculated by evaluating the XPath expression with all context information being the same as that for the call to the dyn:map function itself, except for the following:

      - The context node is the node whose value is being calculated.
      - the context position is the position of the node within the node set passed as the first argument to the dyn:map function, arranged in document order.
      - the context size is the number of nodes passed as the first argument to the dyn:map function.

      If the expression string passed as the second argument is an invalid XPath expression (including an empty string), this function returns an empty node set.

      If the XPath expression evaluates as a node set, the dyn:map function returns the union of the node sets returned by evaluating the expression for each of the nodes in the first argument. Note that this may mean that the node set resulting from the call to the dyn:map function contains a different number of nodes from the number in the node set passed as the first argument to the function.

      If the XPath expression evaluates as a number, the dyn:map function returns a node set containing one exsl:number element (namespace http://exslt.org/common) for each node in the node set passed as the first argument to the dyn:map function, in document order. The string value of each exsl:number element is the same as the result of converting the number resulting from evaluating the expression to a string as with the number function, with the exception that Infinity results in an exsl:number holding the highest number the implementation can store, and -Infinity results in an exsl:number holding the lowest number the implementation can store.

      If the XPath expression evaluates as a boolean, the dyn:map function returns a node set containing one exsl:boolean element (namespace http://exslt.org/common) for each node in the node set passed as the first argument to the dyn:map function, in document order. The string value of each exsl:boolean element is 'true' if the expression evaluates as true for the node, and '' if the expression evaluates as false.

      Otherwise, the dyn:map function returns a node set containing one exsl:string element (namespace http://exslt.org/common) for each node in the node set passed as the first argument to the dyn:map function, in document order. The string value of each exsl:string element is the same as the result of converting the result of evaluating the expression for the relevant node to a string as with the string function.

      Parameters:
        `myContext` - The ExpressionContext passed by the extension processor
        `nl` - The node set
        `expr` - The expression string
      Returns:
        The node set after evaluation
      Throws:
        `org.xml.sax.SAXNotSupportedException`

    - #### evaluate

          public static XObject evaluate(ExpressionContext myContext,
                                         java.lang.String xpathExpr)
                                  throws org.xml.sax.SAXNotSupportedException

      The dyn:evaluate function evaluates a string as an XPath expression and returns the resulting value, which might be a boolean, number, string, node set, result tree fragment or external object. The sole argument is the string to be evaluated.

      If the expression string passed as the second argument is an invalid XPath expression (including an empty string), this function returns an empty node set.

      You should only use this function if the expression must be constructed dynamically, otherwise it is much more efficient to use the expression literally.

      Parameters:
        `myContext` - The ExpressionContext passed by the extension processor
        `xpathExpr` - The XPath expression string
      Returns:
        The evaluation result
      Throws:
        `org.xml.sax.SAXNotSupportedException`

    - #### closure

          public static org.w3c.dom.NodeList closure(ExpressionContext myContext,
                                                     org.w3c.dom.NodeList nl,
                                                     java.lang.String expr)
                                              throws org.xml.sax.SAXNotSupportedException

      The dyn:closure function creates a node set resulting from transitive closure of evaluating the expression passed as the second argument on each of the nodes passed as the first argument, then on the node set resulting from that and so on until no more nodes are found. For example:

            dyn:closure(., '*')

      returns all the descendant elements of the node (its element children, their children, their children's children and so on).

      The expression is thus evaluated several times, each with a different node set acting as the context of the expression. The first time the expression is evaluated, the context node set is the first argument passed to the dyn:closure function. In other words, the node set for each node is calculated by evaluating the XPath expression with all context information being the same as that for the call to the dyn:closure function itself, except for the following:

      - the context node is the node whose value is being calculated.
      - the context position is the position of the node within the node set passed as the first argument to the dyn:closure function, arranged in document order.
      - the context size is the number of nodes passed as the first argument to the dyn:closure function.
      - the current node is the node whose value is being calculated.

      The result for a particular iteration is the union of the node sets resulting from evaluting the expression for each of the nodes in the source node set for that iteration. This result is then used as the source node set for the next iteration, and so on. The result of the function as a whole is the union of the node sets generated by each iteration.

      If the expression string passed as the second argument is an invalid XPath expression (including an empty string) or an expression that does not return a node set, this function returns an empty node set.

      Parameters:
        `myContext` - The ExpressionContext passed by the extension processor
        `nl` - The node set
        `expr` - The expression string
      Returns:
        The node set after evaluation
      Throws:
        `org.xml.sax.SAXNotSupportedException`

Copyright © 2023 Apache XML Project. All Rights Reserved.