`array(xs:string)` not recognized as a type by `registerCustomXPathFunction`
Slightly modifying the example code in the documentation:
const fontoxpath = require("fontoxpath")
// Register a function called 'there' in the 'hello' namespace:
fontoxpath.registerCustomXPathFunction({ namespaceURI: 'hello', localName: 'there' }, ['array(*)'], 'xs:string', (_, str) => `Hello there, ${str[0]}`);
// and call it, using the BracedUriLiteral syntax (Q{})
const out = fontoxpath.evaluateXPathToString('Q{hello}there(["General Kenobi"])');
console.log(out);
This works fine, but if I change array(*) to array(xs:string), I get the error:
Error: XPST0081: Invalid prefix for input array(xs:string)
This is with version 3.17.4; with 3.17.2 I got the slightly different:
Error: XPST0081: The type array(xs:string) could not be found.
Thanks so much for fontoxpath, it's saving me a great deal of work in Node-land!
Hey there,
Thanks for reaching out! What you are seeing is correct, we do not support the parameterized versions of types yet: such as function(xs:string) as xs:string, map(xs:integer) or array(xs:string). We usually 'work around' this by defaulting to more generic types: array(*) would be your work-around. Does this unblock you?
We are currently improving the type system to mainly perform better. After that is done, I will take a moment to see how we can best fit these parameterized types in the engine.
About the error you are getting. That is not a readable one. I will keep this issue open to address that.
Thanks so much for fontoxpath, it's saving me a great deal of work in Node-land!
Awesome, great to hear this! Thanks!
Regards,
Martin
@DrRataplan, yes indeed, array(*) is an OK workaround for me; thanks!