diff options
author | Adrian Kummerlaender | 2014-07-07 22:25:03 +0200 |
---|---|---|
committer | Adrian Kummerlaender | 2014-07-07 22:25:03 +0200 |
commit | 8f05c7de54336daefb214a754de35367098b6510 (patch) | |
tree | fc8d2b8309c88a1e57193784ad4f48bfa573952d /src/function/write_file.cc | |
parent | be99b28838796ff5e1dc91685d6121a55d962a88 (diff) | |
download | InputXSLT-8f05c7de54336daefb214a754de35367098b6510.tar InputXSLT-8f05c7de54336daefb214a754de35367098b6510.tar.gz InputXSLT-8f05c7de54336daefb214a754de35367098b6510.tar.bz2 InputXSLT-8f05c7de54336daefb214a754de35367098b6510.tar.lz InputXSLT-8f05c7de54336daefb214a754de35367098b6510.tar.xz InputXSLT-8f05c7de54336daefb214a754de35367098b6510.tar.zst InputXSLT-8f05c7de54336daefb214a754de35367098b6510.zip |
Implemented custom xercesc::DOMDocument deleter
* pointers to xercesc::DOMDocument were manually released
** this is now solved using a custom deleter for the appropriate std::unqiue_ptr template specialization
* added matching factory method to DomDocumentCache
* updated external function implementations accordingly
** "constructDocument" is now expected to return a DomDocumentCache::document_ptr instance
* updated TransformerFacade accordingly
* this change was implemented to get rid of the manual memory management required by xalan / xerces
Diffstat (limited to 'src/function/write_file.cc')
-rw-r--r-- | src/function/write_file.cc | 23 |
1 files changed, 7 insertions, 16 deletions
diff --git a/src/function/write_file.cc b/src/function/write_file.cc index 024a87a..872160b 100644 --- a/src/function/write_file.cc +++ b/src/function/write_file.cc @@ -5,10 +5,6 @@ #include <xalanc/XMLSupport/FormatterToXML.hpp> #include <xalanc/XMLSupport/FormatterTreeWalker.hpp> -#include <xercesc/dom/DOMDocument.hpp> -#include <xercesc/dom/DOMImplementation.hpp> -#include <xercesc/dom/DOMElement.hpp> - #include <boost/filesystem.hpp> #include <boost/filesystem/fstream.hpp> @@ -34,11 +30,10 @@ bool serializeNodeToFile( if ( contentType == xalan::XalanNode::TEXT_NODE ) { file << InputXSLT::toString(contentNode->getNodeValue()); } else { - xalan::XalanStdOutputStream outputStream(file); + xalan::XalanStdOutputStream outputStream(file); xalan::XalanOutputStreamPrintWriter outputWriter(outputStream); - - xalan::FormatterToXML formatter(outputWriter); - xalan::FormatterTreeWalker walker(formatter); + xalan::FormatterToXML formatter(outputWriter); + xalan::FormatterTreeWalker walker(formatter); formatter.startDocument(); @@ -62,23 +57,19 @@ bool serializeNodeToFile( namespace InputXSLT { -xercesc::DOMDocument* FunctionWriteFile::constructDocument( +DomDocumentCache::document_ptr FunctionWriteFile::constructDocument( boost::filesystem::path filePath, xalan::XalanNode* const contentNode ) { - xercesc::DOMDocument* const domDocument( - xercesc::DOMImplementation::getImplementation()->createDocument( - nullptr, - *XercesStringGuard<XMLCh>("content"), - nullptr - ) + DomDocumentCache::document_ptr domDocument( + DomDocumentCache::createDocument() ); xercesc::DOMNode* const rootNode( domDocument->getDocumentElement() ); - ResultNodeFacade result(domDocument, rootNode, "file"); + ResultNodeFacade result(domDocument.get(), rootNode, "file"); result.setAttribute("path", filePath.string()); if ( contentNode != nullptr ) { |