Presentation is loading. Please wait.

Presentation is loading. Please wait.

Declare A DTD File. Declare A DTD Inline File For example, use DTD to restrict the value of an XML document to contain only character data.

Similar presentations


Presentation on theme: "Declare A DTD File. Declare A DTD Inline File For example, use DTD to restrict the value of an XML document to contain only character data."— Presentation transcript:

1 Declare A DTD File

2 Declare A DTD Inline File For example, use DTD to restrict the value of an XML document to contain only character data.

3 Inline DTD Include the text for a DTD inside the XML document For short XML documents For all XML documents during the development process and if you do not intend your DTD to be applied to other XML documents

4 Inline DTD

5

6 Restrict “GREETING” to contain characters only

7 Types of XML Element

8 External DTD Save the text for a DTD as a separate file and refer this file inside your XML document Using “DOCTYPE” declaration with the “SYSTEM” keyword Add path name if the DTD file is in different path from the XML file

9 External DTD

10

11

12 Comment DTD Files

13

14

15

16 Declare A Container Element Elements that consist of other, predefined elements Can enforce container relationships on XML data at run time The ability to enforce container relationships enables you to model complex relationships between XML data – model relationships between employees, projects, orders, products, retailers, etc.

17 Declare A Container Element

18

19 Contained elements need not to be declared in the same order in the DTD as they are in the XML document Indenting each contained element makes identifying the relationships between elements much easier

20 Declare A Container Element Elements that belong to namespaces must be referenced in DTDs by their fully qualified names. Example,

21

22 Declare A Required Element Required element –Created by validation rule to ensure that a given element is associated with one – and only one – value at runtime –Typically defined as contained elements –E.g., Customer name Social Security number Product Identification number Account number Etc.

23 Declare A Required Element

24

25

26 Declare A Optional Element Optional elements –Elements contained zero or more values at runtime

27 Declare A Multiple Occurring Element Multiple Occurring elements –Elements contained at least one or more values at runtime

28 Declare A Multiple Occurring Element

29

30 Declare Multiple Elements Multiple elements must be separated by commons, like this (aRequiredElement+, anotherRequiredElement, anOptionalElement*)

31 Declare An Character Data Element Use #PCDATA keyword #PCDATA is case-sensitive Cannot contain other predefined elements

32

33 Declare An Character Data Element

34 Declare An Empty Element Empty elements –Elements contained no data at runtime –Use to aggregate data, rather than to define specific values E.g., consider the element named “productDescription”

35

36 Declare An Empty Element

37 Declare Attributes That Hold Characters

38

39

40 Define An Entity Define a validation rule to constrain the value of an XML attribute to a developer-defined external data source Enables you to organize XML code in multiple files and pull the XML code together at runtime Use ENTITY keyword to declare an attribute of external type At runtime, the only data types allowed for an element declared as type ENTITY are those data types defined in the DTD file using declaration

41 Define An Entity

42

43

44 Declare Attributes As Words Define a validation rule using the NMTOKEN keyword to constrain the value of an XML attribute to a single word, or token To constrain a value to a collection of individual tokens, can use the NMTOKENS keyword

45 Declare Attributes As Words

46

47

48

49

50 Restrict Attributes to Lists of Options Constrain XML attribute value to one in a list of predefined options Can declare an attribute of type enumerates list Helps reduce input errors

51 Restrict Attributes to Lists of Options

52 Declare Unique-Identifier Attributes Constrain an attribute to accept unique values

53 Declare Unique-Identifier Attributes

54

55

56 Reference Existing Identifiers Use IDREF to ensure that the value of an XML attribute matches the value of previously defined attribute

57 Reference Existing Identifiers

58

59

60 Define and Reuse Text Within DTDs Describe a single of text, called parameter entity Reference the chunk repeatedly inside a DTD file Helps reduce errors introduced by retyping Define entities before using them Use and a sign % with a space on both sides. –The % sign denotes that this entity is a parameter entity

61 Define and Reuse Text Within DTDs An internal parameter entity An external parameter entity –Use URL what the content is located

62 Define and Reuse Text Within DTDs

63

64


Download ppt "Declare A DTD File. Declare A DTD Inline File For example, use DTD to restrict the value of an XML document to contain only character data."

Similar presentations


Ads by Google