Re: [xsl] Namespace problem

Subject: Re: [xsl] Namespace problem
From: Josh Canfield <joshcanfield@xxxxxxxxx>
Date: Fri, 10 Sep 2004 23:58:09 -0700
Hmm... Your code works in Saxon 8.0, but fails with Xalan 2.5.2.

It appears that the namespace axis is returning the namespace nodes
from the stylesheet instead of the context node.

Josh


On Fri, 10 Sep 2004 18:21:08 -0400, Marc Schneider <mschneider@xxxxxxxxx> wrote:
> 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