How to use the fontoxpath.evaluateXPath function in fontoxpath

To help you get started, we’ve selected a few fontoxpath 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 FontoXML / fontoxpath / test / specs / parsing / registerCustomXPathFunction.tests.ts View on Github external
it('Passes xs:gDay as a javascript date', () => {
			evaluateXPath('test:custom-gDay-param-function(xs:gDay("---29"))');
		});
	});
github FontoXML / fontoxpath / test / specs / parsing / registerXQueryModule.tests.js View on Github external
it('Can declare a function in a module and use the module from an XPath', () => {
		registerXQueryModule(`
module namespace test = "https://www.example.org/test1";

declare %public function test:hello($a) {
   "Hello " || $a
};
`);

		const result = evaluateXPath(
			'test:hello("World")',
			null,
			null,
			null,
			null,
			{
				moduleImports: {
					test: 'https://www.example.org/test1'
				}
			});

		chai.assert.equal(result, 'Hello World');
	});
github FontoXML / fontoxpath / test / specs / parsing / asyncXPath.tests.js View on Github external
it('can run XPath expressions asynchronously', async () => {
		const items = [];
		const it = evaluateXPath('fontoxpath:sleep((), 10)', null, null, null, evaluateXPath.ASYNC_ITERATOR_TYPE);

		for (let value = await it.next(); !value.done; value = await it.next()) {
			items.push(value.value);
		}

		chai.assert(items.length === 0);
	});
github FontoXML / fontoxpath / test / specs / parsing / asyncXPath.tests.js View on Github external
it('can resolve async results', async () => {
		const items = [];
		const it = evaluateXPath('fontoxpath:sleep(true(), 10)', null, null, null, evaluateXPath.ASYNC_ITERATOR_TYPE);

		for (let value = await it.next(); !value.done; value = await it.next()) {
			items.push(value.value);
		}

		chai.assert(items.length === 1);
		chai.assert(items[0] === true);
	});
github FontoXML / fontoxpath / test / specs / parsing / registerCustomXPathFunction.tests.ts View on Github external
it('Passes xs:gYear as a javascript date', () => {
			evaluateXPath('test:custom-gYear-param-function(xs:gYear("2019"))');
		});
		it('Passes xs:gMonthDay as a javascript date', () => {
github FontoXML / fontoxpath / test / specs / parsing / evaluateXPath.tests.ts View on Github external
it('Can evaluate intermediately updating expressions', () =>
		chai.assert.equal(
			evaluateXPath(
				'copy $ele := <element> modify insert node text{"test"} into $ele return $ele',
				documentNode,
				domFacade,
				null,
				evaluateXPath.FIRST_NODE_TYPE,
				{ language: evaluateXPath.XQUERY_UPDATE_3_1_LANGUAGE }
			).outerHTML,
			'<element>test</element>'
		));
</element>
github FontoXML / fontoxpath / test / specs / parsing / registerXQueryModule.tests.ts View on Github external
registerXQueryModule(`
module namespace test = "https://www.example.org/test3/submodule";
declare %public function test:hello ($a) {
  "Hello " || $a
};
`);
		registerXQueryModule(`
module namespace test = "https://www.example.org/test3/mainModule";
import module namespace submodule = "https://www.example.org/test3/submodule";

declare %public function test:hello ($a) {
  submodule:hello($a) || "!!!"
};
`);

		const result = evaluateXPath('test:hello("World")', null, null, null, null, {
			moduleImports: {
				test: 'https://www.example.org/test3/mainModule'
			}
		});

		chai.assert.equal(result, 'Hello World!!!');
	});
github FontoXML / fontoxpath / test / specs / parsing / evaluateXPath.tests.ts View on Github external
			() => evaluateXPath('fontoxpath:sleep(())', documentNode, domFacade),
			'can not be resolved synchronously'
github FontoXML / fontoxpath / test / specs / parsing / debug / stackTrace.tests.ts View on Github external
() =>
				evaluateXPath(
					`if (true()) then
  [] and 1
else
  (1, 2, 3)`,
					null,
					null,
					null,
					null,
					{ debug: true }
				),
			`1: if (true()) then
github FontoXML / fontoxpath / test / xqutsTests.ts View on Github external
async function assertError(expectedError, args: ExpressionArguments, isUpdating) {
	let hasThrown = false;
	try {
		if (isUpdating) {
			const it = evaluateUpdatingExpressionSync(...args);
			executePul(it.pendingUpdateList, args);
		} else {
			evaluateXPath(args[0], args[1], args[2], args[3], null, args[4]);
		}
	} catch (e) {
		hasThrown = true;
		chai.assert.match(e.message, new RegExp(expectedError));
	}
	if (!hasThrown) {
		chai.assert.fail(null, null, `Should throw error ${expectedError}.`);
	}
}