user14353018
user14353018

Reputation:

Error: The markup declaration contained or pointed to by the document type declaration must be well-formed

I got the error:

The markup declaration contained or pointed to by the document type declaration must be well-formed.

And here is a few extra questions.

  1. In JSON file, place = null. In XML document, should I still need to mention it?
  2. sub_company and sub_sub_comany are the same level and have the same elements. In this case do they need to avoid repetition? If so, how do I change the DTD file?
  3. in DTD file, do I need to put "ATTLIST"? if so, how do I know which is ATTLIST without XML document and with JSON file?

companys.dtd file

<!ELEMENT companys (company*)>
<!ELEMENT company (id, companyName, sub_company, place, sub_sub_company)>
<!ELEMENT id (#PCDATA)>
<!ELEMENT companyName (#PCDATA)>
<!ELEMENT sub_company (id, name, employees, subsidiary)>
<!ELEMENT id (#PCDATA)>
<!ELEMENT name (#PCDATA)>
<!ELEMENT employees (#PCDATA)>
<!ELEMENT subsidiary (#PCDATA)>
<!ELEMENT place (#PCDATA)>
<!ELEMENT sub_sub_company (id, name, employees, subsidiary)>
<!ELEMENT id (#PCDATA)>
<!ELEMENT name (#PCDATA)>
<!ELEMENT employees (#PCDATA)>
<!ELEMENT subsidiary (#PCDATA)>

companys.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE companys SYSTEM "companys.dtd">
<companys>
    <company>
        <id>123</id>
        <companyName>Jack company</companyName>
        <sub_company>
            <id>123456</id>
            <name>jack jr company</name>
            <employees>120</employees>
            <subsidiary>20</subsidiary>
        </sub_company>
        <place/>
        <sub_sub_company>
            <id>123321</id>
            <name>jack grand company</name>
            <employees>50</employees>
            <subsidiary>3</subsidiary>
        </sub_sub_company>
    </company>
</companys>

Upvotes: 0

Views: 1038

Answers (1)

zx485
zx485

Reputation: 29042

In DTD, repetitions are not allowed. Remove them, and you'll get

<!ELEMENT companys (company*)>
<!ELEMENT company (id, companyName, sub_company, place, sub_sub_company)>
<!ELEMENT id (#PCDATA)>
<!ELEMENT companyName (#PCDATA)>
<!ELEMENT sub_company (id, name, employees, subsidiary)>
<!ELEMENT name (#PCDATA)>
<!ELEMENT employees (#PCDATA)>
<!ELEMENT subsidiary (#PCDATA)>
<!ELEMENT place (#PCDATA)>
<!ELEMENT sub_sub_company (id, name, employees, subsidiary)>

which will validate your XML.
Regarding ATTLIST: you don't need it, but if you want to be precise, have a look here. It shows how to use it.
I cannot make any remark concerning JSON, because there is no JSON in your question!?!

Upvotes: 1

Related Questions