summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArseny Kapoulkine <arseny.kapoulkine@gmail.com>2016-01-09 17:46:42 -0800
committerArseny Kapoulkine <arseny.kapoulkine@gmail.com>2016-01-09 17:46:42 -0800
commitdf2a0ad28b24681fdc39275b5260132b0a3e6918 (patch)
tree41929fe4908d92bb1225dddd0e133e5b269e35d9
parent85d8b225f2276333001dc0f96179bfef012277ae (diff)
Implement output support for embedded PCDATA values
This is a bit awkward since preserving correct indentation structure requires a bit of extra work, and the closing tag has to be written by _start function to correctly process the rest of the tree.
-rw-r--r--src/pugixml.cpp35
1 files changed, 31 insertions, 4 deletions
diff --git a/src/pugixml.cpp b/src/pugixml.cpp
index c018359..90c677e 100644
--- a/src/pugixml.cpp
+++ b/src/pugixml.cpp
@@ -4018,17 +4018,40 @@ PUGI__NS_BEGIN
if (node->first_attribute)
node_output_attributes(writer, node, indent, indent_length, flags, depth);
- if (!node->first_child)
+ // element nodes can have value if parse_embed_pcdata was used
+ if (!node->value)
{
- writer.write(' ', '/', '>');
+ if (!node->first_child)
+ {
+ writer.write(' ', '/', '>');
- return false;
+ return false;
+ }
+ else
+ {
+ writer.write('>');
+
+ return true;
+ }
}
else
{
writer.write('>');
- return true;
+ text_output(writer, node->value, ctx_special_pcdata, flags);
+
+ if (!node->first_child)
+ {
+ writer.write('<', '/');
+ writer.write_string(name);
+ writer.write('>');
+
+ return false;
+ }
+ else
+ {
+ return true;
+ }
}
}
@@ -4136,6 +4159,10 @@ PUGI__NS_BEGIN
if (node_output_start(writer, node, indent, indent_length, flags, depth))
{
+ // element nodes can have value if parse_embed_pcdata was used
+ if (node->value)
+ indent_flags = 0;
+
node = node->first_child;
depth++;
continue;