Internal DTD - PowerPoint PPT Presentation

About This Presentation
Title:

Internal DTD

Description:

note to Tove /to from Jani /from heading Reminder /heading body Don't ... only letters, digits and point [ . ] , hyphen [ - ], underline [ _ ] and colon ... – PowerPoint PPT presentation

Number of Views:113
Avg rating:3.0/5.0
Slides: 19
Provided by: sanjay70
Learn more at: https://web.mst.edu
Category:
Tags: dtd | hyphen | internal

less

Transcript and Presenter's Notes

Title: Internal DTD


1
  • Internal DTD
  • External DTD

2
  • Internal DTD
  • lt?xml version"1.0"?gt lt!DOCTYPE note lt!ELEMENT
    note (to,from,heading,body)gt lt!ELEMENT to
    (PCDATA)gt lt!ELEMENT from (PCDATA)gt lt!ELEMENT
    heading (PCDATA)gt lt!ELEMENT body (PCDATA)gt gt
    ltnotegt lttogtTovelt/togt ltfromgtJanilt/fromgt
    ltheadinggtReminderlt/headinggt ltbodygtDon't forget me
    this weekendlt/bodygt lt/notegt

3
External DTD
  • lt?xml version"1.0"?gt
  • lt!DOCTYPE note SYSTEM "note.dtd"gt
  • ltnotegt lttogtTovelt/togt ltfromgtJanilt/fromgt
    ltheadinggtReminderlt/headinggt ltbodygtDon't forget me
    this weekend!lt/bodygt lt/notegt

4
DTD
  • Element Ordering is Important in DTD
  • lt!ELEMENT tutorial (PCDATA)gt
  • lt!DOCTYPE tutorial SYSTEM "tutorial.dtd"gtlttutoria
    lgtThis is an XML documentlt/tutorialgt
  • Not a valid document
  • lt!DOCTYPE tutorial SYSTEM "tutorial.dtd"gtlttextgtT
    his is an XML documentlt/textgt                   
            
  •             

Root Element
5
arbitrary instances
  • lt!ELEMENT XXX (AAA , BBB)gtlt!ELEMENT AAA (PCDATA)
    gtlt!ELEMENT BBB (PCDATA)gt
  • lt!ELEMENT XXX (AAA , BBB)gtlt!ELEMENT AAA (PCDATA
    )gt lt!ELEMENT BBB (PCDATA)gt                    
           
  •                            

6
One or several
  • lt!ELEMENT XXX (AAA , BBB)gtlt!ELEMENT AAA (PCDATA
    )gtlt!ELEMENT BBB (PCDATA)gt                     
          

7
? zero or one instance
  • lt!ELEMENT XXX (AAA? , BBB)gtlt!ELEMENT AAA (PCDATA
    )gt lt!ELEMENT BBB (PCDATA)gt                    
           

8
- one from many
  • lt!ELEMENT XXX (AAA , BBB)gtlt!ELEMENT AAA (CCC , DD
    D)gtlt!ELEMENT BBB (CCC  DDD)gtlt!ELEMENT CCC (PCD
    ATA)gt lt!ELEMENT DDD (PCDATA)gt                 
              

9
  • lt!ELEMENT XXX (AAA , BBB)gtlt!ELEMENT AAA (BBB  
    CCC )
  • lt!ELEMENT BBB (PCDATA  CCC )gtlt!ELEMENT CCC (P
    CDATA)gt
  • lt!DOCTYPE tutorial SYSTEM "tutorial.dtd"gt    ltXX
    Xgt        ltAAAgt            Element ltCCC/gt     
       lt/AAAgt         ltBBBgt         Element ltCCC/gt 
              lt/BBBgt     lt/XXXgt                   
            
  •                            

wrong
10
  • lt!ELEMENT attributes (PCDATA)gt lt!ATTLIST 
    attributes
  •         aaa CDATA REQUIRED        bbb CDATA IMP
    LIEDgt                           

11
  • NMTOKEN type can contain only letters, digits and
    point . , hyphen - , underline _ and
    colon
  • NMTOKENS NMTOKEN plus white spaces
  • lt!ELEMENT attributes (PCDATA)gtlt!ATTLIST attribut
    es    aaa CDATA IMPLIED   bbb NMTOKEN REQUIRED
       ccc NMTOKENS REQUIREDgt                     
          

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
  • lt!ELEMENT XXX (AAA , BBB , CCC)gtlt!ELEMENT AAA (
    PCDATA)gtlt!ELEMENT BBB (PCDATA)gtlt!ELEMENT CCC (
    PCDATA)gt lt!ATTLIST AAA       id ID REQUIREDgt 
    lt!ATTLIST BBB    code ID IMPLIED   list NMTOKEN
     IMPLIEDgt            lt!ATTLIST CCC          X I
    D 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
  • lt!ELEMENT XXX (AAA , BBB, CCC, DDD)gtlt!ELEMENT
     AAA (PCDATA)gtlt!ELEMENT BBB (PCDATA)gtlt!ELEMENT
     CCC (PCDATA)gtlt!ELEMENT DDD (PCDATA)gtlt!ATTLIST
     AAA           mark ID REQUIRED
  • lt!ATTLIST BBB         id ID REQUIREDgt          
      lt!ATTLIST CCC                          ref IDREF
     REQUIREDgtlt!ATTLIST DDD
  •        ref IDREFS REQUIREDgt   

16
  • lt!ELEMENT XXX (AAA, BBB)gtlt!ELEMENT AAA (PCDATA
    )gtlt!ELEMENT BBB (PCDATA)gtlt!ATTLIST AAA       t
    rue ( yes  no ) REQUIREDgt    lt!ATTLIST BBB mon
    th (123456789101112) IMPLIEDgt         
                                                   
     

17
  • lt!ELEMENT XXX (AAA, BBB)gtlt!ELEMENT AAA (PCDATA
    )gt lt!ELEMENT BBB (PCDATA)gt   lt!ATTLIST AAA    
    true ( yes  no ) "yes"gt lt!ATTLIST BBB         m
    onth NMTOKEN "1"gt 
  • The values of true are yes, no and yes. The
    values of month are 8, 2 and 1.
                                                   
             

18
  • lt!ELEMENT XXX (AAA)gt lt!ELEMENT AAA EMPTYgt  lt!AT
    TLIST AAA   true ( yes  no ) "yes"gt
  • An element can be defined EMPTY. In such a case
    it can contain only attributes but no
    text.                                         
          
Write a Comment
User Comments (0)
About PowerShow.com