2013-09-01 43 views
1

我想轉換Xml文件位於Zip存檔,在這種特殊情況下它是Docx(OpenXML)Zip文件存檔。當我在尋找答案時,我讀了幾次建議的jar protocol(例如:here)。嘗試各種組合或斜線,反斜線和前綴後,我終於得到了撒克遜輸出別的,「文件不存在」,即:從Zip存檔引用xml文件

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 

輸出這樣的:

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 

這是相當不同的,那麼輸出從我以前的嘗試,當我假設我沒有使用Zip文件資源的正確引用。

有人知道這裏可能存在什麼問題,或者更一般地提供使用Zip歸檔文件中的Xml文件作爲Xml源與Saxon進行轉換的工作示例?

+0

確實的:JAR:文件:/// C:/temp/test.docx /字/ document.xml'工作? –

+0

不幸的是,這是我第一次嘗試並得到的東西之一:'源文件jar:文件:\ c:\ temp \ test.docx!\ word \ document.xml不存在' – theta

回答

2

你通過文件名來作爲Saxom使用-u選項URL,例如

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

這對我的作品在Linux上。

最佳,魯普雷希特

+0

感謝Ruprecht,您的建議在Windows上完美工作:) – theta