|
Subject: Re: [xsl] removing a specific namespace declaration From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Sat, 07 Nov 2009 20:29:07 -0500 |
I'm trying to remove what I believe to be an unused namespace declaration from the output.
eg:
Source:
<?xml version="1.0" encoding="ISO-8859-1"?>
<svg viewBox="0 0 360 792" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:foo="http://www.foo.com">
<!-- svg content -->
</svg>
Becomes: <?xml version="1.0" encoding="ISO-8859-1"?> <svg viewBox="0 0 360 792" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <!-- svg content --> </svg>
ie, the foo namespace is removed in the transformation.
I've seen many posts on removing all namespaces, but can't figure out how to remove a specific namespace.
<xsl:template match="*">
<xsl:element name="{name(.)}" namespace="{namespace-uri(.)}">
<xsl:copy-of select="namespace::*[name(.)!='foo']"/>
<xsl:copy-of select="@*"/>
<xsl:apply-templates/>
</xsl:element>
</xsl:template><xsl:template match="comment()|processing-instruction()|text()"> <xsl:copy/> </xsl:template>
</xsl:stylesheet> T:\ftemp>
-- Upcoming: hands-on XSLT, XQuery and XSL-FO Washington DC Nov 2009 Interested in other classes? http://www.CraneSoftwrights.com/s/i/ Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video Video lesson: http://www.youtube.com/watch?v=PrNjJCh7Ppg&fmt=18 Video overview: http://www.youtube.com/watch?v=VTiodiij6gE&fmt=18 G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Male Cancer Awareness Nov'07 http://www.CraneSoftwrights.com/s/bc Legal business disclaimers: http://www.CraneSoftwrights.com/legal
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| [xsl] removing a specific namespace, tom a | Thread | [xsl] Re: removing a specific names, tom a |
| [xsl] removing a specific namespace, tom a | Date | [xsl] Re: removing a specific names, tom a |
| Month |