-
Notifications
You must be signed in to change notification settings - Fork 0
/
data-extract.xsl
80 lines (68 loc) · 3.18 KB
/
data-extract.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:math="http://www.w3.org/2005/xpath-functions/math"
exclude-result-prefixes="xs math"
xmlns:classical="http://wendellpiez.com/ns/classical"
version="3.0">
<xsl:function name="classical:gimme-td">
<xsl:param name="tr" as="element(tr)"/>
<xsl:param name="class" as="xs:string"/>
<xsl:sequence select="$tr/td[contains-token(@class,$class)]"/>
</xsl:function>
<xsl:template match="/">
<list>
<xsl:apply-templates select="/*/table/tbody/tr"/>
</list>
</xsl:template>
<xsl:template match="tr">
<item>
<xsl:apply-templates select="classical:gimme-td(.,'views-field-title')"/>
<xsl:apply-templates select="classical:gimme-td(.,'views-field-field-greek-definition')"/>
<xsl:apply-templates select="classical:gimme-td(.,'views-field-field-greek-part-of-speech')"/>
<xsl:apply-templates select="classical:gimme-td(.,'views-field-field-greek-semantic-group')"/>
<xsl:apply-templates select="classical:gimme-td(.,'views-field-title')"/>
<xsl:apply-templates select="classical:gimme-td(.,'views-field-field-greek-frequency-rank')"/>
</item>
</xsl:template>
<xsl:variable name="example">
<tr class="odd">
<td class="views-field views-field-title node-greek-vocabulary-lists" >
<div><a href="/greek-core/%CE%BA%CE%B1%CE%AF">καί</a></div> </td>
<td class="views-field views-field-field-greek-definition node-greek-vocabulary-lists" >
<div>and, also, even; καί...καί both...and</div> </td>
<td class="views-field views-field-field-greek-part-of-speech" >
conjunction: coordinating </td>
<td class="views-field views-field-field-greek-semantic-group" >
Conjunctions/Adverbs </td>
<td class="views-field views-field-field-greek-frequency-rank active" >
3 </td>
</tr>
</xsl:variable>
<xsl:template match="td[contains-token(@class,'views-field-title')]">
<ent>
<!-- more to do here inferring Greek values -->
<xsl:value-of select="normalize-space(.)"/>
</ent>
</xsl:template>
<xsl:template match="td[contains-token(@class,'views-field-field-greek-definitione')]">
<def>
<xsl:value-of select="normalize-space(.)"/>
</def>
</xsl:template>
<xsl:template match="td[contains-token(@class,'views-field-field-greek-part-of-speech')]">
<poS>
<xsl:value-of select="normalize-space(.)"/>
</poS>
</xsl:template>
<xsl:template match="td[contains-token(@class,'views-field-field-greek-semantic-group')]">
<gmr>
<xsl:value-of select="normalize-space(.)"/>
</gmr>
</xsl:template>
<xsl:template match="td[contains-token(@class,'views-field-field-greek-frequency-rank active')]">
<frq>
<xsl:value-of select="normalize-space(.)"/>
</frq>
</xsl:template>
</xsl:stylesheet>