Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Sebastiaan Janssen 5060 posts 15522 karma points MVP admin hq
    Jan 17, 2011 @ 11:52
    Sebastiaan Janssen
    0

    CDATA section around an HTML block

    I need to be able to wrap this piece of XML in a CDATA section:

            <description>
              <span style="font-size: 11px; color: #000000; font-family: Arial, Helvetica, sans-serif">
                <xsl:value-of select="data[@alias = 'text']" />
              </span>
            </description>

    So the result should look like this:

    <description><![CDATA[<span style="font-size: 11px; color: #000000; font-family: Arial, Helvetica, sans-serif">Deze nieuwsbrief wordt u gratis aangeboden door xxx (normale abonnementsprijs € 12,95 per jaar).</span>]]></description>

    However, when I change the XML output tag to do so, it doesn't wrap anything in CDATA:

    <xsl:output method="xml" omit-xml-declaration="yes" cdata-section-elements="description content:encoded"/>

    When I do the same thing but I remove the <span> around the <xsl:value-of>, the CDATA wrapper gets produced just fine. 

    Of course when I add the span to the rich text editor (the "text" property is of type RTE), it works just fine, but that's not something I want my editors to have to worry about.

    So how do I do this?

  • Jamie Howarth 306 posts 773 karma points c-trib
    Jan 17, 2011 @ 12:00
    Jamie Howarth
    1

    Try adding "span" to the cdata-section-elements attribute.

    EDIT: Scrub all that, just realised it won't work cause of your thread you posted a few months back...

  • Sebastiaan Janssen 5060 posts 15522 karma points MVP admin hq
    Jan 17, 2011 @ 12:03
    Sebastiaan Janssen
    0

    Ah yes, should've said that I tried that as well, I then get the CDATA block only in the span element.

    <description><span style="font-size: 11px; color: #000000; font-family: Arial, Helvetica, sans-serif"><![CDATA[Deze nieuwsbrief wordt u gratis aangeboden door xxx (normale abonnementsprijs € 12,95 per jaar).]]></span></description>
Please Sign in or register to post replies

Write your reply to:

Draft