Example:Well-Formed XML <?xml version ="1.0"standalone "yes"?> A NAME subelement <BARS> KBAR>NAME>Joe's Bar</NAME> <BEER><NAME>Bud</NAME> <PRICE>2.50</PRICE></BEER> Root tag <BEER<NAME>Miller</NAME> <RRICE>3.00</PRICE></BEER> A BEER 1/BAR> subelement <BAR> </BARS> Tags surrounding a BEER element 11
11 Example: Well-Formed XML <?xml version = “1.0” standalone = “yes” ?> <BARS> <BAR><NAME>Joe’s Bar</NAME> <BEER><NAME>Bud</NAME> <PRICE>2.50</PRICE></BEER> <BEER><NAME>Miller</NAME> <PRICE>3.00</PRICE></BEER> </BAR> <BAR> … </BARS> A NAME subelement A BEER subelement Root tag Tags surrounding a BEER element
DTD Structure <!DOCTYPE <root tag> <!ELEMENT <name>(<components>)> more elements . ]> 12
12 DTD Structure <!DOCTYPE <root tag> [ <!ELEMENT <name> (<components>)> . . . more elements . . . ]>
DTD Elements The description of an element consists of its name (tag),and a parenthesized description of any nested tags. Includes order of subtags and their multiplicity. Leaves (text elements)have #PCDATA (Parsed Character DATA in place of nested tags. 13
13 DTD Elements The description of an element consists of its name (tag), and a parenthesized description of any nested tags. Includes order of subtags and their multiplicity. Leaves (text elements) have #PCDATA (Parsed Character DATA ) in place of nested tags
Example:DTD A BARS object has <!DOCTYPE BARS「 zero or more BAR's nested within. <!ELEMENT BARS (BAR*)> <!ELEMENT BAR (NAME,BEER+)> A BAR has one <!ELEMENT NAME #PCDATA)> NAME and one <!ELEMENT (NAME,PRICE)> or more BEER subobjects. <!ELEMENT PRICE G #PCDATA)> ]> A BEER has a NAME and PRICE NAME and a are text. PRICE. 14
14 Example: DTD <!DOCTYPE BARS [ <!ELEMENT BARS (BAR*)> <!ELEMENT BAR (NAME, BEER+)> <!ELEMENT NAME (#PCDATA)> <!ELEMENT BEER (NAME, PRICE)> <!ELEMENT PRICE (#PCDATA)> ]> A BARS object has zero or more BAR’s nested within. A BAR has one NAME and one or more BEER subobjects. A BEER has a NAME and a PRICE. NAME and PRICE are text
Element Descriptions Subtags must appear in order shown. a tag may be followed by a symbol to indicate its multiplicity. ■*=zero or more. ■+=one or more. ?zero or one. Symbol can connect alternative sequences of tags. 15
15 Element Descriptions Subtags must appear in order shown. A tag may be followed by a symbol to indicate its multiplicity. * = zero or more. + = one or more. ? = zero or one. Symbol | can connect alternative sequences of tags