有什么方法可以用给定文本文件中的文本描述替换给定XML文件<dewey>字段中的DDC编号?

时间:2019-04-10 04:18:16

标签: java xml dom xpath mapping

我正在处理XML文件,在该XML文件中,我必须用下面的文本文件中的文本描述替换下面的XML文件字段中的数字杜威十进制分类代码。我们应该怎么做? 请帮忙。

该xml文件为:

<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- version 1.0 / 2009-11-11T02:23:47+01:00 -->
<!DOCTYPE book SYSTEM "books.dtd">
<book>
<isbn>0006498000</isbn>
<title>Winston's War</title>
<listprice>$10.11</listprice>
<publisher>HarperCollins Publishers Ltd</publisher>
<edition/>
<dewey>813</dewey>
</book>

可用于映射的文本文件位于https://www.oclc.org/en/dewey/resources/summaries.html#dev。下面给出了适用于上述XML文件的摘录:

800 Literature (Belles-lettres) and rhetoric
801 Philosophy and theory
802 Miscellany
803 Dictionaries & encyclopedias
804 [Unassigned]
805 Serial publications
806 Organizations and management
807 Education, research, related topics
808 Rhetoric & collections of literature
809 History, description & criticism
810 American literature in English
811 American poetry in English
812 American drama in English
813 American fiction in English
814 American essays in English
815 American speeches in English
816 American letters in English
817 American humor and satire in English
818 American miscellaneous writings
819 (Optional number)
820 English & Old English literatures
821 English poetry
822 English drama
823 English fiction

我希望输出为:

<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- version 1.0 / 2009-11-11T02:23:47+01:00 -->
<!DOCTYPE book SYSTEM "books.dtd">
<book>
<isbn>0006498000</isbn>
<title>Winston's War</title>
<listprice>$10.11</listprice>
<publisher>HarperCollins Publishers Ltd</publisher>
<edition/>
<dewey>American fiction in English</dewey>
</book>

谢谢。

0 个答案:

没有答案