Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

array(xs:string) not recognized as a type by registerCustomXPathFunction #360

Open
rrthomas opened this issue May 28, 2021 · 2 comments
Open

Comments

@rrthomas
Copy link
Contributor

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!

@DrRataplan
Copy link
Collaborator

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

@rrthomas
Copy link
Contributor Author

@DrRataplan, yes indeed, array(*) is an OK workaround for me; thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants