1 / 64

Declare A DTD File

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. Inline DTD. Include the text for a DTD inside the XML document For short XML documents

Télécharger la présentation

Declare A DTD File

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

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. Restrict “GREETING” to contain characters only

  6. Types of XML Element

  7. 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

  8. External DTD

  9. Comment DTD Files

  10. Comment DTD Files

  11. Comment DTD Files

  12. Comment DTD Files

  13. 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.

  14. Declare A Container Element

  15. Declare A Container Element • 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

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

  17. 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.

  18. Declare A Required Element

  19. Declare A Required Element

  20. Declare A Required Element

  21. Declare A Optional Element • Optional elements • Elements contained zero or more values at runtime <!ELEMENT containerElement ( [ optionalElementN* ] ) >

  22. Declare A Multiple Occurring Element • Multiple Occurring elements • Elements contained at least one or more values at runtime

  23. Declare A Multiple Occurring Element

  24. Declare A Multiple Occurring Element

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

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

  27. Declare An Character Data Element

  28. 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”

  29. Declare An Empty Element

  30. Declare Attributes That Hold Characters

  31. Declare Attributes That Hold Characters

  32. 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 <!ENTITY> declaration

  33. Define An Entity

  34. Define An Entity

  35. Define An Entity

  36. 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

  37. Declare Attributes As Words

  38. Declare Attributes As Words

  39. Declare Attributes As Words

  40. Declare Attributes As Words

  41. Declare Attributes As Words

  42. 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

More Related