File: strip-attributes.xsl

package info (click to toggle)
docbook-xsl 1.78.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 51,544 kB
  • ctags: 821
  • sloc: xml: 156,217; sh: 840; ruby: 229; perl: 183; makefile: 83
file content (27 lines) | stat: -rw-r--r-- 712 bytes parent folder | download | duplicates (24)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                version="1.0">

<xsl:output method="xml"/>

<xsl:param name="attributes" select="''"/>

<xsl:variable name="strip-attributes"
              select="concat(' ', normalize-space($attributes), ' ')"/>

<xsl:template match="@*|text()|comment()|processing-instruction()">
  <xsl:copy/>
</xsl:template>

<xsl:template match="*">
  <xsl:copy>
    <xsl:for-each select="@*">
      <xsl:if test="not(contains($strip-attributes, concat(' ',name(.),' ')))">
        <xsl:copy-of select="."/>
      </xsl:if>
    </xsl:for-each>
    <xsl:apply-templates select="node()"/>
  </xsl:copy>
</xsl:template>

</xsl:stylesheet>