You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by "Rose, Donny" <do...@ixnet.com> on 2000/12/19 22:42:10 UTC

Problem with special characters in

When using XSL with XML to generate HTML, I am unable to get the "&"
character to show up in the value of an attribute of an HTML tag, which I
generate using the <xsl:attribute> tag.

A short sample of the XSL looks like this:
<FRAME>
   <xsl:attribute name="SRC">/servlet/Foo?action=Foo<xsl:apply-templates
select="PARAMS"/></xsl:attribute>
</FRAME>

(Of course, I want to generate many frames and their sources using XSL like
this.)

The apply-templates refered to looks this:
<xsl:template match="PARAMS">
    <xsl:text disable-output-escaping="yes">&amp;</xsl:text>id=<xsl:value-of
select="ID" />
</xsl:template>

Using Xalan Java-2 to process this XSL with a simple XML file, I get:
<FRAME
src="/servlet/Foo?action=FooMe&amp;id=86938974825256874209.220.22.88">

(The XML file is just simple, as to be expected:)
<?xml version="1.0"?>
<PARAMS>
	<ID>86938974825256874209.220.22.88</ID>
</PARAMS>

As you can see, I need "&amp;" to appear as "&", so that the URL will work!

If I call <xsl:apply-templates select="PARAMS"> outside of the
<xsl:attribute> tag, it works like it should, interpreting the "&amp;"
inside the <xsl:text> tag as a "&" chacter.

Thanks for any help you can give,

Donny Rose