我有几个包含 TEI 中历史字母的单个 XML 文件。现在我想将它们合并到一个以日期为标准的文件中。
A1.xml
<?xml version="1.0" encoding="UTF-8"?>
<TEI xml:id="1">
<teiHeader>
<title>Letter 1</title>
<date when="19990202" n="0"></date>
</teiHeader>
<text>
<p>Content of letter 1</p>
</text>
</TEI>
和第二个文件 A2.xml:
<?xml version="1.0" encoding="UTF-8"?>
<TEI xml:id="2">
<teiHeader>
<title>Letter 1</title>
<date when="20010202" n="0"></date>
</teiHeader>
<text>
<p>Content of letter 2</p>
</text>
</TEI>
第三个,A3.xml:
<?xml version="1.0" encoding="UTF-8"?>
<TEI xml:id="3">
<teiHeader>
<title>Letter 3</title>
<date when="18880101" n="0"></date>
</teiHeader>
<text>
<p>Content of letter 3</p>
</text>
</TEI>
这些文件以连续的文件名“A001.xml”到“A999.xml”命名,但不是按所需顺序命名的。所以我更喜欢的输出是单个文件 letters.xml:
<?xml version="1.0" encoding="UTF-8"?>
<CORRESPONDENCE>
<TEI xml:id="3">
<teiHeader>
<title>Letter 3</title>
<date when="18880101" n="0"></date>
</teiHeader>
<text>
<p>Content of letter 3</p>
</text>
</TEI>
<TEI xml:id="1">
<teiHeader>
<title>Letter 1</title>
<date when="19990202" n="0"></date>
</teiHeader>
<text>
<p>Content of letter 1</p>
</text>
</TEI>
<TEI xml:id="2">
<teiHeader>
<title>Letter 1</title>
<date when="20010202" n="0"></date>
</teiHeader>
<text>
<p>Content of letter 2</p>
</text>
</TEI>
</CORRESPONDENCE>
尽管我找到了将多个 XML 文件合并为一个的方法,但我无法使用排序标准让它工作。这甚至可能吗?