Re: [xsl] Re: XPATH Issue

Subject: Re: [xsl] Re: XPATH Issue
From: Michael Kay <mike@xxxxxxxxxxxx>
Date: Wed, 01 Dec 2010 08:57:26 +0000
The XPath expression should select nothing in either case. The XML elements are in namespace, but your XPath expression is searching for elements in no namespace. (Google for "XSLT FAQ default namespace" for more info on this). I don't know why your XPath "worked" in one case - it should not have done.

Michael Kay

On 01/12/2010 02:25, Rajesh Jain wrote:
The XML Document snippet is

<?xml version="1.0" encoding="UTF-8" standalone="no"?><s:Envelope

----- Original Message ---- From: Rajesh Jain<rjain15@xxxxxxxxx> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Sent: Tue, November 30, 2010 9:19:44 PM Subject: XPATH Issue


I have a very strange problem and I have spend a whole day trying to figure what

is wrong.

I have a XPATH expression, and if I evaluate from a XML File on disk it works.

If I evaluate from a DOM Object from a HTTP Source, it doesn't  work. Both the
documents are exactly same.

XML Document SUCCESS</RetrieveResult></RetrieveResponse></s:Body></s:Envelope>

// Document from File

                 // Parse the XML as a W3C document.
                 DocumentBuilder builder =
                 Document document = builder.parse(new

// Alternatively Document from HTTP

               InputStream isr = httpConn.getInputStream();
               Document document = builder.parse(isr);

// If I print this Document, I have the same output as the XML file

// XPATH Expression

                 XPath xpath = XPathFactory.newInstance().newXPath();
                 expression = "//RetrieveResponse/RetrieveResult/StatusType";
                 String statusString = (String)
                     xpath.evaluate(expression, document,

System.out.println("String is: " + statusString);

Please let me know where am I going wrong?

Is it a XPATH issue?


Current Thread