Error: Resolved URL is malformed: unknown protocol: zip

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Error: Resolved URL is malformed: unknown protocol: zip

Gerhard Egger
Hi all,

The following works fine in oXygen (using Saxon 9), but does not work on the commandline!

I have a problem with writing into a zip-file - i.e. a Docx-File.

                <xsl:variable name="template"><xsl:text>/Users/gerhard/Downloads/Archiv/VorlageOriginal.docx</xsl_text></xsl:variable>
....
                <xsl:variable name="filename"><xsl:text>zip:file:</xsl:text><xsl:value-of  select="$template"/><xsl:text>!/word/document.xml</xsl:text></xsl:variable>
.....
                <xsl:result-document href="{$filenamex}">
                    <xsl:copy-of select="$content"/>

                </xsl:result-document>


On the commandline I use: java -jar saxon9ee.jar testfile.xml xml2docx.xsl template=/Users/gerhard/Downloads/Archiv/Template.docx

Here is the error I get:

Error at xsl:result-document on line 261 of xml2docx.xsl:
Resolved URL is malformed: unknown protocol: zip
Resolved URL is malformed


What's wrong?


Thank you all for your reblies :-)


Gerhard

------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are
consuming the most bandwidth. Provides multi-vendor support for NetFlow,
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports.http://sdm.link/zohodev2dev
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: Error: Resolved URL is malformed: unknown protocol: zip

Michael Kay
I don't think Saxon's StandardOutputResolver has ever handled output to ZIP URLs. I suspect this is "added value" implemented by the oXygen team in their own OutputURIResolver.

You can write to a file in a ZIP archive using the EXPath archive module: see

http://www.saxonica.com/documentation/index.html#!functions/expath-archive

Michael Kay
Saxonica


> On 20 Jul 2016, at 15:54, Gerhard Egger <[hidden email]> wrote:
>
> Hi all,
>
> The following works fine in oXygen (using Saxon 9), but does not work on the commandline!
>
> I have a problem with writing into a zip-file - i.e. a Docx-File.
>
>                 <xsl:variable name="template"><xsl:text>/Users/gerhard/Downloads/Archiv/VorlageOriginal.docx</xsl_text></xsl:variable>
> ....
>                 <xsl:variable name="filename"><xsl:text>zip:file:</xsl:text><xsl:value-of  select="$template"/><xsl:text>!/word/document.xml</xsl:text></xsl:variable>
> .....
>                 <xsl:result-document href="{$filenamex}">
>                     <xsl:copy-of select="$content"/>
>
>                 </xsl:result-document>
>
>
> On the commandline I use: java -jar saxon9ee.jar testfile.xml xml2docx.xsl template=/Users/gerhard/Downloads/Archiv/Template.docx
>
> Here is the error I get:
>
> Error at xsl:result-document on line 261 of xml2docx.xsl:
> Resolved URL is malformed: unknown protocol: zip
> Resolved URL is malformed
>
>
> What's wrong?
>
>
> Thank you all for your reblies :-)
>
>
> Gerhard
> ------------------------------------------------------------------------------
> What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
> patterns at an interface-level. Reveals which users, apps, and protocols are
> consuming the most bandwidth. Provides multi-vendor support for NetFlow,
> J-Flow, sFlow and other flows. Make informed decisions using capacity planning
> reports.http://sdm.link/zohodev2dev_______________________________________________
> saxon-help mailing list archived at http://saxon.markmail.org/
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/saxon-help



------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are
consuming the most bandwidth. Provides multi-vendor support for NetFlow,
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports.http://sdm.link/zohodev2dev
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: Error: Resolved URL is malformed: unknown protocol: zip

Radu Coravu
Hi,

I can confirm that Oxygen registers in the Java URL Stream Handler
Factory extra protocols, among which the "zip" protocol implemented
using the open source TrueZIP library.
But maybe Gerhard can try using the "jar" protocol instead (with exactly
the same syntax). It's a protocol built into the Java VM used by Java to
load classes.

