summaryrefslogtreecommitdiffstats
path: root/src/xml/repr-io.cpp
diff options
context:
space:
mode:
authorTavmjong Bah <tavmjong@free.fr>2011-09-08 14:27:40 +0000
committertavmjong-free <tavmjong@free.fr>2011-09-08 14:27:40 +0000
commit8a73582fd88bffa4e219dfce758a930b43c06a98 (patch)
tree625d3418f77eb5db1aa913f522773ed0f4bd4f55 /src/xml/repr-io.cpp
parentObey to dont-scale-strokewidth preference, even when scaling one dimension to... (diff)
downloadinkscape-8a73582fd88bffa4e219dfce758a930b43c06a98.tar.gz
inkscape-8a73582fd88bffa4e219dfce758a930b43c06a98.zip
Preserve CDATA sections on output.
(bzr r10625)
Diffstat (limited to 'src/xml/repr-io.cpp')
-rw-r--r--src/xml/repr-io.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/xml/repr-io.cpp b/src/xml/repr-io.cpp
index 2a0bb6ce8..365415488 100644
--- a/src/xml/repr-io.cpp
+++ b/src/xml/repr-io.cpp
@@ -24,6 +24,7 @@
#include "xml/attribute-record.h"
#include "xml/rebase-hrefs.h"
#include "xml/simple-document.h"
+#include "xml/text-node.h"
#include "io/sys.h"
#include "io/uristream.h"
@@ -497,7 +498,9 @@ sp_repr_svg_read_node (Document *xml_doc, xmlNodePtr node, const gchar *default_
return NULL; // we do not preserve all-whitespace nodes unless we are asked to
}
- return xml_doc->createTextNode(reinterpret_cast<gchar *>(node->content));
+ // We keep track of original node type so that CDATA sections are preserved on output.
+ return xml_doc->createTextNode(reinterpret_cast<gchar *>(node->content),
+ node->type == XML_CDATA_SECTION_NODE );
}
if (node->type == XML_COMMENT_NODE) {
@@ -849,7 +852,12 @@ void sp_repr_write_stream( Node *repr, Writer &out, gint indent_level,
{
switch (repr->type()) {
case Inkscape::XML::TEXT_NODE: {
- repr_quote_write( out, repr->content() );
+ if( dynamic_cast<const Inkscape::XML::TextNode *>(repr)->is_CData() ) {
+ // Preserve CDATA sections, not converting '&' to &amp;, etc.
+ out.printf( "<![CDATA[%s]]>", repr->content() );
+ } else {
+ repr_quote_write( out, repr->content() );
+ }
break;
}
case Inkscape::XML::COMMENT_NODE: {