Bug #5624
closedSaxonCS.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 2 years ago. Updated almost 2 years ago.
100%
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".
Updated by Martin Honnen over 2 years 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
Updated by Michael Kay almost 2 years 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.
Updated by Martin Honnen almost 2 years 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
Updated by Michael Kay almost 2 years 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.
Updated by Martin Honnen almost 2 years 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
Updated by Norm Tovey-Walsh almost 2 years ago
- Status changed from New to In Progress
Updated by Norm Tovey-Walsh almost 2 years 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.
Updated by Martin Honnen almost 2 years 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
Updated by Martin Honnen almost 2 years 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
Updated by Norm Tovey-Walsh almost 2 years 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.
Updated by Norm Tovey-Walsh almost 2 years 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...
Updated by Norm Tovey-Walsh almost 2 years 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.
Updated by Norm Tovey-Walsh almost 2 years 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.
Updated by Norm Tovey-Walsh almost 2 years 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 ...
Updated by Norm Tovey-Walsh almost 2 years 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 :-)
Updated by Martin Honnen almost 2 years 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?
Updated by Norm Tovey-Walsh almost 2 years 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.
Updated by Norm Tovey-Walsh almost 2 years 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.
Updated by O'Neil Delpratt almost 2 years ago
- Fixed in Maintenance Release 11.5 added
Bug fix applied in the Saxon 11.5 maintenance release.
Updated by O'Neil Delpratt almost 2 years 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