How to escape the double quotes using XSLT:

My xls file converting xml file into csv file.

my xml node is as below:

    <?xml version="1.0" encoding="ISO-8859-1"?>
<TRADING_TITLE><TITLE>SBU</TITLE><DESCRIPTION><![CDATA[Simply Be Inquiries]]></DESCRIPTION><REGISTERED><NAME><![CDATA[Speciality Home Shopping (US) Limited]]></NAME><ADDRESS1><![CDATA[Griffin House]]></ADDRESS1><ADDRESS2><![CDATA[40 Lever Street]]></ADDRESS2><ADDRESS3><![CDATA[Manchester]]></ADDRESS3><ADDRESS4><![CDATA[United Kingdom]]></ADDRESS4><ADDRESS5><![CDATA[M60  6ES]]></ADDRESS5></REGISTERED><WEB_ADDRESS>www.simplybe.com</WEB_ADDRESS><COMPANY_NUMBER>03941468</COMPANY_NUMBER><ENQUIRY_DAYS_PER_WEEK>7</ENQUIRY_DAYS_PER_WEEK><ENQUIRY_TEL_NO>18774074675</ENQUIRY_TEL_NO><ORDER_TEL_NO>18774074675</ORDER_TEL_NO><ORDERLINETIMES><WEEKDAY_OPEN>8am</WEEKDAY_OPEN><WEEKDAY_CLOSE>11pm</WEEKDAY_CLOSE><SATURDAY_OPEN>8am</SATURDAY_OPEN><SATURDAY_CLOSE>11pm</SATURDAY_CLOSE><SUNDAY_OPEN>8am</SUNDAY_OPEN><SUNDAY_CLOSE>11pm</SUNDAY_CLOSE></ORDERLINETIMES><ENQUIRYLINETIMES><WEEKDAY_OPEN>8am</WEEKDAY_OPEN><WEEKDAY_CLOSE>11pm</WEEKDAY_CLOSE><SATURDAY_OPEN>8am</SATURDAY_OPEN><SATURDAY_CLOSE>11pm</SATURDAY_CLOSE><SUNDAY_OPEN>8am</SUNDAY_OPEN><SUNDAY_CLOSE>11pm</SUNDAY_CLOSE></ENQUIRYLINETIMES><CORRESPONDENCE><NAME><![CDATA[Simply Be Inquiries]]></NAME><ADDRESS1><![CDATA[777 South State Road 7]]></ADDRESS1><ADDRESS2><![CDATA[Margate, Florida 33068]]></ADDRESS2><ADDRESS3/><ADDRESS4/><ADDRESS5/></CORRESPONDENCE><TRADING_AS_INDICATOR>Y</TRADING_AS_INDICATOR><REGISTERED_NUMBER>03941468</REGISTERED_NUMBER><BRAND_LOGO_NUMBER>DAL90</BRAND_LOGO_NUMBER><FSA_TEXT><![CDATA["Simply Be" is a trading name of Speciality Home Shopping (US) Limited, registered in England with Co No. 03941468 and registered office at Griffin House, 40 Lever Street, Manchester UK M60 6ES]]></FSA_TEXT></TRADING_TITLE>

I want to replace " with "" in whole XML file.Please help.

