kvarec commented on pull request #39:
URL: https://github.com/apache/xalan-c/pull/39#issuecomment-978109633
Example1.cpp
```c++
#include <xalanc/Include/PlatformDefinitions.hpp>
#include <xercesc/util/PlatformUtils.hpp>
#include <xercesc/dom/DOM.hpp>
#include <xercesc/dom/impl/DOMDocumentImpl.hpp>
#include <xalanc/XPath/XPathEvaluator.hpp>
#include <xalanc/XalanSourceTree/XalanSourceTreeDOMSupport.hpp>
#include <xalanc/XalanSourceTree/XalanSourceTreeInit.hpp>
#include <xalanc/XalanSourceTree/XalanSourceTreeParserLiaison.hpp>
#include <xalanc/XercesParserLiaison/XercesDocumentWrapper.hpp>
int main()
{
using xercesc::XMLPlatformUtils;
using xalanc::XPathEvaluator;
XMLPlatformUtils::Initialize();
XPathEvaluator::initialize();
{
using xalanc::XalanDOMString;
using xalanc::XalanSourceTreeInit;
using xalanc::XalanSourceTreeDOMSupport;
using xalanc::XalanSourceTreeParserLiaison;
using xalanc::XalanElement;
using xalanc::XPath;
using xalanc::XalanNode;
XalanSourceTreeInit theSourceTreeInit;
XalanSourceTreeDOMSupport theDOMSupport;
XalanSourceTreeParserLiaison theLiaison(theDOMSupport);
theDOMSupport.setParserLiaison(&theLiaison);
XalanElement* theContextNode = 0;
{
using namespace xercesc;
using xalanc::XercesDocumentWrapper;
DOMImplementation* theDOMImpl =
DOMImplementation::getImplementation();
DOMDocument* theDocument = theDOMImpl->createDocument();
DOMNode *theNode =
theDocument->createElement(XalanDOMString("NODE").c_str());
MemoryManager* theManager = GET_DIRECT_MM(theDocument);
auto theWrapper = XercesDocumentWrapper::create(*theManager,
theDocument, false, false, false);
theContextNode =
static_cast<XalanElement*>(theWrapper->mapNode(theNode));
}
XPathEvaluator().selectSingleNode(
theDOMSupport,
theContextNode,
XalanDOMString("//NODE").c_str());
}
XPathEvaluator::terminate();
XMLPlatformUtils::Terminate();
return 0;
}
```
CMakeLists.txt
```cmake
cmake_minimum_required(VERSION 3.2)
project(example1 CXX)
find_package(XercesC REQUIRED)
find_package(XalanC REQUIRED)
include_directories(
${XercesC_INCLUDE_DIRS}
${XalanC_INCLUDE_DIRS}
)
add_executable(${PROJECT_NAME}
Example1.cpp
)
target_link_libraries(${PROJECT_NAME}
${XercesC_LIBRARIES}
${XalanC_LIBRARIES}
)
```
Move CmakeLists.txt and Example1.cpp to somw dir (for example named "src")
and execute:
`cmake src && make && ./example1`
From gdb:
```
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff79d6cb6 in
xalanc_1_11::XPath::findRoot(xalanc_1_11::XPathExecutionContext&,
xalanc_1_11::XalanNode*, int const*, int, xalanc_1_11::MutableNodeRefList&)
const () from /lib/x86_64-linux-gnu/libxalan-c.so.111
(gdb) bt
#0 0x00007ffff79d6cb6 in
xalanc_1_11::XPath::findRoot(xalanc_1_11::XPathExecutionContext&,
xalanc_1_11::XalanNode*, int const*, int, xalanc_1_11::MutableNodeRefList&)
const () from /lib/x86_64-linux-gnu/libxalan-c.so.111
#1 0x00007ffff79dea5a in
xalanc_1_11::XPath::step(xalanc_1_11::XPathExecutionContext&,
xalanc_1_11::XalanNode*, int const*, xalanc_1_11::MutableNodeRefList&) const ()
from /lib/x86_64-linux-gnu/libxalan-c.so.111
#2 0x00007ffff79dfd5a in
xalanc_1_11::XPath::locationPath(xalanc_1_11::XalanNode*, int const*,
xalanc_1_11::XPathExecutionContext&) const () from
/lib/x86_64-linux-gnu/libxalan-c.so.111
#3 0x00007ffff79dbaf4 in
xalanc_1_11::XPath::executeMore(xalanc_1_11::XalanNode*, int const*,
xalanc_1_11::XPathExecutionContext&) const () from
/lib/x86_64-linux-gnu/libxalan-c.so.111
#4 0x00007ffff79dc2b7 in
xalanc_1_11::XPath::execute(xalanc_1_11::XalanNode*,
xalanc_1_11::PrefixResolver const&, xalanc_1_11::XPathExecutionContext&) const
() from /lib/x86_64-linux-gnu/libxalan-c.so.111
#5 0x00007ffff79d531e in
xalanc_1_11::XPathEvaluator::evaluate(xalanc_1_11::DOMSupport&,
xalanc_1_11::XalanNode*, xalanc_1_11::XPath const&, xalanc_1_11::PrefixResolver
const&, xalanc_1_11::XPathEnvSupport&) ()
from /lib/x86_64-linux-gnu/libxalan-c.so.111
#6 0x00007ffff79d5ca1 in
xalanc_1_11::XPathEvaluator::evaluate(xalanc_1_11::DOMSupport&,
xalanc_1_11::XalanNode*, char16_t const*, xalanc_1_11::PrefixResolver const&,
xalanc_1_11::XPathEnvSupport&) ()
from /lib/x86_64-linux-gnu/libxalan-c.so.111
#7 0x00007ffff79d5deb in
xalanc_1_11::XPathEvaluator::evaluate(xalanc_1_11::DOMSupport&,
xalanc_1_11::XalanNode*, char16_t const*, xalanc_1_11::XalanElement const*) ()
from /lib/x86_64-linux-gnu/libxalan-c.so.111
#8 0x00007ffff79d5ea7 in
xalanc_1_11::XPathEvaluator::selectSingleNode(xalanc_1_11::DOMSupport&,
xalanc_1_11::XalanNode*, char16_t const*, xalanc_1_11::XalanElement const*) ()
from /lib/x86_64-linux-gnu/libxalan-c.so.111
#9 0x0000555555557640 in main () at
/home/user/dev/xalan-c_example1/src/Example1.cpp:50
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]