serialized compiled stylesheets - how to read

Jos Aerts
  • Jos Aerts

    Jos Aerts - 2004-10-27

    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

    • Michael Kay

      Michael Kay - 2004-10-27

      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

      • Jos Aerts

        Jos Aerts - 2004-10-28

        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

        • Michael Kay

          Michael Kay - 2004-10-28

          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

    • Jos Aerts

      Jos Aerts - 2004-10-29

      Many thanks Michael,

      Using some code snippets from 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



Log in to post a comment.