我想使用LateXML(版本 0.8.2)将Latex文件转换为XML 。由于 LateXML 没有(还)包ledmac的转换规则,我尝试自己编写它们,但到目前为止我失败了。
ledmac 的典型用例类似于
\edtext{some text}{\lemma{text}\Afootnote{some explanation}}
我想得到结果
<edtext>
some text
</edtext>
<lemma>
text
</lemma>
<Afootnote>
some explanation
</Afootnote>
文件 test1.tex:
\documentclass{article}
\usepackage{ledmac}
\begin{document}
\section{First Section}
Et et possimus non delectus et id dolor fugiat. Nemo aperiam in vitae atque.
Qui \edtext{pariatur ut fuga}{\lemma{fuga} \Afootnote{quaerat ratione dolorem ex dicta}}.
Sapiente hic est nobis eum. Rerum odit consectetur possimus et quaerat aut veritatis quae.
\end{document}
到目前为止,我的尝试是在与 test1.tex 相同的目录中编写一个文件 ledmac.sty.ltxml。它有以下内容:
package LaTeXML::Package::Pool;
use strict;
use LaTeXML::Package;
use warnings;
#RegisterNamespace('scr'=>"http://bla.com/scr");
DefConstructor('\edtext{}', "<edtext>#1</edtext>");
DefConstructor('\lemma{}', "<lemma>#1</lemma>");
DefConstructor('\Afootnote{}',"<Afootnote>#1</Afootnote>");
Tag('edtext', autoClose=>1);
Tag('lemma', autoClose=>1);
Tag('Afootnote', autoClose=>1);
1;
但是,这会导致表单的六个错误
Error:malformed:edtext <edtext> isn't allowed here
at /media/sf_Dokumente/Leibniz/LeibnizFiles/LateXML-Leibniz/test1.tex; line 6 col 3
Currently in XMLDocument[54493616]<ltx:document _box="LaTeXML::Core::Whatsit=HASH(0x..." _font="Font[serif,medium,upright,10,b..." xmlns="http://dlmf.nist.gov/LaTeXML">...<ltx:section _box="LaTeXML::Core::Whatsit=HASH(0x..." _font="Font[serif,medium,upright,10,b..." refnum="1" xml:id="S1" _ID_counter_p_="1">...<ltx:para _box="LaTeXML::Core::Box=ARRAY(0x344f300)" _font="Font[serif,medium,upright,10,b..." xml:id="S1.p1">...<ltx:p _box="LaTeXML::Core::Box=ARRAY(0x344f300)" _font="Font[serif,medium,upright,10,b...">...
In Core::Document[@0x34474b8] at /media/sf_Dokumente/Leibniz/LeibnizFiles/LateXML-Leibniz/test1.tex; line 6 col 3
<= Core::Definition::Constructor[\edtext... <= Whatsit[\edtext,Core::List[Box[p],Box... <= Core::Document[@0x34474b8] <= ...
Error:malformed:edtext Attempt to close </edtext>, which isn't open
at /media/sf_Dokumente/Leibniz/LeibnizFiles/LateXML-Leibniz/test1.tex; line 6 col 3
Currently in XMLDocument[54493616]<ltx:document _box="LaTeXML::Core::Whatsit=HASH(0x..." _font="Font[serif,medium,upright,10,b..." xmlns="http://dlmf.nist.gov/LaTeXML">...<ltx:section _box="LaTeXML::Core::Whatsit=HASH(0x..." _font="Font[serif,medium,upright,10,b..." refnum="1" xml:id="S1" _ID_counter_p_="1">...<ltx:para _box="LaTeXML::Core::Box=ARRAY(0x344f300)" _font="Font[serif,medium,upright,10,b..." xml:id="S1.p1">...<ltx:p _box="LaTeXML::Core::Box=ARRAY(0x344f300)" _font="Font[serif,medium,upright,10,b...">...
In Core::Document[@0x34474b8] at /media/sf_Dokumente/Leibniz/LeibnizFiles/LateXML-Leibniz/test1.tex; line 6 col 3
<= Core::Definition::Constructor[\edtext... <= Whatsit[\edtext,Core::List[Box[p],Box... <= Core::Document[@0x34474b8] <= ...
我尝试转换的每个命令都会出现这些错误。
如果具有 LateXML 专业知识的人能给我一个提示,如何从这里开始,我将非常感激!
编辑:在 LateXML 邮件列表中发布我的问题后,我被告知必须向 LateXML 提供一个 RelaxNG 方案。所以这似乎是错误消息的原因。