|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: ESCAPE SINGLE QUOTES FOR JAVASCRIPT PARAMETER IN X
Cleyton Jordan wrote:
<A AR="I Don't Watch It" AID="768564" APID="76158" AC="5"/> Here is an XSLT 2.0 function that escapes four characters as needed for JavaScript string literals: <xsl:function name="my:escape" as="xs:string">
<xsl:param name="s" as="xs:string"/>
<xsl:sequence
select="replace(
replace(
replace(
replace($s, "'", "\\'"),
'"',
'\\"'
),
'\r',
'\\r'
),
'\n',
'\\n'
)"/>
</xsl:function>You can the use it as e.g. '<xsl:value-of select="my:escape(@AR)"/>' -- Martin Honnen http://JavaScript.FAQTs.com/
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|






