Search code examples
htmlemailxsltcdata

How to use CDATA to keep vml code intact inside XSL file when rendered by email clients?


I have the below code in an XSL file. However, it is getting stripped out when getting converted to html. Any help in kepping this intact maybe by use of CDATA?.

<!--[if gte mso 9]>
<v:rect xmlns:v="urn:schemas-microsoft-com:vml" fill="true" stroke="false" style="width:600px;height:240px;">
  <v:fill type="tile" src="{$head_bg_image}" color="#c0393f" />
  <v:textbox inset="0,0,0,0">
<![endif]-->


<div> My contents here </div>
<!--[if gte mso 9]>
  </v:textbox>
</v:rect>
<![endif]-->

Thanks everyone. SOlved as below

           <!-- M$ hack for table background images -->
            <xsl:comment>
                <![CDATA[[if gte mso 9]>
                    <v:rect xmlns:v="urn:schemas-microsoft-com:vml" fill="true" stroke="false" color="#c0393f" style="width:600px;height:240px;">
                    <v:fill type="tile" src="]]>

                    <xsl:value-of select="$head_bg_image"/>

                    <![CDATA[" />

                    <v:textbox inset="0,0,0,0">
                    <![endif]]]>
            </xsl:comment>
            <div style="color:#c9be8a;font-weight:700;font-size:19px;width:220px;text-transform:uppercase;margin:147px 0px 0px 107px;">
                <xsl:value-of select="masthead/header/title" disable-output-escaping="yes"/> </div>
            <xsl:comment>
                <![CDATA[[if gte mso 9]>
                    </v:textbox>
                    </v:rect>
                    <![endif]]]>
            </xsl:comment>

Solution

  • Soln solved as

    <!-- M$ hack for table background images -->
            <xsl:comment>
                <![CDATA[[if gte mso 9]>
                    <v:rect xmlns:v="urn:schemas-microsoft-com:vml" fill="true" stroke="false" color="#c0393f" style="width:600px;height:240px;">
                    <v:fill type="tile" src="]]>
    
                    <xsl:value-of select="$head_bg_image"/>
    
                    <![CDATA[" />
    
                    <v:textbox inset="0,0,0,0">
                    <![endif]]]>
            </xsl:comment>
            <div style="color:#c9be8a;font-weight:700;font-size:19px;width:220px;text-transform:uppercase;margin:147px 0px 0px 107px;">
                <xsl:value-of select="masthead/header/title" disable-output-escaping="yes"/> </div>
            <xsl:comment>
                <![CDATA[[if gte mso 9]>
                    </v:textbox>
                    </v:rect>
                    <![endif]]]>
            </xsl:comment>