Saxon b 8.5.1 : XQuery module related error messages.

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Saxon b 8.5.1 : XQuery module related error messages.

Pierrick Brihaye-2
Hi,

I find Saxon's error messages somehow difficult to follow :

in.txt :

import module namespace foo="foo" at './module.txt';
$foo:x

1) no module.txt file :

Error on line 1 column 0 of file:/.../saxonb8.5.1/module.txt:
  XPST0003: XQuery syntax error in #UTF-8#:
    expected "module namespace", found name "UTF-8"
Error on line 2 column 7 of file:/.../saxonb8.5.1/in.txt:
  XPST0003: XQuery syntax error in #...foo" at './module.txt'; $foo:x#:
    Variable $foo:x has not been declared
Failed to compile query

Those # may be difficult to read ;-)
The first message is completely misleading.
The second one is dependant from the first error so... is it necessary,
at least as such ?

2) a module.txt file :

Error on line 2 column 19 of file:/.../saxonb8.5.1/module.txt:
  XQST0048: XQuery static error in #..."foo"; declare variable $x :=#:
    A variable declared in a library module must be in the module namespace
Error on line 3 column 19 of file:/.../saxonb8.5.1/module.txt:
  XQST0048: XQuery static error in #... declare variable $local:y :=#:
    A variable declared in a library module must be in the module namespace
Error on line 1 column 52 of file:/.../saxonb8.5.1/in.txt:
  Static errors were reported in the imported library module
Error on line 2 column 7 of file:/C:/.../saxonb8.5.1/in.txt:
  XPST0003: XQuery syntax error in #...foo" at './module.txt'; $foo:x#:
    Variable $foo:x has not been declared
Failed to compile query

Do we need... 4 (four) messages ? IMHO, the first 2 ones are OK,
as well as the "terminating" "Static errors were reported in the
imported library module" message.

But... do we need a 4th message which is the consequence of
the previous errors ?

Cheers,

p.b.







-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help
Reply | Threaded
Open this post in threaded view
|

RE: Saxon b 8.5.1 : XQuery module related error messages.

Michael Kay
Thanks for this feedback. I take the design of error messages very
seriously, and it's only possible to get it right with a lot of feedback
from people making genuine errors.

>
> in.txt :
>
> import module namespace foo="foo" at './module.txt';
> $foo:x
>
> 1) no module.txt file :
>
> Error on line 1 column 0 of file:/.../saxonb8.5.1/module.txt:
>   XPST0003: XQuery syntax error in #UTF-8#:
>     expected "module namespace", found name "UTF-8"

I can't reproduce this. If module.txt doesn't exist, I get:

Error on line 1 column 52 of file:/c:/temp/test.xq:
  XQST0059: java.io.FileNotFoundException: c:\temp\module.txt (The system
cannot find the
  file specified)

as the only error message. The message you are seeing suggests to me that
module.txt does exist, and starts with the string "UTF-8". Perhaps there's
some other factor in your configuration?

> Error on line 2 column 7 of file:/.../saxonb8.5.1/in.txt:
>   XPST0003: XQuery syntax error in #...foo" at
> './module.txt'; $foo:x#:
>     Variable $foo:x has not been declared
> Failed to compile query
>
> Those # may be difficult to read ;-)

Yes, I've struggled finding a good way to reproduce a piece of query text to
show the error context. I tried putting it between non-ASCII characters, but
they aren't displayed properly on all environments. Using characters such as
quotes or curly braces that can appear in a query can be very confusing.
Perhaps I should try putting the extract on a line of its own with no
delimiters (I already strip any newlines appearing within the quoted
fragment).

> The first message is completely misleading.

It would seem so, but I would like to understand the circumstances that
cause it.

> The second one is dependant from the first error so... is it
> necessary, at least as such ?

It's always difficult to know whether it's worth continuing after an error,
to find further errors. Generally compilers try to do this, and I think it's
usually worth doing. One can try to be a bit more subtle, for example not
reporting any semantic errors if syntax errors have been found, and perhaps
that's what I should be doing in this case.

