Subject: RE: [xsl] Replace new lines by <br> and double quote with special char: Problem retaining HTML tags From: <Ambika.Das@xxxxxxxxxxxxxxxxxx> Date: Fri, 8 Sep 2006 14:45:38 +0530 |
To be more specific, the output is as follows, in a single line. Elem Id, News Details 1234, "<p> This is some data </p><br><p></p><br><p> This is some special characters <AHLN.AS> </p><br><p> A group of students have gone to picnic. </p><br><p> </p><br><PRE> ** This is another special tag<br></PRE></text><br></elem>" Thanks & Regards, Ambika Prasad Das -----Original Message----- From: Ambika Das-IC Sent: Friday, September 08, 2006 2:41 PM To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: RE: [xsl] Replace new lines by <br> and double quote with special char: Problem retaining HTML tags My apologies. There was a typo in the XML. Once again I am giving the input and output. Input is as follows. <?xml version="1.0" encoding="UTF-8" ?> <elem id="1234" date="14 Aug 2006" time="13:36"> <title>Sample Title</title> <text> <p> This is some data </p> <p> </p> <p> This is some special characters <AHLN.AS> </p> <p> A group of students have gone to picnic. </p> <p> </p> <PRE> ** This is another special tag </PRE></text> </elem> The output required is as follows. Elem Id, News Details 1234, "detailed data with character replacement" The point to note here is that there are only two lines because the output is sent for further processing. The string "detailed data with character replacement" represents the output after XML transformation. The new lines replaced with <br>, double quotes with ~ and the whole string in one line. The problem is that when we retain the HTML tags, we do not get the output in one line. Thanks & Regards, Ambika Prasad Das -----Original Message----- From: David Carlisle [mailto:davidc@xxxxxxxxx] Sent: Thursday, September 07, 2006 6:46 PM To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: Re: [xsl] Required help in XSL transformation > Any clues how to implement the same? did you try the template I posted earlier? Why start a new thread with an identical question? Once again, your sample input is not well formed, and you did not post a complete version of your required output, also it's better for the archives if you give threads sensible subject lines. (the subject line above could apply to any message on this list.) I just tried the template that I posted previously and it seems to work... You just need to fill in the replace template and templates for any elements that you need to process by somthing other than copy. David <?xml version="1.0" encoding="UTF-8" ?> <elem id="1234" date="14 Aug 2006" time="13:36"> <title>Sample Title</title> <text> <p> This is some data </p> <p> </p> <p> This is some special characters <AHLN.AS> </p> <p> A group of students have gone to picnic. </p> <p> </p> <PRE> ** This is another special tag </PRE></text> </elem> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="*"> <xsl:copy> <xsl:copy-of select="@*"/> <xsl:apply-templates/> </xsl:copy> </xsl:template> <xsl:template match="p//text()"> <xsl:call-template name="transformXMLString"> <xsl:with-param name="StringToTransform" select="."/> </xsl:call-template> </xsl:template> <xsl:template name="transformXMLString"> <xsl:param name="StringToTransform" select="."/> [replce a by b in <xsl:value-of select="."/>] </xsl:template> </xsl:stylesheet> $ saxon grumble.xml grumble.xsl <?xml version="1.0" encoding="utf-8"?><elem id="1234" date="14 Aug 2006" time="13:36"> <title>Sample Title</title> <text> <p> [replce a by b in This is some data ] </p> <p> [replce a by b in ] </p> <p> [replce a by b in This is some special characters <AHLN.AS> ] </p> <p> [replce a by b in A group of students have gone to picnic. ] </p> <p> [replce a by b in ] </p> <PRE> ** This is another special tag </PRE></text> </elem> DISCLAIMER: This message contains privileged and confidential information and is intended only for the individual named.If you are not the intended recipient you should not disseminate,distribute,store,print, copy or deliver this message.Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system.E-mail transmission cannot be guaranteed to be secure or error-free as information could be intercepted,corrupted,lost,destroyed,arrive late or incomplete or contain viruses.The sender therefore does not accept liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission. If verification is required please request a hard-copy version.
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Replace new lines by <br>, Abel Braaksma | Thread | RE: [xsl] Replace new lines by <br>, Ambika.Das |
RE: [xsl] Replace new lines by <br>, Ambika.Das | Date | Re: [xsl] Replace new lines by <br>, David Carlisle |
Month |