2

Here I am using TransformXML to parse xml to an email.

I have saved xsl stylesheet as a content block and used the above function to parse xml to the email.

When the email is previewed using the xml data from a DE I am constantly seeing this error. I have tried looking around for proper implementation of xsl and seems like what I have done is correct.

Here is the xsl stylesheet:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
    <xsl:apply-templates/>
</xsl:template>
<xsl:template match="message/subscribers/subscriber">
<tr>
    <td align="center" valign="top">
        <table align="center" class="em_main_table" bgcolor="#faf8f9" width="640" border="0" cellspacing="0" cellpadding="0" style="table-layout:fixed; width:640px;">
            <tbody>
                <tr>
                    <td class="em_orange em_aside" valign="top" align="left" style="font-family: 'Montserrat', Arial, sans-serif; font-size: 24px; color: #f0683e; padding-left: 63px; padding-right: 63px; line-height: 28px; font-weight: 300; letter-spacing: 3px;">YOUR ORDER CONFIRMATION</td>
                </tr>
                <tr>
                    <td class="em_black em_aside" valign="top" align="left" style="font-family: Arial, sans-serif; font-size: 14px; color: #000000; padding-left: 63px; padding-right: 63px; line-height: 18px;">Hi <xsl:value-of select="firstname" />,</td>
                </tr>
            </tbody>
        </table>
    </td>
</tr>
</xsl:template>
</xsl:stylesheet>

And here is the xml:

<message>
    <content>
        <id>1234</id>
    </content>
    <subscribers>
        <subscriber>
            <firstname>Sample</firstname>
            <lastname>Sample</lastname>
            <email>[email protected]</email>
        </subscriber>
    </subscribers>
</message>

Also here is the AMPScript that does the transformation part:

%%[
        VAR @data
        SET @data = AttributeValue('data')
        SET @xsl = ContentBlockByKey('test_xsl_file')
        SET @OutputTransform = TreatAsContent(TransformXML(@data,@xsl)))]%%

        %%=v(@OutputTransform)=%%

And lastly this is the error:

Stylesheet must start either with an 'xsl:stylesheet' or an 'xsl:transform' element, or with a literal result element that has an 'xsl:version' attribute, where prefix 'xsl' denotes the 'http://www.w3.org/1999/XSL/Transform' namespace.

enter image description here

1 Answer 1

1

I appreciate this is a very old item but here's a finding:

It works if you encode your XML and XSLT with Base64 method.

  • Create two content blocks of type Code Snippet in Content Builder. One is for your XML and the other one for XSLT.
  • Encode your XML code with Base64 method with UTF-8 character set and paste the string into your XML content block. Do the same with XSLT.

Then use this code: %%=TransformXML(Base64Decode(ContentBlockById(YOUR_XML_CONTENT_BLOCK_ID), "UTF-8"), Base64Decode(ContentBlockById(XSLT_CONTENT_BLOCK_ID), "UTF-8"))=%%

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .