serialized compiled stylesheets - how to read
Added by Anonymous about 20 years ago
Legacy ID: #2825410 Legacy Poster: Jos Aerts (aertsj)
I have some problems with the use of (command-line) compiled stylesheets, so I went back to the samples (using TraxExamples.class). First I compiled foo.xsl and then ran TraxExamples again. For the exampleUseTemplatesObj I get: EXCEPTION: javax.xml.transform.TransformerConfigurationException: javax.xml.transform.TransformerException: org.xml.sax.SAXParseException: Character conversion error: "Unconvertible UTF-8 character beginning with 0xac" (line number may be too low). So my question is: if I have a compiled stylesheet, how do I use saxon (within Java code) to transform? The reason that I want to use a compiled stylesheet is that I do not want the user to be able to see what is exactly in the stylesheet. I am using Saxon7-9-1. Does anyone have code snippets for this ? Many thanks in advance Jozef Aerts
Replies (4)
Please register to reply
RE: serialized compiled stylesheets - how to - Added by Anonymous about 20 years ago
Legacy ID: #2825455 Legacy Poster: Michael Kay (mhkay)
This error could occur because you failed to specify -c on the command line to tell Saxon you were using a compiled stylesheet. Michael Kay
RE: serialized compiled stylesheets - how to - Added by Anonymous about 20 years ago
Legacy ID: #2826006 Legacy Poster: Jos Aerts (aertsj)
Yes, I realize that is the way to do it when you run Saxon from line command. However I am working on a stand-alone Java application that should read in a compiled worksheet. The application uses Saxon as a library. I tried using the TraxExamples, but that is where I get the mentioned error messages. It might be that the TraxExamples exampleUseTemplatesObj compiles the stylesheet on the fly and then uses it, but that is not what I want: my compiled stylesheet resides already on disc. Thanks in advance Jozef Aerts
RE: serialized compiled stylesheets - how to - Added by Anonymous about 20 years ago
Legacy ID: #2826061 Legacy Poster: Michael Kay (mhkay)
There isn't an example in TraxExamples of how to do this: I suggest you look at the code around line 428-437 of net.sf.saxon.Transform. There's a bit of delicate fixing up to make sure the run-time and the compiled stylesheet are using the same configuration and the same NamePool. You shouldn't try to do this in a multithreaded environment where many transformations are using the same Configuration object - it's essential that the run-time code uses the NamePool that was saved with the compiled stylesheet. I should probably put an API around this to protect you from future changes in the implementation. Michael Kay
RE: serialized compiled stylesheets - how to read - Added by Anonymous about 20 years ago
Legacy ID: #2827965 Legacy Poster: Jos Aerts (aertsj)
Many thanks Michael, Using some code snippets from Transform.java I could indeed now successfully build the application. I used the saxonb8-1-1 for this. It's easy - if you now how. Many thanks again Jozef
Please register to reply