Regards,
Radu

Radu Coravu
<oXygen/>  XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

On 7/20/2016 7:17 PM, Michael Kay wrote:

> I don't think Saxon's StandardOutputResolver has ever handled output to ZIP URLs. I suspect this is "added value" implemented by the oXygen team in their own OutputURIResolver.
>
> You can write to a file in a ZIP archive using the EXPath archive module: see
>
> http://www.saxonica.com/documentation/index.html#!functions/expath-archive
>
> Michael Kay
> Saxonica
>
>
>> On 20 Jul 2016, at 15:54, Gerhard Egger <[hidden email]> wrote:
>>
>> Hi all,
>>
>> The following works fine in oXygen (using Saxon 9), but does not work on the commandline!
>>
>> I have a problem with writing into a zip-file - i.e. a Docx-File.
>>
>>                 <xsl:variable name="template"><xsl:text>/Users/gerhard/Downloads/Archiv/VorlageOriginal.docx</xsl_text></xsl:variable>
>> ....
>>                 <xsl:variable name="filename"><xsl:text>zip:file:</xsl:text><xsl:value-of  select="$template"/><xsl:text>!/word/document.xml</xsl:text></xsl:variable>
>> .....
>>                 <xsl:result-document href="{$filenamex}">
>>                     <xsl:copy-of select="$content"/>
>>
>>                 </xsl:result-document>
>>
>>
>> On the commandline I use: java -jar saxon9ee.jar testfile.xml xml2docx.xsl template=/Users/gerhard/Downloads/Archiv/Template.docx
>>
>> Here is the error I get:
>>
>> Error at xsl:result-document on line 261 of xml2docx.xsl:
>> Resolved URL is malformed: unknown protocol: zip
>> Resolved URL is malformed
>>
>>
>> What's wrong?
>>
>>
>> Thank you all for your reblies :-)
>>
>>
>> Gerhard
>> ------------------------------------------------------------------------------
>> What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
>> patterns at an interface-level. Reveals which users, apps, and protocols are
>> consuming the most bandwidth. Provides multi-vendor support for NetFlow,
>> J-Flow, sFlow and other flows. Make informed decisions using capacity planning
>> reports.http://sdm.link/zohodev2dev_______________________________________________
>> saxon-help mailing list archived at http://saxon.markmail.org/
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/saxon-help
>
>
>
> ------------------------------------------------------------------------------
> What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
> patterns at an interface-level. Reveals which users, apps, and protocols are
> consuming the most bandwidth. Provides multi-vendor support for NetFlow,
> J-Flow, sFlow and other flows. Make informed decisions using capacity planning
> reports.http://sdm.link/zohodev2dev
> _______________________________________________
> saxon-help mailing list archived at http://saxon.markmail.org/
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/saxon-help
>



------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are
consuming the most bandwidth. Provides multi-vendor support for NetFlow,
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports.http://sdm.link/zohodev2dev
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: Error: Resolved URL is malformed: unknown protocol: zip

Radu Coravu
Correction, the Java "jar" protocol only knows how to read a resource
from a JAR and you need to write to it.
Besides EXpath you can also try to create an ANT script which unpacks
the DOCX archive, applies the XSLT stylesheet and packs it again at the end.

Regards,
Radu

Radu Coravu
<oXygen/>  XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

On 7/21/2016 7:45 AM, Radu Coravu wrote:

