aspose file tools
The moose likes Web Services and the fly likes XPath with namespace Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Web Services
Reply Bookmark "XPath with namespace" Watch "XPath with namespace" New topic
Author

XPath with namespace

Max Bogdanov
Greenhorn

Joined: Mar 12, 2011
Posts: 11

Hello!
I have no idea why this simple example does not work. Please give me same advice:
(if I remove namespace it works perfect)



Example output:



NamespaceContext implementation class:


Thanks, Max

OC-JA,OCP-JP,OCP-JWCD,OCE-EJBD,OCE-JPAD
N Sahni
Ranch Hand

Joined: Jul 07, 2011
Posts: 55

Hi,

Everything looks good here except the namespace.
The namespace declared in xml is whereas namaspace set in namaspacecontext is Both does not match.


Thanks and Regards,
Nilesh Sahni | nsahni@infocepts.com | www.infocepts.com
Max Bogdanov
Greenhorn

Joined: Mar 12, 2011
Posts: 11

N Sahni wrote:Hi,

Everything looks good here except the namespace.
The namespace declared in xml is whereas namaspace set in namaspacecontext is Both does not match.


It was my copy-paste mistake. I edited my post, the namespaces are same, I checked everything 1000 times))). Thanks.
N Sahni
Ranch Hand

Joined: Jul 07, 2011
Posts: 55

Can you try modifying DocumentBuilderFactory instance like this:

I tried executing your code and replicating the issue. By setting builder.setNamespaceAware(true); it worked properly.
Max Bogdanov
Greenhorn

Joined: Mar 12, 2011
Posts: 11

N Sahni wrote:Can you try modifying DocumentBuilderFactory instance like this:

I tried executing your code and replicating the issue. By setting builder.setNamespaceAware(true); it worked properly.


Thank you so much! Now it works. I didn't know that default value is false.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: XPath with namespace
 
Similar Threads
Binding XML to Java from SOAP message
selectNodeIterator() problem
Java Web Services 2
Namespance prefix transparent XPath lookup
WSDL2Java Question