Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
evaluateXPathToBoolean(
`
declare namespace test = "test";
declare function test:test () as xs:string {
<element>XXX</element>
};
let $ret := test:test()
return $ret instance of xs:string and $ret = "XXX"
`,
null,
null,
null,
{
language: evaluateXPath.XQUERY_3_1_LANGUAGE,
nodesFactory: documentNode
}
),
true
);
});
it('can create an attribute with asynchronous', async () => {
const attribute = await evaluateXPathToAsyncSingleton(
`
declare namespace fontoxpath="http://fontoxml.com/fontoxpath";
attribute {fontoxpath:sleep("attr", 100)} {fontoxpath:sleep("val", 100)}`,
documentNode,
undefined,
{},
{ language: evaluateXPath.XQUERY_3_1_LANGUAGE }
);
chai.assert.equal(attribute.nodeType, 2);
chai.assert.equal(attribute.name, 'attr');
chai.assert.equal(attribute.value, 'val');
});
});
it('xs:QName() with prefix declared in an element constructor', () => {
chai.assert.isTrue(
evaluateXPathToBoolean(
'{xs:QName("prefix:abc")}',
documentNode,
null,
null,
{ language: evaluateXPath.XQUERY_3_1_LANGUAGE }
)
);
});
it('xs:QName() with unknown prefix', () =>
it('returns the root of the given constructed element', () =>
chai.assert.isTrue(
evaluateXPathToBoolean(
`
let $element := ,
$node := $element//node
return root($node) = $element`,
documentNode,
null,
null,
{ language: evaluateXPath.XQUERY_3_1_LANGUAGE }
)
));
it('defined prefixless variables in the empty namespace', () => {
chai.assert.isTrue(
evaluateXPathToBoolean(
'<element xmlns="XXX">{let $x := "A" return $Q{}x}</element> = "A"',
documentNode,
null,
null,
{ language: evaluateXPath.XQUERY_3_1_LANGUAGE }
)
);
});
});
it('allows external variables with defaults and external parameters', () => {
chai.assert.equal(
evaluateXPathToString(
`declare variable $nxa as xs:integer external := 10;
{$nxa}`,
documentNode,
undefined,
{ nxa: 33 },
{ language: evaluateXPath.XQUERY_3_1_LANGUAGE }
),
'33'
);
});
it('sorts //text() across different levels correctly', () => {
chai.assert.equal(
evaluateXPathToString(
'let $dom := Wilheit, T. T., 1986: Some comments on passive microwave measurement of rain. <source>Bull. Amer. Meteor. Soc., 67, 1226–1232, doi:10.1175/1520-0477(1986)067<1226:SCOPMM>2.0.CO;2 return $dom//text() => string-join("~~")',
documentNode,
null,
null,
{ language: evaluateXPath.XQUERY_3_1_LANGUAGE }
),
'Wilheit~~, ~~T. T.~~, ~~1986~~: ~~Some comments on passive microwave measurement of rain.~~Bull. Amer. Meteor. Soc.~~, ~~67~~, ~~1226~~–~~1232~~, doi:~~10.1175/1520-0477(1986)067<1226:SCOPMM>2.0.CO;2'
);
});
it('can declare a namespace', () => {
const result = evaluateXPath(
`
declare namespace prrt = "http://www.w3.org/2005/xpath-functions";
prrt:true()
`,
null,
null,
null,
null,
{ language: evaluateXPath.XQUERY_3_1_LANGUAGE });
chai.assert.equal(result, true);
});
});
it('can create a PI with asynchronous', async () => {
chai.assert.equal(
(
await evaluateXPathToAsyncSingleton(
`
declare namespace fontoxpath="http://fontoxml.com/fontoxpath";
processing-instruction {fontoxpath:sleep("my-pi",100)} {fontoxpath:sleep("data", 100)}`,
documentNode,
undefined,
{},
{ language: evaluateXPath.XQUERY_3_1_LANGUAGE }
)
).nodeType,
7
);
});
});
() =>
evaluateXPathToBoolean(
'declare default function namespace "http://www.w3.org/XML/1998/namespace"; declare %private function lt() as item()*{ true() }; Q{"http://www.w3.org/XML/1998/namespace"}lt()',
documentNode,
undefined,
{},
{ language: evaluateXPath.XQUERY_3_1_LANGUAGE }
),
'XQST0070: The prefixes xml and xmlns may not be used in a namespace declaration or be bound to another namespaceURI.'