Xalan 2.7.0, JDK 1.4.2, WebLogic 8.1.4.

I'm trying to write xpath validation expressions for the following SOAP
message (slightly edited).  I could use some help understanding what I'm
seeing here, and how to make this work well.

----------------
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
                  xmlns:xsd="http://www.w3.org/2001/XMLSchema";
 
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/";>
 <soapenv:Body>
  <ReportResponse xmlns="http://...";>
   <ReportUrl>https://.../Test%20Portfolio.csv</ReportUrl>
   <Warnings/><Errors/>
  </ReportResponse>
 </soapenv:Body>
</soapenv:Envelope>
----------------

I'm processing this with code like this:

----------------
  SOAPPart    soapPart    = message.getSOAPPart();
  Source      xmlSource   = soapPart.getContent();
  TransformerFactory  transformerFactory  =
                TransformerFactory.newInstance();
  Transformer transformer = transformerFactory.newTransformer();
  DOMResult   domResult   = new DOMResult();
  transformer.transform(xmlSource, domResult);
  Node    node    = domResult.getNode();
  System.out.println("node[" + node + "]");

  Element documentElement = ((Document) node).getDocumentElement();

  for (Iterator iter = xpathStrs.iterator(); iter.hasNext(); )
  {
    String  xpathStr    = (String) iter.next();
    XObject object = XPathAPI.eval(documentElement, xpathStr, node);
    System.out.println("object[" + object + "]");
  }
----------------

When I evaluate this expression: /soapenv:Envelope

It fails, saying that "soapenv" must resolve to a namespace.

I then tried instead: /env:Envelope

This works (the Xobject is not null).  I'm not sure why this works, and
the other one does not.

Next, I tried the expression: /env:Envelope/env:Body/ReportResponse

This fails.  I'm guessing it has something to do with the fact that I'm
trying to use the default namespace, but I think referencing no prefix
in Xpath means to use "no namespace", which isn't the same thing.

What's going on here, and what do I need to do differently?

Reply via email to