cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robert Koberg" <...@koberg.com>
Subject RE: How to get xml-entities into Javascript strings?
Date Mon, 26 Aug 2002 15:09:58 GMT
Hi,

You almost have it. But with XSLT you have to watch out for whitespace. There
are two ways to handle it:

1. Use xsl:text
<xsl:text>alert('</xsl:text>
<xsl:value-of select="@name"/>
<xsl:text>');</xsl:text>

2. alert('<xsl:value-of select="normalize-space(@name)"/>');

best,
-Rob

> -----Original Message-----
> From: Koen Pellegrims [mailto:koen.pellegrims@pandora.be]

> Hi,
>
> (Not specifically cocoon-related, flame me if you want to...)
>
> I ran into some trouble trying to generate a snippet of JavaScript from an
> XML-file, containing entity-references.
> The problem can be reduced to this:
>
> XML-file:
> <product name="industri&#235;le merkers"/>
> &#235; is &euml; in HTML, or ë... if you can see this ;-)
>
> XSL:
> <xsl:template match="product">
> 	<script type="text/javascript">
> 		alert('<xsl:value-of select="@name"/>');
> 	</script>
> </xsl:template>
>
> I'm not that strong in JavaScript, but I know JS expects Unicode-type
> encodings of the form \Uxxxx.
> Is there a standard way to convert XML entities into JavaScript entities or
> is there a cunningly simple solution to this problem?
>
> Koen
> >



---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <cocoon-users-unsubscribe@xml.apache.org>
For additional commands, e-mail:   <cocoon-users-help@xml.apache.org>


Mime
View raw message