> Hi,
>
> I can confirm that Oxygen registers in the Java URL Stream Handler
> Factory extra protocols, among which the "zip" protocol implemented
> using the open source TrueZIP library.
> But maybe Gerhard can try using the "jar" protocol instead (with exactly
> the same syntax). It's a protocol built into the Java VM used by Java to
> load classes.
>
> Regards,
> Radu
>
> Radu Coravu
> <oXygen/>  XML Editor, Schema Editor and XSLT Editor/Debugger
> http://www.oxygenxml.com
>
> On 7/20/2016 7:17 PM, Michael Kay wrote:
>> I don't think Saxon's StandardOutputResolver has ever handled output to ZIP URLs. I suspect this is "added value" implemented by the oXygen team in their own OutputURIResolver.
>>
>> You can write to a file in a ZIP archive using the EXPath archive module: see
>>
>> http://www.saxonica.com/documentation/index.html#!functions/expath-archive
>>
>> Michael Kay
>> Saxonica
>>
>>
>>> On 20 Jul 2016, at 15:54, Gerhard Egger <[hidden email]> wrote:
>>>
>>> Hi all,
>>>
>>> The following works fine in oXygen (using Saxon 9), but does not work on the commandline!
>>>
>>> I have a problem with writing into a zip-file - i.e. a Docx-File.
>>>
>>>                 <xsl:variable name="template"><xsl:text>/Users/gerhard/Downloads/Archiv/VorlageOriginal.docx</xsl_text></xsl:variable>
>>> ....
>>>                 <xsl:variable name="filename"><xsl:text>zip:file:</xsl:text><xsl:value-of  select="$template"/><xsl:text>!/word/document.xml</xsl:text></xsl:variable>
>>> .....
>>>                 <xsl:result-document href="{$filenamex}">
>>>                     <xsl:copy-of select="$content"/>
>>>
>>>                 </xsl:result-document>
>>>
>>>
>>> On the commandline I use: java -jar saxon9ee.jar testfile.xml xml2docx.xsl template=/Users/gerhard/Downloads/Archiv/Template.docx
>>>
>>> Here is the error I get:
>>>
>>> Error at xsl:result-document on line 261 of xml2docx.xsl:
>>> Resolved URL is malformed: unknown protocol: zip
>>> Resolved URL is malformed
>>>
>>>
>>> What's wrong?
>>>
>>>
>>> Thank you all for your reblies :-)
>>>
>>>
>>> Gerhard
>>> ------------------------------------------------------------------------------
>>> What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
>>> patterns at an interface-level. Reveals which users, apps, and protocols are
>>> consuming the most bandwidth. Provides multi-vendor support for NetFlow,
>>> J-Flow, sFlow and other flows. Make informed decisions using capacity planning
>>> reports.http://sdm.link/zohodev2dev_______________________________________________
>>> saxon-help mailing list archived at http://saxon.markmail.org/
>>> [hidden email]
>>> https://lists.sourceforge.net/lists/listinfo/saxon-help
>>
>>
>>
>> ------------------------------------------------------------------------------
>> What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
>> patterns at an interface-level. Reveals which users, apps, and protocols are
>> consuming the most bandwidth. Provides multi-vendor support for NetFlow,
>> J-Flow, sFlow and other flows. Make informed decisions using capacity planning
>> reports.http://sdm.link/zohodev2dev
>> _______________________________________________
>> saxon-help mailing list archived at http://saxon.markmail.org/
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/saxon-help
>>
>
>
>
> ------------------------------------------------------------------------------
> What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
> patterns at an interface-level. Reveals which users, apps, and protocols are
> consuming the most bandwidth. Provides multi-vendor support for NetFlow,
> J-Flow, sFlow and other flows. Make informed decisions using capacity planning
> reports.http://sdm.link/zohodev2dev
> _______________________________________________
> saxon-help mailing list archived at http://saxon.markmail.org/
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/saxon-help
>



------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are
consuming the most bandwidth. Provides multi-vendor support for NetFlow,
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports.http://sdm.link/zohodev2dev
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: Error: Resolved URL is malformed: unknown protocol: zip

Michael Kay
In reply to this post by Radu Coravu
>
> I can confirm that Oxygen registers in the Java URL Stream Handler
> Factory extra protocols, among which the "zip" protocol implemented
> using the open source TrueZIP library.
> But maybe Gerhard can try using the "jar" protocol instead (with exactly
> the same syntax). It's a protocol built into the Java VM used by Java to
> load classes.
>

