A DOM_NodeList is a smart-pointer to an underlying Xerces implementation
class. There is no way to create one short of deriving a class from
Xerces' internal class NodeListimpl and implementing what needs to be
implemented. This is a Xerces issue, not a Xalan issue, so you may want to
post a question on the Xerces-C list asking the best way to go about
implementing such a thing.
I have no idea why the destructor of std::vector<> would crash, unless
you're overwriting memory with some errant code. You need to be very
careful when using the Xerces DOM, as the reference counting can cause
problems if you don't understand how it works.
Dave
sk ask
<[EMAIL PROTECTED] To:
[email protected]
oo.com> cc: (bcc: David N
Bertoni/Cambridge/IBM)
Subject: xalan SelectNodeList
03/18/2002 10:32
AM
Hi All,
What is the best way to convert a NodeRefList
> to DOM_NodeList. Tried using a vector of DOM_Nodes
> to return. However, the destructor of the
> std::vector
> crashes. Any tips/pointers would be appreciated.
>
> Here is the code:
bool CimfXMLReader::selectNodes(const TCHAR*
xpathExpr, std::vector<DOM_Node>& nodes)
{
// Set up a XercesParserLiaison and use it to wrap
the DOM_Document
// in a XalanDocument.
XercesDOMSupport theDOMSupport;
XercesParserLiaison theParserLiaison(theDOMSupport);
theParserLiaison.setDoNamespaces(m_parser->getDoNamespaces());
XalanDocument* theDoc =
theParserLiaison.createDocument(getDocument());
assert(theDoc);
XPathEvaluator theEvaluator;
// OK, let's find the context node...
NodeRefList const theContextNodes =
theEvaluator.selectNodeList(
theDOMSupport,theDoc,
XalanDOMString(xpathExpr).c_str(),
theDoc->getDocumentElement());
nodes.clear();
int numNodes = theContextNodes.getLength();
if(numNodes)
{
nodes.reserve(numNodes);
const XercesDocumentBridge* bridge=
theParserLiaison.mapDocument(theDoc);
if(bridge)
{
for(int i=0;i<numNodes;++i)
{
DOM_Node aNode =
bridge->mapNode(theContextNodes.item(i));
nodes.push_back(aNode.cloneNode(false));
}
return true;
}
}
return false;
}
=====
__________________________________________________
Do You Yahoo!?
Yahoo! Sports - live college hoops coverage
http://sports.yahoo.com/