[xsl] Pulling out my hair: XSLT and XML with namespace

Subject: [xsl] Pulling out my hair: XSLT and XML with namespace
From: "Ken Shino" <kenji@xxxxxxxxxxx>
Date: Tue, 6 May 2003 22:14:39 -0400
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"
        <service name="TemperatureService">
                <documentation>Returns current temperature in a given U.S.
zipcode  </documentation>
                <port name="TemperaturePort"

and the following XSLT snippet:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
<xsl:output method="html"/>
<xsl:template match="/">

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

I get the following result:


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.


-- Ken

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

Current Thread