How to use the fontoxpath.evaluateXPathToBoolean 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 / xqutsTests.ts View on Github external
const actualOuterHTML =
		actual.nodeType === actual.DOCUMENT_NODE
			? actual.documentElement.outerHTML
			: actual.outerHTML;
	const expectedOuterHTML =
		expected.nodeType === expected.DOCUMENT_NODE
			? expected.documentElement.outerHTML
			: expected.outerHTML;

	// Try fast string compare
	if (actualOuterHTML === expectedOuterHTML) {
		return;
	}

	if (
		evaluateXPathToBoolean('deep-equal($a, $b)', null, null, {
			a: actual,
			b: expected
		})
	) {
		return;
	}

	// Do comparison on on outer HTML for clear fail message
	chai.assert.equal(actualOuterHTML, expectedOuterHTML);
}
github FontoXML / fontoxpath / test / xqutsTests.js View on Github external
function assertXml (actual, expected) {
	// actual.normalize();
	expected.normalize();

	const actualOuterHTML = actual.nodeType === actual.DOCUMENT_NODE ? actual.documentElement.outerHTML : actual.outerHTML;
	const expectedOuterHTML = expected.nodeType === expected.DOCUMENT_NODE ? expected.documentElement.outerHTML : expected.outerHTML;

	// Try fast string compare
	if (actualOuterHTML === expectedOuterHTML) {
		return;
	}

	if (evaluateXPathToBoolean('deep-equal($a, $b)', null, null, {
		a: actual,
		b: expected
	})) {
		return;
	}

	// Do comparison on on outer HTML for clear fail message
	chai.assert.equal(actualOuterHTML, expectedOuterHTML);
}
github FontoXML / fontoxpath / test / specs / parsing / operators / compares / Compare.tests.ts View on Github external
it('returns false if the first operand is equal to the second', () => {
			chai.assert.isFalse(evaluateXPathToBoolean('1 lt 1'));
		});
github FontoXML / fontoxpath / test / specs / parsing / operators / numeric / Unary.tests.ts View on Github external
it('returns a float when given a float', () =>
		chai.assert.isTrue(
			evaluateXPathToBoolean('-(xs:float("1.5")) instance of xs:float', documentNode)
		));
github FontoXML / fontoxpath / test / specs / parsing / operators / castOperator.tests.ts View on Github external
it('can cast strings to integers: "123"', () =>
			chai.assert.isTrue(
				evaluateXPathToBoolean(
					'let $r := "123" cast as xs:integer return $r instance of xs:integer and $r = 123'
				)
			));
		it('can cast decimals to integers: 123.2', () =>
github FontoXML / fontoxpath / test / specs / parsing / operators / numeric / BinaryOperator.tests.js View on Github external
			() => chai.assert.isTrue(evaluateXPathToBoolean('xs:dayTimeDuration("P4DT26H") + xs:dayTimeDuration("P4DT26H") eq xs:dayTimeDuration("P10DT4H")', documentNode)));
		it('can evaluate "P4DT28H" - "P4DT26H"',
github FontoXML / fontoxpath / test / specs / parsing / operators / numeric / BinaryOperator.tests.ts View on Github external
it('can evaluate "P11Y10M" * 2', () =>
			chai.assert.isTrue(
				evaluateXPathToBoolean(
					'xs:yearMonthDuration("P1Y10M") * xs:double("2") eq xs:yearMonthDuration("P44M")',
					documentNode
				)
			));
		it('can evaluate "P11Y10M" div 2', () =>
github FontoXML / fontoxpath / test / specs / parsing / functions / builtInFunctions.dataTypeConstructors.tests.ts View on Github external
it('xs:unsignedLong()', () =>
		chai.assert.isTrue(
			evaluateXPathToBoolean(
				'xs:unsignedLong("10") instance of xs:unsignedLong+',
				documentNode
			)
		));
	it('xs:unsignedInt()', () =>
github FontoXML / fontoxpath / test / specs / parsing / operators / castOperator.tests.ts View on Github external
it('can cast doubles to strings: INF', () =>
				chai.assert.isTrue(
					evaluateXPathToBoolean(
						'let $r := xs:double("INF") cast as xs:string return $r instance of xs:string and $r = "INF"'
					)
				));
			it('can cast doubles to strings: -INF', () =>
github FontoXML / fontoxpath / test / specs / parsing / xquery / DefaultFunctionNamespace.tests.ts View on Github external
() =>
				evaluateXPathToBoolean(
					'declare default function namespace "http://example.com"; declare default function namespace "http://example.com"; declare %private function lt() as item()*{ true() }; Q{http://example.com}lt()',
					documentNode,
					undefined,
					{},
					{ language: evaluateXPath.XQUERY_3_1_LANGUAGE }
				),
			'XQST0066: A Prolog may contain at most one default function namespace declaration.'