RE: [xsl] ***********Transformation of an XML document containing a default namespace ************

Subject: RE: [xsl] ***********Transformation of an XML document containing a default namespace ************
From: Jarno.Elovirta@xxxxxxxxx
Date: Wed, 24 Oct 2001 12:12:45 +0300
Hip hei!

> "element.xml" -->
> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
> <element xmlns="http://www.e-xmlmedia.com/test/";>
> <titi>titi</titi>
> <toto>toto</toto>
> <tata>tata</tata>
> </element>
> 
> in this one :
> "result.xml"-->
> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
> <ELEMENT xmlns="http://www.e-xmlmedia.com/test/";>
> <TITI>titi</TITI>
> <TOTO>toto</TOTO>
> <TATA>tata</TATA>
> </ELEMENT>
> 
> via this stylesheet :
> "element.xsl" -->
> <xsl:stylesheet version="1.0" xmlns="http://www.e-xmlmedia.com/test/";
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
>   <xsl:template match="/element">

You can't use the default namespace here, see
http://www.w3.org/TR/xslt#section-Expressions, second list, 5th item.

>     <ELEMENT xmlns="http://www.e-xmlmedia.com/test/";>

You don't need this, as you've already declared the namespace in the
xsl:stylesheet

>       <xsl:apply-templates />
>     </ELEMENT>
>   </xsl:template>
>   <xsl:template match="test:titi">

You haven't declared the test namespace, so this will not match your source.
If you declare xmlns:test="http://www.e-xmlmedia.com/test/"; somewhere in
scope for this element, it'll work

>     <TITI>
>       <xsl:value-of select="." />
>     </TITI>
>   </xsl:template>
>   <xsl:template match="test:toto">
>     <TOTO>
>       <xsl:value-of select="." />
>     </TOTO>
>   </xsl:template>
>   <xsl:template match="test:tata">
>     <TATA>
>       <xsl:value-of select="." />
>     </TATA>
>   </xsl:template>
> </xsl:stylesheet>

You should use, however, use just one template to do the uppercasing thingy,
instead of hard coding those like you have above.

Jarno

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


Current Thread