Project

Profile

Help

Create docx output file and folders with the Java API

Added by Daniel Schmid over 6 years ago

We did with Altove Stylevision an XSLT template for XML --> Word.

It runs fine in the console: java -jar ./saxon9he.jar -s:data.xml -xsl:docx.xslt -o:docx/test.xml

It creates the correct folders and files to be zipped and renamed as docx.

My question is how I do it with the Java API?

I am kind of non java export but I use saxon a lot for XML transformation and output the result to the net.sf.saxon.s9api.Serializer... as desribed in the samples

Are there examples how to use saxon java API with (Altova) XSLT to product output folders and XML-files for docx?

thanks a lot!


Replies (2)

RE: Create docx output file and folders with the Java API - Added by Michael Kay over 6 years ago

First, use the s9api API rather than JAXP because JAXP was designed for XSLT 1.0 and doesn't understand multiple output files.

The key thing you are probably missing is to set the base output URI: XsltTransformer.setBaseOutputURI(). This should be the same as the -o option. The base output URI is used for resolving any relative URIs appearing in the href attribute of xsl;result-document.

On the command line, -o sets both the destination URI for the principal output, and the base URI for secondary outputs.

RE: Create docx output file and folders with the Java API - Added by Daniel Schmid over 6 years ago

Thanks for bringing me on track! Finally I got it to work.

    (1-2/2)

    Please register to reply