SaxonCS and providing the license file in various environments (difficulties with Maui/Android)

Added by Martin Honnen over 1 year ago

Using the various .NET 5 or .NET 6 new development platforms like Blazor or Maui I have experimenting with using SaxonCS in various ways, the current API wants me to provide the configuration and/or the license as a file location, I have run into some problems due to the various ways the new platforms allow file access, in Blazor all access is asynchronous, for Maui (targetting various rather different platforms like Windows, Android, iOS, MacOS) a file path like SAXON_LICENSE_DIR in a compatible way might be hard to set up.

For Maui, it seems an app can provide its own resource files in a platform indenpendent way as so called assets but the API to then read an asset is not file location/path based in a general way, it looks as if e.g. FileSystem.OpenAppPackageFileAsync("saxoncsee-sample-config1.xml") only gives me a Stream that might be pulled from an Android package, so I have no base URI for the configuration file to set up in e.g. new Processor(await FileSystem.OpenAppPackageFileAsync("saxoncsee-sample-config1.xml"), baseUriToAllowLicenseFileResolution) to allow Saxon to also find the license file in that package. I can also make sure, for testing at least, that my license is an asset in the same package, C# can then also read that file using a Stream with e.g. await FileSystem.OpenAppPackageFileAsync("saxon-license.lic") but I can't tell Saxon to use a Stream to read its license file, it wants a file location/path set up in an environment variable or in the configuration file or as a configuration property.

So I am having a hard time to get SaxonCS to run, as it bails out if doesn't find its license file.

Would it be possible to also allow SaxonCS to read its license file from a Stream?

Please register to reply