Validation of an XML and DTD

Questions about XML that are not covered by the other forums should go here.
pitanga
Posts: 2

Validation of an XML and DTD

Mon Aug 21, 2017 12:26 pm

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

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


My DTD:

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 id (#CDATA)>
<!ATTLIST date (#CDATA)>
<!ATTLIST lieu (#CDATA)>


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

Errors:

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! :-)
Radu
Posts: 5088

Re: Validation of an XML and DTD

Mon Aug 21, 2017 1:23 pm

Hi,

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

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
pitanga
Posts: 2

Re: Validation of an XML and DTD

Tue Aug 22, 2017 1:19 pm

Thank you! I read a tutorial and now everything works fine!!! :D

Return to “General XML Questions”

Who is online

Users browsing this forum: No registered users and 0 guests