Problem with multiple module imports

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

Problem with multiple module imports

Neil Mayo
Hello,

I encounter an error when I have several XQuery modules which import other
modules in the following pattern:

1 imports 2 (and optionally 3)
2 imports 3 and 4
3 imports 4

It can be seen that the modules do not form a cycle. The attached set of 4
very simple modules (named ns[1..4].xql) illustrates the problem. Running
the main module ns1.xql, with Saxon 8.5 or 8.6, I get the error:

java.lang.IllegalStateException: Variable $var4b has not been fixed up
at [..]
Fatal error during transformation: Variable $var4b has not been fixed up


The problem seems to occur because both ns2 and ns3 use variables from
module ns4. The content of ns2:fun1() can be made to run without error by
any of the following methods:

1) remove the reference to $ns4:var4b from ns3.xql (but the import of ns4
can be left in)

2) remove the ns3 import and function call from ns2.xql, placing them in
ns1 instead

3) turn ns2 into a main module which runs the contents of ns2:fun1()
[see ns2main.xql]


Obviously, only options 2 and 3 give the output I want, including both
the variables in ns4.

I am not sure if this behaviour is by design/XQuery spec or if it
constitutes a bug in Saxon - I thought module imports were okay as long as
they did not form a cycle.

Thanks in advance for any help rendered :)

Neil Mayo

mods.tar (13K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

RE: Problem with multiple module imports

Michael Kay
Thanks. I'll take a look at this. On the face of it, it looks like a bug.

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

> -----Original Message-----
> From: [hidden email]
> [mailto:[hidden email]] On Behalf Of Neil Mayo
> Sent: 04 November 2005 17:26
> To: [hidden email]
> Subject: [saxon] Problem with multiple module imports
>
> Hello,
>
> I encounter an error when I have several XQuery modules which
> import other
> modules in the following pattern:
>
> 1 imports 2 (and optionally 3)
> 2 imports 3 and 4
> 3 imports 4
>
> It can be seen that the modules do not form a cycle. The
> attached set of 4
> very simple modules (named ns[1..4].xql) illustrates the
> problem. Running
> the main module ns1.xql, with Saxon 8.5 or 8.6, I get the error:
>
> java.lang.IllegalStateException: Variable $var4b has not been fixed up
> at [..]
> Fatal error during transformation: Variable $var4b has not
> been fixed up
>
>
> The problem seems to occur because both ns2 and ns3 use variables from
> module ns4. The content of ns2:fun1() can be made to run
> without error by
> any of the following methods:
>
> 1) remove the reference to $ns4:var4b from ns3.xql (but the
> import of ns4
> can be left in)
>
> 2) remove the ns3 import and function call from ns2.xql,
> placing them in
> ns1 instead
>
> 3) turn ns2 into a main module which runs the contents of ns2:fun1()
> [see ns2main.xql]
>
>
> Obviously, only options 2 and 3 give the output I want,
> including both
> the variables in ns4.
>
> I am not sure if this behaviour is by design/XQuery spec or if it
> constitutes a bug in Saxon - I thought module imports were
> okay as long as
> they did not form a cycle.
>
> Thanks in advance for any help rendered :)
>
> Neil Mayo
>




-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help
Reply | Threaded
Open this post in threaded view
|

RE: Problem with multiple module imports

Michael Kay
In reply to this post by Neil Mayo
Just to give you a progress report on this: it's proving a nasty one. It's a
shame it wasn't discovered before Saxon 8.6 went out, but that's the way
things go! It turns out that the way Saxon is processing cross-module
variable references gives no guarantee that a variable declaration will be
processed before the references to that variable, especially (perhaps only,
I'm not quite sure) in cases where the same module is imported by more than
one other module. This is going to require a design change, so it won't be
fixed until there's another release.

As far as I can tell there's no similar problem with functions (probably
because forwards references to functions have always been freely allowed,
which paradoxically makes the fixup problem simpler) so your workaround is
to access the values of global variables via getter functions.

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

