What s wrong with HTML? XML. What XML is NOT XML. A sample XML file. XML extensible Markup Language

What’s wrong with HTML? XML ◆ ◆ C.R. Myers, Assistant Professor School of Printing Management & Sciences Rochester Institute of Technology ◆ ◆ Sim...
Author: Meryl Jennings
23 downloads 1 Views 612KB Size
What’s wrong with HTML? XML

◆ ◆

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-742 C.R. Myers Tuesday, Noon - 2PM Thursday, Noon - 2PM

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 = < ( (>) 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

This is bad XML

9

XML documents must have a root

10

Closing tags are required



This is bad XML This is also bad




This is ok



This is the shortcut for an empty tag


11

12

2

Values must be in quotation marks

Elements must be properly nested

Bad Student!

Badly nested!

Good Student

Looks good!

13

Attributes vs. Elements

14

Attributes vs. Elements

Using an Element for gender:

Using an Attribute for gender:





female

Jane

Jane

Doe

Doe





15

Attribute disadvantages

16

Attributes still useful



Can't contain multiple values





Not very expandable



Great for internal info, not needed by the user



Can't describe structures



More difficult to manipulate



Hard to test against a DTD

Blah, blah, blah. More boring stuff

17

18

3

Types of XML documents

"Well-formed" XML Follows the XML syntax rules



Well-formed





Valid



Invalid

Document Processing Languages 2081-742 CIAS 4 Grad publishing technology

19

"Valid" XML ◆

20

Imbedded DTD

A well-formed XML doc that conforms to a DTD



21

External DTD

22

Parts of a DTD



Elements Attributes Entities PCDATA CDATA

23

24

4

Declaring Elements in a DTD

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:



Charles Myers C.R.

college professor 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 ◆ ◆ ◆ ◆ ◆

37

SGML HTML PDF PostScript Just about anything else

38

7

Suggest Documents