| 
 
Subject: search and replace along with apply-templates From: Robert Koberg <rob@xxxxxxxxxx> Date: Sun, 19 Nov 2000 07:55:37 -0800  | 
I have some JavaScript functions that, on click of a glossed word, open a
new window and writes to it with document.write.  That all works fine except
there is potential for it to break if the defintion contains a single quote.
Is there some way to apply-templates and search for the single quote
character and prepend the js escape character "\" to the single quote?
 Below is where I put together the JS for the switch(case) statement:
<xsl:template match="glossentry">
   <xsl:variable name="theword" select="normalize-space(glossterm)"/>
   case "<xsl:value-of select="$theword"/>":
      item = '<b><xsl:value-of select="$theword"/></b><br/><br/>';
<!-- this part could contain a single quote  -->
      def = '<xsl:apply-templates select="glossdef/example/para"
mode="glossary"/>';
      break;
</xsl:template>
an example of the output:
   case "expatriate":
      item = '<b>expatriate</b><br><br>';
      def = 'The French <i>expatriates</i> in the U.S. got together to
celebrate Bastille Day.<br><br>While managing his company's operations in a
small town southeast of Paris, Leon Chester, then an American
<i>expatriate</i>, noticed that his French colleagues shook hands every
morning.<br><br>';
      break;
--------
This will fail is JS because of the single quote after "<br>While managing
his company's ".  Is there a way to search the string delivered by:
<xsl:apply-templates select="glossdef/example/para" mode="glossary"/>
and escape any single quotes, for example:
   case "expatriate":
      item = '<b>expatriate</b><br><br>';
      def = 'The French <i>expatriates</i> in the U.S. got together to
celebrate Bastille Day.<br><br>While managing his company\'s operations in a
small town southeast of Paris, Leon Chester, then an American
<i>expatriate</i>, noticed that his French colleagues shook hands every
morning.<br><br>';
      break;
tia,
Rob
 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
| Current Thread | 
|---|
  | 
| <- Previous | Index | Next -> | 
|---|---|---|
| Re: Standard XSLT API & Debugging, Mike Brown | Thread | Re: search and replace along with a, Christopher R. Maden | 
| Fw: Bug in SAXON (entity/character , Melvyn Rosengarden | Date | Re: Q.) Encode URL inside HTML Anch, David Carlisle | 
| Month |