Search code examples
xmlvalidationnotepad++dtd

Internal DTD validation using Notepad++


I am new to XML and trying to create a simple XML with DTD.

I am using Notepad++ via XML Tools blugin to validate.

Here is my XML code with internal DTD.

<?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>

If I keep 'standalone="yes"', I received the following error "ERROR: standalone: People declared in the external subset contains white spaces nodes". If I remove it, the code is validated with no issues.

Can anyone shed some light on why the presence of 'standalone="yes"' causes problems? Thank you.

P.S. please read the description of the above problem thoroughly before mark it as duplicate.


Solution

  • 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.

    Reference : Extensible Markup Language (XML) 1.0 (Fifth Edition)