Restricting XQuery to XPath

648 views Asked by At

I've got an app that manages collections of XML files and allows querying using XPath, to allow users to view subsets of collections that match an XPath query.

For various technical reasons, I'm switching to an XQuery engine. I understand that XQuery is a superset of XPath. However, I don't want full XQuery functionality because users may use it to construct new XML objects that don't match my DTD and can't be displayed by my SVG-based viewer.

Can I easily validate query strings as XPath and hand them off to the XQuery engine? Or can I convert them in a simple way?

(I'm using C++ and switching to XQilla.)

2

There are 2 answers

1
Fred Foo On BEST ANSWER

XQilla did turn out to have an XPath 2.0 parser, so I'm using that now.

3
Michael Kay On

If you can't find an XPath 2.0 parser that works in your environment, you could consider converting the query to XQueryX and running queries against it to check that it doesn't use any undesired features.