[cascade:cdata] showing up in published XML

Greg Gomez's Avatar

Greg Gomez

21 Aug, 2015 09:00 PM

Hello:

I've got a transform that wraps the innards of certain nodes in CDATA sections. Here's a snippet:

[cascade:cdata]
            <xsl:copy-of select="./node()"/>
[/cascade:cdata]

The idea is to publish individual xml files to the webserver, which is working pretty good. Except that [cascade:cdata] is appearing in the published file. It's not showing up in the preview in Cascade, though. Here's an example:

<wysiwyg-description>
  <![CDATA[
  [cascade:cdata]
  Let's all eat lunch and then talk about stuff.
  ]]>
  [/cascade:cdata]
 </wysiwyg-description>

Thanks,
Greg

  1. 1 Posted by Ryan Griffith on 24 Aug, 2015 01:58 PM

    Ryan Griffith's Avatar

    Hi Greg,

    Based on the second snippet, it looks like there are multiple CDATA tags in your output. When you have a moment, please attach your Format and sample XML so I can take a closer look in my local instance.

    Thanks!

  2. 2 Posted by Greg Gomez on 24 Aug, 2015 10:34 PM

    Greg Gomez's Avatar

    Hi, Ryan:

    Here you go:

    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
        <xsl:template match="@*|node()">
            <xsl:copy>
                <xsl:apply-templates select="@*|node()"/>
            </xsl:copy>
        </xsl:template>
        <xsl:template match="*[starts-with(name(), 'wysiwyg-')]">
            <xsl:variable name="currentnode" select="name(.)"/>
            <!--<xsl:value-of select="$currentnode"/>-->
            <xsl:element name="{$currentnode}">
            [cascade:cdata]
            <xsl:copy-of select="./node()"/>
            [/cascade:cdata]
            </xsl:element>
        </xsl:template>
    </xsl:stylesheet>
    

    And here's the template:

    <!--#cascade-skip--><pass-through><system-region name="DEFAULT"/></pass-through>
    

    Thanks,
    Greg

  3. 3 Posted by Greg Gomez on 24 Aug, 2015 11:25 PM

    Greg Gomez's Avatar

    Hi, Ryan:

    I updated the template to say this:

    <system-region name="DEFAULT"/>
    

    I realized that I didn't need the cascade-skip and pass-through nodes for this one.

    Also, a little explanation might help you. What I'm trying to do is ensure that WYSIWYG Data Definition fields are wrapped in CDATA. It seems like the easiest way to do that is to name the fields something like wysiwyg-details, and then match nodes that begin with wysiwyg-. That way I don't have to update transforms every time somebody wants to add a new Data Definition or a WYSIWYG to an existing Data Definition (presuming that they name it correctly, beginning with wysiwyg-).

    I hope that makes sense.

    If you're aware of a better way to handle this situation, I would be interested to hear about it.

    Thanks,
    Greg

  4. 4 Posted by Greg Gomez on 25 Aug, 2015 12:03 AM

    Greg Gomez's Avatar

    Hi, Ryan:

    Another update. It appears that this is happening on assets that were created in the past, before I made some changes to the format, template, etc.. Although I can't see any differences between the old assets and newer ones, it does appear that newer assets are publishing correctly.

    If you don't mind, can we keep this one open for a bit and I'll double check this assumption tomorrow.

    Thanks,
    Greg

  5. 5 Posted by Ryan Griffith on 25 Aug, 2015 03:19 PM

    Ryan Griffith's Avatar

    Thank you for the updates, Greg, please keep me posted on your findings.

    Can you confirm if the actual WYSIWYG content contains CDATA tags or not?

    Thanks!

  6. 6 Posted by Greg Gomez on 25 Aug, 2015 05:43 PM

    Greg Gomez's Avatar

    Hi, Ryan:

    Heh, good question. If you mean did it get included in the text entered in the WYSIWYG field, then no.

    I tried that myself just to see what happens. In HTML view, adding CDATA tags causes the wrapped text to disappear in the visual editor. Adding to the visual editor causes the angle brackets to be converted to entities.

    Did I understand you correctly?

    Thank you!
    Greg

  7. 7 Posted by Ryan Griffith on 25 Aug, 2015 07:27 PM

    Ryan Griffith's Avatar

    Hi Greg,

    The CDATA tags would be hidden in the visual editor since they are scripting related. I should clarify, if you open up the HTML editor for the WYSIWYG, do you see any CDATA tags in there?

    Thanks!

  8. 8 Posted by Greg Gomez on 25 Aug, 2015 09:21 PM

    Greg Gomez's Avatar

    Hi, Ryan:

    Nope.

    Also, as I said, new pages appear to be publishing correctly. So, in other words, I did some fiddling and housekeeping, and things seem to be fine now. I'll confirm that as I go forward, but I think this one's resolved for now.

    Although, the other issue with my JSON format generating no root element is back, so I may resurrect that thread.

    You're always very helpful. Let me know if there's anything else you need from me.

    Thanks!
    Greg

  9. 9 Posted by Ryan Griffith on 26 Aug, 2015 03:07 PM

    Ryan Griffith's Avatar

    Thank you for following up, Greg, perhaps the issue is with some legacy content or something, which fixes itself when you update the content.

    Although, the other issue with my JSON format generating no root element is back, so I may resurrect that thread.

    Make sure you have that #cascade-skip tag in your template and a bogus element around your DEFAULT region. This setup should resolve the root element problem.

    I'm going to go ahead and close this discussion, please feel free to comment or reply to re-open if you have any additional questions.

    Have a great day!

  10. Ryan Griffith closed this discussion on 26 Aug, 2015 03:07 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac