Wohlgeformtes XML ist haben immer korrekte Syntax.
gegen ein DTD validiert gültiges XML.
Wohlgeformte XML Dokumente
Ein „wohlgeformtes“ XML Dokument hat korrekte XML Syntax.
Ein „wohlgeformtes“ XML Dokument ist ein Dokument, das an die XML Syntaxrichtlinien sich anpaßt, die in den vorhergehenden Kapiteln beschrieben wurden:
XML Dokumente müssen ein Wurzelelement haben
XML Elemente müssen einen schließenden Umbau haben
XML Umbauten sind der empfindliche Fall
XML Elemente müssen richtig genistet werden
XML Attributwerte müssen immer veranschlagen werden
<?xml version="1.0" encoding="ISO-8859-1"?>
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
Valid XML Documents
A "Valid" XML document also conforms to a DTD.
A "Valid" XML document is a "Well Formed" XML document, which
also conforms to the rules of a Document Type Definition (DTD):
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE note SYSTEM "InternalNote.dtd">
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
XML DTD
A DTD defines the legal elements of an XML document.
The function of a DTD is to define the legal building blocks of an XML document. It defines the document structure with a list of legal elements.
A DTD can be declared inline in your XML document, or as an external reference.
Internal DTD
This is an XML document with a Document Type Definition:
<?xml version="1.0"?>
<!DOCTYPE note [
<!ELEMENT note (to,from,heading,body)>
<!ELEMENT to (#PCDATA)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT heading (#PCDATA)>
<!ELEMENT body (#PCDATA)>
]>
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
The DTD is interpreted like this:
!ELEMENT note (in line 2) defines the element "note" as having four elements: "to,from,heading,body".
!ELEMENT to (in line 3) defines the "to" element to be of the type "CDATA".
!ELEMENT from (in line 4) defines the "from" element to be of the type "CDATA"
and so on.....
External DTD
This is a copy of the file "note.dtd" containing the Document Type Definition:
<?xml version="1.0"?>
<!DOCTYPE note SYSTEM "note.dtd">
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
This is a copy of the file "note.dtd" containing the Document Type Definition:
<?xml version="1.0"?>
<!ELEMENT note (to,from,heading,body)>
<!ELEMENT to (#PCDATA)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT heading (#PCDATA)>
<!ELEMENT body (#PCDATA)>
Keywords: valid xml, xml schema, xml document, w3c xml schema, xml parser, xml DTD, Internal DTD ,External DTD