RE: [xsl] Namespace problem

Subject: RE: [xsl] Namespace problem
From: "Xia Li" <xli@xxxxxxxxxxxxx>
Date: Fri, 10 Sep 2004 17:27:50 -0700
Hi,
	It seems your code has no problem. The problem lies in the XSLT processor
you are using.

The namespace axis of the context node <operation> contains three namespace
nodes,
"http://schemas.xmlsoap.org/wsdl/";,
"http://www.xmethods.net/sd/TemperatureService.wsdl";, and
"http://www.w3.org/XML/1998/namespace";

Only namespace "http://www.xmethods.net/sd/TemperatureService.wsdl";
satisfies the predicate
[starts-with(name(),substring-before(parent::node()/@name,':'))].

So the
<xsl:value-of
select="namespace::*[starts-with(name(),substring-before(parent::node()/@nam
e,':'))]"/>
should return the namespace
"http://www.xmethods.net/sd/TemperatureService.wsdl"; rather than the
namespace "http://www.w3.org/XML/1998/namespace"; whose name is "xml".

	I suggest you try other XSLT processors(other than Xalan) to see if you can
get the desired result.

	Lisa


-----Original Message-----
From: Marc Schneider [mailto:mschneider@xxxxxxxxx]
Sent: Friday, September 10, 2004 3:21 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: [xsl] Namespace problem


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()/@nam
e,':'))]"/>
							</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