Project

Profile

Help

.NET: Loading relative URI of /configuration/resources/schemaDocument

Added by T Hata almost 7 years ago

Configuration file (config.xml):




	
	
		test.xsd
	

Schema file (test.xsd):




.NET console program:


namespace TempSaxon
{
	class Program
	{
		static void Main( string[] args )
		{
			Saxon.Api.Processor processor = new Saxon.Api.Processor( System.IO.File.OpenRead( args[0] ) );
		}
	}
}

Build the program and place the files like this:

P:\test>dir /a:-d /b /s
P:\test\TempSaxon.exe
P:\test\files\config.xml
P:\test\files\test.xsd

Saxon reads the configuration file but fails to load the schema, when you run it like this:

P:\test>TempSaxon.exe files\config.xml
Loading schema document file:/P:/test/test.xsd
Using parser org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser
Warning
  java.io.FileNotFoundException: Could not find file 'P:\test\test.xsd'.

Unhandled Exception: net.sf.saxon.type.SchemaException: java.io.FileNotFoundException: Could not find file 'P:\test\test.xsd'.
   at net.sf.saxon.trans.ConfigurationReader.makeConfiguration(Source source)
   at net.sf.saxon.Configuration.readConfigurationFile(Source source)
   at net.sf.saxon.Configuration.readConfiguration(Source source)
   at Saxon.Api.Processor..ctor(Stream configurationFile)
   at TempSaxon.Program.Main(String[] args)

So.. Is @schemaDocument@ supposed to be resolved from the current directory? Or shall I construct the processor in another way?


Replies (1)

RE: .NET: Loading relative URI of /configuration/resources/schemaDocument - Added by Michael Kay almost 7 years ago

Thanks for pointing this out. This is an API design issue which I have raised here:

https://saxonica.plan.io/issues/3664

The implementation is apparently defaulting the base URI to the current working directory, which is OK as a fallback but we ought to provide a better way of supplying the base URI, e.g. a constructor that accepts a File, or a URI plus a stream.

    (1-1/1)

    Please register to reply