-
Notifications
You must be signed in to change notification settings - Fork 1
/
listatts2.xsl
60 lines (51 loc) · 1.7 KB
/
listatts2.xsl
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
49
50
51
52
53
54
55
56
57
58
59
60
<xsl:stylesheet
xmlns:xsl = 'http://www.w3.org/1999/XSL/Transform'
version = '1.0' >
<xsl:output method='text'/>
<xsl:key name='elements' match='*' use='name()'/>
<xsl:key
name='attributes'
match='@*'
use='concat(concat(name(parent::*),":::"),name())'
/>
<xsl:key name='allSameAttributes' match='@*' use='name(parent::*)'/>
<xsl:template match='/'>
<xsl:apply-templates select='//*'>
<xsl:sort select='name()'/>
</xsl:apply-templates>
</xsl:template>
<xsl:template match = '*' >
<xsl:if test='generate-id() = generate-id(key("elements",name()))'>
<xsl:text>
</xsl:text>
<xsl:value-of select='name()'/>
<xsl:apply-templates select='key("allSameAttributes",name())'>
<xsl:sort select='name()'/>
</xsl:apply-templates>
</xsl:if>
</xsl:template>
<xsl:template match='@*'>
<xsl:if test='generate-id() =
generate-id(key("attributes",concat(name(parent::*),":::",name())))'>
<xsl:text>
 </xsl:text>
<xsl:value-of select='name()'/>
<xsl:text>: </xsl:text>
<xsl:apply-templates
select='key("attributes",concat(name(parent::*),":::",name()))'
mode='values'>
<xsl:sort/>
</xsl:apply-templates>
</xsl:if>
</xsl:template>
<xsl:template match='@*' mode='values'>
<xsl:variable name='sameValues'
select='key("attributes",concat(name(parent::*),":::",name()))[.
= current()]' />
<xsl:if test='generate-id() = generate-id($sameValues)'>
<xsl:value-of select='.'/>
<xsl:text>(</xsl:text>
<xsl:value-of select='count($sameValues)'/>
<xsl:text>) </xsl:text>
</xsl:if>
</xsl:template>
<xsl:template match='text()'/>
</xsl:stylesheet>