XML - Basics and more

Download Report

Transcript XML - Basics and more

XML
BASICS and more…
What is XML?

In common:
 XML
is a standard, simple, self-describing way of
encoding both text and data so that content can be
processed with relatively little human intervention
and exchanged across diverse hardware, operating
systems, and applications
What is XML??
stands for EXtensible Markup Language
 is a markup language much like HTML
 was designed to describe data
 tags are not predefined
 you must define your own tags
 uses a Document Type Definition (DTD) or
an XML Schema to describe the data

Differences between HTML & XML
It's quite similar to HTML
 2 fundamental differences

 Separation
of form and content
Tags define structure and content of the data
 Form defined in a style sheet (XSL)

 XML
is extensible
HTML Tags defined by W3C
 In XML everyone can define his own tags

What does it look like?
<?xml version="1.0"?>
<note>
<from>Steffen D</from>
<to>Christiane</to>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
What does it do?
Nothing!
 Note with a header and message body
 Has a sender and a receiver

Just pure information wrapped in XML Tags
 Software is needed to send, receive or read it

What does it mean?

<?xml version="1.0"?>
 The
XML declaration
 should always be included
 defines the XML version of the document

<note>
 the
first element of the document (root element)
What does it mean??

<from>Steffen D</from><to>Christiane</to>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
 4 child elements of the root (to, from, heading, and
body)

</note>
 end
of the root element
What rules to obey!

In XML all elements must have a closing tag
 Except
<tag/>
elements must be properly nested
<b><i></b></i>
 XML tags are case sensitive
 All documents must have a single
tag pair to define the root element

<root>
<child>
<subchild>
</subchild>
</child>
</root>
What rules to obey!!
Children are nested within root
 attribute values

 Provide
additional information about elements
 <note date=’ 5/12/03’>
 Put single or double quotes around
 Don’t use them too often
Produce VALID XML
Define set of rules
 Apply to all tags in your XML language
 most common way is to use a DTD (Document
Type Definition)
 document that follows all of the rules for that
language is called valid


<!DOCTYPE note SYSTEM "InternalNote.dtd">
Document Type Definition (DTD)
define what kind of data each element will
consist of
 method is borrowed from SGML and has its
own specific language and syntax
 controls the syntax and semantics of an XML
file

Document Type Definition ((DTD))

<!ELEMENT note (from, to+, heading, body)>
 Specifying
the sequence in which elements appear
 Specifying the number of times an element can
appear ( +,*,?,nothing)

<!ELEMENT body (#CDATA )>
 type
of data an item can hold
 CDATA - any character also HTML
Conclusion
if a document follows all rules it is
well formed
 documents are required to be well-formed
 offers widely adopted way of representing text
and data
 can be processed easily
 perfect to store and exchange data
 easy to read and understand

the end
Thank you for your attention
Any questions?
Resources
World Wide Web Consortium (W3C)
http://www.w3.org/XML
 W3Schools

 http://www.w3schools.com/

UC Computing & Communications


http://www.washington.edu/computing/training/540/index.html
Software AG
 http://www.softwareag.com/xml/about/starters.htm