xsl-list
[Top] [All Lists]

RE: [xsl] Assign the XML text to Javascript Variable value

2010-02-11 09:59:56
Hi,

I don't know how to start in this cases.

Anyway here place in my XSL & XML

<xsl:template match="/">
<html><body onload="version()">
<xsl:apply-templates/>
</body></html>
</xsl:template>

<xsl:template match="text()">
<xsl:variable name="txt" select="text()"/>
<script type="javascript">
function version()
{
document.write(txt.replace("Ganesh", "Selva"));
}
</script>
<xsl:apply-templates/>
</xsl:template>

XML: (actual in my input is huge
Size here place sample lines)

<p>this is testing by "Ganesh"</p>
<para>this is testing by Ganesh</para>
<div>this is testing by <b>Ganesh</b></div>

Output
<p>this is testing by <i>"</i>Selva<i>"</i></p>
<para>this is testing by Selva</para>
<div>this is testing by <b>Selva</b></div>

Thanks,
Selva

-----Original Message-----
From: Andrew Welch [mailto:andrew(_dot_)j(_dot_)welch(_at_)gmail(_dot_)com] 
Sent: Thursday, February 11, 2010 9:10 PM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: Re: [xsl] Assign the XML text to Javascript Variable value

I have developed one XSL for viewing purpose in xml file, I want know how
to
assign the xml text into javascript "var" value. Within the XSL file (i.e.
text())

Actual in my requirement is particular word in XML file (i.e. this word
anywhere appears in the xml element) need to change another one word (e.g
"Ganesh" to "Selva"). Also how to handle the special character (quotes,
apos, plus, minis, etc...). This is during the browser viewing purpose.


Design your HTML and Javascript by hand, get that working... Then
write the XSLT to transform your input into that output.  If you are
having problems with the transform, post the sample output, the
relevant part of your transform, and some sample input.


-- 
Andrew Welch
http://andrewjwelch.com
Kernow: http://kernowforsaxon.sf.net/

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



Confidentiality Notice:  This transmittal is a confidential communication.  If 
you are not the intended recipient, you are hereby notified that you have 
received this transmittal in error and that any review, dissemination, 
distribution or copying of this transmittal is strictly prohibited.  If you 
have received this communication in error, please notify this office 
immediately by reply and immediately delete this message and all of its 
attachments, if any.


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--