C
Christoph Niemann
Hello,
I want to output an element with an attribute. The attribute's value
shall contain a entity reference. Is that possible at all?
I use this source-XML and xsl-stylesheet:
[-------------xml-source-----------------]
<?xml version="1.0" encoding="utf-8"?>
<slideshow>
<slide name="01_welcome">
<p>This is a test!</p>
</slide>
</slideshow>
[-----------xsl-stylesheet---------------]
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xslutput method="xml"
doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
indent="yes"
encoding="utf-8"/>
<xsl:template match="/">
<xsl:element name="html">
<xsl:element name="head"/>
<xsl:element name="body">
<xsl:apply-templates/>
</xsl:element>
</xsl:element>
</xsl:template>
<xsl:template match="slide">
<!-- This works as expected. Output is:
<p>&foo;</p>
-->
<xsl:element name="p">
<xsl:text disable-output-escaping="yes">&foo;</xsl:text>
</xsl:element>
<!-- This, however, doesn't. Output is:
<img src="&foo; />
-->
<xsl:element name="img">
<xsl:attribute name="src">
<xsl:text disable-output-escaping="yes">&foo;</xsl:text>
</xsl:attribute>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
Now, xsltproc as well as saxon do escape the & within the attribute
value. Is that the intended behaviour? If so, how so I put an entity
reference in an attribute value?
Thanks in advance,
Christoph
I want to output an element with an attribute. The attribute's value
shall contain a entity reference. Is that possible at all?
I use this source-XML and xsl-stylesheet:
[-------------xml-source-----------------]
<?xml version="1.0" encoding="utf-8"?>
<slideshow>
<slide name="01_welcome">
<p>This is a test!</p>
</slide>
</slideshow>
[-----------xsl-stylesheet---------------]
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xslutput method="xml"
doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
indent="yes"
encoding="utf-8"/>
<xsl:template match="/">
<xsl:element name="html">
<xsl:element name="head"/>
<xsl:element name="body">
<xsl:apply-templates/>
</xsl:element>
</xsl:element>
</xsl:template>
<xsl:template match="slide">
<!-- This works as expected. Output is:
<p>&foo;</p>
-->
<xsl:element name="p">
<xsl:text disable-output-escaping="yes">&foo;</xsl:text>
</xsl:element>
<!-- This, however, doesn't. Output is:
<img src="&foo; />
-->
<xsl:element name="img">
<xsl:attribute name="src">
<xsl:text disable-output-escaping="yes">&foo;</xsl:text>
</xsl:attribute>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
Now, xsltproc as well as saxon do escape the & within the attribute
value. Is that the intended behaviour? If so, how so I put an entity
reference in an attribute value?
Thanks in advance,
Christoph