Absence of %encoding in href attribute of xsl:result-document

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

Absence of %encoding in href attribute of xsl:result-document

Colin Paul Adams
In the following code fragment:

<xsl:result-document method="text"
href="mailto:[hidden email]?from=[hidden email]&amp;subject=Testing
mailto: in xsl:result-document">

Saxon reports:

Error
  Invalid syntax for base URI: Illegal character in opaque part at index 77:
  mailto:[hidden email]?from=[hidden email]&subject=Testing mailto: in
  xsl:result-document
Transformation failed: Run-time errors were reported

As far as I can tell, it should not do this.

In section 5.8 of the XSLT 2.0 CR, it reads:

"If the URI reference is relative, then it is resolved (unless
otherwise specified) against the base URI of the containing element
node, according to the rules of [RFC3986], after first escaping all
characters that need to be escaped to make it a valid RFC3986 URI
reference. (But a relative URI in the href attribute of
xsl:result-document is resolved against the Base Output URI.)"

So I think you should be performing the %encoding before attempting
resolution.
Then, the result of the resolution should be the initial IRI reference
unchanged excepting the % encoding. This is then a legal mailto URI
(if I put %20s in place of the blanks in the original code, then it
works).
--
Colin Adams
Preston Lancashire


-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help
Reply | Threaded
Open this post in threaded view
|

RE: Absence of %encoding in href attribute of xsl:result-document

Michael Kay
Thanks for reporting this. I have logged a bug and it will be fixed in the
next release. In the meantime, please call iri-to-uri() to encode the URI
explicitly.

Note that Saxon does not support use of a "mailto" URI out-of-the-box,
though the required effect can probably be achieved using a user-written
OutputURIResolver.

Michael Kay
http://www.saxonica.com/
 

> -----Original Message-----
> From: [hidden email]
> [mailto:[hidden email]] On Behalf Of
> Colin Paul Adams
> Sent: 09 November 2005 10:45
> To: [hidden email]
> Subject: [saxon] Absence of %encoding in href attribute of
> xsl:result-document
>
> In the following code fragment:
>
> <xsl:result-document method="text"
> href="mailto:[hidden email]?from=[hidden email].
> co.uk&amp;subject=Testing
> mailto: in xsl:result-document">
>
> Saxon reports:
>
> Error
>   Invalid syntax for base URI: Illegal character in opaque
> part at index 77:
>  
> mailto:[hidden email]?from=[hidden email]&
> subject=Testing mailto: in
>   xsl:result-document
> Transformation failed: Run-time errors were reported
>
> As far as I can tell, it should not do this.
>
> In section 5.8 of the XSLT 2.0 CR, it reads:
>
> "If the URI reference is relative, then it is resolved (unless
> otherwise specified) against the base URI of the containing element
> node, according to the rules of [RFC3986], after first escaping all
> characters that need to be escaped to make it a valid RFC3986 URI
> reference. (But a relative URI in the href attribute of
> xsl:result-document is resolved against the Base Output URI.)"
>
> So I think you should be performing the %encoding before attempting
> resolution.
> Then, the result of the resolution should be the initial IRI reference
> unchanged excepting the % encoding. This is then a legal mailto URI
> (if I put %20s in place of the blanks in the original code, then it
> works).
> --
> Colin Adams
> Preston Lancashire
>
>
> -------------------------------------------------------
> SF.Net email is sponsored by:
> Tame your development challenges with Apache's Geronimo App
> Server. Download
> it for free - -and be entered to win a 42" plasma tv or your very own
> Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
> _______________________________________________
> saxon-help mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/saxon-help
>




-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help
Reply | Threaded
Open this post in threaded view
|

Re: Absence of %encoding in href attribute of xsl:result-document

Christian Roth-4
Michael Kay wrote:

>I have logged a bug and it will be fixed in the
>next release.

In the bug description, it reads:

    Thus Saxon currently allows

    href="file:///c:/My%20Documents/out.html"

    but under the spec it should also allow

    href="file:///c:/My Documents/out.html"


I'm unsure what the final URI result should be for:

(1) href="file:///20%50BUCKS.txt"
(2) href="20%50BUCKS.txt"
(3) href="file:20%MOREBUCKS.txt"

How does the processor determine whether it needs to quote the '%' sign
or if it is already an URI what it looks at, and therefore must not
quote unallowed characters?

Note that the file on disk for (2) is actually named "20%50BUCKS.txt".

Regards, Christian.




-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help
Reply | Threaded
Open this post in threaded view
|

Re: Absence of %encoding in href attribute of xsl:result-document

Colin Paul Adams
In reply to this post by Michael Kay
>>>>> "Michael" == Michael Kay <[hidden email]> writes:

    Michael> Note that Saxon does not support use of a "mailto" URI
    Michael> out-of-the-box, though the required effect can probably
    Michael> be achieved using a user-written OutputURIResolver.

Well, that is what I had assumed. I thought I had a "first" with
gestalt, when adding this functionality, and I was only testing it
with Saxon because I could not find an official error message for what
to do if the output resolver failed to successfully resolve a
destination.
So I tested it with Saxon to see what happens, and Saxon
too issues it's own error message.

Perhaps we need an additional error message?
Saxon currently puts out messages like:

Error
  Invalid syntax for base URI: Illegal character in opaque part at index 92:
  mailto:[hidden email]?from=[hidden email]&subject=Testing%20mailto:%20in xsl:result-document
Transformation failed: Run-time errors were reported

But I accidentally discovered that Saxon DOES support mailto - I got
my email message delivered OK.

