473,320 Members | 1,794 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Outputting entity references in XUL attributes with XSL

Hello,

I'm trying to get XUL output with an element that has an attribute
containing an entity reference. Can this be done? I saw another post
exactly like this...but the solutions they gave didn't work for me.
[-------------XML------------]

<contextMenu>
<building />
<contact/>
<company/>
</contextMenu>
[-----------XSL---------------]
....
<xsl:output method="xml" version="1.0" encoding="ISO-8859-1"
indent="yes"/>
.....
<xsl:template match="contextMenu">
<menuitem>
<xsl:attribute name="label" disable-output-escaping="yes">
&amp;context.add.<xsl:value-of select="name()" class="text" />;
</xsl:attribute>
</menuitem>
<xsl:template>
<building />
<contact/>
<company/>
</contextMenu>
[-----------expected XUL---------------]
....
<menuitem label="&context.add.building;">
<menuitem label="&context.add.contact;">
<menuitem label="&context.add.company;">
[-----------actual XUL---------------]
....
<menuitem label="&amp;context.add.building;">
<menuitem label="&amp;context.add.contact;">
<menuitem label="&amp;context.add.company;">

Feb 5 '07 #1
2 1647
As you've discovered, text content that contains an ampersand is *NOT*
the same thing as an entity reference until it's been converted all the
way to a text string and reparsed from that.

XSL 2.0 may be able to construct "real" entity references; I don't think
XSL 1.0 can do so.
Feb 5 '07 #2
Paquette.Jim wrote:
I'm trying to get XUL output with an element that has an attribute
containing an entity reference. Can this be done? I saw another post
exactly like this...but the solutions they gave didn't work for me.
<xsl:attribute name="label" disable-output-escaping="yes">
&amp;context.add.<xsl:value-of select="name()" class="text" />;
</xsl:attribute>
Unfortunately disable-output-escaping doesn't work on attributes:

"It is an error for output escaping to be disabled for a text node that
is used for something other than a text node in the result tree. Thus,
it is an error to disable output escaping for an xsl:value-of or
xsl:text element that is used to generate the string-value of a comment,
processing instruction or attribute node;"

You can do this with XSLT 2.0, can you use XSLT 2.0?

--
Oleg Tkachenko [XML MVP, MCPD]
http://blog.tkachenko.com | http://www.XmlLab.Net | http://www.XLinq.Net
Feb 6 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Douglas Reith | last post by:
Hi There, Can someone please tell me why the XML spec states that an attribute value with an external entity is forbidden? Or point me to the appropriate document? Or better still, perhaps you...
5
by: Dean A. Hoover | last post by:
I am writing a parser for xml that will not have an associated DTD. I want to be able to handle certain character references (e.g., &copy;) in the program. When I run the following against a...
2
by: Christoph Niemann | last post by:
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...
5
by: Stephan Hoffmann | last post by:
Hi, I use XML mainly as a source for HTML. HTML browsers 'know' certain entity references like &eacute; or &auml;. When I use XSL to transform XML to HTML or XML, these entities are replaced...
9
by: Jukka K. Korpela | last post by:
I noticed that Internet Explorer (6.0, on Win XP SP 2, all fixes installed) incorrectly renders e.g. &harr &euro &Omega literally and not as characters denoted by the entities, but if a semicolon...
5
by: Mateusz Loskot | last post by:
Hi, I'd like to ask how XML parsers should handle attributes which consists of &quot; entity as value. I know XML allows to use both: single and double quotes as attribute value terminator. That's...
6
by: Tuomas Rannikko | last post by:
Hello, I'm currently writing a XML processor for the fun of it. There is something I don't understand in the spec though. I'm obviously missing something important. The spec states that both...
9
by: Max | last post by:
Hello! I would want to know if attributes values can be entity references and if the parser, during processing, can replace with blank string a non registered entity. Eg: <example...
5
by: wshaer | last post by:
Hi This is the task: and these are my classes: public class Engine{ // Declare the varibles
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.