Difference between importing in Java and NET versions of Saxon

View: New views
2 Messages — Rating Filter:   Alert me  

Difference between importing in Java and NET versions of Saxon

by John Windle :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi

I'm trying to use a library of functions under XQuery.

I got them to work under Java but have to move to the NET version but
they wont run. No doubt
I'm making neophyte mistakes but the problem is 2 different results on
the different platforms.

There are 2 problems I've encountered.

The first is the way files in my library itself import other functions found
in different files in the library.

For example:
Library is called crash_lib (a directory holding files), and it contains
3 files
lstar_peak_count.xq, lstar_peak_max.xq and utilityfns.xq
So I create a query, clash.xq, and it references lstar_peak_count.xq,
lstar_peak_max.xq
as follows:
import module namespace lpc =
"http://www.blah.com/PIM/XML/Uniformity/lstar_peak_count" at
"file:crash_lib/lstar_peak_count.xq";
import module namespace lpm =
"http://www.blah.com/PIM/XML/Uniformity/lstar_peak_max" at
"file:crash_lib/lstar_peak_max.xq";

However both lstar_peak_count.xq and lstar_peak_max.xq want to reference
utilityfns.xq
under the java version of Saxon they have to do it with the line:
import module namespace util =
"http://www.blah.com/PIM/XML/Uniformity/utilityfns" at
"file:crash_lib/utilityfns.xq";

This import doesn't work under the NET implementation of Saxon and the
line needs
to be altered to:
import module namespace util =
"http://www.blah.com/PIM/XML/Uniformity/utilityfns" at "file:utilityfns.xq";

Is the difference deliberate?

The second problem is that once I found out how to find utilities in the
library
I got errors claiming multiple definitions of functions in any query
that uses
more than a single library include. This multiple definition doesn't
happen under
java version just under the NET version.

I've attached a zip file that contains an xquery, dummy input file and a
reduced
library folder that demonstrates the problems. Unpack the zip file to a
directory
and to demonstrate that it works under Java run something like:
java -cp "C:\saxon\saxon9he.jar" net.sf.saxon.Query -t
-s:dummy_filelist.xml -q:clash_j.xq

demonstrate the import problem under the NET version run somthing like:
c:/saxon/bin/Query.exe -t -q:clash_j.xq -s:dummy_filelist.xml

demonstrate the multiple definition problem run something like:
c:/saxon/bin/Query.exe -t -q:clash.xq -s:dummy_filelist.xml

In general the files delivered have a _j if I expect them to run under
the Java
version and omit it if I expect them to run under the NET version.

Using Saxon-HE 9.2 for .NET and Java, on Windows XP service pack 2

Any help appreciated.

Regards

john


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
saxon-help@...
https://lists.sourceforge.net/lists/listinfo/saxon-help 

XqueryImportProblems.zip (4K) Download Attachment

Re: Difference between importing in Java and NET versions ofSaxon

by Michael Kay :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

>
> There are 2 problems I've encountered.
>
> The first is the way files in my library itself import other
> functions found in different files in the library.
>
> For example:
> Library is called crash_lib (a directory holding files), and
> it contains
> 3 files
> lstar_peak_count.xq, lstar_peak_max.xq and utilityfns.xq So I
> create a query, clash.xq, and it references
> lstar_peak_count.xq, lstar_peak_max.xq as follows:
> import module namespace lpc =
> "http://www.blah.com/PIM/XML/Uniformity/lstar_peak_count" at
> "file:crash_lib/lstar_peak_count.xq";
> import module namespace lpm =
> "http://www.blah.com/PIM/XML/Uniformity/lstar_peak_max" at
> "file:crash_lib/lstar_peak_max.xq";

If the files are all in the same directory, then you should use a simple
relative URI: at "lstar_peak_max.xq".

A colon before the first "/" in the URI indicates that it is an absolute
URI. I don't think the RFCs for the file URI scheme attach any meaning to a
file URI of this form - at best, the interpretation is very likely to vary
from one system to another (it's not the most wonderful of specifications,
and implementors have to do a lot of guesswork to work out what the RFC
authors intended some of the permitted syntax to mean.)

Saxon on Java uses the java.net.URI class for resolving URIs, and the
java.net.URL class for dereferencing them. On .NET, it uses the default
XmlResolver provided in the .NET library, unless this is overridden with a
user-supplied XmlResolver. So it's not surprising that if you use
"unorthodox" URIs, you get different results.

I would recommend sticking either to absolute URIs of the form
file:///a/b/c.xq, or relative URIs such as "one.xq", "two/one.xq", or
"../one.xq".

>
> The second problem is that once I found out how to find
> utilities in the library I got errors claiming multiple
> definitions of functions in any query that uses more than a
> single library include. This multiple definition doesn't
> happen under java version just under the NET version.

If you import the same module from two different places, Saxon will load a
single copy provided that the absolute URIs in the two cases are the same.
If the absolute URIs are different, it will load two copies, which is likely
to result in such errors. The absolute URI is obtained by resolving the
relative URI used in the "at" clause of the module import against the base
URI of the query containing the import.

Regards,

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


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
saxon-help@...
https://lists.sourceforge.net/lists/listinfo/saxon-help