You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@abdera.apache.org by Are Gulbrandsen <a....@usit.uio.no> on 2009/08/27 21:20:18 UTC
Problems with escaped ampersand in feed id
Hi
I'm implementing atom feeds for a digital library application at the
University of Oslo using Abdera. I'm new to Abdera but up to this
problem, Abdera has been a pleasure to work with compared to Rome.
Every search in the library application will have an equivalent atom
feed. The feed will for instance be used by a department to show the
last submitted theses or articles.
I have generated an atom feed id based on a tag uri (RFC 4151) where
the search parameters form the last (specific) part of the URI, for
instance:
tag:duo.uio.no,2009-09:/search?language=365&yearFrom=2008&yearTo=2009
The problem is that the ampersands in the id gets escaped to & and
the id becomes:
tag:duo.uio.no,2009-09:/search?
language=365&yearFrom=2008&yearTo=2009
I have fetched and checked the ID with feed.getId(), and the escaping
seems to be happening after feed.writeTo().
I have tried both feed.writeTo("prettyxml", response.getWriter()) and
feed.writeTo(response.getWriter()).
After much browsing around the Abdera Javadocs and Googling I'm still
clueless about why Abdera would escape the characters in the ID. -
Anyone got an idea or a tip on how to resolve this?
Best Regards,
Are D. Gulbrandsen
The XML-group,
Center for Information Technology Services
University of Oslo
Re: Problems with escaped ampersand in feed id
Posted by Robert Weber <rw...@gmail.com>.
Thank you for the update Are...i will mark your ticket as solved.
Robert
On Fri, Aug 28, 2009 at 3:47 AM, Are Gulbrandsen <
a.d.gulbrandsen@usit.uio.no> wrote:
> Hi again
>
> Thanks for the suggestions.
>
> I found a simple solution to this.
>
> As a reference I'll rephrase the challenge:
>
> - I want to make any search in my application have a corresponding Atom
> feed
> - The application uses query parameters: ?param1=value1¶m2=value2...
> - The feed ID should be the same for any searches wich are equivalent.
> parameter permutations can give several equivalent searches:
> ?param1=value1¶m2=value2
> ?param2=value2¶m1=value1
> - I want to mint an Atom feed ID using the Tag URI scheme
> - The feed ID should be easy for humans to read
>
> I first looked at the Tag URI scheme, and found how to mint the ID.
> Ref http://taguri.org/
> tagURI = "tag:" taggingEntity ":" specific
>
> The first parts were easy:
> tag:duo.uio.no,2009-09:
>
> The specific part was the challenge.
>
> The Atom specification was not a great help:
> http://tools.ietf.org/html/rfc4287#section-4.2.6
>
> I first decided on using a normal query syntax:
> search?param1=value1¶m2=value2
>
> The problem is that the ampersands are escaped to make the ID-string valid
> XML content, which makes an ugly, long and difficult to read ID (a search
> can typically have 6 parameters).
>
> The sollution was in http://en.wikipedia.org/wiki/URI_scheme
> where semicolon is suggested as a parameter delimiter in the query, exactly
> to avoid the problem with & in the query string.
>
> (I now know that this was suggestes by Tim Berners-Lee as early as in 1995
> in Hypertext Markup Language - 2.0, ref http://tools.ietf.org/html/rfc1866 section
> 8.2.1)
>
> We'll use the following feed ID scheme:
> tag:duo.uio.no,2009-09:search?param1=value1;param2=value2
>
> To make sure that equivalent searches have the same feed-ID, I remove any
> unnecessary parameters (like format=atom) and sort the parameters before
> minting the feed ID.
>
>
>
> Best Regards,
> Are D. Gulbrandsen
> The XML-group,
> Center for Information Technology Services
> University of Oslo
>
>
--
Robert Weber, MBA
PO Box 702
Scottsdale, Az USA 85252-0702
Ph: (480) 259-0646
Current project:
"hem paz" when translated into Portuguese signifies "in peace"
Xhtml Code Example(s):
<span style="font-weight:bold;">Hemp Arizona (<a href="
http://hempaz.design.officelive.com"
onclick="java_script:this.target='_blank'">USA</a>)</span>
<span style="font-weight:bold;">Clik <a href="http://
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=7683956"
onclick="java_script:this.target='_blank'">here</a> to make a donation to
the Medical Marijuana Initiative (<a href="http://hempaz.com/mmi.aspx"
onclick="java_script:this.target='_blank'">MMI</a>)™</span>
Re: Problems with escaped ampersand in feed id
Posted by Robert Weber <rw...@gmail.com>.
Hello Are:
My view to your problem is limited.
However, I would attempt first to decipher the default 'coding'.
Unicode-8 or Unicode-16 would, perhaps, allow a different '&'
representation than the 'current' replacement that you are now experiencing.
For example, from my copy of 'Babel
Map<http://www.babelstone.co.uk/Software/BabelMap.html>',
I see a potential 'hex' replacement of '&' and a potential 'decimal'
replacement of '&'.
The 'UCN <http://www.unicode.org/versions/Unicode5.1.0/>' replacement
referring back to the 'utf-8' and 'utf-16' formats returns a replacement of
'\u0026'.
Either way you slice it, you are attempting to place a 'server' character
inside of a 'client' view.
You will need a 'method' that can toggle back to '&' prior to presenting the
valid mark-up back to the client screen.
Perhaps embedded in a returned 'CDATA' statement to isolate the machine
character(s).
The Ruby <http://rubyzero.wordpress.com> programming language has some
interesting methods of converting 'to_string', to_int', etc.
I will point there and if I see a potential solution, I will return a 'flag'
to you (and, most probably, upload the solution to the 'blog' server.
Sorry...I am not all the wizard I am made out to be.
But, I try.
Robert
On Thu, Aug 27, 2009 at 12:20 PM, Are Gulbrandsen <
a.d.gulbrandsen@usit.uio.no> wrote:
> Hi
>
> I'm implementing atom feeds for a digital library application at the
> University of Oslo using Abdera. I'm new to Abdera but up to this problem,
> Abdera has been a pleasure to work with compared to Rome.
>
> Every search in the library application will have an equivalent atom feed.
> The feed will for instance be used by a department to show the last
> submitted theses or articles.
>
> I have generated an atom feed id based on a tag uri (RFC 4151) where the
> search parameters form the last (specific) part of the URI, for instance:
> tag:duo.uio.no,2009-09:/search?language=365&yearFrom=2008&yearTo=2009
>
> The problem is that the ampersands in the id gets escaped to & and the
> id becomes:
> tag:duo.uio.no
> ,2009-09:/search?language=365&yearFrom=2008&yearTo=2009
>
> I have fetched and checked the ID with feed.getId(), and the escaping seems
> to be happening after feed.writeTo().
>
> I have tried both feed.writeTo("prettyxml", response.getWriter()) and
> feed.writeTo(response.getWriter()).
>
> After much browsing around the Abdera Javadocs and Googling I'm still
> clueless about why Abdera would escape the characters in the ID. - Anyone
> got an idea or a tip on how to resolve this?
>
>
> Best Regards,
> Are D. Gulbrandsen
> The XML-group,
> Center for Information Technology Services
> University of Oslo
>
>
--
Robert Weber, MBA
PO Box 702
Scottsdale, Az USA 85252-0702
Ph: (480) 259-0646
Current project:
"hem paz" when translated into Portuguese signifies "in peace"
Xhtml Code Example(s):
<span style="font-weight:bold;">Hemp Arizona (<a href="
http://hempaz.design.officelive.com"
onclick="java_script:this.target='_blank'">USA</a>)</span>
<span style="font-weight:bold;">Clik <a href="http://
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=7683956"
onclick="java_script:this.target='_blank'">here</a> to make a donation to
the Medical Marijuana Initiative (<a href="http://hempaz.com/mmi.aspx"
onclick="java_script:this.target='_blank'">MMI</a>)™</span>
Re: Problems with escaped ampersand in feed id
Posted by Are Gulbrandsen <a....@usit.uio.no>.
Hi again
On 27. aug.. 2009, at 21.20, Are Gulbrandsen wrote:
> The problem is that the ampersands in the id gets escaped to &
> and the id becomes:
> tag:duo.uio.no,2009-09:/search?
> language=365&yearFrom=2008&yearTo=2009
> ...
> After much browsing around the Abdera Javadocs and Googling I'm
> still clueless about why Abdera would escape the characters in the
> ID. - Anyone got an idea or a tip on how to resolve this?
Sorry about that, it's of course because it's a reserved character in
XML and needs to be escaped for the content to be well formed...
Best Regards,
Are D. Gulbrandsen