Restricting XQuery to XPath
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 XQue开发者_高级运维ry 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.)
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.
XQilla did turn out to have an XPath 2.0 parser, so I'm using that now.
精彩评论