Presentation is loading. Please wait.

Presentation is loading. Please wait.

Www.monash.edu.au CSE3201 Information Retrieval Systems DTD Document Type Definition.

Similar presentations


Presentation on theme: "Www.monash.edu.au CSE3201 Information Retrieval Systems DTD Document Type Definition."— Presentation transcript:

1 www.monash.edu.au CSE3201 Information Retrieval Systems DTD Document Type Definition

2 www.monash.edu.au 2 Valid XML Document A well-formed document complies to the syntax specified by W3C recommendation. A valid XML document is a well-formed XML document that also complies to the rules specified in a DTD or XML Schema. The rules include: –Naming of elements, attributes. –Structure of the document

3 www.monash.edu.au 3 DTD Example Harry Potter and the Philosopher’s Stone J.K Rowlings … <!DOCTYPE bookshop [ <!ATTLIST price value CDATA #IMPLIED > ]>

4 www.monash.edu.au 4 DOCTYPE declaration It is used to declare the name of a document. The name should be the same to the root element’s name. NOTE: a DOCTYPE declaration DOES NOT replace a declaration of a root element. The root element needs to be declared separately using an element declaration. <!DOCTYPE bookshop [ … ]>

5 www.monash.edu.au 5 ELEMENT declaration Content model defines what can be included between the opening tag and the closing tag of an element. Content Model: any, empty, text only (simple), element only (complex), mixed.

6 www.monash.edu.au 6 Content Model - Any An element defined with an ANY content model may contain anything, eg elements, character data, comments, etc

7 www.monash.edu.au 7 Content Model - Empty An element defined with an empty content model may not contain any text or child element. The existence of an attribute does not affect the structure of a content model. XML: DTD:

8 www.monash.edu.au 8 Content Model – Text only (Simple) An element declared with this content model can only contain textual data (simple string) and entity references. Example: XML: Harry Potter and Philosopher’s stone DTD:

9 www.monash.edu.au 9 Content Model – Element Only (Complex) An element declared with this content model may only contain elements and entity references. Example: XML: DTD:

10 www.monash.edu.au 10 Content Model - Mixed An element declared with this content model may contain intersperse child elements with text. Example XML: text mixed with child text DTD:

11 www.monash.edu.au 11 Cardinality Defines how many child elements may appear for the declared element. OperatorDescription NoneOne and only one child is allowed ?Zero or one child *Zero or more child(ren) +One or more child(ren)

12 www.monash.edu.au 12 Sequence Indicator Defined the occurrence of the child elements. Possible occurences: –“Followed by”=> AND => “, “ –”Choice of” => OR => “ | “

13 www.monash.edu.au 13 Sequence Indicator – “Followed By” DTD: XML: Mr John V Smart Jr

14 www.monash.edu.au 14 Sequence Indicator – “Choice of” DTD: <!ELEMENT personName ((Mr |Ms |Dr ),firstName,middleName,lastName,( Jr |Sr))> XML John V Smart

15 www.monash.edu.au 15 Attribute Declaration <!ATTLIST elementName attrName1 attrType1 attrDefault defaultValue1 … attrNameN attrTypeN attrDefault defaultValueN> DTD: <!ATTLIST personName titleCDATA #IMPLIED firstName CDATA#REQUIRED surname CDATA#REQUIRED > XML:

16 www.monash.edu.au 16 Attribute Type (some) TypeDescription CDATACharacter Data (Simple String) Enumerated Values One of a series IDA unique identifier for each instance of this element type IDREFA reference to an element with ID type attribute

17 www.monash.edu.au 17 Attribute Defaults ValuesDescription #REQUIREDAttribute must appear in every instance of the element. #IMPLIEDAttribute is OPTIONAL. #FIXED (plus default value) Attribute is OPTIONAL. If it does appear, it must match the default value. If it does not appear, the parser may supply the default value.

18 www.monash.edu.au 18 #Required - Example <!DOCTYPE friends [ ]> Jenny Genius jgenius@einstein.com

19 www.monash.edu.au 19 #Implied - Example <!DOCTYPE friends [ ]> … (next slide)

20 www.monash.edu.au 20 #Implied - Example Jenny Genius jgenius@einstein.com John Howard jhoward@oz.gov.au

21 www.monash.edu.au 21 #Fixed-Example <!DOCTYPE friends [ ]>

22 www.monash.edu.au 22 #Fixed-Valid Instances Jenny Genius jgenius@einstein.com John Howard jhoward@oz.gov.au

23 www.monash.edu.au 23 #Fixed – Invalid Instance Jenny Genius jgenius@einstein.com

24 www.monash.edu.au 24 Entity Storage Unit Entity is declared in DTD (except predefined entity) and is referred in DTD/XML document.

25 www.monash.edu.au 25 Entity Example <!DOCTYPE footNote [ ]> All &uni; websites contain the following disclaimer "&disclaimer;"

26 www.monash.edu.au 26 External DTD Re-use of DTD. Easy to maintain –single update Public DTD http://www.csse.monash.edu.au/DTDs/maria/book.dtd Local DTD book.dtd

27 www.monash.edu.au 27 External DTD Example DTD file

28 www.monash.edu.au 28 External DTD Example XML file Jenny Genius jgenius@einstein.com NOTE: the value of the xml declaration attribute “standalone” has to be set to “no” when an external DTD is used.

29 www.monash.edu.au 29 Mixed DTDs Internal and external can be mixed. The external has to be declared first. <!DOCTYPE article PUBLIC “MyPublicDTD/Book” http://www.csse.monash.edu.au/DTDs/maria/book.dtd http://www.csse.monash.edu.au/DTDs/maria/book.dtd [ DTD declarations … ]> Conflict management : –the internal DTD subset always take priority –the internal DTD will overide the external declaration. internal DTD subset

30 www.monash.edu.au 30 Limitations of DTD Non-XML syntax DTD is not Extensible Weak Data Typing No inheritance Possible solution: XML Schema


Download ppt "Www.monash.edu.au CSE3201 Information Retrieval Systems DTD Document Type Definition."

Similar presentations


Ads by Google