[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: document( URI ) with accented chars fails

Subject: Re: document( URI ) with accented chars fails
From: "Martynas Jusevičius martynas@xxxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 18 Nov 2020 12:16:00 -0000
Re:  document( URI ) with accented chars fails
We use this in bash scripts:

urlencode()
{
    python -c 'import urllib, sys; print urllib.quote(sys.argv[1] if
len(sys.argv) > 1 else sys.stdin.read()[0:-1])' "$1"
}

On Wed, Nov 18, 2020 at 12:32 PM Alexandre HoC/de
alexandre.hoide@xxxxxxxxxx <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
wrote:
>
> On Tue, Nov 17, 2020 at 10:51:25PM -0000, Alexandre HoC/de
alexandre.hoide@xxxxxxxxxx wrote:
> > On Tue, Nov 17, 2020 at 09:26:23PM -0000, Michael Kay mike@xxxxxxxxxxxx
wrote:
> > > The document() function expects a URI, not a filename, and URIs never
contain accented characters.
> > >
> > > XSLT 2.0+ has functions to escape special characters using %HH escapes
so you can turn arbitrary filenames into valid URIs.
> > >
> > > For xsltproc you'll need some processor-specific solution and I can't
help you with that.
>
> It is not directly XSLT related, but just in case :
>
> The EXSLT has a `str:encode-uri`B9 function but, unfortunately,
> `xsltproc` from `libxslt` does not implement it.
>
> So, I have now enriched my bash script used to build
> the fileslist.xml with a small Perl script including the Perl
> module bURIbB2, and applied to each file path.
>
> ~~~{filename-to-uri.pl}
> #!/usr/bin/env perl
> use URI::file;
> my $uri = URI::file->new( $ARGV[0] );
> print $uri . "\n";
> ~~~
>
> applied on each file name with :
> ~~~{bash command line}
> $ perl filename-to-uri.pl <the-filename-to-convert-to-uri>
> ~~~
>
> Best regards and thanks again,
> Alexandre HoC/de
>
> 1. http://exslt.org/str/functions/encode-uri/index.html
> 2. https://metacpan.org/pod/URI
>    (on GNU Guix the package is `perl-uri`)

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.