Here is a transformation that you can run which demonstrates it works:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                version="2.0">

<xsl:output method="xml" encoding="utf-8" indent="no"
            omit-xml-declaration="yes"/>

<xsl:template name="initial">

  <xsl:result-document method="text" href="mailto:[hidden email]?from=[hidden email]&amp;subject=Testing%20mailto:%20in%20xsl:result-document">
    This is the body of an email message generated automatically by
    <xsl:value-of select="system-property('xsl:product-name')"/>
    (see <xsl:value-of select="system-property('xsl:vendor-url')"/>)

    It makes use of the ePOSIX SMTP client.

    The transformation source is:

<xsl:value-of select="unparsed-text('')"/>
   
  </xsl:result-document>

</xsl:template>

</xsl:stylesheet>

Actually, support for mailto is not that great - my real
transformation lacks the %20s (hence my origianl email), but this
isn't a BUG in mailto - it's correct behaviour.
What IS a BUG, as far as I can see, is it will not allow the use of
the < and > characters (entered as &lt; and &gt; of course).
But that's a JDK issue, not a saxon issue.

From StandardOutputURIResolver.java:


  // See if the Java VM can conjure up a writable URL connection for us.
  // This is optimistic: I have yet to discover a URL scheme that it can handle.

So I beat you too the discovery!
--
Colin Adams
Preston Lancashire


-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help
Reply | Threaded
Open this post in threaded view
|

Re: Absence of %encoding in href attribute of xsl:result-document

Colin Paul Adams
In reply to this post by Christian Roth-4
>>>>> "Christian" == Christian Roth <[hidden email]> writes:

    Christian> How does the processor determine whether it needs to
    Christian> quote the '%'

You have to assume that % is present as part of %-encoding, I believe.
% is not an unreservd character in IRIs anyway, so the following is
not a legal IRI:

file:///My%illegalIRI
--
Colin Adams
Preston Lancashire


-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help
Reply | Threaded
Open this post in threaded view
|

RE: Absence of %encoding in href attribute of xsl:result-document

Michael Kay
In reply to this post by Christian Roth-4
After this change, Saxon will assume that any % signs in the URI represents
the result of escaping a special character. So the filename "100%.xml" must
be written as "100%25.xml". The URI "20%MOREBUCKS.xml" will be rejected as
illegal.

Michael Kay
http://www.saxonica.com/

 

> -----Original Message-----
> From: [hidden email]
> [mailto:[hidden email]] On Behalf Of
> Christian Roth
> Sent: 13 November 2005 01:13
> To: Saxon-Help Mailing List
> Subject: Re: [saxon] Absence of %encoding in href attribute
> of xsl:result-document
>
> Michael Kay wrote:
>
> >I have logged a bug and it will be fixed in the
> >next release.
>
> In the bug description, it reads:
>
>     Thus Saxon currently allows
>
>     href="file:///c:/My%20Documents/out.html"
>
>     but under the spec it should also allow
>
>     href="file:///c:/My Documents/out.html"
>
>
> I'm unsure what the final URI result should be for:
>
> (1) href="file:///20%50BUCKS.txt"
> (2) href="20%50BUCKS.txt"
> (3) href="file:20%MOREBUCKS.txt"
>
> How does the processor determine whether it needs to quote
> the '%' sign
> or if it is already an URI what it looks at, and therefore must not
> quote unallowed characters?
>
> Note that the file on disk for (2) is actually named "20%50BUCKS.txt".
>
> Regards, Christian.
>
>
>
>
> -------------------------------------------------------
> SF.Net email is sponsored by:
> Tame your development challenges with Apache's Geronimo App
> Server. Download
> it for free - -and be entered to win a 42" plasma tv or your very own
> Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
> _______________________________________________
> saxon-help mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/saxon-help
>




-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help
Reply | Threaded
Open this post in threaded view
|

RE: Absence of %encoding in href attribute of xsl:result-document

Michael Kay
In reply to this post by Colin Paul Adams
> But I accidentally discovered that Saxon DOES support mailto - I got
> my email message delivered OK.

Thanks, that's nice to know.

Michael Kay




-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help
Reply | Threaded
Open this post in threaded view
|

Re: Absence of %encoding in href attribute of xsl:result-document

Colin Paul Adams
>>>>> "Michael" == Michael Kay <[hidden email]> writes:

    >> But I accidentally discovered that Saxon DOES support mailto -
    >> I got my email message delivered OK.

    Michael> Thanks, that's nice to know.

However, http DOESN'T work.
I got it working with gestalt, and then tried using the same
stylesheet with saxon to the same server.
The server never saw the request.

I might be having a go with ftp in a few days - if so I'll let you
know the result.
--
Colin Adams
Preston Lancashire


-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.  Get Certified Today
Register for a JBoss Training Course.  Free Certification Exam
for All Training Attendees Through End of 2005. For more info visit:
http://ads.osdn.com/?ad_id=7628&alloc_id=16845&op=click
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help
Reply | Threaded
Open this post in threaded view
|

Re: Absence of %encoding in href attribute of xsl:result-document

Colin Paul Adams
>>>>> "Colin" == Colin Paul Adams <[hidden email]> writes:

    Colin> I might be having a go with ftp in a few days - if so I'll
    Colin> let you know the result.

Ftp works.
--
Colin Adams
Preston Lancashire


-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.  Get Certified Today
Register for a JBoss Training Course.  Free Certification Exam
for All Training Attendees Through End of 2005. For more info visit:
http://ads.osdn.com/?ad_id=7628&alloc_id=16845&op=click
_______________________________________________
saxon-help mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help