Вы находитесь на странице: 1из 36

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 Partnership via Shared
A Information N
V E
A T

Partner 1 Partner 2
Marshalling Unmarshalling
DTD
XSLT

n et
XML r XML
te
In
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: <!– ITM Business Solutions Pvt. Ltd.-->
Structure of an XML document
<?xml version="1.0"?>
<PARENT>
<CHILD>
Content Here
</CHILD>
<EMPTY/>
</PARENT>
An example of XML
<?xml version="1.0" encoding="ISO-8859-1"?>
<note>
<to>Rani</to>
PARSE TREE
<from>Raja</from>
<heading>Message</heading>
<body>9872108977</body>
</note>
XML document life cycle

XML XML Parser


Document
Trans-
Format-
Formatio ting
n
XSL (XSL-FO) Formatted
(XSLT) Output
Style Sheet 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> … </element>
Empty 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? no
yes
Syntax 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
<?xml version="1.0"?>
<!DOCTYPE note [
<!ELEMENT note (to,from,heading,body)>
<!ELEMENT to (#PCDATA)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT heading (#PCDATA)>
<!ELEMENT body (#PCDATA)>
]>
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
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
 <?xml version="1.0" encoding="ISO-8859-
1"?>
 <?xml-stylesheet type="text/xsl"
href="simple.xsl"?>
 <breakfast menu>
 <food>
 <name>Belgian Waffles</name>
 <price>$5.95</price>
 <description> two of our famous Belgian
Waffles </description>
 <calories>650</calories>
 </food>
 </breakfast menu>
XSLT Style Sheet
 <?xml version="1.0" encoding="ISO-8859-1" ?>
 - <html xsl:version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/1999/xhtml">
 - <body style="font-family:Arial;font-size:12pt;background-color:#EEEEEE">
 - <xsl:for-each select="breakfast_menu/food">
 - <div style="background-color:teal;color:white;padding:4px">
 - <span style="font-weight:bold">
   <xsl:value-of select="name" />
   </span>
  -
   <xsl:value-of select="price" />
   </div>
 - <div style="margin-left:20px;margin-bottom:1em;font-size:10pt">
   <xsl:value-of select="description" />
 - <span style="font-style:italic">
   ( <xsl:value-of select="calories" /> calories per serving)
   </span>
   </div>
   </xsl:for-each>
   </body>
   </html
Converted HTML File
What is XPath?
XPath is a syntax for defining parts of an XML
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
<?xml version="1.0" encoding="ISO-8859-1" ?>
- <bookstore>
- <book category="COOKING">
  <title lang="en">Everyday Italian</title>
  <author>Giada De Laurentiis</author>
  <year>2005</year>
  <price>40.00</price>
  </book>
- <book category="CHILDREN">
  <title lang="en">Harry Potter</title>
  <author>J K. Rowling</author>
  <year>2005</year>
  <price>29.99</price>
  </book>
-   </bookstore>

Selecting title Nodes with Price>35

/bookstore/book[price>35]/title
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
engines (IBM, Oracle, Microsoft, etc.)
XQuery is a W3C Recommendation
Web services
The basic Web services platform is XML
+ 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)
What is WSDL?
WSDL is an XML-based language for
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
What is UDDI?
UDDI is a directory service where businesses
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
References
www.google.com
XML tutorial
http://www.w3schools.com/w3c/
A technical introduction to XML
http://www.xml.com/pub/a/98/10/guide0.ht
ml
Thank you!
Queries?

Вам также может понравиться