-
Notifications
You must be signed in to change notification settings - Fork 0
/
extract_l-t-pairs.xsl
77 lines (63 loc) · 2.82 KB
/
extract_l-t-pairs.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
<?xml version="1.0"?>
<!--+
| Usage: java -Xmx2048m net.sf.saxon.Transform -it:main THIS_FILE inDir=DIR
|
| - specify inDir and inFile in this script
| - output is in dir out_put
+-->
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xhtml="http://www.w3.org/1999/xhtml"
exclude-result-prefixes="xs xhtml">
<xsl:strip-space elements="*"/>
<xsl:output method="xml" name="dis"
encoding="UTF-8"
omit-xml-declaration="yes"
indent="no"/>
<xsl:output method="xml" name="dep"
encoding="UTF-8"
omit-xml-declaration="yes"
indent="no"/>
<xsl:output method="xml" name="xml"
encoding="UTF-8"
omit-xml-declaration="no"
indent="yes"/>
<xsl:output method="text" name="txt"
encoding="UTF-8"/>
<xsl:param name="inDir" select="'src_fad2merge/inc'"/>
<xsl:param name="inFile" select="'V_fad_smenob.xml'"/>
<xsl:param name="outDir" select="'out_put'"/>
<xsl:variable name="debug" select="false()"/>
<xsl:variable name="nl" select="'
'"/>
<xsl:variable name="tb" select="'	'"/>
<xsl:variable name="sr" select="'\*'"/>
<xsl:template match="/" name="main">
<xsl:for-each select="for $f in collection(concat($inDir,'?recurse=yes;select=',$inFile,';on-error=warning')) return $f">
<xsl:variable name="current_file" select="(tokenize(document-uri(.), '/'))[last()]"/>
<xsl:variable name="current_dir" select="substring-before(document-uri(.), $current_file)"/>
<xsl:variable name="current_location" select="concat($inDir, substring-after($current_dir, $inDir))"/>
<xsl:variable name="relative_path" select="substring-after($current_dir, $inDir)"/>
<xsl:variable name="file_name" select="substring-before($current_file, '.xml')"/>
<xsl:if test="true()">
<xsl:message terminate="no">
<xsl:value-of select="concat('-----------------------------------------', $nl)"/>
<xsl:value-of select="concat('location ', $current_location, $nl)"/>
<xsl:value-of select="concat('processing file ', $current_file, $nl)"/>
<xsl:value-of select="'-----------------------------------------'"/>
</xsl:message>
</xsl:if>
<xsl:result-document href="{$outDir}/{$file_name}.csv" format="txt">
<xsl:for-each select=".//e">
<xsl:variable name="cl" select="normalize-space(./lg/l)"/>
<xsl:for-each select=".//t">
<xsl:value-of select="concat($cl,$tb,normalize-space(.),$nl)"/>
</xsl:for-each>
</xsl:for-each>
</xsl:result-document>
<!--xsl:result-document href="{$outDir}/{$current_location}/{$file_name}.dis" format="dis">
<xsl:value-of disable-output-escaping="yes" select=".//disambiguation"/>
</xsl:result-document-->
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>