SLIDE 5 5
17
An Introduction to XML and Web Technologies
Entity Declarations (2/3) Entity Declarations (2/3)
Internal parameter entity declarations – apply to the DTD, not the instance document
Example:
<!E <!ENT NTITY ITY % Shap hape " e "(rect ect|c |cir ircle cle|po |poly ly|de |defa faul ult)" t)">
<!ATT TTLIS LIST ar T area sha ea shape pe %S %Sha hape pe; "rec rect" t">
corresponds to
<!A <!ATT TTLIS LIST ar T area sha ea shape pe (r (rec ect| t|cir circle cle|p |poly
|def efaul ault) t) "r "rect ect"> ">
18
An Introduction to XML and Web Technologies
Entity Declarations (3/3) Entity Declarations (3/3)
External parsed entity declarations – references to XML data in other files
Example:
<!ENTITY widgets SYSTEM "http://www.brics.dk/ixwt/widgets.xml" SYSTEM "http://www.brics.dk/ixwt/widgets.xml">
External unparsed entity declarations – references to non-XML data
Example:
SYSTEM "http://www.brics.dk/ixwt/widget.gif” SYSTEM "http://www.brics.dk/ixwt/widget.gif” NDATA gif NDATA gif >
<!NOTATION gif SYSTEM "http: SYSTEM "http://www.iana.org/assignments/media-types/image/gif"> //www.iana.org/assignments/media-types/image/gif">
- <!ATTLIST thing img ENTITY
ENTITY #REQUIRED>
not widely used!
19
An Introduction to XML and Web Technologies
Conditional Sections Conditional Sections
Allow parts of schemas to be enabled/disabled by a switch
Example:
<!ELEMENT person (firstname,lastname)> ]]> <![%person.full; [ <!ELEMENT person (firstname,lastname,email+,phone?)> <!ELEMENT email (#PCDATA)> <!ELEMENT phone (#PCDATA)> ]]> <!ELEMENT firstname (#PCDATA)> <!ELEMENT lastname (#PCDATA)>
- <!ENTITY % person.simple "INCLUDE" >
<!ENTITY % person.full "IGNORE" >
20
An Introduction to XML and Web Technologies
Checking Validity with DTD Checking Validity with DTD
A DTD processor (also called a validating XML parser) parses the input document (includes checking well-formedness) checks the root element name for each element, checks its contents and attributes checks uniqueness and referential constraints (ID/IDREF(S) attributes)