What Is XML? XML stands for EXtensible Markup
Language XML is a markup language much like HTML XML was designed to carry data, not to display data XML tags are not predefined. We must define our own tags XML is designed to be self-descriptive XML is a W3C Recommendation
Difference between XML and HTML XML was designed to carry data, not displaying
data
XML has no predefined tags 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.
Why Do We Need XML? XML Separates Data from HTML XML Simplifies Data Sharing XML Simplifies Data Transport XML Simplifies Platform Changes XML is Used to Create New Internet
Languages
Data Sharing-XML J A V A
Partnership via Shared Information
Partner 1
Partner 2
Marshalling
XML
N E T
DTD XSLT
In
et n r te
Unmarshalling
XML
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 Comments in XML:
Structure of an XML document
Content Here
<EMPTY/>
An example of XML <note>
Rani PARSE TREE
Raja Message 9872108977
XML document life cycle
XML Document XSL Style Sheet
XML Parser TransFormatio n (XSLT)
Formatting (XSL-FO) Formatted Output
Result Tree
Why Is XML Important? Plain Text Easy to edit Useful for storing small amounts of data Possible to efficiently store large amounts of XML data through an XML front end to a database
Data Identification Tell you what kind of data you have Can be used in different ways by different applications
Why Is XML Important? Stylability XSL---Extensible Style sheet Language Different XSL formats can then be used to
display the same data in different ways
Hierarchical Faster to access Easier to rearrange
XML Building blocks Element Delimited by angle brackets Identify the nature of the content they surround General format: <element> … Empty element:
Attribute Name-value pairs that occur inside start-tags after element name, like: <element attribute=“value”>
XML 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 Content Elements can have different content types: element content, mixed content, simple content, or empty content and attributes
XML elements must follow the naming
rules
XML 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
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
What is XSL? Preferred style sheet language of XML a method for transforming XML documents a method for formatting XML documents
XSL consists of three parts: XSLT - a language for transforming XML
documents XPath - a language for navigating in XML documents XSL-FO-a language for formatting in XML documents
CSS & XSL CSS XSL Can be used with HTML? yes
no
Can be used with XML?
yes
yes
Transformation language? yes Syntax
no CSS
XML
XML Application1—Separate data XML can Separate Data from HTML Store data in separate XML files Using HTML for layout and display
Benefits: Changes in the underlying data will not require any changes to your HTML
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.
Benefits: Reduce the complexity of interpreting data Easier to expand and upgrade a system
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
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
Document Type Declaration ]> <note>
Tove Jani Reminder Don't forget me this weekend!
What is XSLT? XSLT stands for XSL Transformations XSLT transforms an XML document into another
XML document XSLT is a W3C Recommendation XSLT uses XPath to find information in an XML document. XPath is used to navigate through elements and attributes in XML documents.
Simple XML File
1"?>
Belgian Waffles <price>$5.95 <description> two of our famous Belgian Waffles 650
XSLT Style Sheet -
xmlns="http://www.w3.org/1999/xhtml"> - - <xsl:for-each select="breakfast_menu/food"> -
- <span style="font-weight:bold"> <xsl:value-of select="name" /> <xsl:value-of select="price" />
<xsl:value-of select="description" /> - <span style="font-style:italic"> ( <xsl:value-of select="calories" /> calories per serving)
document XPath uses path expressions to navigate in XML documents XPath contains a library of standard functions XPath is a major element in XSLT XPath is a W3C Standard
What is XQuery? XQuery is the language for querying XML data XQuery for XML is like SQL for databases XQuery is built on XPath expressions XQuery is supported by all the major database
+ HTTP. The HTTP protocol is the most used Internet protocol. XML provides a language which can be used between different platforms and programming languages and still express complex messages and functions. Web services platform elements SOAP
(Simple Object Access Protocol) UDDI (Universal Description, Discovery and Integration)
describing Web services and how to access them. WSDL stands for Web Services Description Language WSDL is written in XML WSDL is an XML document WSDL is also used to locate Web services WSDL is not yet a W3C standard
can register and search for Web services. UDDI stands for Universal Description, Discovery and Integration UDDI is a directory for storing information about web services UDDI is a directory of web service interfaces described by WSDL UDDI communicates via SOAP UDDI is built into the Microsoft .NET platform
http://www.w3schools.com/w3c/ A technical introduction to XML http://www.xml.com/pub/a/98/10/guide0.ht ml