XML export produces invalid XML
| Project: | Views Bonus Pack |
| Version: | 6.x-1.x-dev |
| Component: | Views Export |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs review |
In views_bonus_export.theme.inc are these lines, starting at line 63:
<?php
foreach ($row as $field => $content) {
$vars['themed_rows'][$num][$field] = str_replace(
array('&', '<', '>'),
array('&', '<', '>'),
$content);
}
?>A few problems.
First, there is no need to check for >. The W3C's XML spec sec. 2.4 only says to worry if it's within a CDATA section (because it could conflict with ]]>), but those were removed per #494848: CDATA is pointless.
Second, & and < should not be altered unless they are not part of "markup delimiters, or within a comment." For example, if you come across <b>, the opening < should not be altered. Also, if you come across across &, that should not be altered. Unfortunately the current code will convert the tag to <b> and the entity to &amp;. And if either is within a comment, they should be skipped entirely.

#1
Although trying to use Drupal's theme rendering system to build the XML document is a laudable goal, it is fraught with difficulties. Rather than re-inventing the wheel I propose the following strategy:
I doubt many people want to theme the XML export (but probably have too at the moment).
I've attached a patch that cleans up the XML export of VBP, it does:
#2
#3
@Steven - thanks a lot for the help. The exports are "lovely" :)
I'm testing the module for integration with other app and I'll be post more about this, for information.
Great idea, views_bonus!