需要针对工作更改file_properties并遵守演示文件here 我改变了它。但这个错误仍然存在。我对XML不太熟悉。任何人都可以帮助修复解析文件时发生的错误。
这是xml文件:
<?xml version="1.0" encoding="UTF-8"?>
<jwnl_properties language="en"/></jwnl_properties>
<version publisher="Princeton" number="3.0" language="en"/>
<dictionary class="net.didion.jwnl.dictionary.FileBackedDictionary">
<param name="dictionary_path" value="C:\Program Files\WordNet- 3.0\2.1\dict\"/>
</dictionary>
<param name="morphological_processor" value="net.didion.jwnl.dictionary.morph.DefaultMorphologicalProcessor">
<param name="operations">
<param value="net.didion.jwnl.dictionary.morph.LookupExceptionsOperation"/>
<param value="net.didion.jwnl.dictionary.morph.DetachSuffixesOperation">
<param name="noun" value="|s=|ses=s|xes=x|zes=z|ches=ch|shes=sh|men=man|ies=y|"/>
<param name="verb" value="|s=|ies=y|es=e|es=|ed=e|ed=|ing=e|ing=|"/>
<param name="adjective" value="|er=|est=|er=e|est=e|"/>
<param name="operations">
<param value="net.didion.jwnl.dictionary.morph.LookupIndexWordOperation"/>
<param value="net.didion.jwnl.dictionary.morph.LookupExceptionsOperation"/>
</param>
</param>
<param value="net.didion.jwnl.dictionary.morph.TokenizerOperation">
<param name="delimiters">
<param value=" "/>
<param value="-"/>
</param>
<param name="token_operations">
<param value="net.didion.jwnl.dictionary.morph.LookupIndexWordOperation"/>
<param value="net.didion.jwnl.dictionary.morph.LookupExceptionsOperation"/>
<param value="net.didion.jwnl.dictionary.morph.DetachSuffixesOperation">
<param name="noun" value="|s=|ses=s|xes=x|zes=z|ches=ch|shes=sh|men=man|ies=y|"/>
<param name="verb" value="|s=|ies=y|es=e|es=|ed=e|ed=|ing=e|ing=|"/>
<param name="adjective" value="|er=|est=|er=e|est=e|"/>
<param name="operations">
<param value="net.didion.jwnl.dictionary.morph.LookupIndexWordOperation"/>
<param value="net.didion.jwnl.dictionary.morph.LookupExceptionsOperation"/>
</param>
</param>
</param>
</param>
</param>
</param>
<param name="dictionary_element_factory" value="net.didion.jwnl.princeton.data.PrincetonWN17FileDictionaryElementFactory"/>
<param name="file_manager" value="net.didion.jwnl.dictionary.file_manager.FileManagerImpl">
<param name="file_type" value="net.didion.jwnl.princeton.file.PrincetonRandomAccessDictionaryFile"/>
<param name="dictionary_path" value="c:\program files\wordnet-3.0\2.0\dict"/>
</param>
</dictionary>
<resource class="PrincetonResource"/>
</jwnl_properties>
这是在运行获取单词感官的简单代码时发生的错误。程序中似乎没有错误。
[Fatal Error] :2:35: The markup in the document following the root element must be well-formed.
net.didion.jwnl.JWNLException: Error parsing the properties file
at net.didion.jwnl.JWNL.initialize(JWNL.java:117)
at Summarization.main(Summarization.java:46)
Caused by: org.xml.sax.SAXParseException; lineNumber: 2; columnNumber: 35; The markup in the document following the root element must be well-formed.
at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
at javax.xml.parsers.DocumentBuilder.parse(Unknown Source)
at net.didion.jwnl.JWNL.initialize(JWNL.java:115)
... 1 more
答案 0 :(得分:1)
似乎在您的XML中,<jwnl_properties>
标记已关闭三次,首先将其设置为空元素(结尾为/>
),然后再用{{1}再次关闭然后你在文件的末尾得到另一个</jwnl_properties>
。
如果您从
</jwnl_properties>
到
<jwnl_properties language="en"/></jwnl_properties>
问题应该在那里消失,但它不会完全消失,因为如果我没有弄错的话,你的<jwnl_properties language="en">
也会被关闭两次:第6行和第3行,你需要摆脱其中一个。如果你这样做,我认为你的XML会很好,但我可能会遗漏一些东西。