xml: Delete xml:base and dedup models output. Signed-off-by: Tim 'mithro' Ansell <me@mith.ro>
diff --git a/xmlsort.xsl b/xmlsort.xsl index 6974f45..c15bcaf 100644 --- a/xmlsort.xsl +++ b/xmlsort.xsl
@@ -4,14 +4,15 @@ <xsl:output method="xml" indent="yes"/> <xsl:strip-space elements="*"/> + <xsl:template match="/"> <xsl:apply-templates/> </xsl:template> <xsl:template match="*"> <xsl:copy> - <!-- Sort the attributes by name. --> - <xsl:for-each select="@*"> + <!-- Sort the attributes by name and remove the xml:base attribute --> + <xsl:for-each select="@*[name()!='xml:base']"> <xsl:sort select="name( . )"/> <xsl:copy/> </xsl:for-each> @@ -19,6 +20,19 @@ </xsl:copy> </xsl:template> + <!-- Remove duplicate model nodes --> + <xsl:key name="model-by-name" match="model" use="@name" /> + <xsl:template match="models"> + <models> + <xsl:for-each select="model[count(. | key('model-by-name', @name)[1]) = 1]"> + <xsl:copy> + <xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute> + <xsl:apply-templates/> + </xsl:copy> + </xsl:for-each> + </models> + </xsl:template> + <xsl:template match="text()|comment()|processing-instruction()"> <xsl:copy/> </xsl:template>