This document was uploaded by user and they confirmed that they have the permission to share
it. If you are author or own the copyright of this book, please report to us by using this DMCA
report form. Report DMCA
C.R. Myers, Assistant Professor School of Printing Management & Sciences Rochester Institute of Technology
◆ ◆
Simple, but not powerful Tags pre-defined Not strict about syntax Tags are formatting oriented
1
What XML is NOT
XML– eXtensible Markup Language ◆ ◆ ◆ ◆ ◆
2
Open standard Any kind of data Unicode character set Clear syntax Unambiguous structure
◆ ◆ ◆ ◆
A A A A
replacement for HTML programming language network transport protocol database
3
XML ◆ ◆
◆
4
A sample XML file Doc. Proc. Lang.2081-742C.R. Myers
A language for creating markup languages Resembles HTML or SGML ◆ Tags, attributes and values ◆ DTD's Portable data
5
6
1
Conceptual structure
XML entities ◆
Course
◆ ◆
Name
Number
Instructor
Time
◆
Time
◆
less than = < (<) greater than = > (>) quotation mark = " (") apostrophe = ' (') ampersand = & (&)
7
XML syntax rules ◆ ◆ ◆ ◆ ◆ ◆
8
Tags are case-sensitive is different from
Tags are case sensitive Each document must have a root Closing tags are required Values must be enclosed in quotation marks Elements must be properly nested Entities must be declared
Declaring Elements in a DTD (cont’d) Creates an element which can contain both plain text and tags Creates an element which can contain plain text but NOT other tags Creates an empty element
General Form: element-name is the name of the tag you are defining element-rule determines what content is legal in the tag
25
Declaring Elements in a DTD (cont’d)
26
Declaring Elements in a DTD (cont’d)
Creates an element with children which must be present in the order listed Creates an element with options. Either child1 or child2 must appear, but not both.
Creates an element with a child which must appear zero or one times Creates an element with a child which must appear one or more times Creates an element with a child which may appear zero or more times
27
Declaring Attributes in a DTD
28
Possible values for default
General form:
#REQUIRED means that the value must be specified #IMPLIED means that the value is optional
target-element is the element to which the attribute applies name is the attribute name type is what type of data the attribute contains default is whether the item is required 29
30
5
Legal types
An XML Example
CDATA Character data
◆
We will define a person like this:
◆
A person is required to be either male or female A person has a name which consists of: ◆ A first name ◆ A last name ◆ One (optional) nickname A person has an occupation A person has a description
◆
A list of values e.g. for marital status (single | married | divorced | widowed)
◆ ◆
31
An XML Example ◆
32
The “person” DTD
We will define a person like this:
CharlesMyersC.R.
college professor <description>bald geek
33
What's wrong with DTD's ◆ ◆
34
XML Schema
DTD’s use old SGML style definitions DTD are not written in XML
◆
35
XML definition system developed to replace Document Type Definitions
36
6
Other related technologies ◆ ◆ ◆ ◆ ◆ ◆
Transforming XML
CSS - Cascading Style Sheets for display XSL - Extensible Stylesheet Language for display XSLT - XSL Transformations Xpath - Allows XML files to include other content Xlink - Allows XML files to link to other XML files Xquery - Allows XML files to query databases
◆
XSLT ◆ Extensible Stylesheet Language - Transformations ◆ Can convert XML to other languages ◆ ◆ ◆ ◆ ◆