zulfi123786
zulfi123786

Reputation: 175

XML DTD validation error issue

I am getting the below error while vaidating such a simple xml document, am I missing something

XML

<person>
    <profession>cryptographer</profession>
</person>

DTD

<!ELEMENT person (profession)>
<!ELEMENT profession (#PCDATA)>

Error:

The Markup In The Document Preceding The Root Element Must Be Well-formed.

Validator - http://www.xmlvalidation.com/

Please help

Thanks

Upvotes: 0

Views: 926

Answers (1)

Daniel Haley
Daniel Haley

Reputation: 52848

I can reproduce the error you're seeing with this and I'm assuming this is what you're submitting:

<!ELEMENT person (profession)>
<!ELEMENT profession (#PCDATA)>
<person>
    <profession>cryptographer</profession>
</person>

If I put your DTD in an internal subset in a DOCTYPE declaration (between the [ and ]), it validates using that service.

<!DOCTYPE person [
<!ELEMENT person (profession)>
<!ELEMENT profession (#PCDATA)>
]>
<person>
    <profession>cryptographer</profession>
</person>

Edit

If you are trying to reference an external DTD, you will still need to add a DOCTYPE declaration to reference the DTD.

Example:

<!DOCTYPE person SYSTEM "so.dtd">
<person>
    <profession>cryptographer</profession>
</person>

If you submit this, you will be prompted to load the DTD. This is the DTD you would upload/paste:

<!ELEMENT person (profession)>
<!ELEMENT profession (#PCDATA)>

NOTE: When you first submit the XML, be sure that you don't have "Validate against external XML schema" selected! DTD and Schema are two different things.

Upvotes: 2

Related Questions