Type: Function

How to get evaluateXPathToArray?


import evaluateXPathToArray from 'fontoxml-selectors/src/evaluateXPathToArray.js'

Resolve to a JSON array using an algorithm inspired by {@link https://www.w3.org/TR/xslt-xquery-serialization-31/#json-output XQuery serialization to JSON}.

The following transformations are used:

  • XPath arrays (the item created using the array{...} or [...] syntaxes) are transformed

to JavaScript arrays,

  • Maps to JavaScript objects, the keys are converted to strings. If this means a duplicate

key occurs, an error is thrown,

  • Nodes are outputted as nodes,

  • Numbers, booleans and strings are outputted as their JavaScript counterparts,

  • Zero length sequences are the null value,

  • Sequences with a length greater than 1 cause an error.

You can also use functions defined in XQuery modules. Refer to the concept page of XQuery for details. While XQuery update facility is allowed, mutating existing nodes is not allowed. Use the execute-update-script operation to mutate the document using XQUF.


  1. xquery


    The XQuery script to evaluate

  2. contextNode


    Type: Node | NULL

    The initial context of the query. If context is absent, it is still possible to evaluate some queries, like '1+1', or queries using only variables.

  3. domFacade


    Type: Blueprint

    The blueprint (or blueprint compatible interface) to use for this query.

  4. variables


    Type: Object<String, any>

    Any variables to use for this query. They will be prefixed with a '$' sign See https://github.com/FontoXML/fontoxpath for more info on this parameter.

    Default value

  5. options


    Type: Object<String, any>

    See https://github.com/FontoXML/fontoxpath for more info on this parameter.


    Default value


The result of the query.