Subject: Re: [xsl] outputting an <a href> with a URL which contains "&func" From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx> Date: Tue, 22 Jan 2002 10:28:28 +0000 |
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 &. Try: <a href="http://....?dtype=C&func=front&state=&style="> ... </a> > 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 & 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 disable-output-escaping="yes">http://....?dtype=C&func=front&state=&style=</xsl:text> </xsl:attribute> 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 as: <a><xsl:attribute name="href"> <xsl:text>http://....?dtype=C&func=front&state=&style=</xsl:text> </xsl:attribute> 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&func=front&state=&style="> Cheers, Jeni --- Jeni Tennison http://www.jenitennison.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] outputting an <a href> wi, Joerg Heinicke | Thread | [xsl] self discovery, Greg Martel |
RE: [xsl] self discovery, Andrew Welch | Date | Re: [xsl] XSL sorting, Jeni Tennison |
Month |