Re: encode-for-uri() and filenames?

Dear Martin (cc XProc Dev),

Thank you for the quick response. When I try the diagnostic you mention, it
reports the filename with percent-escaping. Here's the XProc again:

<?xml version="1.0" encoding="UTF-8"?>
<p:declare-step xmlns:p="http://www.w3.org/ns/xproc" xmlns:c="
http://www.w3.org/ns/xproc-step"
  version="3.0">
  <p:input port="source">
    <p:inline>
      <doc>Hello world!</doc>
    </p:inline>
  </p:input>
  <p:output port="result"/>
  <p:variable name="output-filename"
select="encode-for-uri('test-1a%7%.xml')"/>
  <p:identity message="{$output-filename}"/>
  <p:store name="store-step" href="{$output-filename}"/>
  <p:identity>
    <p:with-input pipe="result-uri@store-step"/>
  </p:identity>
</p:declare-step>


Here's the terminal output after execution finishes:

djb@koala-4 verb % morgana test.xpl
=================================
MorganaXProc-IIIse 0.9.4.8-beta
Copyright 2011-2020 by <xml-project /> Achim Berndzen
=================================

[12:18:09.829] test-1a%257%25.xml
<?xml version="1.0" encoding="UTF-8"?>
<c:result xmlns:c="http://www.w3.org/ns/xproc-step
">file:/Users/djb/repos/cz/pos/verb/test-1a%257%25.xml</c:result>


And here's the filename created on the file system:

test-1a%7%.xml


My first assumption when I don't get the results I want (especially with
XProc, which is the XML technology with which I have the least experience)
is that it's because of user error, and therefore a matter of my having
misunderstood something about how XProc works. But I'll open an issue on
Morgana now, as well, as you suggest.

Best,

David

On Sun, Nov 22, 2020 at 12:13 PM Martin Honnen <martin.honnen@gmx.de> wrote:

>
> On 22.11.2020 17:34, David Birnbaum wrote:
>
> Dear XProc Dev,
>
> I've been struggling with filenames that are not compatible with URIs, and
> attempting to work around the limitation by using encode-for-uri() when I
> save the file. I described the general problem on the eXist-open mailing
> list, so I won't repeat it here, but my issue has an XProc aspect, and may
> even be an XProc—rather than broader filename—issue, and I would be
> grateful if someone on this list to help clarify that aspect of it for me.
>
> Here is a test XProc file, which I run under MorganaXProc-IIIse
> 0.9.4.8-beta:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <p:declare-step xmlns:p="http://www.w3.org/ns/xproc" xmlns:c="
> http://www.w3.org/ns/xproc-step"
>   version="3.0">
>   <p:input port="source">
>     <p:inline>
>       <doc>Hello world!</doc>
>     </p:inline>
>   </p:input>
>   <p:output port="result"/>
>   <p:variable name="output-filename"
> select="encode-for-uri('test-1a%7%.xml')"/>
>   <p:identity message="{$output-filename}"/>
>   <p:store href="{$output-filename}"/>
>   <p:identity/>
> </p:declare-step>
>
>
> Because the percent signs as they are used in the filename are
> incompatible with URI encoding, I expect them to be percent-encoded
> themselves, with the modified filename echoed to stderr (in the
> <p:identity> step) and used to save the test file (in the <p:store> step).
> What happens instead is that the percent encoded value is written, as
> expected, to stderr:
>
> test-1a%257%25.xml
>
>
> but the file is saved to the local filesystem as if encode-for-uri() had
> not been applied, that is, as:
>
> test-1a%7%.xml
>
>
>
> I don't have an explanation for that, perhaps ask Achim by raising an
> issue on Morgana on Sourceforge.
>
> It would also be interesting to see what
>
>   <p:identity><p:with-input pipe="result-uri@store-step"/></p:identity>
>
> outputs (where you name the `p:store name="store-step"`)
>
>

Received on Sunday, 22 November 2020 17:33:21 UTC