0
votes

I am trying to run Saxon HE from java, using code that can be found in Saxon resources. I have tried changing it so that it doesn't create an aditional file from the java code, but instead having the xslt file doing that throught the use of "result-document".

My xslt did work as intended in Altova XMLSpy, but I wanted to see if I could get Saxon doing the same thing - no luck there, save from a massive head ache and loads of frustration and lots of wishes that Python will get support for this some day soon...

I get the following error message: The system identifier of the principal output file is unknown.

When I google it, I find an answer that the base uri can't be found, but nowhere can be seen how to set the base uri...

So my firt question is: Where is the base uri set? Is it in the java class or in the xslt file? I cannot see where I would set this in the xslt file, so my guess is that I would have to set this as a property of the compiler/transformer?

ANother question is about the actual href attribute of the result-document. If I want to point to a relative path, what is the syntax, and maybe what would an example look like? And what about absolute paths?

In my file that is working in Altova, I somehow get the base uri for the source xml file that is to be transformed, and then I direct the output to a relative directory. In Saxon, the base uri instead seems to get the location of the xslt file... No idea why this is the case. When setting an absolute path, I get an error stating I'm using an unknown protocol. So I entered "file:///" before the path. Now I get a warning complaining about a document not beeing available at a path that is concatenated of the xslt file path, and a lookup path I'm using during the transform.

As you can see, I'm all over the place here, so some guide lines and help would be greatly appreciated.

1
Can you please show your code? - Daniel Haley

1 Answers

0
votes

There are two APIs for running a Saxon transformation, and you haven't said which of them you are using.

Either way, a relative URI used in the href attribute of xsl:result-document is resolved relative to the "base output URI" of the transformation.

If you're using the JAXP transformation API, this was designed for XSLT 1.0, which doesn't recognize the concept of a base output URI. Saxon therefore uses the SystemID of the JAXP Result object provided as the destination of the transformation. If the JAXP Result object doesn't have a system ID, for example if you supply a DOMResult or StreamResult with no system ID specified, you're likely to get an error.

By contrast the s9api API was designed for XSLT 2.0 (with extensions for 3.0), and its XsltTransformer object therefore has an explicit setBaseOutputURI() method.

If you did something and it didn't work, then please tell us exactly what you did and exactly how it failed, and then we can help you get it right next time. It's hard to debug code that we can't see.