使用 Notepad++ 进行内部 DTD 验证

Internal DTD validation using Notepad++

我是 XML 的新手,正在尝试使用 DTD 创建一个简单的 XML。

我正在通过 XML Tools blugin 使用 Notepad++ 进行验证。

这是我的带有内部 DTD 的 XML 代码。

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!DOCTYPE People [
    <!ELEMENT People (name, phone*)>
    <!ELEMENT name (#PCDATA)*>
    <!ELEMENT phone (#PCDATA)*>   
    <!ATTLIST phone type (home) #REQUIRED>
]>

<People>
    <name> John Smith </name>
    <phone type="home">+1 (123) 456-7890 </phone>
</People>

如果我保留 'standalone="yes"',我会收到以下错误 "ERROR: standalone: People declared in the external subset contains white spaces nodes"。如果我删除它,代码将通过验证而不会出现任何问题。

谁能解释为什么 'standalone="yes"' 的存在会导致问题? 谢谢。

P.S。请在标记为重复之前仔细阅读上述问题的描述。

Validity constraint: Standalone Document Declaration

The standalone document declaration must have the value "no" if any external markup declarations contain declarations of:

  • attributes with default values, if elements to which these attributes apply appear in the document without specifications of values for these attributes, or

  • entities (other than amp, lt, gt, apos, quot), if references to those entities appear in the document, or

  • attributes with tokenized types, where the attribute appears in the document with a value such that normalization will produce a
    different value from that which would be produced in the absence of
    the declaration, or

  • element types with element content, if white space occurs directly within any instance of those types.

参考 : Extensible Markup Language (XML) 1.0 (Fifth Edition)