summaryrefslogtreecommitdiff
path: root/src/core/XML.cpp
diff options
context:
space:
mode:
authorBenjamin Paassen <bpaassen@techfak.uni-bielefeld.de>2015-01-08 15:17:40 +0100
committerBenjamin Paassen <bpaassen@techfak.uni-bielefeld.de>2015-01-08 15:17:40 +0100
commit33b92b72ed160f22dc627e841d5f84de4ebc0c6c (patch)
tree597ebe6611f4317901817d05e00d8388e9960bf0 /src/core/XML.cpp
parentfd8ce97afb16e17102ec8f109103ed334ad0e939 (diff)
Changed the DemoOutput algorithm as suggested by Andreas: We first transform the document graph to an XML tree and the XML tree in turn has the methods to serialize to XML text, or, in this case, XHTML text.
Diffstat (limited to 'src/core/XML.cpp')
-rw-r--r--src/core/XML.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/core/XML.cpp b/src/core/XML.cpp
index ad69ba1..038cb86 100644
--- a/src/core/XML.cpp
+++ b/src/core/XML.cpp
@@ -4,7 +4,12 @@
namespace ousia {
namespace xml {
-void Element::serialize(std::ostream& out, unsigned int tabdepth)
+void Node::serialize(std::ostream& out){
+ out << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
+ doSerialize(out, 0);
+}
+
+void Element::doSerialize(std::ostream& out, unsigned int tabdepth)
{
for (unsigned int t = 0; t < tabdepth; t++) {
out << '\t';
@@ -15,7 +20,7 @@ void Element::serialize(std::ostream& out, unsigned int tabdepth)
}
out << ">\n";
for (auto &n : children) {
- n->serialize(out, tabdepth + 1);
+ n->doSerialize(out, tabdepth + 1);
}
for (unsigned int t = 0; t < tabdepth; t++) {
out << '\t';
@@ -23,7 +28,7 @@ void Element::serialize(std::ostream& out, unsigned int tabdepth)
out << "</" << name << ">\n";
}
-void Text::serialize(std::ostream& out, unsigned int tabdepth)
+void Text::doSerialize(std::ostream& out, unsigned int tabdepth)
{
for (unsigned int t = 0; t < tabdepth; t++) {
out << '\t';