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

Re: outputting an <a href> with a URL which contains "

Subject: Re: outputting an <a href> with a URL which contains "&func"
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Tue, 22 Jan 2002 10:28:28 +0000
a href with
Hi Saverio,

> I'm trying to output an <a href> from an XSL template.
> The value of the href attribute is a URL which contains the string
> ``&func''

You need to escape the & as &amp;. Try:

<a href="http://....?dtype=C&amp;func=front&amp;state=&amp;style=">

> The following results in an error regarding the reference to entity "func".
> The error states that the reference must end with the ';' delimiter.
> <a><xsl:attribute name="href"><xsl:text
> disable-output-escaping="yes">http://....?dtype=C&func=front&state=&style="></xsl:text>
> </xsl:attribute></a>
> I have been able to circumvent this error with the following code.
> <a><xsl:attribute name="href"><xsl:text
> disable-output-escaping="yes"><![CDATA[http://....?dtype=C&func=front&state=&style=]]></xsl:text>
> </xsl:attribute>

XSLT documents are XML documents. In XML, all ampersands in attribute
or element content must be escaped, either with &amp; or (for element
content) by wrapping the text within a CDATA section. Your second set
of code is exactly the same as:

<a><xsl:attribute name="href"><xsl:text

The disable-output-escaping that you're adding in the above is having
absolutely no effect on what you get in the result, by the way.
Disabling output escaping only works for the element content that you
generate, not for attribute values. So the above is exactly the same

<a><xsl:attribute name="href">

And of course any attribute with a fixed name can be added literally
instead of through xsl:attribute, if you want, so the above is exactly
the same as:

<a href="http://....?dtype=C&amp;func=front&amp;state=&amp;style=">



Jeni Tennison

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Current Thread


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.
First Name
Last Name
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.