strip-attributes.xsl 712 B

123456789101112131415161718192021222324252627
  1. <?xml version="1.0"?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3. version="1.0">
  4. <xsl:output method="xml"/>
  5. <xsl:param name="attributes" select="''"/>
  6. <xsl:variable name="strip-attributes"
  7. select="concat(' ', normalize-space($attributes), ' ')"/>
  8. <xsl:template match="@*|text()|comment()|processing-instruction()">
  9. <xsl:copy/>
  10. </xsl:template>
  11. <xsl:template match="*">
  12. <xsl:copy>
  13. <xsl:for-each select="@*">
  14. <xsl:if test="not(contains($strip-attributes, concat(' ',name(.),' ')))">
  15. <xsl:copy-of select="."/>
  16. </xsl:if>
  17. </xsl:for-each>
  18. <xsl:apply-templates select="node()"/>
  19. </xsl:copy>
  20. </xsl:template>
  21. </xsl:stylesheet>