Hi, As I understand your requirement is replacing line feed with '\n'
I found following method, and works for me. Try following : <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl=" http://www.w3.org/1999/XSL/Transform" xmlns:tns=" http://www.example.org/Echo/"> <xsl:output method="text" encoding="UTF-8" indent="yes"/> <xsl:variable name="_crlf"><xsl:text> </xsl:text></xsl:variable> <xsl:template name="escapeNewLine"> <xsl:param name="text" select="string(.)"/> <xsl:choose> <xsl:when test="contains($text, $_crlf)"> <xsl:value-of select="substring-before($text, $_crlf)"/>\n<xsl:call-template name="escapeNewLine"> <xsl:with-param name="text" select="substring-after($text, $_crlf)"/> </xsl:call-template> </xsl:when> <xsl:otherwise> <xsl:value-of select="$text"/> </xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template match="/"><tns:echoOut xmlns:tns=" http://www.example.org/Echo/"><out><xsl:call-template name="escapeNewLine"> <xsl:with-param name="text" select="."/> </xsl:call-template></out></tns:echoOut> </xsl:template> </xsl:stylesheet> [1] http://stackoverflow.com/questions/3541278/replace-r-n-newlines-using-xslt-and-net-c-sharp-vs-2008 Thanks, Milinda On Thu, Nov 20, 2014 at 3:35 AM, Hasitha Aravinda <hasi...@wso2.com> wrote: > Hi team, > > I have requirement to replace 
 character and replace it with \n using > XSLT. So I came up with following XSLT and Proxy service. ( Capp is > attached ) > > <?xml version="1.0" encoding="UTF-8"?> > <xsl:stylesheet version="1.0" xmlns:xsl=" > http://www.w3.org/1999/XSL/Transform" xmlns:tns=" > http://www.example.org/Echo/"> > <xsl:output method="text" encoding="UTF-8" indent="yes"/> > <xsl:template name="escapeNewLine"> > <xsl:param name="text" select="string(.)"/> > <xsl:choose> > <xsl:when test="contains($text, '
')"> > <xsl:value-of select="substring-before($text, > '
')"/>\n<xsl:call-template name="escapeNewLine"> > <xsl:with-param name="text" > select="substring-after($text, '
')"/> > </xsl:call-template> > </xsl:when> > <xsl:otherwise> > <xsl:value-of select="$text"/> > </xsl:otherwise> > </xsl:choose> > </xsl:template> > <xsl:template match="/"><tns:echoOut xmlns:tns=" > http://www.example.org/Echo/"><out><xsl:call-template > name="escapeNewLine"> > <xsl:with-param name="text" select="."/> > </xsl:call-template></out></tns:echoOut> > </xsl:template> > </xsl:stylesheet> > > *And Proxy : * > > <?xml version="1.0" encoding="UTF-8"?> > <proxy xmlns="http://ws.apache.org/ns/synapse" name="TestXSLT" > transports="http https" startOnLoad="true" trace="disable"> > <target> > <inSequence> > <xslt key="conf:xslt/Test.xslt" source="//in"/> > <respond/> > </inSequence> > <outSequence/> > <faultSequence/> > </target> > <publishWSDL key="conf:xslt/Echo.wsdl"/> > </proxy> > > > In above transformation, it replace all the space with \n. For following > request. > > <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" > xmlns:echo="http://www.example.org/Echo/"> > <soapenv:Header/> > <soapenv:Body> > <echo:echo> > <in>a b > c d > </in> > </echo:echo> > </soapenv:Body> > </soapenv:Envelope> > > Response will be like this. > > <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" > xmlns:echo="http://www.example.org/Echo/"> > <soapenv:Body> > <echo:echo> > <text xmlns="http://ws.apache.org/commons/ns/payload">a\nb > \n\n\n\n\n\n\n\n\nc\nd > \n\n\n\n\n\n\n\n\n</text> > </echo:echo> > </soapenv:Body> > </soapenv:Envelope> > > What could be the issue. ? I tried with both &#xA; and 
 still no > luck. > > Thanks, > Hasitha. > > -- > Hasitha Aravinda, > Software Engineer, > WSO2 Inc. > Email: hasi...@wso2.com > Mobile: +94 71 8 210 200 > > > _______________________________________________ > Dev mailing list > Dev@wso2.org > http://wso2.org/cgi-bin/mailman/listinfo/dev > > -- Milinda Perera Software Engineer; WSO2 Inc. http://wso2.com , Mobile: (+94) 714 115 032
_______________________________________________ Dev mailing list Dev@wso2.org http://wso2.org/cgi-bin/mailman/listinfo/dev