[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] stripping useless xmlns?
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|