Oh, sorry... I understand now. We have some pretty hairy JS regexps to handle this for pastes into our editor. I would not recommend it.
What I would recommend (if you need an alert) is to write the string to a html div and show/hide your custom alert box. This way you do not need to worry about converting it. It is a ~standard~ browser entity. best, -Rob p.s. you still need to normalize your spaces in js > -----Original Message----- > From: Koen Pellegrims [mailto:[EMAIL PROTECTED]] > Sent: Monday, August 26, 2002 9:21 AM > To: [EMAIL PROTECTED] > Subject: RE: How to get xml-entities into Javascript strings? > > > Maybe my post wasn't very clear; the XML contains ë but JavaScript > expects \U00EB (which is 235 in hex). > Instead of reinventing the wheel, I was hoping there would be some standard > way to convert from one into the other. > > K. > > > -----Oorspronkelijk bericht----- > > Van: Robert Koberg [mailto:[EMAIL PROTECTED]] > > Verzonden: maandag 26 augustus 2002 17:10 > > Aan: [EMAIL PROTECTED] > > Onderwerp: RE: How to get xml-entities into Javascript strings? > > > > > > 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ële merkers"/> > > > ë is ë 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]> > > > > > > > --------------------------------------------------------------------- > 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]> > --------------------------------------------------------------------- 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]>