>
> 2) a module.txt file :
>
> Error on line 2 column 19 of file:/.../saxonb8.5.1/module.txt:
>   XQST0048: XQuery static error in #..."foo"; declare variable $x :=#:
>     A variable declared in a library module must be in the
> module namespace
> Error on line 3 column 19 of file:/.../saxonb8.5.1/module.txt:
>   XQST0048: XQuery static error in #... declare variable $local:y :=#:
>     A variable declared in a library module must be in the
> module namespace
> Error on line 1 column 52 of file:/.../saxonb8.5.1/in.txt:
>   Static errors were reported in the imported library module
> Error on line 2 column 7 of file:/C:/.../saxonb8.5.1/in.txt:
>   XPST0003: XQuery syntax error in #...foo" at
> './module.txt'; $foo:x#:
>     Variable $foo:x has not been declared
> Failed to compile query
>
> Do we need... 4 (four) messages ? IMHO, the first 2 ones are OK,
> as well as the "terminating" "Static errors were reported in the
> imported library module" message.
>
> But... do we need a 4th message which is the consequence of
> the previous errors ?
>
In this case the errors are all semantic errors, so it's very hard to see a
general way of deciding that the "undeclared variable" error is a
consequence of the previous errors. I'll see if I can do some fine tuning,
however.




-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help
Reply | Threaded
Open this post in threaded view
|

RE: Saxon b 8.5.1 : XQuery module related error messages.

Michael Kay
In reply to this post by Pierrick Brihaye-2
>
> Do we need... 4 (four) messages ? IMHO, the first 2 ones are OK,
> as well as the "terminating" "Static errors were reported in the
> imported library module" message.
>
> But... do we need a 4th message which is the consequence of
> the previous errors ?
>

Testing this, I am not seeing the 4th message with Saxon 8.5.1, although it
is there with Saxon 8.5.

Michael Kay
http://www.saxonica.com/




-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help
Reply | Threaded
Open this post in threaded view
|

Re: Saxon b 8.5.1 : XQuery module related error messages.

Pierrick Brihaye
In reply to this post by Michael Kay
Michael Kay wrote:
> Thanks for this feedback. I take the design of error messages very
> seriously, and it's only possible to get it right with a lot of feedback
> from people making genuine errors.

Some other ones (on another config) :

let $a := <x a="b"><!--a--></x>/self::comment() return <a>{$a}</a>

Warning: on line 1 of file:/C:/.../saxonb8-5-1/in.txt:
The self axis will never select any element() nodes when starting at an
comment() node
<?xml version="1.0" encoding="UTF-8"?>
<a/>

OK. I get a warning for my stupid question. No way to disable it ?

Then :
let $a := <x a="b"><!--a--></x>/parent::comment() return <a>{$a}</a>
Warning

Then :
let $a := <x a="b"><!--a--></x>/ancestor::comment() return <a>{$a}</a>
Warning

let $a := <x a="b"><!--a--></x>/ancestor-or-self::comment() return
<a>{$a}</a>
No warning !

let $a := <x a="b"><!--a--></x>/parent::comment() return <a>{$a}</a>
Warning...

let $a := <x a="b"><!--a--></x>/namespace::comment() return <a>{$a}</a>
error :
XPST0003: XQuery syntax error in #...!--a--></x>/namespace::comment#:
The namespace axis is not available in XQuery
Failed to compile query

... very explicit.

All other axes logically report no warning. So... isn't there a problem
with the ancestor-or-self axis on comment() node-tests ?

Will check other combinations when I have time :-)

Cheers,

p.b.






-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.
Get Certified Today * Register for a JBoss Training Course
Free Certification Exam for All Training Attendees Through End of 2005
Visit http://www.jboss.com/services/certification for more information
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help
Reply | Threaded
Open this post in threaded view
|

RE: Re: Saxon b 8.5.1 : XQuery module related error messages.

Michael Kay
> OK. I get a warning for my stupid question. No way to disable it ?

You can write an ErrorListener which decides selectively which warnings to
display.
>
> let $a := <x a="b"><!--a--></x>/ancestor-or-self::comment() return
> <a>{$a}</a>
> No warning !

The data isn't quite clever enough to spot that one. The warnings are
actually based on two tables:

(a) a table of starting-node-kind/axis pairs that will always be empty

(b) a table of axis/required-node-kind pairs that will always be empty.

element/ancestor-or-self isn't in the first table, and
ancestor-or-self/comment isn't in the second. To catch that
element/ancestor-or-self::comment() is always empty, a combined table of
starting-node-kind/axis/required-node-kind would be needed. Something to do
on a rainy Sunday.

Michael Kay
http://www.saxonica.com/




-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.
Get Certified Today * Register for a JBoss Training Course
Free Certification Exam for All Training Attendees Through End of 2005
Visit http://www.jboss.com/services/certification for more information
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help