Resolver goes to Internet for XQuery module's namespace URI #229

Closed
opened 2025-03-11 16:59:48 +01:00 by galtm · 14 comments
galtm commented 2025-03-11 16:59:48 +01:00 (Migrated from github.com)

I'm trying to upgrade the xspec/xspec repo to use a version 6 resolver instead of a version 5 one. Some of the tests failed because the resolver seems to be fetching a resource from the Internet based on the XQuery module's namespace URI. While investigating locally, I found that the process failed when my computer had an Internet connection and passed when it didn't. I'm using Windows locally, but on GitHub, the failures happened across platforms (Windows, macOS, and Linux), with Saxon 12.5 and 11.6.

Is it correct that the resolver is going to the XQuery module's namespace URI on the Internet instead of treating the namespace URI as merely a symbolic identifier?

If so, is there a better workaround than setting XML_CATALOG_ACCESS_EXTERNAL_DOCUMENT="" where needed? (I can't use that setting for all test cases because some of them need access.)

Reproducing the problem

I unwrapped the XSpec parts of the test case and made a very small, self-contained one.

  1. Unzip the attached ZIP-file into some directory
  2. In that directory, also place a saxon-12.5 subdirectory containing the Saxon-HE 12.5 Java distribution and place a xmlresolver-6.0.13 subdirectory containing the XML Resolver.
  3. From that directory, execute java -cp "saxon-12.5\saxon-he-12.5.jar;xmlresolver-6.0.13\lib\xmlresolver-6.0.13.jar" net.sf.saxon.Query -q:resolver-uses-internet.xq (if using Linux or macOS, presumably use forward slashes and colon path separator)

With no internet connection, step 3 works as expected:

<?xml version="1.0" encoding="UTF-8"?>Hello

With an internet connection, it fails like this:

Static error in {<} of https://www.datypic.com/functx/
  XPST0003  The file imported for module http://www.functx.com is not a valid XQuery library
  module. The content starts: <?xml version="1.0" encoding="...
Static error(s) in query

resolver-uses-internet.zip

I'm trying to upgrade the xspec/xspec repo to use a version 6 resolver instead of a version 5 one. Some of the tests failed because the resolver seems to be fetching a resource from the Internet based on the XQuery module's namespace URI. While investigating locally, I found that the process failed when my computer had an Internet connection and passed when it didn't. I'm using Windows locally, but on GitHub, the failures happened across platforms (Windows, macOS, and Linux), with Saxon 12.5 and 11.6. Is it correct that the resolver is going to the XQuery module's namespace URI on the Internet instead of treating the namespace URI as merely a symbolic identifier? If so, is there a better workaround than setting `XML_CATALOG_ACCESS_EXTERNAL_DOCUMENT=""` where needed? (I can't use that setting for all test cases because some of them need access.) ### Reproducing the problem I unwrapped the XSpec parts of the test case and made a very small, self-contained one. 1. Unzip the attached ZIP-file into some directory 2. In that directory, also place a `saxon-12.5` subdirectory containing the Saxon-HE 12.5 Java distribution and place a `xmlresolver-6.0.13` subdirectory containing the XML Resolver. 3. From that directory, execute `java -cp "saxon-12.5\saxon-he-12.5.jar;xmlresolver-6.0.13\lib\xmlresolver-6.0.13.jar" net.sf.saxon.Query -q:resolver-uses-internet.xq` (if using Linux or macOS, presumably use forward slashes and colon path separator) With no internet connection, step 3 works as expected: ``` <?xml version="1.0" encoding="UTF-8"?>Hello ``` With an internet connection, it fails like this: ``` Static error in {<} of https://www.datypic.com/functx/ XPST0003 The file imported for module http://www.functx.com is not a valid XQuery library module. The content starts: <?xml version="1.0" encoding="... Static error(s) in query ``` [resolver-uses-internet.zip](https://github.com/user-attachments/files/19189923/resolver-uses-internet.zip)
ndw commented 2025-03-11 18:09:55 +01:00 (Migrated from github.com)

