xsl-list
[Top] [All Lists]

Pulling out my hair: XSLT and XML with namespace

2003-05-06 19:14:39
Hello everyone.

I hope I'm not repeating a post of another message in this list, but I've
looked everywhere on the net with both Google and Altavista, and cannot
figure out what is wrong with my XPath/XSLT parsing.

Given the following XML file:

<?xml version="1.0"?>
<definitions name="TemperatureService"
targetNamespace="http://www.xmethods.net/sd/TemperatureService.wsdl";
xmlns:tns="http://www.xmethods.net/sd/TemperatureService.wsdl";
xmlns:xsd="http://www.w3.org/1999/XMLSchema";
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/";
xmlns="http://schemas.xmlsoap.org/wsdl/";>
        <service name="TemperatureService">
                <documentation>Returns current temperature in a given U.S.
zipcode  </documentation>
                <port name="TemperaturePort"
binding="tns:TemperatureBinding">
                        <soap:address
location="http://services.xmethods.net:80/soap/servlet/rpcrouter"/>
                </port>
        </service>
</definitions>

and the following XSLT snippet:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:output method="html"/>
<xsl:template match="/">

<xsl:for-each select="definitions/service/port">
POST Path = <xsl:value-of select="soap:address/@location"/>
</xsl:for-each>

I get the following result:

(BLANK DOCUMENT)

Now, if I remove the 'xmlns="http://schemas.xmlsoap.org/wsdl/";' from the
XML, I get the following error:

    Prefix must resolve to a namespace: soap

So, if I change the "POST Path" line to say:

<xsl:value-of select="name(*)"/>

I get the following result:

    POST Path = soap:address

Yet, I am unable to specify that "soap:address" in my XPath to get the XSL
value of the data.

I'm literally pulling my hair out here.  I also want to know why NOTHING is
rendered when a root-wide namespace is specified in the XML.  Short of
writing my own parser, can someone please shed some light and tell me what
I'm doing wrong, and possibly show me an example of what is required to get
the desired result?  This is a SOAP WSDL file that I'm parsing for an
experimental project of my own, and I cannot figure this out.  I've looked
all over w3schools.com and still cannot get things figured out.

However, this works:

<xsl:value-of select="*/@location"/>

Which returns the correct result.  If I'm going to walk the path, this is
not going to be a valid solution.

Help!

Thanks.
-- Ken


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



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