This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Escaping an apostrophe for JavaScript
- To: <xsl-list at lists dot mulberrytech dot com>
- Subject: [xsl] Escaping an apostrophe for JavaScript
- From: "Frank T. O'Connor" <foconnor at kabel-us dot com>
- Date: Sat, 24 Feb 2001 21:44:50 -0500
- Reply-To: xsl-list at lists dot mulberrytech dot com
- Thread-Index: AcCez+m64oLjfVGBRSSXcYd5DXqwlgAACbJQ
- Thread-Topic: [xsl] plugging the result of exec() of system() while traversing
Using MSXML3.
Trying to write the following string:
<img
src="blah.gif"
onMouseOver="window.status='Frank O\'Connor'; return true;"
/>
The problem is my source XML doesn't have the apostrophe escaped for
javascrpt. The source node simply has "O'Connor" in it.
I can't seem to figure out any way of using translate or substring to
convert the apostrophe to a backslash-apostrophe. There doesn't seem to
be any way to locate the location of a substring within a string. Unless
I loop it one character at a time.
I was thinking perhaps I could make up a entity that is
backslash-apostrophe, and then tell translate to replace apostrophe with
this entity.
But I'm not sure where to put this DTD information in my XSL file.
I tried this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet [
<!ENTITY test "\'">
]>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
...
</xsl:stylesheet>
but I get this error:
The element 'xsl:stylesheet' is used but not declared in the DTD/Schema
any suggestion?
Thanks,
-frank
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list