Re: [xsl] Re: XPATH Issue

Subject: Re: [xsl] Re: XPATH Issue
From: Martin Honnen <Martin.Honnen@xxxxxx>
Date: Wed, 01 Dec 2010 11:47:51 +0100
Rajesh Jain wrote:
The XML Document snippet is

                 // Parse the XML as a W3C document.
                 DocumentBuilder builder =
                     DocumentBuilderFactory.newInstance().newDocumentBuilder();
                 Document document = builder.parse(new
File("C:\\Users\\smirxj0\\Documents\\Java\\GPN.xml"));

I think if you want to use that API successfully with XPath and XSLT then you need to first ensure that you create a namespace aware DocumentBuilderFactory with i.e.
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
DocumentBuilder builder = dbf.newDocumentBuilder();
as http://download.oracle.com/javase/6/docs/api/javax/xml/parsers/DocumentBuilderFactory.html#setNamespaceAware%28boolean%29 says the default is false.
Nevertheless then, as long as you use XPath 1.0, you need to bind and use a prefix for to select any nodes in a namespace.


--

	Martin Honnen
	http://msmvps.com/blogs/martin_honnen/

Current Thread