Re: [xsl] default namespace in match attribute of xsl:template

Subject: Re: [xsl] default namespace in match attribute of xsl:template
From: "Joe Fawcett" <joefawcett@xxxxxxxxxxx>
Date: Tue, 4 Feb 2003 07:58:10 -0000
----- Original Message ----- 
From: "Peter Paulus" <paulus@xxxxxxxx>
To: "XSL-List" <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Tuesday, February 04, 2003 7:36 AM
Subject: [xsl] default namespace in match attribute of xsl:template


> Hello XSL-list,
>
> We have an XML that looks like this:
>
> <soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope'>
> <soap:Boby>
> <reponse xmlns='someuri'>
>     <files>
>     <files>
> </response>
> </soap:Body>
> </soap:Envelope>
>
> the XSL looks like this:
>
> <xsl:template match='/'>
> <xsl:apply-templates select='Envelope'/>
> </xsl:template>
>
> <xsl:template match='soap:Envelope'>
> <xsl:message>soap:Envelope</xsl:message>
> <xsl:apply-templates select='Body'/>
> </xsl:template>
>
> <xsl:template match='soap:Body'>
> <xsl:message>soap:Body</xsl:message>
> <xsl:apply-templates select='response'/>
> </xsl:template>
>
> <xsl:template match='response'>
> <xsl:message>response</xsl:message>
> </xsl:template>
>
> The response element falls in the default namespace 'someuri'. How do you
> indicate this namespace in the match parameter of xsl:template. We tried
> match='response', match=':response', match='namespace::/response',
> match='#default:response'.
>
> By the way, we are using Xalan++ 1.4 as the processor. XML is parsed by
> Xerces++ 2.1.
>
> Is there a right way to do this?
>
> With kind regards,
> Peter Paulus
>
You must declare a dummy prefix in your stylesheet, e.g. xmlns:dp='someuri',
probably the same place you declare the sop one. Then use 'dp' as a prefix
in your XPath.

Joe

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


Current Thread