On 3/10/2011 12:38 AM, Naveen Arora wrote:

DESCRIPTION OF THE PROBLEM :
Failure in trying to select element using XPath when the document has
mixed namespaces tags.
Example of document:
<?xml version='1.0'?><Response user="user"
requestId="clientName@requestId">blah0<SOAP:Envelope
<mailto:clientName@requestId%22%3Eblah0%3CSOAP:Envelope>
xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/";><SOAP:Header>blah1</SOAP:Header><SOAP:Body></SOAP:Body></SOAP:Envelope></Response
<http://schemas.xmlsoap.org/soap/envelope/%22%3E%3CSOAP:Header%3Eblah1%3C/SOAP:Header%3E%3CSOAP:Body%3E%3C/SOAP:Body%3E%3C/SOAP:Envelope%3E%3C/Response>>


The XPathEvaluator to select the element
"/,Response/SOAP:Envelope/SOAP:Header" does not work correctly and gives
I'm going to assume this "," is a typo.

incorrect results.  (However...document with usage of no namespace or
usage of namespace through out the document work properly in identifying
the element.)


FULL PRODUCT VERSION :
libxalan-c1_4_0.so
libxerces-c.so.21.0

CODE DESIGN:
The code design has been borrowed from Sample file
"c/samples/SimpleXPathAPI/SimpleXPathAPI.cpp"


REPRODUCIBILITY :
The behavior is consistently reproducible.
This is likely a limitation in the sample code you're using, rather than a bug. You need to take a look at the PrefixResolver interface and implement one that works for your case. Its purpose is to map namespace prefixes like "SOAP" to the corresponding namespace URIs, which in this case is "http://schemas.xmlsoap.org/soap/envelope/";.

The sample application uses a derivative called ElementPrefixResolver that takes the root element and looks at that element for namespace declarations. This won't work for you, because not all of the namespace declarations appear in the root element of your document. You need to create an implementation of PrefixResolver that knows about all of the namespace prefixes and URIs in your documents.

Dave

Reply via email to