Project

Profile

Help

Bug #5624

closed

SaxonCS.exe validate -t -xsd:http://www.w3.org/TR/xmlschema11-1/XMLSchema.xsd -s:https://www.w3.org/TR/xslt-30/schema-for-xslt30.xsd fails (at least on Windows) with URIResolver for schema file must return a Source

Added by Martin Honnen over 1 year ago. Updated about 1 year ago.

Status:
Closed
Priority:
Low
Category:
Command Line
Sprint/Milestone:
Start date:
2022-07-29
Due date:
% Done:

100%

Estimated time:
Legacy ID:
Applies to branch:
11, 12, trunk
Fix Committed on Branch:
11, 12, trunk
Fixed in Maintenance Release:
Platforms:
.NET

Description

Running some command line tests with SaxonCS 11.4 on Windows I find that using the command line

SaxonCS.exe validate -t -xsd:http://www.w3.org/TR/xmlschema11-1/XMLSchema.xsd -s:https://www.w3.org/TR/xslt-30/schema-for-xslt30.xsd

fails (at least on Windows) with "URIResolver for schema file must return a Source".

Actions #1

Updated by Martin Honnen over 1 year ago

Linux doesn't work either:

SaxonCS-11.4/SaxonCS validate -t -xsd:http://www.w3.org/TR/xmlschema11-1/XMLSchema.xsd -s:https://www.w3.org/TR/xslt-30/schema-for-xslt30.xsd
SaxonCS-EE 11.4 from Saxonica
.NET 5.0.13 on Linux
Using license serial number V...
URIResolver for schema file must return a Source
Exiting with code 2
Actions #2

Updated by Michael Kay over 1 year ago

Sorry that we've dropped the ball on this one.

On Mac I wasn't able to reproduce the problem in my (Rider) development environment, in either 11.x or 12.x.

On Linux we reproduced the problem on 11.4 (as issued).

I haven't tried it yet on Windows because my Windows machine is refusing to wake up after the Christmas holidays....

I downloaded a clean version of 11.4 on Mac and tried that from the command line. It loads the schema OK. If I try to validate a local document that works:

SaxonCS-b6 validate  -t -xsd:http://www.w3.org/TR/xmlschema11-1/XMLSchema.xsd -s:/Users/mike/Desktop/temp/test.xsd

But if I try to validate a remote document accessed over HTTP, I get a different failure:

SaxonCS-b6 validate  -t -xsd:http://www.w3.org/TR/xmlschema11-1/XMLSchema.xsd -s:http://www.w3.org/TR/xslt-30/schema-for-xslt30.xsd -u 
SaxonCS-EE 11.4 from Saxonica
.NET 6.0.3 on MacOS
Using license serial number V010895
Loading schema document http://www.w3.org/TR/xmlschema11-1/XMLSchema.xsd
Finished loading schema document http://www.w3.org/TR/xmlschema11-1/XMLSchema.xsd
Schema checking successful. Time: 835ms.
Memory used: 0Mb
System.AggregateException: One or more errors occurred. (Object reference not set to an instance of an object.) (Object reference not set to an instance of an object.)
 ---> System.NullReferenceException: Object reference not set to an instance of an object.

I think this is bug #5664.

Actions #3

Updated by Martin Honnen over 1 year ago

I can still reproduce the error with 11.4 on Windows:

PS C:\Users\marti> & 'C:\Program Files\Saxonica\SaxonCS-b6-11.4\SaxonCS-b6.exe' validate -t -xsd:http://www.w3.org/TR/xmlschema11-1/XMLSchema.xsd -s:https://www.w3.org/TR/xslt-30/schema-for-xslt30.xsd
SaxonCS-EE 11.4 from Saxonica
.NET 6.0.7 on Windows 10.0.22621.0
Using license serial number V...
...
URIResolver for schema file must return a Source
Exiting with code 2
Actions #4

Updated by Michael Kay over 1 year ago

Need to explore whether the problem also applies when loading a schema, via HTTP, that isn't one of the ones known to the standard catalog resolver.

Actions #5

Updated by Martin Honnen over 1 year ago

Here is another test:

PS C:\Users\marti\OneDrive\Documents\XSD\assertion-attribute-sequence> & 'C:\Program Files\Saxonica\SaxonCS-b6-11.4\SaxonCS-b6.exe' validate -t -xsd:http://www.w3.org/TR/xmlschema11-1/XMLSchema.xsd -s:https://github.com/martin-honnen/martin-honnen.github.io/raw/master/xsd/sample1.xsd
SaxonCS-EE 11.4 from Saxonica
.NET 6.0.7 on Windows 10.0.22621.0
Using license serial number V...
...
URIResolver for schema file must return a Source
Exiting with code 2
Actions #6

Updated by Michael Kay about 1 year ago

  • Assignee set to Norm Tovey-Walsh
Actions #7

Updated by Norm Tovey-Walsh about 1 year ago

  • Status changed from New to In Progress
Actions #8

