You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-users@xalan.apache.org by "Arigapudi, Shyam" <Sh...@ugs.com> on 2002/03/15 16:52:44 UTC

selectSingleNode

Hi,
 I already have a DomDocument from xerces.

 I saw the stub about converting xalandocument to xerces and viceversa.
 I am stuck at trying to convert the the XObjectPtr to a xalanNode. Then I
want
to map it back to Dom_node and go on.
 Here is a simple function that I am trying to write and it does not work.
Could
someone help me out. Thanks.

DOM_Node aNode;
	// Set up a XercesParserLiaison and use it to wrap the DOM_Document
	// in a XalanDocument.
	XercesDOMSupport   theDOMSupport;
	XercesParserLiaison	theParserLiaison(theDOMSupport);
	XalanDocument* theDoc =
theParserLiaison.createDocument(getDocument(),false,true);

	assert(theDoc);
	XPathEvaluator	theEvaluator;

	// OK, let's find the context node...
	XalanNode* const	theContextNode =
		theEvaluator.selectSingleNode(
		theDOMSupport,theDoc,
		XalanDOMString("/").c_str(),
		theDoc->getDocumentElement());
	if(theContextNode != 0)
	{
		// OK, let's evaluate the expression...
		const XObjectPtr	theResult(
			theEvaluator.evaluate(
			theDOMSupport,
			theContextNode,
			XalanDOMString(xpathExpr).c_str(),
			theDoc->getDocumentElement()));
		
		assert(theResult.null() == false);
		const XercesDocumentBridge* bridge=
theParserLiaison.mapDocument(theDoc);
		if(bridge)
		{
			//How to get the xalanNode from the Evaluator
			const XalanNode *xnode = (const
XalanNode*)theResult.get();
			XalanDOMString str = xnode->getNodeValue();
			aNode = bridge->mapNode( xnode);
		}
	}


Regards,
Shyam Arigapudi
www.eds.com
shyam@ugs.com