diff options
Diffstat (limited to 'src/uscxml/Message.cpp')
-rw-r--r-- | src/uscxml/Message.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/uscxml/Message.cpp b/src/uscxml/Message.cpp index c3f4281..27e01e2 100644 --- a/src/uscxml/Message.cpp +++ b/src/uscxml/Message.cpp @@ -110,6 +110,30 @@ Arabica::DOM::Document<std::string> Data::toDocument() { return document; } +Arabica::DOM::Node<std::string> Event::getFirstDOMElement() const { + Arabica::DOM::Node<std::string> data = dom.getDocumentElement().getFirstChild(); + while (data) { + if (data.getNodeType() == Arabica::DOM::Node_base::TEXT_NODE) { + std::string trimmed = boost::trim_copy(data.getNodeValue()); + if (trimmed.length() == 0) { + data = data.getNextSibling(); + continue; + } + } + break; + } + return data; +} + +Arabica::DOM::Document<std::string> Event::getStrippedDOM() const { + Arabica::DOM::DOMImplementation<std::string> domFactory = Arabica::SimpleDOM::DOMImplementation<std::string>::getDOMImplementation(); + Arabica::DOM::Document<std::string> document = domFactory.createDocument("", "", 0); + if (dom) { + document.getDocumentElement().appendChild(document.importNode(getFirstDOMElement(), true)); + } + return document; +} + Arabica::DOM::Document<std::string> Event::toDocument() { Arabica::DOM::DOMImplementation<std::string> domFactory = Arabica::SimpleDOM::DOMImplementation<std::string>::getDOMImplementation(); Arabica::DOM::Document<std::string> document = data.toDocument(); |