How to use the fontoxpath.evaluateXPathToMap 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 / qt3tests.ts View on Github external
[evaluateXPathToString('@role', variable).substr(1)]: getFile(
					(cwd ? cwd + '/' : '') + evaluateXPathToString('@file', variable)
				)
			}),
		{}
	);

	// Params area also variables. But different
	evaluateXPathToNodes('param', environmentNode).forEach(paramNode => {
		variables[evaluateXPathToString('@name', paramNode)] = evaluateXPath(
			evaluateXPathToString('@select', paramNode)
		);
		console.log(variables);
	});

	const namespaces = evaluateXPathToMap(
		'(namespace!map:entry(@prefix/string(), @uri/string())) => map:merge()',
		environmentNode
	);

	return {
		contextNode: fileName ? getFile((cwd ? cwd + '/' : '') + fileName) : null,
		variables,
		namespaceResolver: Object.keys(namespaces).length ? prefix => namespaces[prefix] : null
	};
}
github FontoXML / fontoxpath / test / specs / parsing / axes / PrecedingAxis.tests.js View on Github external
it('returns all the preceding nodes', () => {
		const result = evaluateXPathToMap(
				`
let $dom := <element>
	
		
			
		
	
	
		
			
		
		
			
		
		
			</element>
github FontoXML / fontoxpath / test / specs / parsing / axes / PrecedingAxis.tests.ts View on Github external
it('returns all the preceding nodes', () =&gt; {
		const result = evaluateXPathToMap(
			`
let $dom := <element>
	
		
			
		
	
	
		
			
		
		
			
		
		
			</element>
github FontoXML / fontoxpath / test / specs / parsing / functions / functions.json.tests.ts View on Github external
it('can parse json objects', () =>
		chai.assert.deepEqual(
			evaluateXPathToMap('parse-json("{""a"": 1}")', documentNode, domFacade),
			{ a: 1 }
		));
github FontoXML / fontoxpath / test / specs / parsing / maps / mapFunctions.tests.ts View on Github external
it('does nothing if the key is not present', () =>
			chai.assert.deepEqual(evaluateXPathToMap('map:remove(map{"a":1}, "b")', documentNode), {
				a: 1
			}));
github FontoXML / fontoxpath / test / specs / parsing / maps / mapFunctions.tests.ts View on Github external
it('replaces the old value', () =>
			chai.assert.deepEqual(
				evaluateXPathToMap('map{"a": 1} => map:put("a", 2)', documentNode),
				{ a: 2 }
			));
github FontoXML / fontoxpath / test / specs / parsing / maps / MapConstructor.tests.js View on Github external
		() => chai.assert.isOk(evaluateXPathToMap('map {"a": 1, "b":2}', documentNode)), 'It should be able to be parsed');
github FontoXML / fontoxpath / test / specs / parsing / maps / MapConstructor.tests.js View on Github external
		() => chai.assert.deepEqual(evaluateXPathToMap('map {*: 1}', documentNode), { 'A piece of text': 1 }));
github FontoXML / fontoxpath / test / specs / parsing / evaluateXPath.tests.ts View on Github external
			chai.assert.throws(() => evaluateXPathToMap('map{1:(2,3)}'), 'Serialization error');
		});
github FontoXML / fontoxpath / test / qt3testsXQueryX.ts View on Github external
async function getXQueries(directory, testName) {
		const testDirectory = path.join(baseDir, directory);
		const testFilePath = path.join(testDirectory, testName) + '.xml';
		if (!testFs.existsSync(testFilePath)) {
			return null;
		}

		const xml = sync(await testFs.readFile(testFilePath));
		const xQueries = evaluateXPathToMap(
			'(/descendant::test-case/map:entry(@name, (test/@file/string(), test/string())[1])) => map:merge()',
			xml
		);

		for (const key of Object.keys(xQueries)) {
			const value = xQueries[key];

			if (value.substring(value.length - 3) === '.xq') {
				const xQueryPath = path.join(testDirectory, value);
				if (testFs.existsSync(xQueryPath)) {
					xQueries[key] = normalizeEndOfLines(await testFs.readFile(xQueryPath));
				} else {
					xQueries[key] = null;
				}
			} else {
				xQueries[key] = normalizeEndOfLines(value);