Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
741 views
in Technique[技术] by (71.8m points)

xslt - Read a remote zipped xml with just XSL

I want to know if it's possible for an XSLT file to read data from an XML located within folders of a remote zip(from the server at work), without any external processors (saxon and so forth) and without downloading it.

Failing that, I'll resort to just reading the information from the zip... which brings me to my other (newb)issue.

I currently have an XSLT that accesses and gets the data from the downloaded and extracted XML file, but I can't do this without extracting it. I've read that with Altova and xslt 2.0 it is possible to read from within a zip file using the document() function, though, as of yet I have not been able achieve this.

this is how I'm trying to do it: document('name.zip|zip/folder/folder2/iwantthis.xml')

It just doesn't seem to find the file. I'd be almost eternally grateful if you show me the error of my ways and guide me into XSLThood.

Thank you kindly

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I don't think there is a general way of doing that.

However, in many Java-based XSLT processors (at least Saxon and Xalan), you can use 'jar:' URLs to refer to resources inside zip files. Prefix the URL pointing to the zip file with jar: and suffix it with !/ and the path to the file inside it. Like this: jar:file:///the/path/to/foo.zip!/foo.xml.

To achieve the same in other processors, you would probably need figure out if they allow registering a custom "URI handler" or an equivalent to deal with the special URIs you want to support.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...