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 "Gaur, Manish" <Mg...@rsasecurity.COM> on 2002/07/30 09:33:10 UTC
A PerfixResolver Question
Hi,
If I were to evaluate the expression "not(ancestor-or-self::A:Signature)"
on the following input Document, the result should be all nodes
except the Signature node.
<DocumentRoot>
<ManyNodes1>
</ManyNodes1>
<A:Signature xmlns:A="someuri"/>
<ManyNodes1>
</ManyNodes1>
<ManyNodes1>
</ManyNodes1>
</DocumentRoot>
This is what I am doing,
//..(decls and inits)
const char *expression = "not(ancestor-or-self::A:Signature)" ;
// select all nodes
const XObjectPtr theResult(
theEvaluator.evaluate(
theDOMSupport,
theDocument,
XalanDOMString("(/descendant-or-self::node()/.|//@*|//namespace::*)").c_str(
))) ;
// for each node evaluate expression
for (NodeRefList::size_type j = 0; j < (theResult->nodeset()).getLength();
++j)
{
XalanNode *thisNode = (theResult->nodeset()).item(j) ;
XPathEvaluator objEvaluator ;
// evaluate expression on node
const XObjectPtr objPointer(
objEvaluator.evaluate(
theDOMSupport,
thisNode,
XalanDOMString(expression).c_str(),
ElementPrefixResolverProxy(
theDocument->getDocumentElement(),
XPathEnvSupportDefault(),
theDOMSupport))) ;
if(objPointer->boolean())
// do something
}
As you notice, I am using ElementPrefixResolverProxy and initializing
the namespaceContext as the documentElement.
Ofcourse, this fails with an XSLException on the first node in the nodelist
itself (which is the document root node), as it doesn't know about the
xmlns:A namespace yet so it cannot resolve it.
My question is, what is the right namespaceContext for
expressions (and documents) like these??
or am I missing something fundamental here?
Your help is greatly appreciated.
Regards,
/Manish
PS: Sorry for such a long message. Please feel free to ask for
clarifications.