[erlang-questions] Edoc href problem with '&'

Richard Carlsson richardc@REDACTED
Tue Nov 11 13:47:44 CET 2008


Ali Yakout wrote:
> Hi,
>  
> I'm trying to place a link in my overview.edoc that contains the '&' character
> the overview.edoc contains something like
> href="http://mysite.com/url?docno=&objectId=09004cff82bf1356&action=current&format=pdf"
> 
> $ gmake doc
>     overview.edoc: at line 8: error in XML parser: {fatal,
>                              {error_scanning_entity_ref,
>                                  {file,file_name_unknown},
>                                  {line,11},
>                                  {col,109}}}.
>     edoc: error in doclet 'edoc_doclet': {'EXIT',error}.

This is normal - you cannot use & characters in the XHTML text except as
part of an entity reference.

> I tried to replace the '&' with the xml code \&
> href=http://mysite.com/url?docno=\&objectId=09004cff82bf1356\&action=current\&format=pdf

It should be written without a backslash: just & or & (and the
href string needs double-quotes around it).

> The edoc then succeeds but the link is unusable :(
> It appears in the html like
> http://mysite.com/url?docno=\&objectId=09004cff82bf1356\&action=current\&format=pdf
> <http://mysite.com/url?docno=\&objectId=09004cff82bf1356\&action=current\&format=pdf>

It is unusable because of the \ characters.

When I write the link like this in overview.edoc:
href="http://mysite.com/url?docno=&objectId=09004cff82bf1356&action=current&format=pdf"

I get the following (identical) text in the generated HTML:

href="http://mysite.com/url?docno=&objectId=09004cff82bf1356&action=current&format=pdf"

which the browser interprets (or should interpret) as

http://mysite.com/url?docno=&objectId=09004cff82bf1356&action=current&format=pdf

and everything works fine.

See for example this blog for more information:
http://thesimpleweb.blogspot.com/2005/09/why-you-should-escape-your-ampersands.html

(Since edoc parses your xhtml and later exports it to a new file, there
is no choice involved - you must escape your ampersands, even in URLs.)

    /Richard



More information about the erlang-questions mailing list