Page 1 of 1

Validation of an XML and DTD

Posted: Mon Aug 21, 2017 12:26 pm
by pitanga
I have a problem with my XML and DTD and I can't understand what it is. Normally, my xml is well formed:

Code: Select all

<?xml version='1.0' encoding='UTF-8' standalone="no"?>
<!DOCTYPE corpus SYSTEM "POUR.dtd">

  <position type="contre">
    <discours auteur="AĆ©cio Neves" id="1" date="25/08/2016" lieu="Senado Federal">


Code: Select all

<?xml version='1.0' encoding='UTF-8'?>
<!ELEMENT corpus (position, discours)>
<!ELEMENT position (type)>
<!ATTLIST contre (#CDATA)>
<!ELEMENT discours (auteur, id, date, lieu)>
<!ATTLIST auteur (#CDATA)>
<!ATTLIST date (#CDATA)>
<!ATTLIST lieu (#CDATA)>

My validation: xmllint CONTRE.xml --dtdvalid CONTRE.dtd --noout


Code: Select all

CONTRE.dtd:5: parser error : ATTLIST: no name for Attribute
<!ATTLIST contre (#CDATA)>
CONTRE.dtd:5: parser error : Content error in the external subset
<!ATTLIST contre (#CDATA)>

Can anybody help me? Thank you! :-)

Re: Validation of an XML and DTD

Posted: Mon Aug 21, 2017 1:23 pm
by Radu

You can try to google and follow a DTD tutorial.
The ATTLIST keyword connects an element with an attribute (name,value) definition.
For example if you define this element:

Code: Select all

<!ELEMENT position (type)>

you can define an attribute for it like:

Code: Select all

<!ATTLIST position contre CDATA #IMPLIED>

meaning that "contre" is an attribute of element "position", that it has simple character data and that it can be missing from the document (that #IMPLIED part).


Re: Validation of an XML and DTD

Posted: Tue Aug 22, 2017 1:19 pm
by pitanga
Thank you! I read a tutorial and now everything works fine!!! :D