How to use the fontoxpath/expressions/adaptJavaScriptValueToXPathValue 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 / expressions / adaptJavaScriptValueToXPathValue.tests.ts View on Github external
it('turns numbers into doubles', () => {
		const xpathSequence = adaptJavaScriptValueToXPathValue(1.0, 'xs:double');
		chai.assert(xpathSequence.isSingleton(), 'is a singleton sequence');
		chai.assert(xpathSequence.first().type === 'xs:double', 'is a double');
		chai.assert.equal(xpathSequence.first().value, 1.0, 'is 1.0');
	});
github FontoXML / fontoxpath / test / specs / expressions / adaptJavaScriptValueToXPathValue.tests.ts View on Github external
it('turns numbers into integers', () => {
		const xpathSequence = adaptJavaScriptValueToXPathValue(1, 'xs:integer');
		chai.assert(xpathSequence.isSingleton(), 'is a singleton sequence');
		chai.assert(xpathSequence.first().type === 'xs:integer', 'is an integer');
		chai.assert.equal(xpathSequence.first().value, 1, 'is 1');
	});
github FontoXML / fontoxpath / test / specs / expressions / adaptJavaScriptValueToXPathValue.tests.ts View on Github external
it('turns date into xs:gYearMonth', () => {
		const xpathSequence = adaptJavaScriptValueToXPathValue(
			new Date(Date.UTC(2018, 5, 22, 9, 10, 20)),
			'xs:gYearMonth'
		);
		chai.assert(xpathSequence.isSingleton(), 'is a singleton sequence');
		chai.assert(xpathSequence.first().type === 'xs:gYearMonth', 'is a gYearMonth');
		chai.assert.deepEqual(
			xpathSequence.first().value,
			DateTime.fromString('2018-06Z'),
			'is June 2018'
		);
	});
github FontoXML / fontoxpath / test / specs / expressions / adaptJavaScriptValueToXPathValue.tests.ts View on Github external
it('turns date into xs:time', () => {
		const xpathSequence = adaptJavaScriptValueToXPathValue(
			new Date(Date.UTC(2018, 5, 22, 9, 10, 20)),
			'xs:time'
		);
		chai.assert(xpathSequence.isSingleton(), 'is a singleton sequence');
		chai.assert(xpathSequence.first().type === 'xs:time', 'is a time');
		chai.assert.deepEqual(
			xpathSequence.first().value,
			DateTime.fromString('09:10:20Z'),
			'is 09:10:20'
		);
	});
github FontoXML / fontoxpath / test / specs / expressions / adaptJavaScriptValueToXPathValue.tests.ts View on Github external
it('turns nodes into nodes', () => {
		const xpathSequence = adaptJavaScriptValueToXPathValue(new slimdom.Document());
		chai.assert(xpathSequence.isSingleton(), 'is a singleton sequence');
		chai.assert(xpathSequence.first().type === 'document()', 'is a document');
	});
github FontoXML / fontoxpath / test / specs / expressions / adaptJavaScriptValueToXPathValue.tests.ts View on Github external
it('turns date into xs:gMonthDay', () => {
		const xpathSequence = adaptJavaScriptValueToXPathValue(
			new Date(Date.UTC(2018, 5, 22, 9, 10, 20)),
			'xs:gMonthDay'
		);
		chai.assert(xpathSequence.isSingleton(), 'is a singleton sequence');
		chai.assert(xpathSequence.first().type === 'xs:gMonthDay', 'is a gMonthDay');
		chai.assert.deepEqual(
			xpathSequence.first().value,
			DateTime.fromString('-06-22Z'),
			'is 22nd June'
		);
	});
github FontoXML / fontoxpath / test / specs / expressions / adaptJavaScriptValueToXPathValue.tests.ts View on Github external
it('turns strings into xs:string*', () => {
		const xpathSequence = adaptJavaScriptValueToXPathValue(['a', 'b', 'c'], 'xs:string*');
		chai.assert.equal(xpathSequence.tryGetLength().value, 3, 'is a sequence with length 3');
		const values = xpathSequence.getAllValues();
		chai.assert(xpathSequence.first().type === 'xs:string', 'first is a string');
		chai.assert(values[1].type === 'xs:string', 'second is a string');
		chai.assert(values[2].type === 'xs:string', 'third is a string');
		chai.assert.equal(xpathSequence.first().value, 'a', 'is a');
		chai.assert.equal(values[1].value, 'b', 'is b');
		chai.assert.equal(values[2].value, 'c', 'is c');
	});
github FontoXML / fontoxpath / test / specs / expressions / adaptJavaScriptValueToXPathValue.tests.ts View on Github external
it('can automatically convert booleans', () => {
			const xpathSequence = adaptJavaScriptValueToXPathValue(true, 'item()');
			chai.assert(xpathSequence.isSingleton(), 'is a singleton sequence');
			chai.assert(xpathSequence.first().type === 'xs:boolean', 'is a boolean');
			chai.assert.equal(xpathSequence.first().value, true, 'is true');
		});
github FontoXML / fontoxpath / test / specs / expressions / adaptJavaScriptValueToXPathValue.tests.ts View on Github external
it('can automatically convert objects', () => {
			const xpathSequence = adaptJavaScriptValueToXPathValue({}, 'item()');
			chai.assert(xpathSequence.isSingleton(), 'is a singleton sequence');
			chai.assert(xpathSequence.first().type === 'map(*)', 'is a map');
		});
github FontoXML / fontoxpath / test / specs / expressions / adaptJavaScriptValueToXPathValue.tests.ts View on Github external
it('can automatically convert null to the empty sequence', () => {
			const xpathSequence = adaptJavaScriptValueToXPathValue(null);
			chai.assert(xpathSequence.isEmpty(), 'is the empty sequence');
		});