接受 '<' 的 DTD 元素类型
DTD Element Type to accept '<'
我有一个 xml 文件,可能如下所示:
<unclassified>
WOOD FIRM FINED #30,000 OVER TEEN'S LOST ARM<
</unclassified>
.dtd 声明:
<!ELEMENT unclassified (#PCDATA)>
不幸的是,这似乎不起作用,因为我总是收到这样的错误:
[Fatal Error] arm1sub.sgml:14:46: The content of elements must consist of well-formed character data or markup.
org.xml.sax.SAXParseException; systemId: file:/home/sfalk/workspace/project/target/classes/meter_corpus/PA/annotated/courts/12.07.99/arm/arm1sub.sgml; lineNumber: 14; columnNumber: 46; The content of elements must consist of well-formed character data or markup.
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:257)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:348)
at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:205)
我怎样才能完成这项工作?我希望这在某种程度上是可行的,而无需操纵我的 .xml 文件 ..
您无法更改 DTD 中的任何内容来解决此问题。 必须更改 "XML" 文档本身。 (从技术上讲,您的文档甚至不是 XML。)
DTD(和 XSD)的权限是验证,但XML有效的先决条件是格式正确。 (事实上 ,文档成为XML的先决条件是它格式正确。)
阅读 Well-formed vs Valid XML 以获得对差异的详尽解释。对于您的特定问题,将 <
替换为 <
以使您的 XML 格式正确。
如果要使用包含对 xml 解析器无效字符的值,您可以使用 CDATA:http://www.w3schools.com/xml/xml_cdata.asp
<unclassified>
<![CDATA[WOOD FIRM FINED #30,000 OVER TEEN'S LOST ARM<]]>
</unclassified>
或者可能是你放的比你不想的低...
<unclassified>
WOOD FIRM FINED #30,000 OVER TEEN'S LOST ARM
</unclassified>
我有一个 xml 文件,可能如下所示:
<unclassified>
WOOD FIRM FINED #30,000 OVER TEEN'S LOST ARM<
</unclassified>
.dtd 声明:
<!ELEMENT unclassified (#PCDATA)>
不幸的是,这似乎不起作用,因为我总是收到这样的错误:
[Fatal Error] arm1sub.sgml:14:46: The content of elements must consist of well-formed character data or markup.
org.xml.sax.SAXParseException; systemId: file:/home/sfalk/workspace/project/target/classes/meter_corpus/PA/annotated/courts/12.07.99/arm/arm1sub.sgml; lineNumber: 14; columnNumber: 46; The content of elements must consist of well-formed character data or markup.
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:257)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:348)
at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:205)
我怎样才能完成这项工作?我希望这在某种程度上是可行的,而无需操纵我的 .xml 文件 ..
您无法更改 DTD 中的任何内容来解决此问题。 必须更改 "XML" 文档本身。 (从技术上讲,您的文档甚至不是 XML。)
DTD(和 XSD)的权限是验证,但XML有效的先决条件是格式正确。 (事实上 ,文档成为XML的先决条件是它格式正确。)
阅读 Well-formed vs Valid XML 以获得对差异的详尽解释。对于您的特定问题,将 <
替换为 <
以使您的 XML 格式正确。
如果要使用包含对 xml 解析器无效字符的值,您可以使用 CDATA:http://www.w3schools.com/xml/xml_cdata.asp
<unclassified>
<![CDATA[WOOD FIRM FINED #30,000 OVER TEEN'S LOST ARM<]]>
</unclassified>
或者可能是你放的比你不想的低...
<unclassified>
WOOD FIRM FINED #30,000 OVER TEEN'S LOST ARM
</unclassified>