Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Dr Alexiei Dingli XML Technologies DTD. 2 Document Type Definition Defines –the legal building blocks of an XML document –the document structure –The.

Similar presentations


Presentation on theme: "1 Dr Alexiei Dingli XML Technologies DTD. 2 Document Type Definition Defines –the legal building blocks of an XML document –the document structure –The."— Presentation transcript:

1 1 Dr Alexiei Dingli XML Technologies DTD

2 2 Document Type Definition Defines –the legal building blocks of an XML document –the document structure –The legal elements and attributes A DTD can be defined inside an xml document or outside What’s in a DTD?

3 3 An XML file can carry a description of its own format Independent groups of people can agree to use a standard DTD for interchanging data Applications can use a standard DTD to verify that the data received from the outside world is valid A DTD can be used to verify the data Why do we need a DTD?

4 4 An inside DTD (1)

5 5 An inside DTD (2)

6 6 !DOCTYPE note defines that the root element of this document is note. !ELEMENT note defines that the note element contains four elements: "to,from,heading,body". !ELEMENT to defines the to element to be of the type "#PCDATA". !ELEMENT from defines the from element to be of the type "#PCDATA". !ELEMENT heading defines the heading element to be of the type "#PCDATA". !ELEMENT body defines the body element to be of the type "#PCDATA". An inside DTD (3)

7 7 External DTD

8 8 Elements Attributes Entities PCDATA CDATA The building blocks

9 9 Main building block Can contain text, other elements or be empty The elements b, title and br can be used as follows: Hello world Hello Tom Elements

10 10 Provide extra information about elements Always placed inside the opening tag Always have a name/value pair Which is the element, attribute and value? Attributes

11 11 Entity ReferencesCharacter << >> && "" &apos;' Entities

12 12 Text that will NOT be parsed by a parser Tags inside the text will NOT be treated as markup and entities will not be expanded CDATA

13 13 Parsed character data Character data is the text found between the start tag and the end tag of an XML element Text that WILL be parsed by a parser –The text will be examined by the parser for entities and markup Tags inside the text will be treated as markup and entities will be expanded However, parsed character data should not contain any &, characters; these need to be represented by the & < and > entities, respectively PCDATA

14 14 Different Elements

15 15 The Empty Element

16 16 Element with PCDATA

17 17 Element with Any

18 18 *Sequence must be respected Elements with Children

19 19 Element with one child

20 20 One or more – Zero or more – Zero or One – Occurrences

21 21 Either or – Mixed content – Mixing...

22 22 Declaring Attributes

23 23 TypeDescription CDATAThe value is character data (en1|en2|..)The value must be one from an enumerated list IDThe value is a unique id IDREFThe value is the id of another element IDREFSThe value is a list of other ids NMTOKENThe value is a valid XML name NMTOKENSThe value is a list of valid XML names ENTITYThe value is an entity ENTITIESThe value is a list of entities NOTATIONThe value is a name of a notation xml:The value is a predefined xml value Atribute Type

24 24 ValueExplanation valueThe default value of the attribute #REQUIREDThe attribute is required #IMPLIEDThe attribute is not required #FIXED valueThe attribute value is fixed Attribute Value

25 25 Mount Cook CDATA example

26 26 XML Tutorial Enumerated Example

27 27 Mount Cook ID example

28 28 Homer Flinstone Fred Burns ID Ref example

29 29 Bart Simpson ID Refs example

30 30 * Can contain only letters, digits, points, hyphen, underline and colon Mount Cook NMTOKEN example

31 31 * Allow you to add data which is not XML Notation example

32 32 Mount Cook Entity example

33 33 Entities are variables used to define shortcuts to standard text or special characters –Entity references are references to entities –Entities can be declared internal or external More about Entities

34 34 &writer;&copyright; Internal Entities

35 35 &writer;&copyright; External Entities

36 36 Example

37 37 Define an XML Vocabulary for a Toaster Markup Language (TML) It must support features such as: –Print message on toast –Display on LCD –Time stamp Exercise

38 38 Questions?


Download ppt "1 Dr Alexiei Dingli XML Technologies DTD. 2 Document Type Definition Defines –the legal building blocks of an XML document –the document structure –The."

Similar presentations


Ads by Google