I will investigate. In the meantime, could you try with 5.3.0, please? I still consider the 6.x branch a little bit "beta".

I will investigate. In the meantime, could you try with 5.3.0, please? I still consider the 6.x branch a little bit "beta".
galtm commented 2025-03-11 18:40:16 +01:00 (Migrated from github.com)

I will investigate. In the meantime, could you try with 5.3.0, please? I still consider the 6.x branch a little bit "beta".

Sure. Has 5.3.0 been released yet? (I'm not in a big hurry.)

Thanks for investigating.

> I will investigate. In the meantime, could you try with 5.3.0, please? I still consider the 6.x branch a little bit "beta". Sure. Has 5.3.0 been released yet? (I'm not in a big hurry.) Thanks for investigating.
ndw commented 2025-03-11 19:11:56 +01:00 (Migrated from github.com)

Yes. It went out yesterday shortly before or after 6.0.13.

Yes. It went out yesterday shortly before or after 6.0.13.
galtm commented 2025-03-11 20:53:27 +01:00 (Migrated from github.com)

I see 5.3.0 listed at Maven Central, but the XSpec repo's script is trying to get it from https://github.com/xmlresolver/xmlresolver/releases/download/5.3.0/xmlresolver-5.3.0.zip which doesn't seem to be there. Is it supposed to be?

I see 5.3.0 listed at [Maven Central](https://central.sonatype.com/artifact/org.xmlresolver/xmlresolver/versions), but the XSpec repo's script is trying to get it from https://github.com/xmlresolver/xmlresolver/releases/download/5.3.0/xmlresolver-5.3.0.zip which doesn't seem to be there. Is it supposed to be?
ndw commented 2025-03-11 21:01:50 +01:00 (Migrated from github.com)

Ah. That I might have to do by hand. I'll do that first thing tomorrow.

Ah. That I might have to do by hand. I'll do that first thing tomorrow.
ndw commented 2025-03-12 10:53:24 +01:00 (Migrated from github.com)

The 5.3.0 release is now on package releases page. Apologies for the inconvenience.

The 5.3.0 release is now on package releases page. Apologies for the inconvenience.
galtm commented 2025-03-12 12:52:04 +01:00 (Migrated from github.com)

Thanks! Version 5.3.0 works fine. I don't mind deferring the update to v6.

Thanks! Version 5.3.0 works fine. I don't mind deferring the update to v6.
ndw commented 2025-03-12 13:21:44 +01:00 (Migrated from github.com)

Okay. I'm very curious about why 6.0.13 reports different results. I will investigate that in the next few days. Thanks again for reporting it!

Okay. I'm *very* curious about why 6.0.13 reports different results. I will investigate that in the next few days. Thanks again for reporting it!
ndw commented 2025-03-12 16:49:12 +01:00 (Migrated from github.com)

I can't reproduce this. Can you confirm that it works if you use 5.3.0 and fails if you use 6.0.13 and change nothing else? Here's what I get:

$ java -cp he/saxon-he-12.5.jar:xmlresolver-6.0.13/lib/xmlresolver-6.0.13.jar  net.sf.saxon.Query -q:resolver-uses-internet.xq
<?xml version="1.0" encoding="UTF-8"?>Hello%     

And it works the same way with or without an internet connection.

What's especially strange is that the message you quoted is

Static error in {<} of https://www.datypic.com/functx/

But there are no occurrences of https://www.datypic.com/ in your test case at all.

It feels very strongly like something else is going on.

I can't reproduce this. Can you confirm that it works if you use 5.3.0 and fails if you use 6.0.13 and change nothing else? Here's what I get: ``` $ java -cp he/saxon-he-12.5.jar:xmlresolver-6.0.13/lib/xmlresolver-6.0.13.jar net.sf.saxon.Query -q:resolver-uses-internet.xq <?xml version="1.0" encoding="UTF-8"?>Hello% ``` And it works the same way with or without an internet connection. What's especially strange is that the message you quoted is > Static error in {<} of https://www.datypic.com/functx/ But there are *no* occurrences of `https://www.datypic.com/` in your test case at all. It feels very strongly like something else is going on.
galtm commented 2025-03-12 18:43:18 +01:00 (Migrated from github.com)

Yes, it works with 5.3.0, and it fails with 6.0.13 if my Internet connection is on.

>java -cp "saxon-12.5\saxon-he-12.5.jar;xmlresolver-6.0.13\lib\xmlresolver-6.0.13.jar" net.sf.saxon.Query -q:resolver-uses-internet.xq
Static error in {<} of https://www.datypic.com/functx/
  XPST0003  The file imported for module http://www.functx.com is not a valid XQuery library
  module. The content starts: <?xml version="1.0" encoding="...
Static error(s) in query

>java -cp "saxon-12.5\saxon-he-12.5.jar;xmlresolver-5.3.0\lib\xmlresolver-5.3.0.jar" net.sf.saxon.Query -q:resolver-uses-internet.xq
<?xml version="1.0" encoding="UTF-8"?>Hello

In my repro steps, the XQuery library module has

module namespace functx = "http://www.functx.com";

and if I point a web browser to http://www.functx.com/ then it redirects to https://www.datypic.com/functx/. Maybe that's where the datypic.com part is coming from in the error message.

Yes, it works with 5.3.0, and it fails with 6.0.13 if my Internet connection is on. ``` >java -cp "saxon-12.5\saxon-he-12.5.jar;xmlresolver-6.0.13\lib\xmlresolver-6.0.13.jar" net.sf.saxon.Query -q:resolver-uses-internet.xq Static error in {<} of https://www.datypic.com/functx/ XPST0003 The file imported for module http://www.functx.com is not a valid XQuery library module. The content starts: <?xml version="1.0" encoding="... Static error(s) in query >java -cp "saxon-12.5\saxon-he-12.5.jar;xmlresolver-5.3.0\lib\xmlresolver-5.3.0.jar" net.sf.saxon.Query -q:resolver-uses-internet.xq <?xml version="1.0" encoding="UTF-8"?>Hello ``` In my repro steps, the XQuery library module has ``` module namespace functx = "http://www.functx.com"; ``` and if I point a web browser to `http://www.functx.com/` then it redirects to `https://www.datypic.com/functx/`. Maybe that's where the datypic.com part is coming from in the error message.
ndw commented 2025-03-12 19:59:33 +01:00 (Migrated from github.com)

That is truly puzzling. I will dig in and take a closer look tomorrow.

I'm sure you're right about the URI. If it's easy for you to test with 6.0.12, I'd be curious to know if this is in any way related to the changes I just made. I'm guessing not, but since I'm completely perplexed, I wouldn't bet the cost of lunch at a cheap diner on it.

That is truly puzzling. I will dig in and take a closer look tomorrow. I'm sure you're right about the URI. If it's easy for you to test with 6.0.12, I'd be curious to know if this is in any way related to the changes I just made. I'm guessing not, but since I'm completely perplexed, I wouldn't bet the cost of lunch at a cheap diner on it.
galtm commented 2025-03-12 20:31:00 +01:00 (Migrated from github.com)

For me, 6.0.12 and 6.0.13 behave the same way.

For me, 6.0.12 and 6.0.13 behave the same way.
galtm commented 2025-03-13 16:32:30 +01:00 (Migrated from github.com)

v6.0.14 does the trick. Thanks!

v6.0.14 does the trick. Thanks!
ndw commented 2025-03-13 16:38:08 +01:00 (Migrated from github.com)

Cool Thank you. I recommend you stick with 5.3.0 until 6.1.0 comes out. I expect that to be "soon" but as you can see, there are still some rough edges in the 6.x codebase.

Cool Thank you. I recommend you stick with 5.3.0 until 6.1.0 comes out. I expect that to be "soon" but as you can see, there are still some rough edges in the 6.x codebase.
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
XmlResolver/xmlresolver#229
No description provided.