adding namespaces to org.apache.camel.model.language.ExpressionDefinition.xpath(), default namespace doesn't work



I have a problem with xpath and its namespaces. I have soap message like follows:



<soap:Envelope xmlns:soap="http://ift.tt/sVJIaE">
<soap:Body>
<incident xmlns="some default namespace"
xmlns:xmime="http://ift.tt/1leiEyB"
xmlns:ns3="some namespace">
<Company type="String">Test</Company>
</incident>
</soap:Body>
</soap:Envelope>


and I need to provide xpath that compares company name with another string. My xpath is "/soap:Envelope/soap:Body/incident[Company='Test'']" and I use it inside this part of code:



org.apache.camel.model.language.ExpressionDefinition.xpath("/soap:Envelope/soap:Body/incident[IncidentID='IM004559231']",
new beans.Xpath().createXpathNamespaces())


method Xpath().createXpathNamespaces() creates necessary namespaces:



public static Namespaces createXpathNamespaces() {
Namespaces namespaces = new Namespaces(Namespaces.DEFAULT_NAMESPACE, "some default namespace");
namespaces.add("soap", "http://ift.tt/sVJIaE");
namespaces.add("xmime", "http://ift.tt/1leiEyB");
namespaces.add("ns3", "some namespace");
return namespaces;
}


and here's the problem. When soap doesn't contains this part (default namespace): xmlns="some default namespace" everything works great; xpath returns true when Company=specified name or false when Test!=specified name but when default namespace is added to soap xpath return always false. Did I something wrong or is other way to add to xpath default namespaces? Thanks in advance.


No comments:

Post a Comment