W3C home > Mailing lists > Public > xmlschema-dev@w3.org > June 2001

Re: Handling Ampersands

From: Eric van der Vlist <vdv@dyomedea.com>
Date: Wed, 20 Jun 2001 17:07:46 +0200
Message-ID: <3B30BC42.DCC75FB5@dyomedea.com>
To: "Whitwell, Martyn" <martyn.whitwell@ic.ac.uk>
Cc: xmlschema-dev@w3.org

Looks more like a XML question than related to W3C XML Schema ;=)
however see my comments inline...

"Whitwell, Martyn" wrote:
> Dear all,
> I'd like to define an element which will contain a URL to a resource
> ..
> <xsd:element name="mylink" type="xsd:string" />
> ..
> I have a problem regarding the URL - it contains ampersands (the "and"
> symbol: &). e.g.:
> <mylink>
> http://www.streetmap.co.uk/streetmap.dll?grid2map?X=526500&Y=179400&arrow=Y
> </mylink>
> XML does not like these on their own, it prefers them escaped, i.e.

Not only does it prefer it, but it requires it since otherwise your XML
Document isn't well formed.

> <mylink>
> http://www.streetmap.co.uk/streetmap.dll?grid2map?X=526500&amp;Y=179400&amp;
> arrow=Y
> </mylink>
> However, the escaped-ampersand version will not link to the website!

Your escaped-ampersand version will not link to a website straight away
since no browser would know that the content of the "mylink" element is
a link.

It needs to be transformed in a way or another into something that will
be understood as a link.

If this transformation is done through XSLT into a HTML href element,
the XSLT processor will take care of unescaping the "&amp;"...

The problem can still happen with old browsers if you are transforming
XHTML and I don't think you can imagine any solution for this!

Hope this helps.

> Is there anyway I can define the element's type so that it will allow
> miscellaneous ampersands, or is it possible to un-escape the ampersand in a
> stylesheet? (and if so, how?)
> Thanks in advance for all your help.
> Regards,
> Martyn Whitwell.
> Imperial College, London.

Pour y voir plus clair dans la nebuleuse XML...
Eric van der Vlist       http://xmlfr.org            http://dyomedea.com
http://xsltunit.org      http://4xt.org           http://examplotron.org
Received on Wednesday, 20 June 2001 11:07:49 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:55:52 UTC