Professional Documents
Culture Documents
Web Programming
Maymester 2004
XML fundamental concepts
• XML is not a language, but a structure for
defining application-specific mini-
languages
• Tags, elements and attributes
• Tag names can be ANYTHING (depends
on application
Example XML document
XML/HTML entities
• Some symbols cannot appear in
document content because they confuse
parsing
• Entities represent these symbols
< <
> >
& &
" “ (double quote)
Well-Formed XML document
• Every tag has a matching closing tag
• Tags are properly nested
• You can have an empty element, which is
its own matching close tag
• <danger voltage=“480” />
• All attribute values appear in quotes
Valid XML document
• A valid document must be well-formed
• In addition, the document conforms to a
language definition
• The language definition specifies possible
tags, their contents, and their attributes
• Two types of language definitions:
– Document Type Definition (DTD)
– XML Schema
Document Type Definition
• Example: a letter contains a source and
destination address, a salutation, one or
more paragraphs, and a closing
DTD Attribute Definitions
• REQUIRED: must always appear
• IMPLIED: optional
• FIXED: required, and always has same
value
DTD Data Types & Quantifiers
• #PCDATA =“parsed character data”, can
contain no XML markup chars
• Use entities to replace markup chars
• “X+” means one or more instances of X
• “X*” means zero or more instances of X
• “X?” means zero or one instances of X
Where to put DTDs
• Can be embedded in the DOCTYPE
declaration, as in previous example
• SYSTEM DTD refers to a file on the same
machine: