|
Subject: Re: [xsl] Style sheet to perform namespace mapping from input to output From: "Andrew Welch" <andrew.j.welch@xxxxxxxxx> Date: Tue, 25 Mar 2008 10:40:12 +0000 |
It wasn't meant to be copied verbatim :) "old" refers to your N
namespace and "new" refers to N+1.
If your elements weren't prefixed then you'll need to invent a prefix
mapped to the existing namespace, such as "old", and then put all
result elements in the new namespace, using:
( xmlns:old="the N namespace" defined on the root element)
<xsl:template match="old:*">
<xsl:element name="{local-name(.)}" namespace="the N+1 namespace">
<xsl:copy-of select="@*"/>
<xsl:apply-templates/>
</xsl:element">
</xsl:template>
You don't need the namespace attribute on xsl:element if you've
already defined the default namespace on the root element, but
personally I like it there.
On 24/03/2008, Farrukh Najmi <farrukh@xxxxxxxxxxxxxxxxxxxxx> wrote:
> Thanks David. The resulting style sheet gives an error similar to:
>
> ERROR: 'Namespace for prefix 'new' has not been declared.'
>
> I am assuming that I need to somehow add the 'new' namespace declaration
> via 'xmlns:new ' attribute in result tree.
>
> This is probably a dumb question but how do I replace xmlns:old
> namespace declaration with xmlns:new namespace declaration?
>
> Thanks again for your kind help.
>
>
> David Carlisle wrote:
> > declare old and new prefixes on xsl:stylesheet, then something like
> >
> > <xsl:template match="old:*">
> > <xsl:element name="new:{local-name(.)">
> > <xsl:copy-of select="@*"/>
> > <xsl;apply-templates/>
> > </xsl:element">
> > </xsl:template>
> >
>
>
>
> --
> Regards,
> Farrukh Najmi
>
> Web: http://www.wellfleetsoftware.com
>
>
--
Andrew Welch
http://andrewjwelch.com
Kernow: http://kernowforsaxon.sf.net/
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] Style sheet to perform na, Mukul Gandhi | Thread | [xsl] XSL FO questions, Kamal |
| RE: [xsl] Increase Doc-available ti, Michael Kay | Date | Re: [xsl] how to match elements in , Mansour |
| Month |