Presentation is loading. Please wait.

Presentation is loading. Please wait.

XML & Data Structures for the Internet Yingcai Xiao.

Similar presentations

Presentation on theme: "XML & Data Structures for the Internet Yingcai Xiao."— Presentation transcript:

1 XML & Data Structures for the Internet Yingcai Xiao

2 What is XML? What is it for? Examples How 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-independent. 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 WP 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 Proxy of Interface 2 Client 2 Application 1 UDDI Registry 1 WSDL Interface 1 UDDI Registry 2 Application 2WSDL Interface 2 SOAP WEB Proxy of Interface 1 Client 1 A Web service is an application that exposes Web methods over the Web.

7 . What is XML?

8  Extensible Markup Language.  De facto data language for the Internet.  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.. XML

9 XML Example (Guitars.xml) Gibson SG 1977 Tobacco Sunburst Rosewood Fender Stratocaster Black Maple

10 XML Example (Guitars.xml)  Document element (root): Guitars.  Guitar elements are children of Guitars.  Make contain data.  Empty element:  Nested elements.  The content of an XML document can be viewed as a tree.  Attributes

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).  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

14 . How to validate XML data?

15 Examples\c13\Validate\ Typo => xsd:Year should be xsd:string run.bat Validate Guitars.xml Guitars.xsd run-bad-xml.bat Validate Guitars-Missing-Make.xml Guitars.xsd Example: 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 Level-2-Core.  SAX: Simple API for XML, unofficial,  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.GetElementsByTagName ("Guitar"); foreach (XmlNode node in nodes) { Console.WriteLine(“Maker {0}; Model {1}", node["Make"].InnerText, node["Model"].InnerText); }

19  XML Path Language  For addressing parts of an XML document.  “/Guitars/Guitar” is an XPath expression.  XPath

20 . How to display XML data with styles?

21 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.CSS 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 tes/quotes.aspx/ XSL

22 . How to translate XML into other languages?

23  Extensible Stylesheet Language Transformations.  Converting XML documents into HTML documents.  Converting HTML documents into other XML documents.  Example XML\Transform\Transform.cs XSL Transformations (XSLT)

24 How to Program the Internet? (Write code that runs on the Internet) Web Service & Cloud Computing

Download ppt "XML & Data Structures for the Internet Yingcai Xiao."

Similar presentations

Ads by Google