For XML export, it would make sense to have an option allowing field content to be wrapped in CDATA.

Files: 
CommentFileSizeAuthor
#16 views_data_export_d6-1465432-16.patch3.21 KBjunedkazi
PASSED: [[SimpleTest]]: [MySQL] 0 pass(es). View
#13 views_data_export-1465432-xml-cdata.patch6.46 KBSteven Jones
PASSED: [[SimpleTest]]: [MySQL] 92 pass(es). View
#11 xml_field_cdata-1465432-10.patch3.12 KBjunedkazi
PASSED: [[SimpleTest]]: [MySQL] 89 pass(es). View
#8 xml_field_cdata-1465432-8.patch3.09 KBjunedkazi
FAILED: [[SimpleTest]]: [MySQL] 89 pass(es), 0 fail(s), and 88 exception(s). View
#5 views_data_export-1465432-5.patch2.24 KBklausi
PASSED: [[SimpleTest]]: [MySQL] 78 pass(es). View
#3 views_data_export-1465432-3.patch2.24 KBklausi
PASSED: [[SimpleTest]]: [MySQL] 78 pass(es). View
#1 views_data_export-1465432-1.patch2.74 KBDmitriy.trt
PASSED: [[SimpleTest]]: [MySQL] 78 pass(es). View

Comments

Dmitriy.trt’s picture

Status: Active » Needs review
FileSize
2.74 KB
PASSED: [[SimpleTest]]: [MySQL] 78 pass(es). View

Patch with implementation.

aoturoa’s picture

thanks Dmitriy.trt for the patch, exactly what i needed.
I made small change so the CDATA is not applied on empty content.

Sorry for not using git patch, but the code below is pretty self explainable.

Index: views_data_export.theme.inc
===================================================================
--- views_data_export.theme.inc	(revision 681)
+++ views_data_export.theme.inc	(working copy)
@@ -383,7 +383,7 @@
           array('<', '>'),
           $content);
       }
-      else{
+      elseif(!empty($content)) {
         // Escape CDATA end sequence only.
         $content = '<![CDATA[' . str_replace(']]>', ']]]]><![CDATA[>', $content) . ']]>';
       }
klausi’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
2.24 KB
PASSED: [[SimpleTest]]: [MySQL] 78 pass(es). View

Patch looks RTBC to me, integrated the suggestions from #2.

Dmitriy.trt’s picture

Status: Reviewed & tested by the community » Needs work

Zero will not be wrapped with CDATA. It's just a guess. Please set back to RTBC if I'm wrong.

klausi’s picture

Status: Needs work » Needs review
FileSize
2.24 KB
PASSED: [[SimpleTest]]: [MySQL] 78 pass(es). View

Right, we should better check for the empty string instead of using empty().

Dmitriy.trt’s picture

Integer zero can't get here, right? Asking because 0 != '' results in FALSE and integer zero still won't be wrapped. Sorry I don't have this module installed at the moment and can't dig into it with debugger or properly analyze the code.

Leo Pitt’s picture

Hi, it would be great if it were possible to apply CDATA to individual fields rather than all fields in the view.

junedkazi’s picture

FileSize
3.09 KB
FAILED: [[SimpleTest]]: [MySQL] 89 pass(es), 0 fail(s), and 88 exception(s). View

Ok so I need it to be based on per field. So I am attaching a patch for review.Also a cleanup as there were some + signs in the comments.

junedkazi’s picture

Setting it to needs review.

Status: Needs review » Needs work

The last submitted patch, xml_field_cdata-1465432-8.patch, failed testing.

junedkazi’s picture

Status: Needs work » Needs review
FileSize
3.12 KB
PASSED: [[SimpleTest]]: [MySQL] 89 pass(es). View
Steven Jones’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

This patch looks okay, but we need some tests to make sure this functionality works. There should be test for not-escaping certain fields, which would be a good basis for a test.

Steven Jones’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests
FileSize
6.46 KB
PASSED: [[SimpleTest]]: [MySQL] 92 pass(es). View

Here's a patch for the testbot.

Steven Jones’s picture

Status: Needs review » Fixed
Issue tags: +Needs tests

Thanks everyone, committed to 7.x-3.x.

Steven Jones’s picture

Version: 7.x-3.x-dev » 6.x-2.x-dev
Status: Fixed » Patch (to be ported)

Now needs backporting.

junedkazi’s picture

Status: Patch (to be ported) » Needs review
FileSize
3.21 KB
PASSED: [[SimpleTest]]: [MySQL] 0 pass(es). View
junedkazi’s picture

Issue summary: View changes

removed comments that were potentially unrelated to the feature request/issue

  • Steven Jones committed 002f4e6 on 7.x-4.x
    Issue #1465432 by klausi, junedkazi, Dmitriy.trt, Steven Jones |...
Steven Jones’s picture

Issue summary: View changes
Status: Needs review » Fixed

@junedkazi thanks for the patch!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.