Invalid String Output in XML View
Goldcap - September 9, 2008 - 15:41
| Project: | Views Datasource |
| Version: | 6.x-1.0-alpha2 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | allisterbeharry |
| Status: | closed |
Description
XML doesn't allow for HTML Entities in output without a wrapping CDATA tag. Note that apostrophes and other unusual characters, even after using the following function:
views_xml_strip_illegal_chars($input)
The following xml validation error will occur:
XML Parsing Error: undefined entity
Location: http://andydev.drupal.poly.com/xml/nodes
Line Number 22, Column 21: Foo&pos;s Bar
--------------------^
Fix attatched to wrap all text nodes in CDATA tags via the XML Output theme.
| Attachment | Size |
|---|---|
| views-view-xml.tpl_.php_.diff | 369 bytes |

#1
Encoding the entities as numeric values instead of shorthand codes would also work and is cross-parser capable, since it doesn't depend on HTML-specific entities.
E.g. Instead of using amp in an entity, use #38. This would be a trivial change to views_xml.module. See the attached patch.
This can be used in conjunction with the patch above, or on its own (CDATA sections won't be necessary).
#2
Since this has two patches attached now, I figured I'd better change the status.
#3
I like the idea but your patches need a bit of work. Please also patch for XHTML and RDFa. Please roll all patches into one file (preferably using cvs diff -upNR for better readability). Please do not comment out the code that you are replacing, just remove it.
This patch is racing against #286715: Invalid xml due to incorrectly encoded greater-than symbol but this is the better approach.
cheers
#4
This problem is actually specific to one entity - the apostrophe ('). there was a typo in the code: I had &pos; instead of '. Fixed in alpha3: http://drupal.org/node/598242
#5
#6
Automatically closed -- issue fixed for 2 weeks with no activity.