[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

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


Subject: RE: [xsl] Assign the XML text to Javascript Variable value
From: "Selvaganesh" <selvaganesh_t@xxxxxxxxxxxxxx>
Date: Thu, 11 Feb 2010 21:34:25 +0530

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.j.welch@xxxxxxxxx] 
Sent: Thursday, February 11, 2010 9:10 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
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/



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.


Current Thread
Keywords