XML-DTD-外部子集中的内容错误 [英] XML - DTD - Content error in the external subset
本文介绍了XML-DTD-外部子集中的内容错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试验证以下.dtd代码:
I'm trying to validate following .dtd code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE PERSON [
<!ELEMENT lista_plac_dokument (autor, informacje_o_dokumencie, zatrudnieni)>
<!ELEMENT autor (autor_imię, autor_nazwisko, autor_adres+)>
<!ELEMENT autor_imię (#PCDATA)>
<!ELEMENT autor_nazwisko (#PCDATA)>
<!ELEMENT autor_adres (ulica,(kod_pocztowy|zip),miasto,kraj)>
<!ELEMENT ulica (#PCDATA)>
<!ELEMENT kod_pocztowy (#PCDATA)>
<!ELEMENT miasto (#PCDATA)>
<!ELEMENT kraj (#PCDATA)>
<!ELEMENT informacje_o_dokumencie (kategoria_dokumentu)>
<!ELEMENT kategoria_dokumentu (#PCDATA)>
<!ELEMENT zatrudnieni (osoba*)>
<!ELEMENT osoba (imię, nazwisko, stanowisko, data_zatrudnienia, wynagrodzenie_brutto_12_miesięcy, informacje_osobiste+)>
<!ATTLIST osoba osoba_id ID #REQUIRED>
<!ELEMENT imię (#PCDATA)>
<!ELEMENT nazwisko (#PCDATA)>
<!ELEMENT stanowisko (#PCDATA)>
<!ELEMENT data_zatrudnienia (#PCDATA)>
<!ELEMENT wynagrodzenie_brutto_12_miesięcy (#PCDATA)>
<!ELEMENT informacje_osobiste (wiek?)>
<!ELEMENT wiek (#PCDATA)>
]>
但是每次我尝试使用以下命令检查其语法时:
but each time I'm trying to check the syntax of it with the usage of following command:
xmllint --loaddtd person.dtd person.xml --noout
我确实收到以下错误:
person.dtd:29: parser error : Start tag expected, '<' not found
]>
^
person.dtd:2: parser error : Content error in the external subset
<!DOCTYPE PERSON [
^
person.dtd:2: parser error : Content error in the external subset
<!DOCTYPE PERSON [
^
推荐答案
.dtd
文件(外部声明子集)必须仅包含实际的标记声明(<!ELEMENT ...>
和其他).<!DOCTYPE ... [
和]>
仅在 .xml
文件(实例文档)中使用.
The .dtd
file (the external declaration subset) must only contain actual markup declarations (<!ELEMENT ...>
and others). <!DOCTYPE ... [
and ]>
is only used in an .xml
file (an instance document).
尝试删除
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE PERSON [
从一开始就
]>
从 .dtd
文件的末尾开始
.
from the end of your .dtd
file.
这篇关于XML-DTD-外部子集中的内容错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文