Updated by Norm Tovey-Walsh about 1 year ago

I'm trying with 12, not 11.4, and I'm getting different failures. On macOS:

$ ./SaxonCS validate -t -xsd:http://www.w3.org/TR/xmlschema11-1/XMLSchema.xsd -s:https://www.w3.org/TR/xslt-30/schema-for-xslt30.xsd
SaxonCS-EE 12.0 from Saxonica
.NET 6.0.12 on MacOS
Using license serial number V...
Loading schema document http://www.w3.org/TR/xmlschema11-1/XMLSchema.xsd
: An error has occurred while opening external DTD 'http://www.w3.org/TR/xmlschema11-1/XMLSchema.dtd': Value cannot be null. (Parameter 'path1')
Fatal error during validation: : An error has occurred while opening external DTD 'http://www.w3.org/TR/xmlschema11-1/XMLSchema.dtd': Value cannot be null. (Parameter 'path1')
Exiting with code 2

My first thought is that this is related to http->https redirection. I expect someone somewhere isn't following redirection to get the DTD.

On Linux, I get a different error:

$ ./SaxonCS validate -t http://www.w3.org/TR/xmlschema11-1/XMLSchema.xsd -s:https://www.w3.org/TR/xslt-30/schema-for-xslt30.xsd
SaxonCS-EE 12.0 from Saxonica
.NET 6.0.13 on Linux
Using license serial number V010583
Validation error on line 13 column 2 of schema-for-xslt30.xsd:
  XQDY0084: Cannot validate <Q{.../XMLSchema}schema>: no element declaration available
  See https://www.w3.org/TR/xmlschema11-1/#cvc-elt clause 1
Validation error on line 56 column 2 of XMLSchema.xsd:
  XQDY0084: Cannot validate <Q{.../XMLSchema}schema>: no element declaration available
  See https://www.w3.org/TR/xmlschema11-1/#cvc-elt clause 1

Possibly the same underlying problem, though I can't explain why the results are different.

Actions #9

Updated by Martin Honnen about 1 year ago

I get a similar error on Windows now with SaxonCS 12, much like your MacOs result:

PS C:\Users\marti> & 'C:\Program Files\Saxonica\SaxonCS-12.0\SaxonCS.exe' validate -t -xsd:http://www.w3.org/TR/xmlschema11-1/XMLSchema.xsd -s:https://www.w3.org/TR/xslt-30/schema-for-xslt30.xsd
SaxonCS-EE 12.0 from Saxonica
.NET 6.0.10 on Windows 10.0.22621.0
Using license serial number ..
..
Loading schema document http://www.w3.org/TR/xmlschema11-1/XMLSchema.xsd
: An error has occurred while opening external DTD 'http://www.w3.org/TR/xmlschema11-1/XMLSchema.dtd': Value cannot be null. (Parameter 'path1')
Fatal error during validation: : An error has occurred while opening external DTD 'http://www.w3.org/TR/xmlschema11-1/XMLSchema.dtd': Value cannot be null. (Parameter 'path1')
Exiting with code 2

For SaxonCS-b6-11.4 I continue to get the URIResolver for schema file must return a Source:

PS C:\Users\marti> & 'C:\Program Files\Saxonica\SaxonCS-b6-11.4\SaxonCS-b6.exe' validate -t -xsd:http://www.w3.org/TR/xmlschema11-1/XMLSchema.xsd -s:https://www.w3.org/TR/xslt-30/schema-for-xslt30.xsd
SaxonCS-EE 11.4 from Saxonica
.NET 6.0.7 on Windows 10.0.22621.0
Using license serial number ..
..
URIResolver for schema file must return a Source
Exiting with code 2
Actions #10

Updated by Martin Honnen about 1 year ago

For my WSL Ubuntu Linux with 12 I get a similar error to the one on Windows or yours on MacOs:

mh@LibertyDell:~$ SaxonCS-12.0/SaxonCS validate -t -xsd:http://www.w3.org/TR/xmlschema11-1/XMLSchema.xsd -s:https://www.w3.org/TR/xslt-30/schema-for-xslt30.xsd
SaxonCS-EE 12.0 from Saxonica
.NET 6.0.13 on Linux
Using license serial number ..
Loading schema document http://www.w3.org/TR/xmlschema11-1/XMLSchema.xsd
: An error has occurred while opening external DTD 'http://www.w3.org/TR/xmlschema11-1/XMLSchema.dtd': Value cannot be null. (Parameter 'path1')
Fatal error during validation: : An error has occurred while opening external DTD 'http://www.w3.org/TR/xmlschema11-1/XMLSchema.dtd': Value cannot be null. (Parameter 'path1')
Exiting with code 2
Actions #11

Updated by Norm Tovey-Walsh about 1 year ago

Rider is really being very recalcitrant. I simply can't get the debugger to work and it's entirely unclear why.

A quick look at the XmlResolverCS project doesn't support the hypothesis that redirects aren't being followed. But it doesn remind me that I need to do a .NET 6 release. And apparently WebClient is deprecated so I should fix that.

