xsl-list
[Top] [All Lists]

Re: [xsl] Re: XPATH Issue

2010-12-01 04:48:18
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/

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>