Subject: stripping useless xmlns? From: "Mark D. Anderson" <mda@xxxxxxxxxxxxxx> Date: Fri, 3 Mar 2000 19:58:14 -0800 |
due to spotty support for exclude-result-prefixes and/or the fact that the spec seems to allow putting pretty much any namespace nodes it likes for xsl:element, my generated instances keep getting all these xmlns:some-unused-prefix="whatever" nodes all over the place. doesn't hurt anything, it just bothers me. so how hard would it be write a post-processing stylesheet that stripped out all xmlns nodes for prefixes that aren't used? i think it would go something like this, except this gets "unexpected node test" on the namespace match, and i'm sure there are other bugs too.... -mda <xsl:stylesheet version="1.0" xmlns:xsl='http://www.w3.org/1999/XSL/Transform'> <!-- collect up all prefixes used --> <xsl:variable name="used_prefixes" select="substring-before(name(//*), ':')"/> <!-- match all namespace nodes --> <xsl:template match="namespace::*" priority="99"> <xsl:if test="$used_prefixes = substring-after(name(.),':')"> <xsl:copy/> </xsl:if> </xsl:template> <!-- emit everything else --> <xsl:template match="/"><xsl:apply-templates/></xsl:template> <xsl:template match="node()|@*"> <xsl:copy> <xsl:apply-templates select="node()|@*"/> </xsl:copy> </xsl:template> </xsl:stylesheet> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
How to test for NULL?, Frick, Gary | Thread | XSLT: Spaces/Generating NMTOKENS/ID, Wolfgang May |
How to test for NULL?, Frick, Gary | Date | Re: Creating IMG tags using MSXML, Mark Volkmann |
Month |