Hi,
Sorry for the belated response. This is an interesting issue. It is actually not related to Spring Integration but just how the underlying JAXP implementation works (and I believe Jaxen would handle this similarly; see link below).
Essentially you have 2 options to handle your use-case:
1) Don't provide a namespace prefix (Just an empty String. Null is not allowed.). Then your Xpath Expression will use a colon ":" to indicate the default namespace. If you leave the colon off, the XPath expression will not match.
Code:
BooleanTestXPathMessageSelector selector = new BooleanTestXPathMessageSelector(
"boolean(/:TrdCaptRpt)", "", "http://svn.msk.trd.ru/xsd/fixml");
selector.accept(new GenericMessage<String>(xml)));
2) The second option is to provide an arbitrarily chosen namespace prefix. It turns out that the namespace Uri is the really important piece of information, not the prefix itself. Please see the following explanation at:
http://jaxen.codehaus.org/faq.html
"In XPath 1.0, all unprefixed names are unqualified. There is no requirement that the prefixes used in the XPath expression are the same as the prefixes used in the document being queried. Only the namespace URIs need to match, not the prefixes."
Therefore, the following example will work as well:
Code:
BooleanTestXPathMessageSelector selector = new BooleanTestXPathMessageSelector(
"boolean(/foobar:TrdCaptRpt)", "foobar", "http://svn.msk.trd.ru/xsd/fixml");
selector.accept(new GenericMessage<String>(xml)));
Both example (using your provided XML sample) will return true. For some more explanations, please see:
http://www.edankert.com/defaultnamespaces.html
I certainly agree that this is poorly (not) documented in our reference docs and not easily to find on the internet either. Therefore, I have created a Jira to improve the respective documentation: https://jira.springsource.org/browse/INT-2292
Cheers,