> -----Original Message-----
> From: [hidden email]
> [mailto:[hidden email]] On Behalf Of Neil Mayo
> Sent: 04 November 2005 17:26
> To: [hidden email]
> Subject: [saxon] Problem with multiple module imports
>
> Hello,
>
> I encounter an error when I have several XQuery modules which
> import other
> modules in the following pattern:
>
> 1 imports 2 (and optionally 3)
> 2 imports 3 and 4
> 3 imports 4
>
> It can be seen that the modules do not form a cycle. The
> attached set of 4
> very simple modules (named ns[1..4].xql) illustrates the
> problem. Running
> the main module ns1.xql, with Saxon 8.5 or 8.6, I get the error:
>
> java.lang.IllegalStateException: Variable $var4b has not been fixed up
> at [..]
> Fatal error during transformation: Variable $var4b has not
> been fixed up
>
>
> The problem seems to occur because both ns2 and ns3 use variables from
> module ns4. The content of ns2:fun1() can be made to run
> without error by
> any of the following methods:
>
> 1) remove the reference to $ns4:var4b from ns3.xql (but the
> import of ns4
> can be left in)
>
> 2) remove the ns3 import and function call from ns2.xql,
> placing them in
> ns1 instead
>
> 3) turn ns2 into a main module which runs the contents of ns2:fun1()
> [see ns2main.xql]
>
>
> Obviously, only options 2 and 3 give the output I want,
> including both
> the variables in ns4.
>
> I am not sure if this behaviour is by design/XQuery spec or if it
> constitutes a bug in Saxon - I thought module imports were
> okay as long as
> they did not form a cycle.
>
> Thanks in advance for any help rendered :)
>
> Neil Mayo
>




-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help
Reply | Threaded
Open this post in threaded view
|

RE: Problem with multiple module imports

Michael Kay
In reply to this post by Neil Mayo
This problem has now been fixed. As suggested in the interim response, it
required a certain amount of redesign of the order in which variables and
functions are processed in XQuery. I'm expecting to produce an 8.6.1 release
in the next week or two and this will contain the fix.

Michael Kay

> -----Original Message-----
> From: [hidden email]
> [mailto:[hidden email]] On Behalf Of Neil Mayo
> Sent: 04 November 2005 17:26
> To: [hidden email]
> Subject: [saxon] Problem with multiple module imports
>
> Hello,
>
> I encounter an error when I have several XQuery modules which
> import other
> modules in the following pattern:
>
> 1 imports 2 (and optionally 3)
> 2 imports 3 and 4
> 3 imports 4
>
> It can be seen that the modules do not form a cycle. The
> attached set of 4
> very simple modules (named ns[1..4].xql) illustrates the
> problem. Running
> the main module ns1.xql, with Saxon 8.5 or 8.6, I get the error:
>
> java.lang.IllegalStateException: Variable $var4b has not been fixed up
> at [..]
> Fatal error during transformation: Variable $var4b has not
> been fixed up
>
>
> The problem seems to occur because both ns2 and ns3 use variables from
> module ns4. The content of ns2:fun1() can be made to run
> without error by
> any of the following methods:
>
> 1) remove the reference to $ns4:var4b from ns3.xql (but the
> import of ns4
> can be left in)
>
> 2) remove the ns3 import and function call from ns2.xql,
> placing them in
> ns1 instead
>
> 3) turn ns2 into a main module which runs the contents of ns2:fun1()
> [see ns2main.xql]
>
>
> Obviously, only options 2 and 3 give the output I want,
> including both
> the variables in ns4.
>
> I am not sure if this behaviour is by design/XQuery spec or if it
> constitutes a bug in Saxon - I thought module imports were
> okay as long as
> they did not form a cycle.
>
> Thanks in advance for any help rendered :)
>
> Neil Mayo
>




-------------------------------------------------------
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. For more info visit:
http://ads.osdn.com/?ad_id=7628&alloc_id=16845&op=click
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help