Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Entity references in attributes with xsl

Reply
Thread Tools

Entity references in attributes with xsl

 
 
Christoph Niemann
Guest
Posts: n/a
 
      08-24-2004
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"
xmlnssl="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">&amp;foo;</xsl:text>
</xsl:element>

<!-- This, however, doesn't. Output is:
<img src="&amp;foo; />
-->
<xsl:element name="img">
<xsl:attribute name="src">
<xsl:text disable-output-escaping="yes">&amp;foo;</xsl:text>
</xsl:attribute>
</xsl:element>
</xsl:template>

</xsl:stylesheet>


Now, xsltproc as well as saxon do escape the &amp; 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
 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      08-24-2004


Christoph Niemann wrote:


> I want to output an element with an attribute. The attribute's value
> shall contain a entity reference. Is that possible at all?


> Now, xsltproc as well as saxon do escape the &amp; within the attribute
> value. Is that the intended behaviour? If so, how so I put an entity
> reference in an attribute value?


Saxon has an extension function:
http://saxon.sourceforge.net/saxon6....xon:entity-ref
which might solve that (I haven't tried).

--

Martin Honnen
http://JavaScript.FAQTs.com/
 
Reply With Quote
 
 
 
 
Imiro
Guest
Posts: n/a
 
      08-24-2004
Hi,

could it be question of using '%' -sign instead of '&':


<xsl:element name="img">
<xsl:attribute name="src">
<xsl:text disable-output-escaping="yes">%amp;foo;</xsl:text>
</xsl:attribute>
</xsl:element>

Since maybe its like pcdata in first and cdata in second example? Not sure though

--Imiro
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Entity Framework - Reassigning child entity's parent Norm ASP .Net 3 07-06-2009 07:28 PM
How to relate a SQL based entity with an Object based entity in Entity Framework markla ASP .Net 1 10-06-2008 09:42 AM
Entity Name or Entity Number? Samuel van Laere HTML 4 02-24-2007 10:11 PM
Outputting entity references in XUL attributes with XSL Paquette.Jim XML 2 02-06-2007 09:28 AM
XSL Question tp xsl:for-each and xsl:variable schaf@2wire.ch XML 1 05-27-2005 09:25 PM



Advertisments