> I want to configure support for namespaces when querying nodes from a
> XalanDocument (this isn't strictly correct, but you should get the
> idea):-
>
>
> SelectSingleNode( const std::string & xPathExpression, XalanNode *
> Context )
> {
> TheEvaluator->selectSingleNode( *TheDOMSupport,
> Context,
> XalanDOMString(
> xPathExpression.c_str() ).c_str() ) ;
>
> }
>
> Problem: This call causes a core dump whenever I request something like
> this:-
>
> SelectSingleNode ( "prefix:ElementName/prefix:SubElement/text()" ,
> CurrentContext ) ;
I suspect you're getting a core dump because an exception is being thrown
which you're not catching. The documentation for XPathEvaluator looks like
this:
* @param domSupport An instance of the corresponding
DOMSupport-derived for the DOM implementation being used.
* @param contextNode The source tree context node
* @param xpathString The XPath expression to evaluate
* @param namespaceNode A node to use for namespace prefix
resolution.
So you can see the last parameter, which you're omitting, can be an
instance of a XalanElement, which the XPathEvaluator instance will use to
resolve prefixes. If the namespace declaration for "prefix" occurs on the
document element, you can do the following:
TheEvaluator->selectSingleNode( *TheDOMSupport,
Context,
XalanDOMString(xPathExpression.c_str()
).c_str(),
Context->getOwnerDocument()->getDocumentElement() ) ;
Otherwise, you can create your own derivative of PrefixResolver and return
whatever string you want to bind to "prefix."
If you download the lastest CVS code, you'll find a new class called
XalanDocumentPrefixResolver, which searches the entire document for
namespace declarations. This won't work in the case where "prefix" is
bound to multiple namespace URIs, but it does work for the simpler ones.
If you want to use prefixes which are not defined in the instance document,
you'll need your own derivate of PrefixResolver.
> As a side point, how can the documentation be improved, I find it
> somewhat lacking in detail ;-)
It can be improved by people volunteering to work on it. ;-)
Dave