-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathextract_clustering_data.xsl
More file actions
47 lines (38 loc) · 1.45 KB
/
extract_clustering_data.xsl
File metadata and controls
47 lines (38 loc) · 1.45 KB
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
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:transform
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
version="3.0">
<xsl:output method="text"/>
<xsl:variable name="year-list" as="xs:string *">
<xsl:for-each select="//tr">
<xsl:value-of select="substring-before(substring-after(td[1],'gv/'),'_')" />
</xsl:for-each>
</xsl:variable>
<xsl:variable name="all_refs" as="xs:string *">
<xsl:for-each select="//tr">
<xsl:value-of select="td[2]"/>
</xsl:for-each>
</xsl:variable>
<xsl:template match="/">
<xsl:variable name="dom" select="."/>
<xsl:for-each select="distinct-values($year-list)">
<xsl:sort data-type="number" select="."/>
<xsl:variable name="year" select="."/>
"<xsl:value-of select="."/>"<xsl:text> </xsl:text>
<xsl:variable name="rows" as="node() *">
<xsl:for-each select="$dom//tr[contains(td[1],$year)]">
<xsl:copy-of select="."/>
</xsl:for-each>
</xsl:variable>
<xsl:for-each select="distinct-values($all_refs)">
<xsl:variable name="ref" select="."/>
<xsl:variable name="counter" as="xs:integer *">
<xsl:for-each select="$rows//td[.=$ref]">1</xsl:for-each>
</xsl:variable>
<xsl:value-of select="sum($counter)"/><xsl:text> </xsl:text>
</xsl:for-each><xsl:text>
</xsl:text>
</xsl:for-each>
</xsl:template>
</xsl:transform>