1 / 18

Internal DTD External DTD

Internal DTD External DTD. Internal DTD

inara
Télécharger la présentation

Internal DTD External DTD

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Internal DTD • External DTD

  2. Internal DTD • <?xml version="1.0"?> <!DOCTYPE note [ <!ELEMENT note (to,from,heading,body)> <!ELEMENT to (#PCDATA)> <!ELEMENT from (#PCDATA)> <!ELEMENT heading (#PCDATA)> <!ELEMENT body (#PCDATA)> ]> <note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend</body> </note>

  3. External DTD • <?xml version="1.0"?> • <!DOCTYPE note SYSTEM "note.dtd"> • <note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body> </note>

  4. DTD Root Element • Element Ordering is Important in DTD • <!ELEMENT tutorial (#PCDATA)> • <!DOCTYPE tutorial SYSTEM "tutorial.dtd"><tutorial>This is an XML document</tutorial> • Not a valid document • <!DOCTYPE tutorial SYSTEM "tutorial.dtd"><text>This is an XML document</text>

  5. * arbitrary instances • <!ELEMENT XXX (AAA , BBB)><!ELEMENT AAA (#PCDATA)><!ELEMENT BBB (#PCDATA)> • <!ELEMENT XXX (AAA* , BBB)><!ELEMENT AAA (#PCDATA)> <!ELEMENT BBB (#PCDATA)>

  6. + One or several • <!ELEMENT XXX (AAA+ , BBB)><!ELEMENT AAA (#PCDATA)><!ELEMENT BBB (#PCDATA)>

  7. ? – zero or one instance • <!ELEMENT XXX (AAA? , BBB)><!ELEMENT AAA (#PCDATA)> <!ELEMENT BBB (#PCDATA)>

  8. |- one from many • <!ELEMENT XXX (AAA , BBB)><!ELEMENT AAA (CCC , DDD)><!ELEMENT BBB (CCC | DDD)><!ELEMENT CCC (#PCDATA)> <!ELEMENT DDD (#PCDATA)>

  9. <!ELEMENT XXX (AAA+ , BBB+)><!ELEMENT AAA (BBB | CCC )<!ELEMENT XXX (AAA+ , BBB+)><!ELEMENT AAA (BBB | CCC ) <!ELEMENT BBB (#PCDATA | CCC )*><!ELEMENT CCC (#PCDATA)> <!DOCTYPE tutorial SYSTEM "tutorial.dtd">    <XXX>        <AAA>Element: <CCC/>        </AAA>         <BBB>         Element: <CCC/>           </BBB>     </XXX> wrong

  10. <!ELEMENT attributes (#PCDATA)> <!ATTLIST  attributes •         aaa CDATA #REQUIRED        bbb CDATA #IMPLIED>

  11. NMTOKEN type can contain only letters, digits and point [ . ] , hyphen [ - ], underline [ _ ] and colon [ : ] • NMTOKENS – NMTOKEN plus white spaces • <!ELEMENT attributes (#PCDATA)><!ATTLIST attributes    aaa CDATA #IMPLIED   bbb NMTOKEN #REQUIRED   ccc NMTOKENS #REQUIRED>

  12. ID type can contain only characters permitted for NMTOKEN and must start with a letter. No element type may have more than one ID attribute specified. The value of an ID attribute must be unique between all values of all ID attributes.

  13. <!ELEMENT XXX (AAA+ , BBB+ , CCC+)><!ELEMENT AAA (#PCDATA)><!ELEMENT BBB (#PCDATA)><!ELEMENT CCC (#PCDATA)> <!ATTLIST AAA       id ID #REQUIRED> <!ATTLIST BBB    code ID #IMPLIED   list NMTOKEN #IMPLIED>            <!ATTLIST CCC          X ID #REQUIRED         Y NMTOKEN #IMPLIED<!ELEMENT XXX (AAA+ , BBB+ , CCC+)><!ELEMENT AAA (#PCDATA)><!ELEMENT BBB (#PCDATA)><!ELEMENT CCC (#PCDATA)> <!ATTLIST AAA       id ID #REQUIRED> <!ATTLIST BBB    code ID #IMPLIED   list NMTOKEN #IMPLIED>            <!ATTLIST CCC          X ID #REQUIRED         Y NMTOKEN #IMPLIED

  14. The value of IDREF attribute must match the value of some ID attribute in the document. The value of IDREFS attribute can contain several references to elements with ID attribute separated with whitespaces.

  15. <!ELEMENT XXX (AAA+ , BBB+, CCC+, DDD+)><!ELEMENT AAA (#PCDATA)><!ELEMENT BBB (#PCDATA)><!ELEMENT CCC (#PCDATA)><!ELEMENT DDD (#PCDATA)><!ATTLIST AAA           mark ID #REQUIRED<!ELEMENT XXX (AAA+ , BBB+, CCC+, DDD+)><!ELEMENT AAA (#PCDATA)><!ELEMENT BBB (#PCDATA)><!ELEMENT CCC (#PCDATA)><!ELEMENT DDD (#PCDATA)><!ATTLIST AAA           mark ID #REQUIRED <!ATTLIST BBB         id ID #REQUIRED>            <!ATTLIST CCC                          ref IDREF #REQUIRED><!ATTLIST DDD        ref IDREFS #REQUIRED>   

  16. <!ELEMENT XXX (AAA+, BBB+)><!ELEMENT AAA (#PCDATA)><!ELEMENT BBB (#PCDATA)><!ATTLIST AAA       true ( yes | no ) #REQUIRED>    <!ATTLIST BBB month (1|2|3|4|5|6|7|8|9|10|11|12) #IMPLIED>          <!ELEMENT XXX (AAA+, BBB+)><!ELEMENT AAA (#PCDATA)><!ELEMENT BBB (#PCDATA)><!ATTLIST AAA       true ( yes | no ) #REQUIRED>    <!ATTLIST BBB month (1|2|3|4|5|6|7|8|9|10|11|12) #IMPLIED>          

  17. <!ELEMENT XXX (AAA+, BBB+)><!ELEMENT AAA (#PCDATA)> <!ELEMENT BBB (#PCDATA)>   <!ATTLIST AAA    true ( yes | no ) "yes"> <!ATTLIST BBB         month NMTOKEN "1"> <!ELEMENT XXX (AAA+, BBB+)><!ELEMENT AAA (#PCDATA)> <!ELEMENT BBB (#PCDATA)>   <!ATTLIST AAA    true ( yes | no ) "yes"> <!ATTLIST BBB         month NMTOKEN "1">  • The values of true are yes, no and yes. The values of month are 8, 2 and 1.:

  18. <!ELEMENT XXX (AAA+)> <!ELEMENT AAA EMPTY>  <!ATTLIST AAA   true ( yes | no ) "yes"><!ELEMENT XXX (AAA+)> <!ELEMENT AAA EMPTY>  <!ATTLIST AAA   true ( yes | no ) "yes"> • An element can be defined EMPTY. In such a case it can contain only attributes but no text.

More Related