Oh, there's an intervening method which resolves the context node from a
XalanDOMString expression. That is:
//! evaluate an XPath expression for a given XalanDOM and a given starting
context
void evaluateQuery( XalanDocument * const pXalanDoc,
XalanDOMString xdsContext,
XalanDOMString xdsPathExpr,
NodeRefList& theResult,
bool * const pbFound )
{
*pbFound = false;
if ( (XalanDocument *) NULL != pXalanDoc )
{
// attempt to locate the requested context node
XalanNode* const theContextNode = pMyXPathEvaluator->selectSingleNode(
*pMyXalanSourceTreeDOMSupport,
pXalanDoc,
xdsContext.c_str(),
pXalanDoc->getDocumentElement() );
evaluateQuery( pXalanDoc,
theContextNode, xdsContext, theResult, pbFound );
}
}
and, of course, one more to go from const char*'s to XalanDOMString's (but
that is just a one line wrapper which hides the XalanDOMString(const char *
const).c_str() junk from the "client".
On Thursday 16 June 2005 08:08 am, Lonnie VanZandt wrote:
> The method which calls selectNodeList (and wherein selectNodeList dies):
>
> //! evaluate an XPath expression for a given XalanDOM and a given
> starting context
> void evaluateQuery( XalanDocument * const pXalanDoc,
> XalanNode * const theContextNode,
> XalanDOMString xdsPathExpr,
> NodeRefList& theResult,
> bool * const pbFound )
> {
> *pbFound = false;
>
> if ( (XalanDocument * const) NULL != pXalanDoc )
> {
> // a null node indicates that the context couldn't be found
> if ( (XalanNode * const) NULL != theContextNode)
> {
> // OK, let's evaluate the expression...
> pMyXPathEvaluator->selectNodeList(
> theResult,
> *pMyXalanSourceTreeDOMSupport,
> theContextNode,
> xdsPathExpr.c_str(),
> pXalanDoc->getDocumentElement() );
>
> * pbFound = ( !theResult.empty() );
> }
> }
> }
>
> The calling method (in a derived class which contains the above method):
>
> NodeRefList nodeRefList;
> bool bFound = false;
> pDBDXMLProcessor->evaluateQuery( pRequestXalanDoc,
> "/casperAPI", "trigger", nodeRefList, &bFound );
>
> The context initialization in the base class' constructor:
>
> try
> {
> XMLPlatformUtils::Initialize();
>
> // Initialize Xalan.
> XalanTransformer::initialize();
>
> // initialize the XalanSourceTree
> pMyXalanSourceTreeInit = new XalanSourceTreeInit();
>
> // We'll use these to parse the XML file.
> pMyXalanSourceTreeDOMSupport = new XalanSourceTreeDOMSupport();
> pMyXalanSourceTreeParserLiaison = new
> XalanSourceTreeParserLiaison( *pMyXalanSourceTreeDOMSupport );
>
> // Hook the two DOM manager and the Xalan parser together
>
> pMyXalanSourceTreeDOMSupport->setParserLiaison(
> pMyXalanSourceTreeParserLiaison );
>
> // our XPathEvaluator
> XPathEvaluator::initialize();
> pMyXPathEvaluator = new XPathEvaluator();
>
> // instantiate an Xalan Transformer
> pMyXalanTransformer = new XalanTransformer();
> }
> catch (const XMLException& toCatch)
> {
> std::cerr << "Xalan and Xerces initialization failed. Error code
> was "
> << toCatch.getCode() << "." << std::endl;
>
> //throw toCatch;
> }
>
> And, finally, parsing of pRequestXalanDoc:
>
> //! parse the given XML input into a read-only Xalan DOM Document
> XalanDocument * const parseString( const char * const
> sXmlInputCharArray ) const
> {
> // wrap the input string within a stream handler
> std::istringstream issXml( sXmlInputCharArray );
>
> // promote the input XML character buffer into an XSLTInputSource
> const XSLTInputSource xisXml( issXml );
>
> XalanDocument * const pXalanDoc =
> pMyXalanSourceTreeParserLiaison->parseXMLStream( xisXml );
>
> return pXalanDoc;
> }
>
> On Thursday 16 June 2005 07:59 am, Axel Weiß wrote:
> > Lonnie VanZandt wrote:
> > > Not quite, the crash still occurs in the same location - but assuredly
> > > it is a good idea to call that initialize() method nevertheless.
> >
> > Hi Lonnie,
> >
> > would you, please, provide us with some example you're working on?
> >
> > Just to be in-line with what you're telling about...
> >
> > Cheers,
> > Axel
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]