Subject: Re: [xsl] Assign the XML text to Javascript Variable value From: Robert Koberg <rob@xxxxxxxxxx> Date: Thu, 11 Feb 2010 08:34:04 -0800 |
It seems like you are trying to process the XSL and javascript at the same time. You script elements are just being written to the result, they will not be triggered during the transform. You probably want to transform the XML with XSL into a string and then work on that with your JS. How are you transforming on the client? If it is a processing instruction then you need to either do the string replace in the XSL. You could use recursive templates to do what you are trying to do with the txt.replace. Something like: http://www.dpawson.co.uk/xsl/sect2/StringReplace.html Or, let the transform complete and then onload trigger some JS function to do the replace. best, -Rob On Feb 11, 2010, at 8:04 AM, Selvaganesh wrote: > 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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Assign the XML text to Ja, Selvaganesh | Thread | Re: [xsl] Assign the XML text to Ja, Michael Ludwig |
RE: [xsl] Assign the XML text to Ja, Selvaganesh | Date | [xsl] Is there a better way for doi, Wolfgang Laun |
Month |