From 9bb990c9a663edc43aebb87ed84b00e6d90685c0 Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Tue, 17 Jan 2017 20:44:31 +0100 Subject: Update markdown syntax to use pandoc's peculiarities --- articles/2014-10-30_expanding_xslt_using_xalan_and_cpp.md | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'articles/2014-10-30_expanding_xslt_using_xalan_and_cpp.md') diff --git a/articles/2014-10-30_expanding_xslt_using_xalan_and_cpp.md b/articles/2014-10-30_expanding_xslt_using_xalan_and_cpp.md index b0a53c4..07c12de 100644 --- a/articles/2014-10-30_expanding_xslt_using_xalan_and_cpp.md +++ b/articles/2014-10-30_expanding_xslt_using_xalan_and_cpp.md @@ -14,7 +14,7 @@ As Xalan itself offers no easy way of creating node trees from scratch I had to Because Xerces doesn't fully adhere to the principles of [RAII] I suggest wrapping [`xercesc::DOMDocument`] inside a `std::unique_ptr` specialized on a corresponding custom deleter as follows: -~~~ +```cpp class document_deleter { friend std::unique_ptr; @@ -35,14 +35,13 @@ document_ptr document( nullptr ) ); -~~~ -{: .language-cpp} +``` Notable in the example above is the usage of a special [`XercesStringGuard`] class template I implemented to simplify the conversion between `char` based strings and the custom `XMLCh` type used by Xerces. After one has constructed the desired document tree using the standard DOM manipulations provided by [`xercesc::DOMDocument`] the next step is the conversion of this Xerces specific document into a [`xalan::XalanDocument`] instance usable by Xalan. As Xalan is based on Xerces it offers a class especially for this task called [`xalan::XercesDOMWrapperParsedSource`] that may be used as follows: -~~~ +```cpp xalan::XercesParserLiaison parser; xalan::XercesDOMSupport domSupport(parser); xalan::XercesDOMWrapperParsedSource parsedSource( @@ -52,12 +51,11 @@ xalan::XercesDOMWrapperParsedSource parsedSource( ); xalan::XalanDocument* const xalanDocument = parsedSource.getDocument(); -~~~ -{: .language-cpp} +``` After one has converted the Xerces document into a Xalan document its parent nodes have to be included into a [`xalan::XPathExecutionContext::BorrowReturnMutableNodeRefList`] which then may finally be passed into `xalan::XObjectFactory::createNodeSet`. -~~~ +```cpp xalan::XPathExecutionContext::BorrowReturnMutableNodeRefList nodes( executionContext ); @@ -67,8 +65,7 @@ nodes->addNodes( ); return executionContext.getXObjectFactory().createNodeSet(nodes); -~~~ -{: .language-cpp} +``` Note that while the listings above should be enough to get you started on implementing external functions which are able to return node trees, they do not contain the logic necessary to keep the [`xalan::XercesDOMWrapperParsedSource`] instance including its helper classes alive through the whole duration of processing a XSL transformation and do not showcase the additional method implementations required to satisfy the [`xalan::Function`] interface. -- cgit v1.2.3