My xls file is as below:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="text" version="1.0" encoding="UTF-8" />
    <xsl:template match="/">

        <!--  Now process each notification detail -->
        <xsl:for-each select="descendant::TRADING_TITLE">

            <xsl:text>,</xsl:text>
            <xsl:text>A,</xsl:text>
            <xsl:text>,</xsl:text>
            <xsl:text>,</xsl:text>
            <xsl:choose>
                <xsl:when test="TITLE != ''">
                    <xsl:text>"</xsl:text>
                    <xsl:value-of select="TITLE"></xsl:value-of>
                    <xsl:text>"</xsl:text>
                    &comma;
                </xsl:when>
                <xsl:otherwise>
                    <xsl:value-of select="TITLE"></xsl:value-of>
                    &comma;
                </xsl:otherwise>
            </xsl:choose>       

            <xsl:text>"</xsl:text>
            <xsl:value-of select="DESCRIPTION"></xsl:value-of>
            <xsl:text>"</xsl:text>
            &comma;
            <xsl:text>"</xsl:text>
            <xsl:value-of select="REGISTERED/NAME"></xsl:value-of>
            <xsl:text>"</xsl:text>
            &comma;
            <xsl:text>"</xsl:text>  
            <xsl:value-of select="REGISTERED/ADDRESS1"></xsl:value-of>
            <xsl:text>"</xsl:text>
            &comma;
            <xsl:text>"</xsl:text>
            <xsl:value-of select="REGISTERED/ADDRESS2"></xsl:value-of>
            <xsl:text>"</xsl:text>
            &comma; 
            <xsl:text>"</xsl:text>
            <xsl:value-of select="REGISTERED/ADDRESS3"></xsl:value-of>
            <xsl:text>"</xsl:text>
            &comma;
            <xsl:text>"</xsl:text>
            <xsl:value-of select="REGISTERED/ADDRESS4"></xsl:value-of>
            <xsl:text>"</xsl:text>
            &comma;
            <xsl:text>"</xsl:text>
            <xsl:value-of select="REGISTERED/ADDRESS5"></xsl:value-of>
            <xsl:text>"</xsl:text>
            &comma;
            <xsl:text>"</xsl:text>
            <xsl:value-of select="WEB_ADDRESS"></xsl:value-of>
            <xsl:text>"</xsl:text>
            &comma;
            <xsl:text>"</xsl:text>
            <xsl:value-of select="COMPANY_NUMBER"></xsl:value-of>
            <xsl:text>"</xsl:text>
            &comma;
            <xsl:text>"</xsl:text>
            <xsl:value-of select="ENQUIRY_DAYS_PER_WEEK"></xsl:value-of>
            <xsl:text>"</xsl:text>
            &comma;
            <xsl:text>"</xsl:text>
            <xsl:value-of select="ENQUIRY_TEL_NO"></xsl:value-of>
            <xsl:text>"</xsl:text>
            &comma;
            <xsl:text>"</xsl:text>
            <xsl:value-of select="ORDER_TEL_NO"></xsl:value-of>
            <xsl:text>"</xsl:text>
            &comma;
            <xsl:text>"</xsl:text>
            <xsl:value-of select="ORDERLINETIMES/WEEKDAY_OPEN"></xsl:value-of>
            <xsl:text>"</xsl:text>
            &comma;
            <xsl:text>"</xsl:text>
            <xsl:value-of select="ORDERLINETIMES/WEEKDAY_CLOSE"></xsl:value-of>
            <xsl:text>"</xsl:text>
            &comma;
            <xsl:text>"</xsl:text>
            <xsl:value-of select="ORDERLINETIMES/SATURDAY_OPEN"></xsl:value-of>
            <xsl:text>"</xsl:text>
            &comma;
            <xsl:text>"</xsl:text>
            <xsl:value-of select="ORDERLINETIMES/SATURDAY_CLOSE"></xsl:value-of>
            <xsl:text>"</xsl:text>
            &comma;
            <xsl:text>"</xsl:text>
            <xsl:value-of select="ORDERLINETIMES/SUNDAY_OPEN"></xsl:value-of>
            <xsl:text>"</xsl:text>
            &comma;
            <xsl:text>"</xsl:text>
            <xsl:value-of select="ORDERLINETIMES/SUNDAY_CLOSE"></xsl:value-of>
            <xsl:text>"</xsl:text>
            &comma;
            <xsl:text>"</xsl:text>
            <xsl:value-of select="ENQUIRYLINETIMES/WEEKDAY_OPEN"></xsl:value-of>
            <xsl:text>"</xsl:text>
            &comma;
            <xsl:text>"</xsl:text>
            <xsl:value-of select="ENQUIRYLINETIMES/WEEKDAY_CLOSE"></xsl:value-of>
            <xsl:text>"</xsl:text>
            &comma;
            <xsl:text>"</xsl:text>
            <xsl:value-of select="ENQUIRYLINETIMES/SATURDAY_OPEN"></xsl:value-of>
            <xsl:text>"</xsl:text>
            &comma;
            <xsl:text>"</xsl:text>
            <xsl:value-of select="ENQUIRYLINETIMES/SATURDAY_CLOSE"></xsl:value-of>
            <xsl:text>"</xsl:text>
            &comma;
            <xsl:text>"</xsl:text>
            <xsl:value-of select="ENQUIRYLINETIMES/SUNDAY_OPEN"></xsl:value-of>
            <xsl:text>"</xsl:text>
            &comma;
            <xsl:text>"</xsl:text>
            <xsl:value-of select="ENQUIRYLINETIMES/SUNDAY_CLOSE"></xsl:value-of>
            <xsl:text>"</xsl:text>
            &comma;
            <xsl:text>"</xsl:text>
            <xsl:value-of select="CORRESPONDENCE/NAME"></xsl:value-of>
            <xsl:text>"</xsl:text>
            &comma;
            <xsl:text>"</xsl:text>
            <xsl:value-of select="CORRESPONDENCE/ADDRESS1"></xsl:value-of>
            <xsl:text>"</xsl:text>
            &comma;
            <xsl:text>"</xsl:text>
            <xsl:value-of select="CORRESPONDENCE/ADDRESS2"></xsl:value-of>
            <xsl:text>"</xsl:text>
            &comma;
            <xsl:text>"</xsl:text>
            <xsl:value-of select="CORRESPONDENCE/ADDRESS3"></xsl:value-of>
            <xsl:text>"</xsl:text>
            &comma;
            <xsl:text>"</xsl:text>
            <xsl:value-of select="CORRESPONDENCE/ADDRESS4"></xsl:value-of>
            <xsl:text>"</xsl:text>
            &comma;
            <xsl:text>"</xsl:text>
            <xsl:value-of select="CORRESPONDENCE/ADDRESS5"></xsl:value-of>
            <xsl:text>"</xsl:text>
            &comma;
            <xsl:text>"</xsl:text>
            <xsl:value-of select="TRADING_AS_INDICATOR"></xsl:value-of>
            <xsl:text>"</xsl:text>
            &comma;
            <xsl:text>"</xsl:text>
            <xsl:value-of select="REGISTERED_NUMBER"></xsl:value-of>
            <xsl:text>"</xsl:text>
            &comma;
            <xsl:text>"</xsl:text>
            <xsl:value-of select="BRAND_LOGO_NUMBER"></xsl:value-of>
            <xsl:text>"</xsl:text>
            &comma;
            <xsl:text>"</xsl:text>
            <xsl:text>"</xsl:text>
            <xsl:value-of select="FSA_TEXT"></xsl:value-of>
            <xsl:text>"</xsl:text>
            <xsl:text>"</xsl:text>
        </xsl:for-each> 
    </xsl:template>

