How to use openrosa-xpath-evaluator - 2 common examples

To help you get started, we’ve selected a few openrosa-xpath-evaluator examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github enketo / enketo-core / src / js / xpath-evaluator-binding.js View on Github external
export default function( addExtensions ) {
    const evaluator = new XPathJS.XPathEvaluator();

    /*
     * Note: it's inefficient to extend XPathJS here (for every model instance)
     * instead of just once in the prototype.
     *
     * However, this is done to prevent breaking Medic Mobile.
     * The performance impact is probably negligible, since we don't instantiate
     * models very often.
     *
     * In any case, you don't have to use it like this. It was done for
     * Enketo Validate only. In an app that doesn't override enketo-xpathjs,
     * I'd recommend using `require('extension')(require('enketo-xpathjs'))` instead
     * and leave the addExtensions parameter empty here.
     */
    if ( typeof addExtensions === 'function' ) {
        addExtensions( XPathJS );
github enketo / enketo-core / src / js / xpath-evaluator-binding.js View on Github external
* instead of just once in the prototype.
     *
     * However, this is done to prevent breaking Medic Mobile.
     * The performance impact is probably negligible, since we don't instantiate
     * models very often.
     *
     * In any case, you don't have to use it like this. It was done for
     * Enketo Validate only. In an app that doesn't override enketo-xpathjs,
     * I'd recommend using `require('extension')(require('enketo-xpathjs'))` instead
     * and leave the addExtensions parameter empty here.
     */
    if ( typeof addExtensions === 'function' ) {
        addExtensions( XPathJS );
    }

    XPathJS.bindDomLevel3XPath( this.xml, {
        'window': {
            JsXPathException: true,
            JsXPathExpression: true,
            JsXPathNSResolver: true,
            JsXPathResult: true,
            JsXPathNamespace: true
        },
        'document': {
            jsCreateExpression( ...args ) {
                return evaluator.createExpression( ...args );
            },
            jsCreateNSResolver( ...args ) {
                return evaluator.createNSResolver( ...args );
            },
            jsEvaluate( ...args ) {
                return evaluator.evaluate( ...args );

openrosa-xpath-evaluator

Wrapper for browsers' XPath evaluator with added support for OpenRosa extensions.

Apache-2.0
Latest version published 5 months ago

Package Health Score

73 / 100
Full package analysis