Is there an API that provides XQuery compilation results?
Wednesday, 13 November 2019 · 3 messages · last reply 15 Nov 2019
PV
Peter Villadsen13 Nov 2019 00:36 #
When I use the GUI application I can see some error description (even if it a little terse) when my queries are incorrect. For instance I might get:
Stopped at tableFields.xq, 27/50:
[XQST0118] Different start and end tag: <Artifact>...</Artiact>.
If I submit a query like <Artifact></Artiact>
However, I cannot seem to find an API that brings me that information? I tried:
xquery:parse("<B></C>", map {'pass':true()})but that did not get the result I expected. Also, while we're at at it, it would be nice to also get the optimized query.
Best Regards
Peter Villadsen
Principal Architect
Microsoft Business Applications Group
ZD
Zimmel, Daniel13 Nov 2019 10:05 #
With
xquery:parse(), I wondered about this myself, so I second this question without having an answer :-(
You will get a query plan if it is a non-static error:xquery:parse("let $a := <B></B> return $a + 1", map {'compile':true(),'pass':true()})… but what the pass option does is not clear to me. Definitely not passing the type error here.
If you only need to catch the error message without the query plan, there’s always try/catch of course.
Best, Daniel
Quoted text · Peter Villadsen · 15 lines
Von: Peter Villadsen <Peter.Villadsen at microsoft.com> Gesendet: Mittwoch, 13. November 2019 00:36 An: basex-talk at mailman.uni-konstanz.de Betreff: [basex-talk] Is there an API that provides XQuery compilation results? When I use the GUI application I can see some error description (even if it a little terse) when my queries are incorrect. For instance I might get: Stopped at tableFields.xq, 27/50: [XQST0118] Different start and end tag: <Artifact>...</Artiact>. If I submit a query like <Artifact></Artiact> However, I cannot seem to find an API that brings me that information? I tried: xquery:parse("<B></C>", map {'pass':true()}) but that did not get the result I expected. Also, while we’re at at it, it would be nice to also get the optimized query. Best Regards Peter Villadsen Principal Architect Microsoft Business Applications Group
CG
Christian Grün15 Nov 2019 18:21 #
Hi Daniel,
Quoted text · Zimmel, Daniel · 1 line
> … but what the pass option does is not clear to me. Definitely not passing the type error here.
I have slightly updated the comment in our documentation. By default, the option is false. If an error is raised, the line/column number and the optional file uri will refer to the location of the function call. If the option is enabled, the line/column and file uri will be adopted from the raised error. See the following example:
(: main.xq :)
let $query := 'sub.xq'
let $options := map { 'pass': false() }
return xquery:parse-uri($query, $options)(: sub.xq :)
1 2
The function raises the following error:
Stopped at main.xq, 3/24:
[XPST0003] Unexpected end of query: '2'.
If pass is enabled, the feedback is:
Stopped at sub.xq, 1/4:
[XPST0003] Unexpected end of query: '2'.
Hope this helps,
Christian
[1] http://docs.basex.org/wiki/XQuery_Module#XQuery_Parsing
Quoted text · Zimmel, Daniel · 57 lines
> > > > If you only need to catch the error message without the query plan, there’s always try/catch of course. > > > > Best, Daniel > > > > Von: Peter Villadsen <Peter.Villadsen at microsoft.com> > Gesendet: Mittwoch, 13. November 2019 00:36 > An: basex-talk at mailman.uni-konstanz.de > Betreff: [basex-talk] Is there an API that provides XQuery compilation results? > > > > When I use the GUI application I can see some error description (even if it a little terse) when my queries are incorrect. For instance I might get: > > > > Stopped at tableFields.xq, 27/50: > > [XQST0118] Different start and end tag: <Artifact>...</Artiact>. > > > > If I submit a query like <Artifact></Artiact> > > > > However, I cannot seem to find an API that brings me that information? I tried: > > > > xquery:parse("<B></C>", map {'pass':true()}) > > > > but that did not get the result I expected. Also, while we’re at at it, it would be nice to also get the optimized query. > > > > > > Best Regards > > > > Peter Villadsen > > Principal Architect > > Microsoft Business Applications Group > >
Written for BaseX 9.2. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery