~psmay/+junk/win-vim-xsl-kit

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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?xml version="1.0" encoding="UTF-8"?>
<!-- Use lower-case-names.xsl first -->
<xsl:transform
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
	>
	<xsl:output method="xml" version="1.0" encoding="utf-8" omit-xml-declaration="yes"/>
	
	<!-- If it's not an HTML element, just copy it -->
	<xsl:template match="@*|node()">
		<xsl:copy>
			<xsl:apply-templates select="@*|node()"/>
		</xsl:copy>
	</xsl:template>

	<!-- If it *is* an HTML element, scrutinize. -->
	<xsl:template match="
		a | abbr | acronym | address | applet | area | b | base | basefont |
		bdo | big | blockquote | body | br | button | caption | center | cite |
		code | col | colgroup | dd | del | dfn | dir | div | dl | dt | em |
		fieldset | font | form | frame | frameset | h1 | h2 | h3 | h4 | h5 |
		h6 | head | hr | html | i | iframe | img | input | ins | isindex |
		kbd | label | legend | li | link | map | menu | meta | noframes |
		noscript | object | ol | optgroup | option | p | param | pre | q | s |
		samp | script | select | small | span | strike | strong | style | sub |
		sup | table | tbody | td | textarea | tfoot | th | thead | title | tr |
		tt | u | ul | var
	">
		<xsl:copy>
			<xsl:apply-templates select="@*" mode="html-attributes"/>
			<xsl:apply-templates select="node()"/>
		</xsl:copy>
	</xsl:template>
	
	<xsl:template mode="html-attributes" match="@*">
		<xsl:apply-templates select="self::node()"/>
	</xsl:template>
	<!-- What to remove -->
	<xsl:template mode="html-attributes" match="
		@style | @bgcolor | @selected | @align | @border | @height | @width |
		@topmargin | @bottommargin | @leftmargin | @rightmargin |
		@cellspacing | @cellpadding | @background |
		@colspan[number(.)=1] |
		@rowspan[number(.)=1] |
		html/@version[number(.)=6] |
		@required[. = 'false'] |
		@align | @halign | @valign
	"/>
</xsl:transform>