I think Saxon recognizes the JAR protocol/scheme for input, but not for output.

On output, using the standard OutputURIResolver, if it's any scheme other than "file" we do this:

URLConnection connection = absoluteURI.toURL().openConnection();
connection.setDoInput(false);
connection.setDoOutput(true);
connection.connect();
OutputStream stream = connection.getOutputStream();
StreamResult result = new StreamResult(stream);
result.setSystemId(absoluteURI.toASCIIString());
return result;

and in my experience it usually fails, with a few possible exceptions like WebDAV. But I'm sure it depends on what protocol handlers have been configured at the Java level.

Another issue with the JAR protocol is that the URI syntax doesn't follow RFC 2396, which means that resolving a relative URI against an absolute URI can fail. We've got some tweaks that recognize the JAR scheme specially for this reason, but we won't recognize other schemes like ZIP.

Michael Kay
Saxonica





------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are
consuming the most bandwidth. Provides multi-vendor support for NetFlow,
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports.http://sdm.link/zohodev2dev
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: Error: Resolved URL is malformed: unknown protocol: zip

Eliot Kimber-2
For a client I implemented a Zip output URI writer in order to write
result files directly into a Zip package (which is then returned via a Web
service, so no value in persisting the Zip to disk).

It wasn't hard to do. Unfortunately the code was a work for hire so I
can't share it. But it was a pretty straightforward application of the
Java Zip API--basically I cribbed some sample code I found somewhere.

Cheers,

E.
----
Eliot Kimber, Owner
Contrext, LLC
http://contrext.com




On 7/21/16, 3:24 AM, "Michael Kay" <[hidden email]> wrote:

>>
>> I can confirm that Oxygen registers in the Java URL Stream Handler
>> Factory extra protocols, among which the "zip" protocol implemented
>> using the open source TrueZIP library.
>> But maybe Gerhard can try using the "jar" protocol instead (with
>>exactly
>> the same syntax). It's a protocol built into the Java VM used by Java
>>to
>> load classes.
>>
>
>I think Saxon recognizes the JAR protocol/scheme for input, but not for
>output.
>
>On output, using the standard OutputURIResolver, if it's any scheme other
>than "file" we do this:
>
>URLConnection connection = absoluteURI.toURL().openConnection();
>connection.setDoInput(false);
>connection.setDoOutput(true);
>connection.connect();
>OutputStream stream = connection.getOutputStream();
>StreamResult result = new StreamResult(stream);
>result.setSystemId(absoluteURI.toASCIIString());
>return result;
>
>and in my experience it usually fails, with a few possible exceptions
>like WebDAV. But I'm sure it depends on what protocol handlers have been
>configured at the Java level.
>
>Another issue with the JAR protocol is that the URI syntax doesn't follow
>RFC 2396, which means that resolving a relative URI against an absolute
>URI can fail. We've got some tweaks that recognize the JAR scheme
>specially for this reason, but we won't recognize other schemes like ZIP.
>
>Michael Kay
>Saxonica
>
>
>
>
>
>--------------------------------------------------------------------------
>----
>What NetFlow Analyzer can do for you? Monitors network bandwidth and
>traffic
>patterns at an interface-level. Reveals which users, apps, and protocols
>are
>consuming the most bandwidth. Provides multi-vendor support for NetFlow,
>J-Flow, sFlow and other flows. Make informed decisions using capacity
>planning
>reports.http://sdm.link/zohodev2dev
>_______________________________________________
>saxon-help mailing list archived at http://saxon.markmail.org/
>[hidden email]
>https://lists.sourceforge.net/lists/listinfo/saxon-help
>



------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are
consuming the most bandwidth. Provides multi-vendor support for NetFlow,
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports.http://sdm.link/zohodev2dev
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help