This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: namespaces and copying trees


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@informatik.hu-berlin.de             |
|  op|qo        WWW:    http://www.informatik.hu-berlin.de/~obecker |
\-------------------------------------------------------------------/


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]