Dear Andrew,
Thank you for your help, that is pretty much what I
would like to do. Just I have a basic question, how do
I map nsprefix ? I understood that this isn't a
variable, else it would be $nsprefix I guess.
Thanks
Regards
--- Andrew Welch <andrew(_dot_)j(_dot_)welch(_at_)gmail(_dot_)com> wrote:
On 21/11/2007, ML mail <mlnospam(_at_)yahoo(_dot_)com> wrote:
Dear list,
I would like to modify the name of my elements of
a
certain node to
make it use a new namespace so for that I somehow
need an iteration
process which goes through a specific node and
adds a
prefix to all of my
elements. Let's say I have the following:
<start attr="myattr">
<two>
<three>3</three>
<four>4</four>
</two>
</start>
I need to make it look like this after processing:
<nsprefix:start attr="myattr">
<nsprefix:two>
<nsprefix:three>3</nsprefix:three>
<nsprefix:four>4</nsprefix:four>
</nsprefix:two>
</nsprefix:start>
I started creating a template for that and
defining
all the nodes under
the start node but this sounds quite stupid
because
if there are many
different possibilites it makes a whole lot of
checks
to build. So I
was thinking it's much easier to just detect the
start element and then
iterate through all of it's child elements (in my
case: two, three four)
and add the prefix to these elements.
Unfortunately I
didn't manage to
do that. Can someone provide me help on how to
acheive that ?
Use the standard identity template with a specific
template to put
<start> and all of it's descendants into the
namespace:
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates
select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template
match="*[ancestor-or-self::start]">
<xsl:element name="nsprefix:{local-name()}">
<xsl:copy-of select="@*"/>
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
...make sure "nsprefix" is mapped somewhere.
cheers
--
Andrew Welch
http://andrewjwelch.com
Kernow: http://kernowforsaxon.sf.net/
--~------------------------------------------------------------------
XSL-List info and archive:
http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to:
http://lists.mulberrytech.com/xsl-list/
or e-mail:
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
____________________________________________________________________________________
Get easy, one-click access to your favorites.
Make Yahoo! your homepage.
http://www.yahoo.com/r/hs
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--