Chapter 26 xml and Internet Databases Outline


XML Documents, DTD, and XML Schema


Download 1.69 Mb.
bet2/3
Sana17.02.2023
Hajmi1.69 Mb.
#1207980
1   2   3
Bog'liq
XMLdatabase

XML Documents, DTD, and XML Schema

  • A valid XML document is well formed, and in addition the element names used in the start and end tag pairs must follow the structure specified in a separate XML DTD (Document Type Definition) file or XML schema file.
  • Figure 26.4: a sample XML DTD called projects
    • * Zero or more, + one or more, ? Zero or one
    • Otherwise: exactly once
    • (data type)
    • (#PCDATA) parsed character data

FIGURE 26.4 An XML DTD file called projects

  • To use the DTD file:
  • Store the DTD file in the same file system as the XML document
  • “no”?>
  • “proj.dtd”>

DTD Limitations

  • Data types in DTD are not very general
  • Has its own special syntax and thus requires specialized processors
  • All DTD elements are always forced to follow the specified ordering of the documents, so unordered elements are not permitted.
  • Solution  XML Schema

FIGURE 26.5 An XML schema file called company

  • “Department”, “Employee”, etc. must be named types.
  • The selector “employeeDependent” is an attribute of “Employee”, of type “Dependent”.
  • The field “dependentName” in “Dependent” must be unique.

FIGURE 26.5 (continued) An XML schema file called company.

  • specifies a key constraint for non-primary key element.
  • specifies a primary key.
  • specifies a foreign key; refers to the referencing element type; refers to the referencing attribute.

FIGURE 26.5 (continued) An XML schema file called company

  • Exercise: Define the element “projectWorker” in the type “Project” as an embedded sub-element.
  • Answer:

Download 1.69 Mb.

Do'stlaringiz bilan baham:
1   2   3




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling