Re: [xsl] namespaces and copying trees

Subject: Re: [xsl] namespaces and copying trees
From: Oliver Becker <obecker@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 8 Aug 2001 18:37:52 +0200 (MEST)
Hi Joern,

> Suppose, I have an XHTML document with some additional metadata, seperated
> from the HTML by it's own namespace:
> 
> 
> <html xmlns="http://www.w3.org/1999/xhtml";
>       xmlns:foo="foonamespace">
> 
>   <foo:metadata>
>      <foo:author>Joe User</foo:author>
>      <foo:date>2001-08-07</foo:date>
>   </foo:metadata>
> 
>   <head>
>      ....
>   </head>
>   <body>
>      ...
>   </body>
> </html>
> 
> 
> Now I want (among other things) to generate an HTML version of this
> file, without the metadata. How can I exclude everything in the "foo"
> namespace?

<!-- copy all in the xhtml namespace -->
<xsl:template match="xhtml:*">
   <xsl:element name="{local-name()}">
      <xsl:copy-of select="@*" />
      <xsl:apply-templates />
   </xsl:element>
</xsl:template>

<!-- ignore all in the foo namespace -->
<!-- supposing there are no xhtml elements inside foo elements -->
<xsl:template match="foo:*" />

Cheers,
Oliver


/-------------------------------------------------------------------\
|  ob|do        Dipl.Inf. Oliver Becker                             |
|  --+--        E-Mail: obecker@xxxxxxxxxxxxxxxxxxxxxxx             |
|  op|qo        WWW:    http://www.informatik.hu-berlin.de/~obecker |
\-------------------------------------------------------------------/


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


Current Thread