dtd_schema_xml.py

Created by joelkouakou2080

Created on March 01, 2023

4.06 KB


Soit le document XML (biblio.xml) suivant 

<?xml version="1.0" encoding="iso-8859-1"?>

<!DOCTYPE BIBLIO SYSTEM "BIBLIO.DTD"> 
<BIBLIO SUBJECT="XML">

      <BOOK SUBJECT="applications" LANG="fr" ISBN="9782212090819">

               <AUTHOR>

                             <FIRSTNAME>Jean-Christophe</FIRSTNAME>

                           <LASTNAME>Bernadac</LASTNAME>

             </AUTHOR>

            <AUTHOR>

                            <FIRSTNAME>François</FIRSTNAME> 

                            <LASTNAME>Knab</LASTNAME>

            </AUTHOR>

           <TITLE>Construire une application XML</TITLE>

           <PUBLISHER>

                              <NAME>Eyrolles</NAME>

                             <PLACE>Paris</PLACE>

          </PUBLISHER>

          <DATEPUB>1999</DATEPUB>

      </BOOK>

     <BOOK SUBJECT="général" LANG="fr" ISBN="9782212090529">

      <AUTHOR>

                <FIRSTNAME>Alain</FIRSTNAME> 

               <LASTNAME>Michard</LASTNAME>

      </AUTHOR>

      <TITLE>XML, LangageetApplications</TITLE> <PUBLISHER>

          <NAME>Eyrolles</NAME>

         <PLACE>Paris</PLACE>

         </PUBLISHER>

       <DATEPUB>1998</DATEPUB>

   </BOOK>

<BOOK SUBJECT="applications" LANG="fr" ISBN="9782840825685">

           <AUTHOR>

                       <FIRSTNAME>William).</FIRSTNAME>

                       <LASTNAME>Pardi</LASTNAME>

           </AUTHOR>

          <TRANSLATOR PREFIX="adaptédel'anglaispar">

                       <FIRSTNAME>James</FIRSTNAME>

                       <LASTNAME>Guerin</LASTNAME>

          </TRANSLATOR>

          <TITLE>XML en Action</TITLE>

         <PUBLISHER>

                  <NAME>Microsoft Press</NAME>

                  <PLACE>Paris </PLACE>

       </PUBLISHER>

       <DATEPUB>1999</DATEPUB>

  </BOOK>

</BIBLIO>


1) Créer le DTD (biblio.dtd) 
pour valider le fichier xml 
ci-dessus (completer le fichier
xml en ajoutant 4 livres) 

2) Donner le schéma xml 
(biblio.xsd) pour valider le
fichier xml ci-dessus.

Réponses :
----------

1) 

<!ELEMENT BIBLIO (BOOK+)>
<!ATTLIST BIBLIO SUBJECT CDATA #REQUIRED>
<!ELEMENT BOOK (AUTHOR+, TITLE, PUBLISHER, DATEPUB)>
<!ATTLIST BOOK SUBJECT CDATA #REQUIRED
           LANG CDATA #REQUIRED
           ISBN CDATA #REQUIRED>
<!ELEMENT AUTHOR (FIRSTNAME, LASTNAME)>
<!ELEMENT FIRSTNAME (#PCDATA)>
<!ELEMENT LASTNAME (#PCDATA)>
<!ELEMENT TITLE (#PCDATA)>
<!ELEMENT PUBLISHER (NAME, PLACE)>
<!ELEMENT NAME (#PCDATA)>
<!ELEMENT PLACE (#PCDATA)>
<!ELEMENT DATEPUB (#PCDATA)>
<!ELEMENT TRANSLATOR (FIRSTNAME, LASTNAME)>
<!ATTLIST TRANSLATOR PREFIX CDATA #REQUIRED>

2) 

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="BIBLIO">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="BOOK" maxOccurs="unbounded">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="AUTHOR" maxOccurs="unbounded">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element name="FIRSTNAME" type="xs:string"/>
                    <xs:element name="LASTNAME" type="xs:string"/>
                  </xs:sequence>
                </xs:complexType>
              </xs:element>
              <xs:element name="TITLE" type="xs:string"/>
              <xs:element name="PUBLISHER">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element name="NAME" type="xs:string"/>
                    <xs:element name="PLACE" type="xs:string"/>
                  </xs:sequence>
                </xs:complexType>
              </xs:element>
              <xs:element name="DATEPUB" type="xs:string"/>
            </xs:sequence>
            <xs:attribute name="SUBJECT" type="xs:string" use="required"/>
            <xs:attribute name="LANG" type="xs:string" use="required"/>
            <xs:attribute name="ISBN" type="xs:string" use="required"/>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
      <xs:attribute name="SUBJECT" type="xs:string" use="required"/>
    </xs:complexType>
  </xs:element>
</xs:schema>

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.