1

I want to transform Xml document located in Zip archive, in this particular case it's Docx (OpenXML) Zip file archive. While I was searching for an answer, I read about jar protocol suggested couple of times (for example: here). After trying various combinations or slashes, backslashes and prefixes I finally got Saxon output something else that "File does not exist", i.e.:

java -cp "C:\Program Files\SaxonHE9\saxon9he.jar" net.sf.saxon.Transform ^
    -xsl:style-transform.xslt ^
    -s:file:///c:/temp/test.docx!/word/document.xml ^
    -o:test_out.xml

outputs this:

Warning: at xsl:stylesheet on line 14 column 19 of style-transform.xslt:
  Running an XSLT 1 stylesheet with an XSLT 2 processor
Error
  I/O error reported by XML parser processing
  file:///c:/temp/test.docx!/word/document.xml:
  c:\temp\test.docx!\word\document.xml (The system cannot find the path specified)
Transformation failed: Run-time errors were reported

which is quite different then output from my previous attempts, when I assume I wasn't using correct reference to Zip file resource.

Does someone know what may be this issue here, or more generally provide working example of using Xml file from Zip archive as Xml source for transformation with Saxon?

Community
  • 1
  • 1
theta
  • 24,593
  • 37
  • 119
  • 159
  • Does 's:jar:file:///c:/temp/test.docx!/word/document.xml` work? – Martin Honnen Sep 01 '13 at 12:20
  • Unfortunately not, that was one of the first things I tried and got just: `Source file jar:file:\c:\temp\test.docx!\word\document.xml does not exist` – theta Sep 01 '13 at 12:23

1 Answers1

2

You pass the file name to Saxom as a url using the -u option, for example

java -jar saxon9he.jar -u jar:file:./YOURINPUTARCHIVE.ods\!/content.xml YOURXSLT.xslt

This works for me on linux.

Best, Ruprecht

  • Thanks Ruprecht, your suggestion works perfectly on Windows too :) – theta Sep 01 '13 at 13:22
  • I put the xslt file in a zip, and use the zip path as your style, It can work too. If I encrypt the xslt zip file , how to make the path with password ? – cmf41013 Jan 02 '20 at 11:10