blob: eaddeed7a22400129bd99bf0926ce7a253d5fe47 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
#include "result_node_facade.h"
#include <xercesc/dom/DOMText.hpp>
#include <xercesc/dom/DOMNodeList.hpp>
#include "support/xerces_string_guard.h"
namespace InputXSLT {
ResultNodeFacade::ResultNodeFacade(
xercesc::DOMDocument* document,
const std::string& name
):
ResultNodeFacade(
document,
document->getDocumentElement(),
name
) { }
ResultNodeFacade::ResultNodeFacade(
xercesc::DOMDocument* document,
xercesc::DOMNode* node,
const std::string& name
):
dom_document_(document),
result_node_(
dom_document_->createElement(*XercesStringGuard<XMLCh>(name))
),
root_node_(node) { }
ResultNodeFacade::~ResultNodeFacade() {
this->root_node_->appendChild(this->result_node_);
}
xercesc::DOMElement* ResultNodeFacade::getResultElement() {
return this->result_node_;
}
void ResultNodeFacade::setAttribute(
const std::string& name,
const std::string& value
) {
this->result_node_->setAttribute(
*XercesStringGuard<XMLCh>(name),
*XercesStringGuard<XMLCh>(value)
);
}
void ResultNodeFacade::setValueNode(
const std::string& name,
const std::string& value
) {
xercesc::DOMElement* const nameNode(
this->dom_document_->createElement(*XercesStringGuard<XMLCh>(name))
);
xercesc::DOMText* const valueNode(
this->dom_document_->createTextNode(*XercesStringGuard<XMLCh>(value))
);
nameNode->appendChild(valueNode);
this->result_node_->appendChild(nameNode);
}
void ResultNodeFacade::setContent(const std::string& content) {
this->result_node_->appendChild(
this->dom_document_->createTextNode(*XercesStringGuard<XMLCh>(content))
);
}
void ResultNodeFacade::setContent(xercesc::DOMNode* node) {
this->result_node_->appendChild(node);
}
void ResultNodeFacade::setContent(xercesc::DOMNodeList* nodes) {
for ( std::size_t index = 0; index < nodes->getLength(); ++index ) {
this->setContent(nodes->item(index));
}
}
}
|