fontoxpath
Advanced tools
Comparing version 3.10.0 to 3.11.0
@@ -511,12 +511,9 @@ | ||
/** | ||
* Defines the factory methods used in XQuery. Basically equivalent to the Document interface, but | ||
* with the 'createDocument' factory method added. | ||
* | ||
* @public | ||
*/ | ||
export declare interface INodesFactory { | ||
createAttributeNS(namespaceURI: string, name: string): Attr; | ||
createCDATASection(contents: string): CDATASection; | ||
createComment(contents: string): Comment; | ||
export declare interface INodesFactory extends ISimpleNodesFactory { | ||
createDocument(): Document; | ||
createElementNS(namespaceURI: string, name: string): Element; | ||
createProcessingInstruction(target: string, data: string): ProcessingInstruction; | ||
createTextNode(contents: string): Text; | ||
} | ||
@@ -544,4 +541,19 @@ | ||
/** | ||
* Subset of the constructor methods present on Document. Can be used to create textnodes, elements, | ||
* attributes, CDataSecions, comments and processing instructions. | ||
* | ||
* @public | ||
*/ | ||
export declare interface ISimpleNodesFactory { | ||
createAttributeNS(namespaceURI: string, name: string): Attr; | ||
createCDATASection(contents: string): CDATASection; | ||
createComment(contents: string): Comment; | ||
createElementNS(namespaceURI: string, name: string): Element; | ||
createProcessingInstruction(target: string, data: string): ProcessingInstruction; | ||
createTextNode(contents: string): Text; | ||
} | ||
/** | ||
* @public | ||
*/ | ||
export declare enum Language { | ||
@@ -556,2 +568,9 @@ XPATH_3_1_LANGUAGE = "XPath3.1", | ||
*/ | ||
export declare type Logger = { | ||
trace: (message: string) => void; | ||
}; | ||
/** | ||
* @public | ||
*/ | ||
export declare type Node = { | ||
@@ -567,5 +586,6 @@ nodeType: number; | ||
debug?: boolean; | ||
disableCache?: boolean; | ||
documentWriter?: IDocumentWriter; | ||
disableCache?: boolean; | ||
language?: Language; | ||
logger?: Logger; | ||
moduleImports?: { | ||
@@ -579,2 +599,41 @@ [s: string]: string; | ||
/** | ||
* Parse an XPath or XQuery script and output it as an XQueryX element. Refer to the [XQueryX | ||
* spec](https://www.w3.org/TR/xqueryx-31/) for more info. | ||
* | ||
* The precise generated XQueryX may change in the future when progress is made on supporting the | ||
* XQueryX test set provided with the [QT3 test suite](https://dev.w3.org/2011/QT3-test-suite/). | ||
* | ||
* @example | ||
* Parse "self::element" to an XQueryX element and access it | ||
* ``` | ||
* const xqueryx = parseScript( | ||
* 'self::element', | ||
* { | ||
* language: evaluateXPath.XPATH_3_1_LANGUAGE | ||
* }, | ||
* new slimdom.Document() | ||
* ); | ||
* | ||
* // Get the nametest element | ||
* const nameTestElement = evaluateXPathToFirstNode( | ||
* '//Q{http://www.w3.org/2005/XQueryX}nameTest', | ||
* xqueryx) | ||
* ``` | ||
* | ||
* @public | ||
* | ||
* @param script - The script to parse | ||
* | ||
* @param options - Additional options for parsing. Can be used to switch between parsing XPath or | ||
* XQuery update facility | ||
* | ||
* @param simpleNodesFactory - A NodesFactory will be used to create the DOM. This can be a | ||
* reference to the document in which the XQueryX will be created | ||
* | ||
* @param documentWriter - The documentWriter will be used to append children to the newly created | ||
* dom | ||
*/ | ||
export declare function parseScript<TElement extends Element>(script: string, options: Options, simpleNodesFactory: ISimpleNodesFactory, documentWriter?: IDocumentWriter): TElement; | ||
/** | ||
* Precompile an XPath selector asynchronously. | ||
@@ -658,2 +717,3 @@ * | ||
documentWriter?: IDocumentWriter; | ||
logger?: Logger; | ||
moduleImports?: { | ||
@@ -660,0 +720,0 @@ [s: string]: string; |
{ | ||
"name": "fontoxpath", | ||
"version": "3.10.0", | ||
"version": "3.11.0", | ||
"description": "A minimalistic XPath 3.1 engine in JavaScript", | ||
@@ -11,16 +11,18 @@ "main": "dist/fontoxpath.js", | ||
"scripts": { | ||
"prepare": "npm run build", | ||
"build": "npm run lint && node ./build.js", | ||
"start": "concurrently -k -p \"[{name}]\" -n \"TypeScript,Node\" \"tsc -p ./demo/tsconfig.json -w\" \"ts-node ./demo/server.ts --dist\"", | ||
"test": "ts-mocha --require test/testhook.js \"test/specs/**/*.ts\" --extension ts", | ||
"alltests": "ts-mocha --paths -p test/tsconfig.json \"test/specs/**/*.ts\" test/qt3tests.ts test/qt3testsXQueryX.ts test/xqutsTests.ts test/xqutsTestsXQueryX.ts", | ||
"build": "node ./build.js", | ||
"ci-qt3tests": "cross-env TS_NODE_PROJECT=test/tsconfig.json nyc --no-clean --require ts-node/register --require tsconfig-paths/register mocha --paths -p test/tsconfig.json test/qt3tests.ts", | ||
"ci-qt3testsxqueryx": "cross-env TS_NODE_PROJECT=test/tsconfig.json nyc --no-clean --require ts-node/register --require tsconfig-paths/register mocha --paths -p test/tsconfig.json test/qt3testsXQueryX.ts", | ||
"ci-test": "cross-env TS_NODE_PROJECT=test/tsconfig.json nyc --no-clean --require ts-node/register --require tsconfig-paths/register mocha \"test/specs/**/*.ts\" -p test/tsconfig.json", | ||
"ci-xqutstests": "cross-env TS_NODE_PROJECT=test/tsconfig.json nyc --no-clean --require ts-node/register --require tsconfig-paths/register mocha --paths -p test/tsconfig.json test/xqutsTests.ts", | ||
"ci-xqutstestsxqueryx": "cross-env TS_NODE_PROJECT=test/tsconfig.json nyc --no-clean --require ts-node/register --require tsconfig-paths/register mocha --paths -p test/tsconfig.json test/xqutsTestsXQueryX.ts", | ||
"coverage": "nyc report --reporter=text-lcov | coveralls", | ||
"integrationtests": "ts-mocha --require test/testhook.js \"test/specs/parsing/**/*.ts\" -p test/tsconfig.json", | ||
"prepare": "npm run build", | ||
"qt3tests": "ts-mocha --paths -p test/tsconfig.json test/qt3tests.ts", | ||
"ci-qt3tests": "cross-env TS_NODE_PROJECT=test/tsconfig.json nyc --no-clean --require ts-node/register --require tsconfig-paths/register mocha --paths -p test/tsconfig.json test/qt3tests.ts", | ||
"qt3testsxqueryx": "ts-mocha --paths -p test/tsconfig.json test/qt3testsXQueryX.ts", | ||
"start": "concurrently -k -p \"[{name}]\" -n \"TypeScript,Node\" \"tsc -p ./demo/tsconfig.json -w\" \"ts-node ./demo/server.ts --dist\"", | ||
"test": "ts-mocha --require test/testhook.js \"test/specs/**/*.ts\" --extension ts", | ||
"xqutstests": "ts-mocha --paths -p test/tsconfig.json test/xqutsTests.ts", | ||
"ci-xqutstests": "cross-env TS_NODE_PROJECT=test/tsconfig.json nyc --no-clean --require ts-node/register --require tsconfig-paths/register mocha --paths -p test/tsconfig.json test/xqutsTests.ts", | ||
"xqutstestsxqueryx": "ts-mocha --paths -p test/tsconfig.json test/xqutsTestsXQueryX.ts", | ||
"coverage": "nyc report --reporter=text-lcov | coveralls", | ||
"alltests": "ts-mocha --paths -p test/tsconfig.json \"test/specs/**/*.ts\" test/qt3tests.ts test/qt3testsXQueryX.ts test/xqutsTests.ts test/xqutsTestsXQueryX.ts", | ||
"lint": "tslint \"./src/**/*.ts\" --project . && prettier \"./src/**/*.ts\" --list-different" | ||
@@ -27,0 +29,0 @@ }, |
@@ -54,2 +54,4 @@ # fontoxpath [](https://travis-ci.org/FontoXML/fontoxpath) [](https://david-dm.org/FontoXML/fontoxpath#info=devDependencies) [](http://badge.fury.io/js/fontoxpath) [](https://greenkeeper.io/) [](https://packagephobia.now.sh/result?p=fontoxpath) [](https://coveralls.io/github/FontoXML/fontoxpath?branch=master) | ||
* `debug` `<boolean>` If a debug trace should be tracked, see [debugging](#debugging) for more information. | ||
* `logger` `<Object>` Object with functions used to override the standard logger. | ||
* `trace: <function(string):void>` The logger for the `trace()` function. The argument is the string of the original message. | ||
@@ -56,0 +58,0 @@ ### Example |
Sorry, the diff of this file is too big to display
974980
2264
209