| 1 |
<?xml version="1.0" encoding="UTF-8"?> |
| 2 |
<xsl:stylesheet |
| 3 |
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" |
| 4 |
xmlns="http://www.tei-c.org/ns/1.0" |
| 5 |
xmlns:xs="http://www.w3.org/2001/XMLSchema" |
| 6 |
xmlns:xd="http://www.pnp-software.com/XSLTdoc" exclude-result-prefixes="xs xd"> |
| 7 |
|
| 8 |
<xsl:output |
| 9 |
method="xml" |
| 10 |
version="1.0" |
| 11 |
encoding="UTF-8" |
| 12 |
indent="yes" |
| 13 |
doctype-system="freedict-P5.dtd" |
| 14 |
/> |
| 15 |
|
| 16 |
<xd:doc type="stylesheet"> |
| 17 |
<xd:short>Transformation file to convert the JMdict into TEI P5 Freedict file</xd:short> |
| 18 |
<xd:detail> |
| 19 |
<p>The Japanese Multilingual Dictionary (jmdict) is a free xml database by Jim Breens et al. |
| 20 |
(http://www.edrdg.org/jmdict/j_jmdict.html)</p> |
| 21 |
<p>This stylesheet aims to convert this multilingual resource into a bilingual Freedict file. |
| 22 |
JMdict and TEI P5 DTD are quite different, so the xml elements of JMdict have been turned into TEI elements. |
| 23 |
Following the pretty good JMdict DTD comments, here is how I tried to fit the TEI pattern |
| 24 |
(http://www.tei-c.org/release/doc/tei-p5-doc/fr/html/DI.html): <list> |
| 25 |
<item>ant => ref type="ant"</item> |
| 26 |
<item>dial => usg type="geo"</item> |
| 27 |
<item>field => usg type="dom"</item> |
| 28 |
<item>gloss => cit type="trans"/quote</item> |
| 29 |
<item>k_ele => form type="k_ele"</item> |
| 30 |
<item>keb => orth</item> |
| 31 |
<item>ke_inf => lbl type="ke_inf"</item> |
| 32 |
<item>ke_pri => usg type="pri"</item> |
| 33 |
<item>lsource => lang</item> |
| 34 |
<item>misc => note</item> |
| 35 |
<item>pos => note type="pos"</item> |
| 36 |
<item>pri => pri</item> |
| 37 |
<item>reb => orth</item> |
| 38 |
<item>r_ele => form type="r_ele</item> |
| 39 |
<item>re_inf => lbl typ="re_inf"</item> |
| 40 |
<item>re_nokanji => type="re_nokanji"</item> |
| 41 |
<item>re_pri => usg type="pri"</item> |
| 42 |
<item>re_restr => lbl type="re_restr"</item> |
| 43 |
<item>s_inf => note type="sense"</item> |
| 44 |
<item>stagk => note type="stagk"</item> |
| 45 |
<item>stagr => note type="stagr"</item> |
| 46 |
<item>xref => ref</item> |
| 47 |
</list> |
| 48 |
</p> |
| 49 |
</xd:detail> |
| 50 |
<xd:author>Denis ARNAUD</xd:author> |
| 51 |
<xd:copyright>the author(s), 2016; license: GPL v3 or any later version |
| 52 |
(http://www.gnu.org/licenses/gpl.html).</xd:copyright> |
| 53 |
</xd:doc> |
| 54 |
|
| 55 |
<!-- Here is the place to write the language of the dictionary you expect entry/sense/gloss@xml:lang--> |
| 56 |
<xsl:variable name="targetlang" select="'ger'"/> |
| 57 |
|
| 58 |
<!-- template JMdict --> |
| 59 |
<xsl:template match="JMdict"> |
| 60 |
<TEI xmlns="http://www.tei-c.org/ns/1.0" version="5.0"> |
| 61 |
<text><body><xsl:text>
</xsl:text> |
| 62 |
<xsl:for-each select="entry"> |
| 63 |
<xsl:if test="sense/gloss[@xml:lang = $targetlang]"> |
| 64 |
<entry xml:id='a{ent_seq}'> |
| 65 |
<xsl:apply-templates select="k_ele"/> |
| 66 |
<xsl:apply-templates select="r_ele"/> |
| 67 |
<xsl:apply-templates select="info"/> |
| 68 |
<xsl:apply-templates select="sense"/> |
| 69 |
</entry><xsl:text>
</xsl:text> |
| 70 |
</xsl:if> |
| 71 |
</xsl:for-each> |
| 72 |
</body> |
| 73 |
</text></TEI> |
| 74 |
</xsl:template> |
| 75 |
|
| 76 |
<!--template K_ELE --> |
| 77 |
<xsl:template match="k_ele"><form type="k_ele"><xsl:apply-templates/></form><xsl:text>
</xsl:text></xsl:template> |
| 78 |
|
| 79 |
<!--template R_ELE --> |
| 80 |
<xsl:template match="r_ele"><form type="r_ele"><xsl:apply-templates/></form></xsl:template> |
| 81 |
|
| 82 |
<!--template SENSE --> |
| 83 |
<xsl:template match="sense"> |
| 84 |
<xsl:if test="gloss[@xml:lang = $targetlang]"> |
| 85 |
<sense><xsl:apply-templates/></sense> |
| 86 |
</xsl:if> |
| 87 |
</xsl:template> |
| 88 |
|
| 89 |
<!--template POS --> |
| 90 |
<xsl:template match="pos"><note type="pos"><xsl:value-of select="."/></note></xsl:template> |
| 91 |
|
| 92 |
<!--template XREF --> |
| 93 |
<xsl:template match="xref"> |
| 94 |
<ref><xsl:value-of select="."/></ref> |
| 95 |
</xsl:template> |
| 96 |
|
| 97 |
<!--template ANT --> |
| 98 |
<xsl:template match="ant"> |
| 99 |
<ref type="ant"><xsl:value-of select="."/></ref> |
| 100 |
</xsl:template> |
| 101 |
|
| 102 |
<!--template GLOSS --> |
| 103 |
<xsl:template match="gloss"> |
| 104 |
<xsl:if test="@xml:lang = $targetlang"> |
| 105 |
<xsl:element name="cit"> |
| 106 |
<xsl:attribute name="xml:lang"> |
| 107 |
<xsl:value-of select="@xml:lang" /> |
| 108 |
</xsl:attribute> |
| 109 |
<xsl:attribute name="type"> |
| 110 |
<xsl:text>trans</xsl:text> |
| 111 |
</xsl:attribute> |
| 112 |
<quote><xsl:apply-templates/></quote> |
| 113 |
<xsl:if test="@g_gend"> |
| 114 |
<xsl:element name="gen"><xsl:value-of select="@g_gend" /></xsl:element> |
| 115 |
</xsl:if> |
| 116 |
|
| 117 |
</xsl:element> |
| 118 |
</xsl:if> |
| 119 |
</xsl:template> |
| 120 |
|
| 121 |
<!--template RE_NOKANJI --> |
| 122 |
<xsl:template match="re_nokanji"><lbl type="re_nokanji"><xsl:value-of select="."/></lbl></xsl:template> |
| 123 |
|
| 124 |
<!--template RE_PRI --> |
| 125 |
<xsl:template match="re_pri"><usg type="re_pri"><xsl:value-of select="."/></usg></xsl:template> |
| 126 |
|
| 127 |
<!--template RE_INF --> |
| 128 |
<xsl:template match="re_inf"><lbl type="re_inf"><xsl:value-of select="."/></lbl></xsl:template> |
| 129 |
|
| 130 |
<!--template RE_RESTR --> |
| 131 |
<xsl:template match="re_restr"><lbl type="re_restr"><xsl:value-of select="."/></lbl></xsl:template> |
| 132 |
|
| 133 |
<!--template KE_INF --> |
| 134 |
<xsl:template match="ke_inf"><lbl type="ke_inf"><xsl:value-of select="."/></lbl></xsl:template> |
| 135 |
<!--template KE_PRI --> |
| 136 |
<xsl:template match="ke_pri"><usg type="pri"><xsl:value-of select="."/></usg></xsl:template> |
| 137 |
<!--template KEB --> |
| 138 |
<xsl:template match="keb"><orth><xsl:value-of select="."/></orth></xsl:template> |
| 139 |
<!--template REB --> |
| 140 |
<xsl:template match="reb"><orth><xsl:value-of select="."/></orth></xsl:template> |
| 141 |
<!--template STAGK --> |
| 142 |
<xsl:template match="stagk"><note type="stagk"><xsl:value-of select="."/></note></xsl:template> |
| 143 |
<!--template STAGR --> |
| 144 |
<xsl:template match="stagr"><note type="stagr"><xsl:value-of select="."/></note></xsl:template> |
| 145 |
<!--template FIELD --> |
| 146 |
<xsl:template match="field"><usg type="dom"><xsl:value-of select="."/></usg></xsl:template> |
| 147 |
<!--template MISC --> |
| 148 |
<xsl:template match="misc"><note><xsl:value-of select="."/></note></xsl:template> |
| 149 |
<!--template DIAL --> |
| 150 |
<xsl:template match="dial"><usg type="geo"><xsl:value-of select="."/></usg></xsl:template> |
| 151 |
<!--template PRI --> |
| 152 |
<xsl:template match="pri"><pri><xsl:value-of select="."/></pri></xsl:template> |
| 153 |
<!--template S_INF --> |
| 154 |
<xsl:template match="s_inf"><note type="sense"><xsl:value-of select="."/></note></xsl:template> |
| 155 |
|
| 156 |
<!--template LSOURCE --> |
| 157 |
<xsl:template match="lsource"> |
| 158 |
<xsl:element name="lang"> |
| 159 |
<xsl:if test="@xml:lang"> |
| 160 |
<xsl:attribute name="xml:lang"><xsl:value-of select="@xml:lang" /></xsl:attribute> |
| 161 |
</xsl:if> |
| 162 |
<xsl:if test="@ls_type"> |
| 163 |
<xsl:attribute name="split"><xsl:value-of select="@ls_type" /></xsl:attribute> |
| 164 |
</xsl:if> |
| 165 |
<xsl:if test="@ls_wasei"> |
| 166 |
<xsl:attribute name="orig">ls_wasei</xsl:attribute> |
| 167 |
</xsl:if> |
| 168 |
<xsl:apply-templates/> |
| 169 |
</xsl:element> |
| 170 |
</xsl:template> |
| 171 |
|
| 172 |
<!--Divers caractères : — - ― • ◊ ● ○ ♦ --> |
| 173 |
</xsl:stylesheet> |