XML - PowerPoint PPT Presentation

Loading...

PPT – XML PowerPoint presentation | free to download - id: 7173d7-NjRlZ



Loading


The Adobe Flash plugin is needed to view this content

Get the plugin now

View by Category
About This Presentation
Title:

XML

Description:

XML & Data Structures for the Internet Yingcai Xiao What is XML? What is it for? Examples How to write? How to validate? How to read? How to display? – PowerPoint PPT presentation

Number of Views:2
Avg rating:3.0/5.0
Date added: 25 April 2018
Slides: 25
Provided by: Jason500
Learn more at: http://www.cs.uakron.edu
Category:

less

Write a Comment
User Comments (0)
Transcript and Presenter's Notes

Title: XML


1
XML Data Structures for the Internet
  • Yingcai Xiao

2
What is XML?What is it for?ExamplesHow to
write?How to validate?How to read?How to
display?How to format? How to translate?
3
  • A Common Language for the Internet (free of
    compilation and translation)?

4
  • A Common Language for the Internet
  • Tim Berners-Lee
  • ASCII text (ISO/IEC 8859-1) is platform-independen
    t.
  • HTTP (Hyper Text Transport Protocol)
  • e.g.
  • GET wp.html
  • Assembly Language for the Internet
  • HTML (Hyper Text Markup Language)
  • High-level language for the Internet)
  • hyper text text that describes other text
  • tags type definition of text in text
  • lttitlegtWPlt/titlegt
  • all tags are predefined in HTML
  • only system defined types, no user defined types
  • Recognizable by all types of computers. (World
    Wide Web)

5
  • A Common Language for the Internet
  • XML (eXtensible Markup Language)
  • Allow user defined tags (types)
  • SOAP (Simple Object Access Protocol)
  • Standards for defining objects for the Internet
  • Based on XML
  • WSDL (Web Service Description Language)
  • Standards for describing web services for the
    Internet
  • Based on XML

6
(XML) Web Services
A Web service is an application that exposes Web
methods over the Web.
7
What is XML?
.
8
XML
  • Extensible Markup Language.
  • De facto data language for the Internet.
    http//www.w3.org/TR/REC-XML.
  • HTML expresses appearance
  • XML describes data and its structure.
  • Text based (platform-independent).
  • Object-oriented data representation.
  • Has no predefined tags.
  • Provides rules to format data.

.
9
XML Example (Guitars.xml)
  • lt?xml version"1.0"?gt
  • ltGuitarsgt
  • ltGuitargt
  • ltMakegtGibsonlt/Makegt
  • ltModelgtSGlt/Modelgt
  • ltYeargt1977lt/Yeargt
  • ltColorgtTobacco Sunburstlt/Colorgt
  • ltNeckgtRosewoodlt/Neckgt
  • lt/Guitargt
  • ltGuitargt
  • ltMakegtFenderlt/Makegt
  • ltModelgtStratocasterlt/Modelgt
  • ltYeargtlt/Yeargt
  • ltColorgtBlacklt/Colorgt
  • ltNeckgtMaplelt/Neckgt
  • lt/Guitargt
  • lt/Guitarsgt

10
XML Example (Guitars.xml)
  • Document element (root) Guitars.
  • Guitar elements are children of Guitars.
  • Make contain data.
  • Empty element ltYeargtlt/Yeargt
  • Nested elements.
  • The content of an XML document can be viewed as a
    tree.
  • Attributes
  • ltGuitar Year"1977"gt

11
.
How to define an XML data structure?
12
XML Description
  • XML Elements text-based object-oriented data
    (object)
  • Error checking?
  • Text-based object-oriented type (class)
    definition?
  • Early days document type definitions (DTDs).
  • Today XML Schema Definitions (XSDs).
    http//www.w3.org/TR/xmlschema-1
    http//www.w3.org/TR/xmlschema-2.
  • Schema a collection of meta data.
  • Meta data data that describes data.
  • XSD is an XML-based language for describing XML
    documents and the types that they contain.

13
Example Guitars.xsd
lt?xml version"1.0"?gt ltxsdschema id"Guitars"
xmlns"" xmlnsxsd"http//www.w3.org/2001/XMLSche
ma"gt ltxsdelement name"Guitars"gt
ltxsdcomplexTypegt ltxsdchoice
maxOccurs"unbounded"gt ltxsdelement
name"Guitar"gt ltxsdcomplexTypegt
ltxsdsequencegt ltxsdelement
name"Make" type"xsdstring" /gt
ltxsdelement name"Model" type"xsdstring" /gt
ltxsdelement name"Year"
type"xsdYear minOccurs"0" /gt
ltxsdelement name"Color" type"xsdstring
minOccurs"0" /gt ltxsdelement
name"Neck" type"xsdstring minOccurs"0" /gt
lt/xsdsequencegt
lt/xsdcomplexTypegt lt/xsdelementgt
lt/xsdchoicegt lt/xsdcomplexTypegt
lt/xsdelementgt lt/xsdschemagt
14
.
How to validate XML data?
15
Example Guitars.xsd
  • Examples\c13\Validate\
  • Typo gt xsdYear should be xsdstring
  • run.bat
  • Validate Guitars.xml Guitars.xsd
  • run-bad-xml.bat
  • Validate Guitars-Missing-Make.xml Guitars.xsd

16
.
How to read XML data?
17
XML Parsers
  • Most XML parsers implement one of two popular
    APIs DOM or SAX.
  • DOM Document Object Model http//www.w3.org/TR/DO
    M-Level-2-Core.
  • SAX Simple API for XML, unofficial,
    http//www.saxproject.org.
  • Examples of using XmlDocument
  • Validate
  • ReadXml
  • XmlView
  • Transform
  • Quotes
  • ExpressAnalyzer

18
ReadXml.cs (also see XmlView)
  • using System
  • using System.Xml
  • class MyApp
  • static void Main ()
  • XmlDocument doc new XmlDocument ()
  • doc.Load ("Guitars.xml")
  • XmlNodeList nodes doc.GetElementsByTagNa
    me ("Guitar")
  • foreach (XmlNode node in nodes)
  • Console.WriteLine(Maker 0 Model 1",
    node"Make".InnerText, node"Model".InnerText)

19
XPath
  • XML Path Language
  • For addressing parts of an XML document.
  • /Guitars/Guitar is an XPath expression.
  • http//www.w3.org/TR/xpath.

20
.
How to display XML data with styles?
21
XSL
  • XSL is a language for expressing style sheets.
  • Adopted from CSS, a file that describes how to
    display an XML document of a given type.
  • Styling requires a source XML documents,
    containing the information that the style sheet
    will display and the style sheet itself which
    describes how to display a document of a given
    type. It supports Formatting Objects.
  • It also adds a transformation language for XML
    documents XSLT.
  • Example XML\Quotes\Quotes.xsl
  • http//winserv1.cs.uakron.edu/Examples/C13/Quotes
    /quotes.aspx/

22
How to translate XML into other languages?
.
23
XSL Transformations (XSLT)
  • Extensible Stylesheet Language Transformations.
  • Converting XML documents into HTML documents.
  • Converting HTML documents into other XML
    documents.
  • Example XML\Transform\Transform.cs

24
How to Program the Internet?(Write code that
runs on the Internet)
  • Web Service
  • Cloud Computing
About PowerShow.com