By A. SandanaKaruppan, AP/IT
2
COURSE OUTCOMES
3
OBJECTIVES
4
OUTCOMES
5
PREREQUISITES
6
AGENDA
1. Introduction
2. XML Building blocks
3. Structuring Data
4. XML Namespaces
5. Document Type Definitions (DTDs) and Schemas
6. XML Vocabularies
7. XML Applications
7
AGENDA
1. Introduction
2. XML Building blocks
3. Structuring Data
4. XML Namespaces
5. Document Type Definitions (DTDs) and Schemas
6. XML Vocabularies
7. XML Applications
8
1. INTRODUCTION
What is XML?
eXtensible Markup Language
A simplified version of SGML
Maintains the most useful parts of SGML
Designed so that SGML can be delivered over the Web
XHTML -- a reformulation of HTML 4 in XML 1.0
9
1. INTRODUCTION
10
1. INTRODUCTION
11
1. INTRODUCTION
12
1. INTRODUCTION
13
1. INTRODUCTION
14
1. INTRODUCTION
15
AGENDA
1. Introduction
2. XML Building blocks
3. Structuring Data
4. XML Namespaces
5. Document Type Definitions (DTDs) and Schemas
6. XML Vocabularies
7. XML Applications
16
2. XML BUILDING BLOCKS
PI (Processing Instruction)
Tags
Elements
Content
Attributes
Entities
Comments
17
2.1 XML BUILDING BLOCKS--PROLOG
18
2.2 TAGS
19
2.3 ELEMENTS
20
2.3 ELEMENTS
21
2.4 CONTENT
22
2.5 ATTRIBUTES
23
2.6 ENTITIES
24
2.7 COMMENTS
25
2.8 XML SYNTAX
26
2.9 ANATOMY OF AN ELEMENT
Element type
Attribute
Element (character)
type
AttributeAttribut entity
name e reference
value
<ptype="rule">Useahyphen:
­.</p>
Start-tag Content End-tag
Element
27
2.10 XML VALIDATION
28
2.11 DISPLAYING XML
XML documents do not carry information about how to display the data
We can add display information to XML with
CSS (Cascading Style Sheets)
XSL (eXtensible Stylesheet Language) --- preferred
29
AGENDA
1. Introduction
2. XML Building blocks
3. Structuring Data
4. XML Namespaces
5. Document Type Definitions (DTDs) and Schemas
6. XML Vocabularies
7. XML Applications
30
3. STRUCTURING DATA
XML declaration
Value version
Indicates the XML version to which the document conforms
Root element
Element that encompasses every other elements
Container element
Any element contains other elements
Child elements
Elements inside a container element
Empty element flag
Does not contain any text
DTD documents
End with .dtd extension
31
3. STRUCTURING DATA
XML declaration
Value version
Indicates the XML version to which the document conforms
Root element
Element that encompasses every other elements
Container element
Any element contains other elements
Child elements
Elements inside a container element
Empty element flag
Does not contain any text
DTD documents
End with .dtd extension
32
3. STRUCTURING DATA - EXAMPLE
33
AGENDA
1. Introduction
2. XML Building blocks
3. Structuring Data
4. XML Namespaces
5. Document Type Definitions (DTDs) and Schemas
6. XML Vocabularies
7. XML Applications
34
4. XML NAMESPACES
XML
Allows document authors to create custom elements
Naming collisions
XML namespace
Collection of element and attribute names
Uniform resource identifier (URI)
Uniquely identifies the namespace
A string of text for differentiating names
Any name except for reserved namespace xml
Directory
Root element and contains other elements
35
AGENDA
1. Introduction
2. XML Building blocks
3. Structuring Data
4. XML Namespaces
5. Document Type Definitions (DTDs) and Schemas
6. XML Vocabularies
7. XML Applications
36
5. DOCUMENT TYPE DEFINITIONS (DTDS) AND SCHEMAS
37
5.1 DOCUMENT TYPE DEFINITIONS (DTDS)
38
5.1.1 SIMPLE DTD EXAMPLES -
39
5.1.1 SIMPLE DTD EXAMPLES -
40
5.1.2 STRUCTURE OF A DOCUMENT TYPE DEFINITION
41
5.1.2 STRUCTURE OF A DOCUMENT TYPE DEFINITION
It is possible for a Document Type Declaration to contain both an external DTD subset
and an internal DTD subset.
In this situation, the internal declarations take precedenceover the external ones.
In other words, if both the external and internal DTDs define arule for the same element, the
rule of the internal element will be the one used.
Consider the Document Type Declaration fragment shown in Listing 4.
42
5.1.3 DTD ELEMENTS
All elements in a valid XML document are defined with an element declaration in the DTD.
An element declaration defines the name and all allowed contents of an element.
Element names must start with a letter or an underscore and may contain any combination of
letters, numbers, underscores, dashes, and periods.
Element names must never start with the string xml. Colons should not be used in element
names because they are normally used to reference namespaces.
Each element in the DTD should be defined with the following syntax:
<!ELEMENT elementname rule >
ELEMENT is the tag name that specifies that this is an element definition.
elementname is the name of the element.
rule is the definition to which the elements data content must conform.
43
5.1.3 DTD ELEMENTS - EXAMPLE
44
5.1.3 DTD ELEMENTS - EXAMPLE
45
5.1.3 DTD ELEMENTS - EXAMPLE
46
5.1.3 DTD ELEMENTS - RULE
47
5.2 THE LIMITATIONS OF DTDS
48
48
5.3 W3C XML SCHEMA DOCUMENTS (XSD)
Schemas
Specify XML document structure
Do not use EBNF grammar
Use XML syntax
Can be manipulated like other XML documents
Require validating parsers
XML schemas
Schema vocabulary the W3C created
Recommendation
Schema valid
XML document that conforms to a schema document
Use .xsd extension
49
5.4 W3C XML SCHEMA DOCUMENTS
50
5.5 W3C XML SCHEMA DOCUMENTS
51
AGENDA
1. Introduction
2. XML Building blocks
3. Structuring Data
4. XML Namespaces
5. Document Type Definitions (DTDs) and Schemas
6. XML Vocabularies
7. XML Applications
52
6. XML VOCABULARIES
53
6.1 MATHML
54
6.2 CHEMICAL MARKUP LANGUAGE (CML)
55
6.3 MUSIC XML
Music distribution
Simplifies exchange of musical scores over Internet
Developed by Recordare
Mark up all type of music
DTD
Less powerful than Schema
Simpler to program
Relies heavily on elements rather than attributes
56
6.3 MUSIC XML
Fig. 20.15 MusicXML markup rendered by Finale 2003 (Courtesy of MakeMusic! Inc.).
57
6.4 RSS
58
7.5 OTHER MARKUP LANGUAGES
59
AGENDA
1. Introduction
2. XML Building blocks
3. Structuring Data
4. XML Namespaces
5. Document Type Definitions (DTDs) and Schemas
6. XML Vocabularies
7. XML Applications
60
8. XML APPLICATION1SEPARATE DATA
Benefits:
Changes in the underlying data will not require any changes to your HTML
61
XML APPLICATION2EXCHANGE DATA
Benefits:
Reduce the complexity of interpreting data
Easier to expand and upgrade a system
62
XML APPLICATION3STORE DATA
Benefits:
Accessible to more applications
63
XML APPLICATION4CREATE NEW LANGUAGE
64
XML SUPPORT IN IE 5.0+
65
MICROSOFT XML PARSER
66
9. JAVA APIS FOR XML
67
SUMMARY
68
REFERENCES
www.xml.com
msdn.microsoft.com/xml/default.asp
www.oasis-open.org/cover/xml.html
www.gca.org/whats_xml/default.htm
www.xmlinfo.com
http://www.w3.org
Teach Yourself XML in 21 Days, 3rd Edition
Learning XML, 2nd Edition
Hongming Yu presentation.
XML tutorial http://www.w3schools.com/w3c/
69
QUESTIONS???
70