Actions #12

Updated by Norm Tovey-Walsh about 1 year ago

Even more weird, I can't now reproduce it with either a Debug or a Release build off he current main branch. Going back to the 12_0 tag to try that...

Actions #13

Updated by Norm Tovey-Walsh about 1 year ago

The 12_0 tag didn't help. And it doesn't fail for me on Windows. Going back and trying the 11 branch on Windows next.

Actions #14

Updated by Norm Tovey-Walsh about 1 year ago

Taking a turn towards the even more confusing, I've discovered that the build target makes a difference.

If you just build the .NET app, you get a directory full of DLL files and an executable. If you run the command with that app, it works fine.

$ pwd
/Volumes/Saxonica/src/saxonica/saxondev/build/cs/bin/Debug/net6.0/linux-x64
$ ./SaxonCS validate -t -xsd:http://www.w3.org/TR/xmlschema11-1/XMLSchema.xsd -s:https://www.w3.org/TR/xslt-30/schema-for-xslt30.xsd
SaxonCS-EE 12.0 from Saxonica
.NET 6.0.13 on Linux
Using license serial number V010583
Loading schema document http://www.w3.org/TR/xmlschema11-1/XMLSchema.xsd
Finished loading schema document http://www.w3.org/TR/xmlschema11-1/XMLSchema.xsd
Schema checking successful. Time: 702ms.
Memory used: 4Mb
Processing https://www.w3.org/TR/xslt-30/schema-for-xslt30.xsd
Validation time: 145ms.
Memory used: 2Mb
Validation successful

If you build the "publishable" version of the .NET app, you get a "single file" application which has (I think) all of the DLL files "compiled in". That version fails.

$ cd publish
$ pwd
/Volumes/Saxonica/src/saxonica/saxondev/build/cs/bin/Debug/net6.0/linux-x64/publish
$ ./SaxonCS validate -t -xsd:http://www.w3.org/TR/xmlschema11-1/XMLSchema.xsd -s:https://www.w3.org/TR/xslt-30/schema-for-xslt30.xsd
SaxonCS-EE 12.0 from Saxonica
.NET 6.0.13 on Linux
Using license serial number V010583
Loading schema document http://www.w3.org/TR/xmlschema11-1/XMLSchema.xsd
: An error has occurred while opening external DTD 'http://www.w3.org/TR/xmlschema11-1/XMLSchema.dtd': Value cannot be null. (Parameter 'path1')
Fatal error during validation: : An error has occurred while opening external DTD 'http://www.w3.org/TR/xmlschema11-1/XMLSchema.dtd': Value cannot be null. (Parameter 'path1')
Exiting with code 2

Not less confusing.

Actions #15

Updated by Norm Tovey-Walsh about 1 year ago

Okay. When running from the "just compiled" version that has all those separate DLLs, attempting to resolve the DTD finds it in the "data" DLL, pack://application:,,,XmlResolverData;1.2.0;component/www....

When running from the "single file" version, either the data DLL isn't included or it isn't available. I still think the resolver should get the file from W3C but ...

Actions #16

Updated by Norm Tovey-Walsh about 1 year ago

I have been attempting to load the data assembly by path name. That's not going to work when it's all compiled together. I'm not sure, on reflection, that it was a good idea anyway. A lot of getting XmlResolverCS working was trial and error.

It appears that I can load the assembly "by name". And if I leave the version out of the name, it finds the version that's compiled into the app.

In the meantime, if you download the XmlResolverData nuget package and put the data DLL from that in your current working directory, it might work :-)

Actions #17

Updated by Martin Honnen about 1 year ago

Norm Tovey-Walsh wrote in #note-16:

In the meantime, if you download the XmlResolverData nuget package and put the data DLL from that in your current working directory, it might work :-)

That seems to be true. So in the end the released Saxon 11.4 and 12.0 executables don't have the xmlresolverdata.dll included, only the xmlresolver.dll?

Actions #18

Updated by Norm Tovey-Walsh about 1 year ago

No, the way I'm trying to load the data DLL doesn't work when the DLL is compiled into a single executable. I'm doing the lookup wrong, basically. I've just about got the resolver fixed so this should be fixed in 11.5 and 12.1.

Actions #19

Updated by Norm Tovey-Walsh about 1 year ago

  • Status changed from In Progress to Resolved
  • Applies to branch 12, trunk added
  • Fix Committed on Branch 11, 12, trunk added

Resolved with XmlResolver 2.0.0.

Actions #20

Updated by O'Neil Delpratt about 1 year ago

  • Fixed in Maintenance Release 11.5 added

Bug fix applied in the Saxon 11.5 maintenance release.

Actions #21

Updated by O'Neil Delpratt about 1 year ago

  • Status changed from Resolved to Closed
  • % Done changed from 0 to 100
  • Fixed in Maintenance Release 12.1 added

Bug fix applied in the Saxon 12.1 maintenance release.

Please register to edit this issue

Also available in: Atom PDF