Download - Introduction to XML
![Page 1: Introduction to XML](https://reader036.vdocuments.mx/reader036/viewer/2022081413/546b38a5af795902048b5eb5/html5/thumbnails/1.jpg)
XML IntroductionXML Introduction
XMLXML
http://yht4ever.blogspot.com
[email protected] - NIIT Quang Trung
07/2007
![Page 2: Introduction to XML](https://reader036.vdocuments.mx/reader036/viewer/2022081413/546b38a5af795902048b5eb5/html5/thumbnails/2.jpg)
XML Introdution Slide 2
Contents
Exercises
Application of XML
Introduction to XML
Why Is XML Important?
Markup languages
![Page 3: Introduction to XML](https://reader036.vdocuments.mx/reader036/viewer/2022081413/546b38a5af795902048b5eb5/html5/thumbnails/3.jpg)
XML Introdution Slide 3
Markup languages
A markup language must specify What markup is allowed What markup is required How markup is to be distinguished from text What the markup means
XML only specify the first three, the fourth is specified by DTD
![Page 4: Introduction to XML](https://reader036.vdocuments.mx/reader036/viewer/2022081413/546b38a5af795902048b5eb5/html5/thumbnails/4.jpg)
XML Introdution Slide 4
SGML(ISO 8879)
Standard Generalized Markup Language
The international standard for defining descriptions of structure and content in text documents
Interchangeable: device-independent, system-independent
Tags are not predefined
Using DTD to validate the structure of the document
Large, powerful, and very complex
Heavily used in industrial and commercial for over a decade
![Page 5: Introduction to XML](https://reader036.vdocuments.mx/reader036/viewer/2022081413/546b38a5af795902048b5eb5/html5/thumbnails/5.jpg)
XML Introdution Slide 5
HTML(RFC 1866)
HyperText Markup Language
A small SGML application used on web (a DTD and a set of processing conventions)
Can only use a predefined set of tags
![Page 6: Introduction to XML](https://reader036.vdocuments.mx/reader036/viewer/2022081413/546b38a5af795902048b5eb5/html5/thumbnails/6.jpg)
XML Introdution Slide 6
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
![Page 7: Introduction to XML](https://reader036.vdocuments.mx/reader036/viewer/2022081413/546b38a5af795902048b5eb5/html5/thumbnails/7.jpg)
XML Introdution Slide 7
Difference between XML and HTML
XML was designed to carry data, not displaying data
XML is not a replacement for HTML.
Different goals:XML was designed to describe data and to focus on what data is.HTML was designed to display data and to focus on how data looks.
HTML is about displaying information, XML is about describing information.
![Page 8: Introduction to XML](https://reader036.vdocuments.mx/reader036/viewer/2022081413/546b38a5af795902048b5eb5/html5/thumbnails/8.jpg)
XML Introdution Slide 8
An example of XML
<?xml version="1.0"?><products>
<product id="PRO001"><name>Coca Cola</name><price>5000</price>
</product><product id="PRO002">
<name>Pepsi</name><price>4500</price>
</product><product id="PRO003">
<name>Number One</name><price>5500</price>
</product></products>
![Page 9: Introduction to XML](https://reader036.vdocuments.mx/reader036/viewer/2022081413/546b38a5af795902048b5eb5/html5/thumbnails/9.jpg)
XML Introdution Slide 9
Contents
Exercises
Application of XML
Introduction to XML
Why Is XML Important?
Markup languages
![Page 10: Introduction to XML](https://reader036.vdocuments.mx/reader036/viewer/2022081413/546b38a5af795902048b5eb5/html5/thumbnails/10.jpg)
XML Introdution Slide 10
Why Is XML Important?
Plain Text Easy to edit Platform independent
Data Identification Tell you what kind of data you have Can be used in different ways by different
applications
Easily Processed Vendor-neutral standard
![Page 11: Introduction to XML](https://reader036.vdocuments.mx/reader036/viewer/2022081413/546b38a5af795902048b5eb5/html5/thumbnails/11.jpg)
XML Introdution Slide 11
Why Is XML Important?
Stylability Inherently style-free XSL---Extensible Stylesheet Language Different XSL formats can then be used to display
the same data in different ways
Inline Reusability Can be composed from separate entities Modularize your documents
![Page 12: Introduction to XML](https://reader036.vdocuments.mx/reader036/viewer/2022081413/546b38a5af795902048b5eb5/html5/thumbnails/12.jpg)
XML Introdution Slide 12
Why is XML important?
Linkability -- XLink and XPointer Simple unidirectional hyperlinks Two-way links Multiple-target links “Expanding” links
Hierarchical Faster to access Easier to rearrange
![Page 13: Introduction to XML](https://reader036.vdocuments.mx/reader036/viewer/2022081413/546b38a5af795902048b5eb5/html5/thumbnails/13.jpg)
XML Introdution Slide 13
Contents
Exercises
Application of XML
Introduction to XML
Why Is XML Important?
Markup languages
![Page 14: Introduction to XML](https://reader036.vdocuments.mx/reader036/viewer/2022081413/546b38a5af795902048b5eb5/html5/thumbnails/14.jpg)
XML Introdution Slide 14
XML Building blocks
PI (Processing Instruction)TagsElementsContentAttributesEntitiesComments
![Page 15: Introduction to XML](https://reader036.vdocuments.mx/reader036/viewer/2022081413/546b38a5af795902048b5eb5/html5/thumbnails/15.jpg)
XML Introdution Slide 15
XML Building blocks--Prolog
The part of an XML document that precedes the XML data
Includes
A declaration: version [, encoding, standalone] An optional DTD (Document Type Definition )
Example
<?xml version=“1.0” encoding=“UTF-8” standalone=“yes”?>
![Page 16: Introduction to XML](https://reader036.vdocuments.mx/reader036/viewer/2022081413/546b38a5af795902048b5eb5/html5/thumbnails/16.jpg)
XML Introdution Slide 16
Tags
Tags are used to specify a name for a given piece of information.
A tag consists of opening and closing angular brackets (<>) that enclose the name of the tag.
Example<EMP_NAME>Nick Shaw</EMP_NAME>
![Page 17: Introduction to XML](https://reader036.vdocuments.mx/reader036/viewer/2022081413/546b38a5af795902048b5eb5/html5/thumbnails/17.jpg)
XML Introdution Slide 17
Elements
Elements are represented using tags.An XML document must always have a
root element.General format: <element> … </element>Empty element: <empty-Element />
Example<Authorname>John Smith</Authorname>
![Page 18: Introduction to XML](https://reader036.vdocuments.mx/reader036/viewer/2022081413/546b38a5af795902048b5eb5/html5/thumbnails/18.jpg)
XML Introdution Slide 18
Elements
XML Elements are Extensible XML documents can be extended to carry more information
XML Elements have Relationships Elements are related as parents and children
Elements have ContentElements can have different content types: element content, mixed content, simple content, or empty content and attributes
XML elements must follow the naming rules
![Page 19: Introduction to XML](https://reader036.vdocuments.mx/reader036/viewer/2022081413/546b38a5af795902048b5eb5/html5/thumbnails/19.jpg)
XML Introdution Slide 19
Content
Content refers to the information represented by the elements of an XML document. Character or data content Element content Combination or mixed content
Example<BOOKNAME>The Painted House</BOOKNAME>
![Page 20: Introduction to XML](https://reader036.vdocuments.mx/reader036/viewer/2022081413/546b38a5af795902048b5eb5/html5/thumbnails/20.jpg)
XML Introdution Slide 20
Attributes
Located in the start tag of elements Provide additional information about elements Often provide information that is not a part of data Must be enclosed in quotes Should I use an element or an attribute?
metadata (data about data) should be stored as attributes, and that data itself should be stored as elements
![Page 21: Introduction to XML](https://reader036.vdocuments.mx/reader036/viewer/2022081413/546b38a5af795902048b5eb5/html5/thumbnails/21.jpg)
XML Introdution Slide 21
Entities
An entity is a name that is associated with a block of data.. Internal Entities: < , >… General Entities
• General entities are declared in Document Type Definitions (DTD)
• Example– <! ENTITY nyt "The Times of India.">– For more information, please visit &nyt; Thank you!
Parameter Entities• Are only declared and used in DTDs
– <!ENTITY % bool ("yes | no")>– <ATTLIST membership (%bool;)>
![Page 22: Introduction to XML](https://reader036.vdocuments.mx/reader036/viewer/2022081413/546b38a5af795902048b5eb5/html5/thumbnails/22.jpg)
XML Introdution Slide 22
Comments
Comments are statements used to explain the XML code.
Example <!--PRODUCTDATA is the root element-->
The text contained within a comment entry cannot have two consecutive hyphens <!--PRODUCTDATA is the –-root element-->
![Page 23: Introduction to XML](https://reader036.vdocuments.mx/reader036/viewer/2022081413/546b38a5af795902048b5eb5/html5/thumbnails/23.jpg)
XML Introdution Slide 23
XML Syntax
All XML elements must have a closing tag
XML tags are case sensitive
All XML elements must be properly nested
All XML documents must have a root tag
Attribute values must always be quoted
With XML, white space is preserved
With XML, a new line is always stored as LF
![Page 24: Introduction to XML](https://reader036.vdocuments.mx/reader036/viewer/2022081413/546b38a5af795902048b5eb5/html5/thumbnails/24.jpg)
Anatomy of an element
<p type="rule">Use a hyphen: ­.</p>
Start-tag Content End-tag
Element
Ele
men
t ty
peAttribute
nameAttribut
evalue
(character)entity
reference Ele
men
t ty
pe
Attribute
![Page 25: Introduction to XML](https://reader036.vdocuments.mx/reader036/viewer/2022081413/546b38a5af795902048b5eb5/html5/thumbnails/25.jpg)
XML Introdution Slide 25
XML Validation
"Well Formed" XML document--correct XML syntax
"Valid" XML document “well formed” Conforms to the rules of a DTD (Document Type Definition)
XML DTD defines the legal building blocks of an XML document Can be inline in XML or as an external reference
XML Schema an XML based alternative to DTD, more powerful Support namespace and data types
![Page 26: Introduction to XML](https://reader036.vdocuments.mx/reader036/viewer/2022081413/546b38a5af795902048b5eb5/html5/thumbnails/26.jpg)
XML Introdution Slide 26
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
![Page 27: Introduction to XML](https://reader036.vdocuments.mx/reader036/viewer/2022081413/546b38a5af795902048b5eb5/html5/thumbnails/27.jpg)
XML Introdution Slide 27
Contents
Exercises
Application of XML
Introduction to XML
Why Is XML Important?
Markup languages
![Page 28: Introduction to XML](https://reader036.vdocuments.mx/reader036/viewer/2022081413/546b38a5af795902048b5eb5/html5/thumbnails/28.jpg)
XML Introdution Slide 28
XML Application1—Separate data
XML can Separate Data from HTML Store data in separate XML files Using HTML for layout and display Using Data Islands Data Islands can be bound to HTML elements
Benefits:
Changes in the underlying data will not require any changes to your HTML
![Page 29: Introduction to XML](https://reader036.vdocuments.mx/reader036/viewer/2022081413/546b38a5af795902048b5eb5/html5/thumbnails/29.jpg)
XML Introdution Slide 29
XML Application2—Exchange data
XML is used to Exchange Data Text format Software-independent, hardware-independent Exchange data between incompatible systems, given that
they agree on the same tag definition. Can be read by many different types of applications
Benefits: Reduce the complexity of interpreting data Easier to expand and upgrade a system
![Page 30: Introduction to XML](https://reader036.vdocuments.mx/reader036/viewer/2022081413/546b38a5af795902048b5eb5/html5/thumbnails/30.jpg)
XML Introdution Slide 30
XML Application3—Store Data
XML can be used to Store Data Plain text file Store data in files or databases Application can be written to store and retrieve
information from the store Other clients and applications can access your XML files as
data sources
Benefits:Accessible to more applications
![Page 31: Introduction to XML](https://reader036.vdocuments.mx/reader036/viewer/2022081413/546b38a5af795902048b5eb5/html5/thumbnails/31.jpg)
XML Introdution Slide 31
XML Application4—Create new language
XML can be used to Create new Languages WML (Wireless Markup Language) used to markup Internet
applications for handheld devices like mobile phones (WAP)
MusicXML used to publishing musical scores RSS. MathML.
![Page 32: Introduction to XML](https://reader036.vdocuments.mx/reader036/viewer/2022081413/546b38a5af795902048b5eb5/html5/thumbnails/32.jpg)
XML Introdution Slide 32
XML support in IE 5.0+
Internet Explorer 5.0 has the following XML support: Viewing of XML documents Full support for W3C DTD standards XML embedded in HTML as Data Islands Binding XML data to HTML elements Transforming and displaying XML with XSL Displaying XML with CSS Access to the XML DOM (Document Object Model)
*Netscape 6.0 also have full XML support
![Page 33: Introduction to XML](https://reader036.vdocuments.mx/reader036/viewer/2022081413/546b38a5af795902048b5eb5/html5/thumbnails/33.jpg)
XML Introdution Slide 33
Microsoft XML Parser
Comes with IE 5.0 The parser features a language-neutral programming
model that supports: JavaScript, VBScript, Perl, VB, Java, C++ and more W3C XML 1.0 and XML DOM DTD and validation
![Page 34: Introduction to XML](https://reader036.vdocuments.mx/reader036/viewer/2022081413/546b38a5af795902048b5eb5/html5/thumbnails/34.jpg)
XML Introdution Slide 34
Java APIs for XML
JAXP: Java API for XML Processing JAXB: Java Architecture for XML Binding JDOM: Java DOM DOM4J: an alternative to JDOM JAXM: Java API for XML Messaging (asynchronous) JAX-RPC: Java API for XML-based Remote Process
Communications (synchronous) JAXR: Java API for XML Registries
![Page 35: Introduction to XML](https://reader036.vdocuments.mx/reader036/viewer/2022081413/546b38a5af795902048b5eb5/html5/thumbnails/35.jpg)
XML Introdution Slide 35
XML is a self-descriptive language XML is a powerful language to describe structure
data for web application XML is currently applied in many fields Many vendors already supports or will support XML
Conclusion
![Page 36: Introduction to XML](https://reader036.vdocuments.mx/reader036/viewer/2022081413/546b38a5af795902048b5eb5/html5/thumbnails/36.jpg)
XML Introdution Slide 36
Reference
http://www.w3.orgTeach Yourself XML in 21 Days, 3rd EditionLearning XML, 2nd EditionHongming Yu presentation.XML tutorial
http://www.w3schools.com/w3c/
![Page 37: Introduction to XML](https://reader036.vdocuments.mx/reader036/viewer/2022081413/546b38a5af795902048b5eb5/html5/thumbnails/37.jpg)
XML Introdution Slide 37
Q&A
Feel free to post questions at http://yht4ever.blogspot.com.
or email to: [email protected] or [email protected]
![Page 38: Introduction to XML](https://reader036.vdocuments.mx/reader036/viewer/2022081413/546b38a5af795902048b5eb5/html5/thumbnails/38.jpg)
http://yht4ever.blogspot.com