theta
theta

Reputation: 25631

Reference Xml file from Zip archive

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?

Upvotes: 1

Views: 816

Answers (1)

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

Upvotes: 2

Related Questions