|
Subject: Re: [xsl] Copying Namespace Nodes From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Sun, 27 Nov 2011 16:43:58 -0500 |
I have an element I want to copy and in the source it looks like this:
<a:elem xmlns:a="example.com/ns/a" xsi:type="nsc:foo" xmlns:nsc="example.com/ns/sensitive" xmlns:b="example.com/ns/b" xmlns:c="example.com/ns/c" ... xmlns:z="example.com/ns/z">info</a:elem>
What I want to achieve at the same time:
1) Keep the namespace declaration for the namespace sensitive content of the xsi:type attribute (with prefix nsc).
2) Get rid of all namespace declarations that are not needed here (prefix b, c, ..., z) and that clutter up my result document.
If I use copy-of with copy-namespaces set to 'no' the declaration for namespace sensitive content will be lost. If I say 'yes' everything stays the same. So is there a short way I have not seen yet or is the solution some verbose template? :)
<xsl:template match="*">
<xsl:copy copy-namespaces="no">
<xsl:for-each select="@xsi:type">
<xsl:copy-of
select="../namespace::*[name(.)=substring-before(current(),':')]"/>
<xsl:copy/>
</xsl:for-each>
</xsl:copy>
</xsl:template></xsl:stylesheet> T:\ftemp>
Thanks for help, Heiko
-- Contact us for world-wide XML consulting and instructor-led training Free 5-hour video lecture: XSLT/XPath 1.0 & 2.0 http://ude.my/t37DVX Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Google+ profile: https://plus.google.com/116832879756988317389/about Legal business disclaimers: http://www.CraneSoftwrights.com/legal
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] Copying Namespace Nodes, Dimitre Novatchev | Thread | [xsl] C# code and .NET libraries in, Faleńczyk Jakub |
| Re: [xsl] Copying Namespace Nodes, Dimitre Novatchev | Date | [xsl] C# code and .NET libraries in, Faleńczyk Jakub |
| Month |