Subject: RE: Answers to review questions in "Beginning XSLT": Chapter 8
From: Americo Albuquerque <aalbuquerque@xxxxxxxxxxxxxxxx>
Date: Wed, 19 Mar 2003 19:18:20 -0000
|
Hi Jeni and lars
> -----Mensagem original-----
> De: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] Em nome de
> Jeni Tennison
> Enviada: quarta-feira, 19 de Marco de 2003 18:54
> Para: Lars Huttar
> Cc: XSL-List (E-mail)
> Assunto: Re: Answers to review questions in "Beginning
> XSLT": Chapter 8
>
>
(...)
>
> > 4. Write a template that matches any element in the XHTML
> namespace and
> > generates a copy of that element in no namespace.
> >
> > Answer:
> >
> > <xsl:template match="xhtml:*">
> > <xsl:element name="{local-name()}" namespace="">
> > <xsl:apply-templates select="@* | node()" />
> > </xsl:element>
> > </xsl:template>
> >
(...)
>
> Note that you'll need to use an identity template in addition
> to the template above in order to copy the attributes and the
> non-XHTML elements that are nested within the XHTML element.
>
I know that the question was to create a template that matches any
element in the XHTML namespace,
but with your addition is not copying just the elements in the XHTML
namespace but every very node he finds
so, the new templates could be the normal identity template:
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
But this rases another question that has been bugging me for awaile, how
can I match ANY element of no namespace?
If I do <xsl:template match="*"> I'll match any node even those with a
namespace
The one I remember to solve this is a generic <xsl:template match="*">
and several <xsl:template match="x:*" xmlns:x="..."/> one for each
namespace definition that I want to skip
Is there any other way of doing this???
Thanks.
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
| Current Thread |
Jeni Tennison - Wed, 19 Mar 2003 13:50:25 -0500 (EST)
- Americo Albuquerque - Wed, 19 Mar 2003 14:15:43 -0500 (EST) <=
|
|