New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

fontoxpath

Package Overview
Dependencies
Maintainers
1
Versions
117
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fontoxpath

A minimalistic XPath 3.1 engine in JavaScript

  • 2.3.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
46K
increased by3.35%
Maintainers
1
Weekly downloads
 
Created
Source

fontoxpath Build Status devDependency Status

A minimalistic XPath 3.1 selector engine for (XML) nodes.

Demo page

How to use

let { evaluateXPathToBoolean, domFacade } = require('fontoxpath');
let documentNode = ...;
console.log(evaluateXPathToBoolean('true()', documentNode, domFacade)); // => true

FontoXPath supplies a number of API functions:

  • domFacade: A wrapper to the DOM. All DOM accesses should go through here
  • A number of evaluateXPath.* functions:
    • evaluateXPath(xpath: string, contextNode: Node, domFacade: DomFacade?, variables: Object={}, returnType: number) => *
    • evaluateXPathToNodes(xpath: string, contextNode: Node, domFacade: DomFacade?, variables: Object={}) => Node[]
    • evaluateXPathToFirstNode(xpath: string, contextNode: Node, domFacade: DomFacade?, variables: Object={}) => Node
    • evaluateXPathToBoolean(xpath: string, contextNode: Node, domFacade: DomFacade?, variables: Object={}) => boolean
    • evaluateXPathToNumber(xpath: string, contextNode: Node, domFacade: DomFacade?, variables: Object={}) => number
    • evaluateXPathToNumbers(xpath: string, contextNode: Node, domFacade: DomFacade?, variables: Object={}) => number[]
  • precompileXPath(xpath: string) => Promise<string>
    • A no-op on systems without indexedDB
  • registerCustomXPathFunction(name: string, signature: string[], returnType: string, callback: function)
    • Can be used to register custom functions. They are registered globally.

Features

Note that this engine assumes XPath 1.0 compatibility mode turned off.

Not all XPath 3.1 functions are implemented yet. We accept pull requests for missing features.

The following features are unavailable, but will be implemented at some point in time (and even sooner if you can help!):

  • DateTime related functions
  • Collation related functions (fn:compare#3)
  • The ? lookup operator for maps and arrays
  • XML parsing

The following features are available:

  • maps / arrays
  • variables using let
  • The ! bang operator
  • Most built in dataTypes

For all available features, see the unit tests.

Contribution

To recompile the parser, run the following:

npm install
npm run build [--skip_parser] [--skip_closure]

Note: Rebuilding the closure build depends on Java.

To run the tests, run

npm run test [--ci_mode] [--integration_tests]

The integration tests run all tests only using the externally public API, using the closure build.

QT3 tests

A basic test runner for the QT3 tests can be used by running npm run test --qt3 --integration_tests. For this, a recent version of the QT3 test set should be present at test/assets/.

Keywords

FAQs

Package last updated on 01 Jun 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc