This document provides an overview of XML DTD and Schema. It defines key terms like well-formed, valid, DTD and describes how a DTD is used to define element types and attributes. It also explains different DTD rules like EMPTY, ANY, #PCDATA. The document then covers XML Schema elements, data types, and how to declare elements, attributes and complex/simple types in a schema.
2. Well formed and valid document
• a valid XML document is a more strict form of
a well-formed XML document .
• well formed if it follows all the preceding syntax rules of XML.
• valid XML documents can improve the quality of document processes.
3. DTD
• Document type definition.
• Defines a set of rules for an XML document to make it valid.
• Validated & verified using DTD.
• It will define the element like
Optional
No.of times it can occur
Attributes in it
4. DTD
• Advantage: single DTD can be referenced by many XML documents.
• Types:
Internal
External
14. DTD Element rules
• Content rule
• ANY rule
• Empty rule
• #PCDATA rule
• Structure rule
• Element only rule
• Mixed rule
15. ANY rule
• Element may contain other elements and/or normal character data.
• Syntax:
• Example:
16. EMPTY rule
• Element contain no data
• Syntax:
• Can contain attributes.
• In HTML, image tag<img> doesn't contain any data nut it has
attributes the describes the location, height,..
• Empty elements can contain diagnostic information for the proessing
of data.
17. #PCDATA rule
• Indicated that parsed character data will be contained in the element.
• Syntax:
• Example:
• Example for CDATA:
18. Element-only rule
• Specifies that only elements may appear as children of the current
element.
• If there are to be options for which elements will appear, the listed
elements should be separated by the pipe(|) symbol.
19. Mixed rule
• Elements that may have both character data and child elements in
the data they contain.
• Options will be separated by the pipe symbol(|).
• Sequential lists will be separated by commas.
• Asterisk symbol(*)
26. Attribute types
7. NMTOKEN: <!ATTLIST address country NMTOKEN “usa”>
8. NMTOKENS: <!ATTLIST region states NMTOKENS “KS OK” >
9. NOTATION: <!ATTLIST music play NOTATION “mplayer2.exe “>
10. ENUMERATED: <!ATTLIST college grad (1|0) “1”>
27. Default value types
• #REQUIRED:<!ATTLIST season year CDATA #REQUIRED >
• #IMPLIED:<!ATTLIST field size CDATA #IMPLIED >
• #FIXED:<!ATTLIST bcc hidden #FIXED “true” >
• Default :<!ATTLIST children number CDATA “0”>
28. DTD Entities
• Storage units.
• well-formed XML, normal text, binary data, a database record, and so
on.
• Syntax:
<!ENTITY entityname [SYSTEM | PUBLIC] entitycontent>
48. Declaring Complex Elements
• Syntax:
<xsd:complexType name=’’ [abstract=’’] [base=’’] [block=’’]
➥[final=’’] [mixed=’’]/>
• Block: all, extension, restriction.
• A <complexType>element in the XML Schema Definition Language
may contain only one of the following elements:
all, choice, complexContent, group, sequence, simpleContent.