</xsl:stylesheet>

Output of csv file is coming as:

JDW,A,,,"SBU","Simply Be Inquiries" , "Speciality Home Shopping (US) Limited" , "Griffin House" , "40 Lever Street" , "Manchester" , "United Kingdom" , "M60 6ES" , "www.simplybe.com" , "03941468" , "7" , "18774074675" , "18774074675" , "8am" , "11pm" , "8am" , "11pm" , "8am" , "11pm" , "8am" , "11pm" , "8am" , "11pm" , "8am" , "11pm" , "Simply Be Inquiries" , "777 South State Road 7" , "Margate, Florida 33068" , "" , "" , "" , "Y" , "03941468" , "DAL90" , """Simply Be" is a trading name of Speciality Home Shopping (US) Limited, registered in England with Co No. 03941468 and registered office at Griffin House, 40 Lever Street, Manchester UK M60 6ES""

but the required output is

JDW,A,,,"SBU","Simply Be Inquiries" , "Speciality Home Shopping (US) Limited" , "Griffin House" , "40 Lever Street" , "Manchester" , "United Kingdom" , "M60 6ES" , "www.simplybe.com" , "03941468" , "7" , "18774074675" , "18774074675" , "8am" , "11pm" , "8am" , "11pm" , "8am" , "11pm" , "8am" , "11pm" , "8am" , "11pm" , "8am" , "11pm" , "Simply Be Inquiries" , "777 South State Road 7" , "Margate, Florida 33068" , "" , "" , "" , "Y" , "03941468" , "DAL90" , """Simply Be"" is a trading name of Speciality Home Shopping (US) Limited, registered in England with Co No. 03941468 and registered office at Griffin House, 40 Lever Street, Manchester UK M60 6ES"

Outside of main template define two variables and another template:

    <xsl:variable name="quot">"</xsl:variable>
    <xsl:variable name="doublequot">""</xsl:variable>

    <xsl:template name="string-replace-all">
        <xsl:param name="text" />
        <xsl:choose>
            <xsl:when test="contains($text, $quot)">
                <xsl:value-of select="substring-before($text,$quot)" />
                <xsl:value-of select="$doublequot" />
                <xsl:call-template name="string-replace-all">
                    <xsl:with-param name="text" select="substring-after($text,$quot)" />
                </xsl:call-template>
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="$text" />
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>

and lines 157-161 in XSLT file replace to:

            <xsl:text>"</xsl:text>
            <xsl:call-template name="string-replace-all">
                <xsl:with-param name="text" select="FSA_TEXT" />
            </xsl:call-template>
            <xsl:text>"</xsl:text>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.