I posted this question on the Xalan Java User List, but didn't get any
responses.  I'm hoping someone here can help me.


Both Xalan 2.2.D11 and 2.2.D13 fail.

I'm trying to select a node from a DOM using the XPathAPI.selectSingleNode()
call.  Everything works fine unless the XML has namespaces and I try to
reference them in my XPath expression.

For instance, take the following sample SOAP fault:

<SOAP-ENV:Envelope
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/";
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/";>
    <SOAP-ENV:Body>
        <SOAP-ENV:Fault>
            <faultcode>Client</faultcode>
            <faultstring>The SOAP message request did not contain the
appropriate security token credentials required to execute a request on the
server.</faultstring>
            <faultactor>Server</faultactor>
            <detail>
                <e:yourfaultdetails xmlns:e="mynamespace">
                    <message>The SOAP request did not contain a valid
security token.</message>
                    <errorcode>1000000</errorcode>
                </e:yourfaultdetails>
            </detail>
        </SOAP-ENV:Fault>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>


In my Java code, when I call

XPathAPI.selectSingleNode(doc,
"/SOAP-ENV:Envelope/SOAP-ENV:Body/SOAP-ENV:Fault/faultcode");

It fails saying javax.xml.transform.TransformerException: Prefix must
resolve to a namespace: SOAP-ENV


So, I figure I need to use the selectSingleNode() API where I pass in a
namespace node as the third parameter.  BUT, FOR THE LOVE OF XALAN, WHAT IS
A NAMESPACE NODE?!  I've tried passing it the document root of the above
SOAP fault.  I've tried creating a new document with a single element with
the SOAP-ENV namespace declared and passing that element as the third
parameter.  I've even declared the namespace in an element and passed the
attribute that contains the "xmlns:SOAP-ENV" name.

Please, someone, tell me what I'm doing wrong.

Thanks,
Scott

Reply via email to