[xsl] Namespace problem

Subject: [xsl] Namespace problem
From: Marc Schneider <mschneider@xxxxxxxxx>
Date: Fri, 10 Sep 2004 18:21:08 -0400
I'm working on a stylesheet to process an XML (WSDL) file where some of the attribute are QNames. I need to separate the QName in the namespace URI and the local name. I'm having trouble resolving the correct namespace URI.

I have the following template which is producing the wrong value for the attribute portType_nspc.

<xsl:template match="wsdl:operation">
<xsl:element name="operation">
<xsl:choose>
<xsl:when test="contains(parent::node()/@name,':')">
<xsl:attribute name="portType_nspc">
<xsl:choose>
<xsl:when test="contains(parent::node()/@name,':')">
<xsl:value-of select="namespace::*[starts-with(name(),substring-before(parent::node()/@name,':'))]"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="ancestor::*[last()]/@targetNamespace"/>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="portType_nspc"/>
</xsl:otherwise>
</xsl:choose>
</xsl:element>
</xsl:template>


when run on the following document

<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/"; name="TemperatureService"
	targetNamespace="http://www.xmethods.net/sd/TemperatureService.wsdl";
	xmlns:tns="http://www.xmethods.net/sd/TemperatureService.wsdl";>
	<portType name="tns:TemperaturePortType">
		<operation name="tns:getTemp">
			<input message="tns:getTempRequest"/>
			<output message="tns:getTempResponse"/>
		</operation>
	</portType>
</definitions>

I'm getting

<operation portType_nspc="http://www.w3.org/XML/1998/namespace"/>

when I expect to get

<operation portType_nspc="http://www.xmethods.net/sd/TemperatureService.wsdl"/>

I've tried it with several different versions of Xalan (both C++ and Java versions) and get the same results.

Any ideas as to what is going wrong?

Marc

Current Thread