aboutsummaryrefslogtreecommitdiff
path: root/src/support/dom/document_cache_item.cc
blob: 8cc1c24bb09d97981e24c4135197142c069bea41 (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
#include "support/dom/document_cache_item.h"

#include <xercesc/dom/DOMImplementation.hpp>
#include <xercesc/util/XMLString.hpp>

#include "support/xerces_string_guard.h"

namespace InputXSLT {

DomDocumentCache::item::item(const std::string& rootNode):
	parser_(),
	dom_support_(parser_),
	document_(
		xercesc::DOMImplementation::getImplementation()->createDocument(
			nullptr,
			*XercesStringGuard(rootNode),
			nullptr
		)
	),
	parsed_source_() { }

DomDocumentCache::item::~item() {
	this->document_->release();
}

bool DomDocumentCache::item::isFinalized() const {
	return static_cast<bool>(this->parsed_source_);
}

xercesc::DOMDocument* DomDocumentCache::item::getXercesDocument() const {
	return this->document_;
}

xalan::XalanDocument* DomDocumentCache::item::getXalanDocument() {
	if ( this->parsed_source_ ) {
		return this->parsed_source_->getDocument();
	} else {
		this->parsed_source_.reset(
			new xalan::XercesDOMWrapperParsedSource(
					document_,
					parser_,
					dom_support_
			)
		);

		return this->parsed_source_->getDocument();
	}
}

}