[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [edict-jmdict] DIfferent DTDs for JMdict and JMnedict
G'day,
>> Unless of course some xlst wizard has a converter already (^_^).
>
> I wrote a converter (in attachment).
> You can use it on a Unix platform with the following command :
>
> sed 's/ENTITY \([^ ]*\) ".*"/ENTITY \1 "\1"/' JMnedict.xml | xsltproc
> jmnedict_to_jmdict.xsl - > JMnedict2.xml
>
> the 'sed' command is used to protect entities in the xml file.
Thank you very much!
I finally got to try it out. The xsl file you made doesn't preserve
the <k_ele> and <r_ele> tags, so the resulting file isn't quite the
same as JMdict. However, it gave me enough of a start that I could
add them in. I attach my modified file, which preserves these, and
also hardcodes 'eng' into the language, just in case anyone else may
find it useful
--
Francis Bond <http://www2.nict.go.jp/x/x161/en/member/bond/>
NICT Language Infrastructure Group
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<JMnedict>
<xsl:apply-templates select="JMnedict/entry"/>
</JMnedict>
</xsl:template>
<xsl:template match="entry">
<entry>
<ent_seq><xsl:value-of select="position()*10" />
</ent_seq>
<xsl:apply-templates select="k_ele" />
<xsl:apply-templates select="r_ele" />
<xsl:apply-templates select="trans" />
</entry>
</xsl:template>
<xsl:template match="k_ele">
<k_ele>
<xsl:copy-of select="keb" />
<xsl:apply-templates select="ke_inf" />
<xsl:copy-of select="ke_pri" />
</k_ele>
</xsl:template>
<xsl:template match="ke_inf">
<ke_inf>
<xsl:text disable-output-escaping="yes">&</xsl:text>
<xsl:value-of select="." />;</ke_inf>
</xsl:template>
<xsl:template match="r_ele">
<r_ele>
<xsl:copy-of select="reb" />
<xsl:copy-of select="re_restr" />
<xsl:apply-templates select="re_inf" />
<xsl:copy-of select="re_pri" />
</r_ele>
</xsl:template>
<xsl:template match="re_inf">
<re_inf>
<xsl:text disable-output-escaping="yes">&</xsl:text>
<xsl:value-of select="." />;</re_inf>
</xsl:template>
<xsl:template match="trans">
<sense>
<xsl:apply-templates select="name_type" />
<xsl:apply-templates select="trans_det" />
</sense>
</xsl:template>
<xsl:template match="name_type">
<misc>
<xsl:text disable-output-escaping="yes">&</xsl:text>
<xsl:value-of select="." />;</misc>
</xsl:template>
<xsl:template match="trans_det">
<gloss xml:lang="eng">
<!-- <xsl:if test="@xml:lang!='eng'"> -->
<!-- <xsl:attribute name="xml:lang"> -->
<!-- <xsl:value-of select="@xml:lang" /> -->
<!-- </xsl:attribute> -->
<!-- </xsl:if> -->
<xsl:value-of select="." />
</gloss>
</xsl:template>
</xsl:stylesheet>