xsl-list
[Top] [All Lists]

Re: [xsl] using xsl:output-character to render characters in 2 ways

2009-11-12 07:51:46
I care because in some situations (such as attribute values) I need
the quote to be escaped but in other situations (eg in a JS function)
I do not, the JS does not work in an HTML doc if it is escaped.


On Thu, Nov 12, 2009 at 12:47 PM, Michael Kay <mike(_at_)saxonica(_dot_)com> 
wrote:

(a) character maps apply to all characters in the result tree, regardless
whether they originated in the source document or the stylesheet.

(b) there's something fishy about your requirements that make one wants to
probe deeper. If you care whether or not numeric character references are
used in the result document, then you're not using XML the way it was
designed to be used.

Regards,

Michael Kay
http://www.saxonica.com/
http://twitter.com/michaelhkay

-----Original Message-----
From: Tom T [mailto:tomw289(_at_)googlemail(_dot_)com]
Sent: 12 November 2009 12:16
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] using xsl:output-character to render
characters in 2 ways

I wish to process single quotes in the following way:

- when it is retreived from the source XML it should be
escaped to &#39;

- when it is embedded within the XSLT stylesheet it should
not be escaped and rendered as a '.

To acheive this I have set up the following output-characters
in a character map:

<xsl:output-character character="&#39;" string="&#38;#39;" />
<xsl:output-character character="&single-quote;" string="&#39;" />

This works but it means I have to use the &single-quote;
entity every time I want to use a single quote in the xslt
(eg for javascript.)

Is there a better way to do this in XSLT 2?

Thanks

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--