Presentation is loading. Please wait.

Presentation is loading. Please wait.

XML - DTD Week 4 Anthony Borquez. What can XML do? provides an application independent way of sharing data. independent groups of people can agree to.

Similar presentations


Presentation on theme: "XML - DTD Week 4 Anthony Borquez. What can XML do? provides an application independent way of sharing data. independent groups of people can agree to."— Presentation transcript:

1 XML - DTD Week 4 Anthony Borquez

2 What can XML do? provides an application independent way of sharing data. independent groups of people can agree to use a common DTD for interchanging data Your application can use a standard DTD to verify that data that you receive from the outside world is valid You can also use a DTD to verify your own data

3 <!DOCTYPE note [ ]> Tove Jani Reminder Don't forget me this weekend!

4 The building blocks of XML documents Elements Tags Attributes Entities PCDATA CDATA

5 Elements Main building blocks of both XML and HTML documents HTML elements are "body" and "table” XML elements could be "note" and "message“ Can contain text, other elements, or be empty Examples of empty HTML elements are "hr", "br" and "img".

6 Tags Tags are used to markup elements. A starting tag like mark up the beginning of an element A body element: body text in between. A message element: some message in between

7 Attributes Attributes provide extra information about elements placed inside the start tag of an element Attributes come in name/value pairs E.g. the attribute is "src". value of the attribute is "computer.gif". Since the element itself is empty it is closed by a " /"

8 PCDATA PCDATA means parsed character data character data - the text found between the start tag and the end tag of an XML element. PCDATA is text that will be parsed by a parser Tags inside the text will be treated as markup and entities will be expanded.

9 CDATA CDATA also means character data CDATA is 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.

10 Entities Entities are variables used to define common text Entity references are references to entities the HTML entity reference: " " Entities are expanded when a document is parsed by an XML parser. << >> && "“ &apos;‘ The following entities are predefined in XML:

11 Declaring an Element elements are declared with an element declaration Empty elements – Elements with data – –or –example:

12 Elements with children (sequences) or

13 Wrapping <!DOCTYPE note [ ]> Tove Jani Reminder Don't forget me this weekend

14 Declaring Attributes attributes are declared with an ATTLIST declaration DTD example: – XML example: –

15 Declaring only one occurrence of the same element Example: The example declaration above declares that the child element message can only occur one time inside the note element.

16 Declaring minimum one occurrence of the same element Example: The + sign in the example above declares that the child element message must occur one or more times inside the note element.

17 Declaring zero or more occurrences of the same element Example: The * sign in the example above declares that the child element message can occur zero or more times inside the note element.

18 Declaring zero or one occurrences of the same element Example: The ? sign in the example above declares that the child element message can occur zero or one times inside the note element.

19 Declaring mixed content Example The example above declares that the element note must contain at least one to child element, exactly one from child element, exactly one header, zero or more message, and some other parsed character data as well. Puh!

20 Declaring Attributes XML element attributes are declared with an ATTLIST declaration The attribute-type can have the following values:

21 The attribute-default-value can have the following values:

22 Attribute declaration example DTD example: XML example: In the above example the element square is defined to be an empty element with the attributes width of type CDATA. The width attribute has a default value of 0.

23 Default attribute value Syntax: DTD example: XML example: Specifying a default value for an attribute, assures that the attribute will get a value even if the author of the XML document didn't include it.

24 Implied attribute Syntax: DTD example: XML example: Use an implied attribute if you don't want to force the author to include an attribute and you don't have an option for a default value either.

25 Required attribute Syntax: DTD example: XML example: Use a required attribute if you don't have an option for a default value, but still want to force the attribute to be present.

26 Fixed attribute value Syntax: DTD example: XML example: Use a fixed attribute value when you want an attribute to have a fixed value without allowing the author to change it. If an author includes another value, the XML parser will return an error.

27 Enumerated attribute values Syntax: DTD example: XML example: or Use enumerated attribute values when you want the attribute values to be one of a fixed set of legal values.

28 Entities Entities as variables used to define shortcuts to common text. Entity references are references to entities. Entities can be declared internal. Entities can be declared external

29 Internal Entity Declaration Syntax: DTD Example: XML example: &writer;&copyright;

30 External Entity Declaration Syntax: DTD Example: XML example: &writer;&copyright;

31 XML Examples <!DOCTYPE TVSCHEDULE [ ]>

32 <!DOCTYPE REPORT [ ]>

33 <!DOCTYPE NEWSPAPER [ ]>

34 <!DOCTYPE CATALOG [ ]>


Download ppt "XML - DTD Week 4 Anthony Borquez. What can XML do? provides an application independent way of sharing data. independent groups of people can agree to."

Similar presentations


Ads by Google