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:[EMAIL PROTECTED]]

> 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:     <[EMAIL PROTECTED]>
For additional commands, e-mail:   <[EMAIL PROTECTED]>

Reply via email to