Myers
Myers
1 2
3 4
5 6
1
Conceptual structure XML entities
◆ less than = < (<)
Course ◆ greater than = > (>)
◆ quotation mark = " (")
Name Number Instructor Time Time ◆ apostrophe = ' (')
◆ ampersand = & (&)
7 8
9 10
11 12
2
Values must be in quotation marks Elements must be properly nested
<student id=1234>Bad Student!</student> <tag1><tag2>Badly nested!</tag1></tag2>
<student id="1234">Good Student</student> <tag1><tag2>Looks good!</tag2></tag1>
13 14
15 16
17 18
3
Types of XML documents "Well-formed" XML
◆ Well-formed ◆ Follows the XML syntax rules
◆ Valid <?xml version="1.0"?>
<course>
◆ Invalid <name>Document Processing Languages</name>
<number>2081-742</number>
<college>CIAS</college>
<credits>4</credits>
<desc>Grad publishing technology</desc>
</course>
19 20
21 22
23 24
4
Declaring Elements in a DTD Declaring Elements in a DTD (cont’d)
General Form: <!ELEMENT name ANY>
Creates an element which can contain both
<!ELEMENT element-name element-rule> plain text and tags
element-name is the name of the tag you are defining <!ELEMENT name (#PCDATA)>
element-rule determines what content is legal in the tag Creates an element which can contain plain
text but NOT other tags
<!ELEMENT name EMPTY>
Creates an empty element
25 26
27 28
29 30
5
Legal types An XML Example
CDATA ◆ We will define a person like this:
Character data ◆ A person is required to be either male or female
◆ A person has a name which consists of:
◆ A first name
A list of values
◆ A last name
e.g. for marital status ◆ One (optional) nickname
31 32
33 34
35 36
6
Other related technologies Transforming XML
◆ CSS - Cascading Style Sheets for display ◆ XSLT
◆ Extensible Stylesheet Language - Transformations
◆ XSL - Extensible Stylesheet Language for display
◆ Can convert XML to other languages
◆ XSLT - XSL Transformations ◆ SGML
◆ Xpath - Allows XML files to include other content ◆ HTML
◆ PDF
◆ Xlink - Allows XML files to link to other XML files
◆ PostScript
◆ Xquery - Allows XML files to query databases ◆ Just about anything else
37 38