Problem/Motivation
Where a field for export contains valid xml, or is pushed through a field formatter that outputs valid xml, it would be nice to be able to exclude that field from xml encoding.
Proposed resolution
Add a new option to the views data export plugin for xml that allows you to specify fields that will be excluded from xml encoding. That way, if a user chooses a field formatter that already outputs valid xml, they can then exclude that field from xml encoding too.
User interface changes
The new "Exclude these fields from XML Entity Encoding" options can be added as checkboxes to the Style Options for the Views data export XML style plugin.
Original report by adam_b
I have a database which includes a lot of useful info in field-collection entities. When I try and export this in XML format, it's output as a table with escaped HTML tags, no matter what format I choose for the field (see attachment).
Is this an issue for this module, or for the field-collection module? Are there any alternatives? I can see ways to handle this, but ideally I'd like a full XML structure.
Issue fork views_data_export-1446102
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #1
adam_b commentedbounce... anybody have any suggestions?
Comment #2
jpcurley25 commentedstruggling with the same problem myself.
Comment #3
jpcurley25 commentedhttp://drupal.org/node/1175082
Comment #4
Thithi32 commentedI don't really understand jpcurley25 answer.
I have the same kind of issue: i'd like to export an xml that would look like:
nodes
-node
--title
--medias
---media
----title
----file
Any idea on how to do this?
Comment #5
Thithi32 commentedWhat I did was modify the xml export template (views-data-export-xml-body--myview-name--mydisplay-name.tpl.php) to insert another view inside my current view:
Hope this help someone.
Comment #6
chop commentedPatch motivation
In my situation, I've written a field formatter that returns a render array that in turn outputs valid xml encoded content. When I apply this field formatter to my field for export, I want to be able to exclude the field from xml encoding by views_data_export_plugin_style_export_xml
Patch Solution
This patch adds checkboxes to
views_data_export_plugin_style_export_xml::options_form(), where you can choose individual fields for exemption from xml entity encoding. Then, during the theme preprocessing intemplate_preprocess_views_data_export_xml_body()we check this setting before xml encoding each fields contents for inclusion in$themed_rows.After applying the patch:
.
Comment #7
adam_b commented#6 works great for me - thanks very much
Comment #8
donundeen commented#5 this looks great, but I can't get it to work. Where does this file need to go?
I've my view name is
"Text and Media XML"
and the Display name is:
"Data export"
I've named my template file:
views-data-export-xml-body--text-and-media-xml--data-export.tpl.php
also tried:
views-data-export-xml-body--text_and_media_xml--data_export.tpl.php
is that right?
I put it in the same directory as the original views-data-export-xml-body.tpl.php ,
but the override isn't happening.
maybe there's something dumb I'm missing?
thanks.
Comment #9
Thithi32 commented@donundeen : the file goes in your theme like other template files. Are you sure your views name and display name are correct? -> look at your views 'advanced' group + Other + System Name (sorry I'm translating from french I'm not sure of the terms). For info, my files are named:
views-data-export-xml-body--xml-panos.tpl.php
views-data-export-xml-footer--xml-panos--views-data-export_1.tpl.php
views-data-export-xml-header--xml-panos--views-data-export_1.tpl.php
views-data-export-xml-body--xml-panos--views-data-export-1.tpl.php
views-data-export-xml-footer--xml-panos--views-data-export_2.tpl.php
views-data-export-xml-header--xml-panos--views-data-export_2.tpl.php
views-data-export-xml-body--xml-pi.tpl.php
views-data-export-xml-footer--xml-pi.tpl.php
views-data-export-xml-header--xml-pi.tpl.php
views-data-export-xml-footer--xml-panos.tpl.php
views-data-export-xml-header--xml-panos.tpl.php
views-view-field--xml-pi--field-video2.tpl.php
Comment #10
Thithi32 commented@donundeen: you can look at 'advanced' + Other + Theme Information to get the list of template files you can use.
Comment #11
peacog commentedThank you for the patch in #6. It's very useful and I'd love to see it committed.
In my case I needed to wrap a field in an additional tag. The patch allows me to create a template in my theme and simply wrap the output like this:
<mytag><?php print $output; ?></mytag>Comment #12
pacproduct commentedPatch #6 works great for me as well. Thank you!
I needed it to embed a sub-view that already outputs some valid XML.
Comment #13
james.williamsPatch #6 works perfectly for me too.
Comment #14
joshf commented#6 worked for me as well; thanks for the patch!
Comment #15
steven jones commented#6: views_data_export-disable_xml_encoding-1446102-6.patch queued for re-testing.
Comment #16
steven jones commentedThis need some tests too.
Comment #17
steven jones commentedHere's a re-roll for the test bot, still need to add tests.
Comment #19
steven jones commentedHow about this one. Fixes the notice and adds a test.
Comment #20
steven jones commentedThanks for the hard work everyone!
Committed to 7.x-3.x.
Comment #21
steven jones commentedComment #22
steven jones commentedHere's a simple patch, that needs some work because the Views API changed from 3 -> 2.
Comment #23
loparr commentedWhich patch can I use for drupal 6 version?
Comment #24
ts145nera commentedThanks for your works.
I would know if there's a way to add custom tag to the field using "Rewrite the output of this field".
I've tried to add
<foo>[field_token]</foo>but tags are been removed in the export
Comment #24.0
ts145nera commentedAdd new summary outlining proposed solution.
Comment #25
dasjojust for reference and our make file, attached is a patch against views_data_export 3.0-beta6 that includes the committed patch #20 and adapts it for xml exports
Comment #27
greggadsdon commentedAs Drupal 6 nears the end of its life and support period, the 6.x version of Views Data Export will not be supported either. To that end, this issue has been closed, and will not be resolved in the 6.x branch of Views Data Export.
If this issue is still relevant to 7.x branch of Views Data Export, then please re-open and move to a relevant 7.x version.