Presentation 6: Introduction to XML and related technologies.

Slides:



Advertisements
Similar presentations
XML-XSL Introduction SHIJU RAJAN SHIJU RAJAN Outline Brief Overview Brief Overview What is XML? What is XML? Well Formed XML Well Formed XML Tag Name.
Advertisements

Copyright © 2003 Pearson Education, Inc. Slide 8-1 Created by Cheryl M. Hughes, Harvard University Extension School Cambridge, MA The Web Wizards Guide.
What is XML? a meta language that allows you to create and format your own document markups a method for putting structured data into a text file; these.
Internet Technology 1 Presentation 10: XML technologies.
1 Web Data Management XML Schema. 2 In this lecture XML Schemas Elements v. Types Regular expressions Expressive power Resources W3C Draft:
Presentation 6: Introduction to XML and related technologies – for use with SOAP / WSDL = Web services.
1 XML DTD & XML Schema Monica Farrow G30
1 Extensible Markup Language: XML HTML: portable, widely supported protocol for describing how to format data XML: portable, widely supported protocol.
XML Schemas Microsoft XML Schemas W3C XML Schemas.
1 Extensible Markup Language: XML HTML: portable, widely supported protocol for describing how to format data XML: portable, widely supported protocol.
Outline IS400: Development of Business Applications on the Internet Fall 2004 Instructor: Dr. Boris Jukic XML.
XML An introduction. xml XML like HTML is created from the Standard Generalized Markup Language, SGML.
1 Extensible Markup Language: XML HTML: widely supported protocol for formatting data XML: widely supported protocol for describing data XML is quickly.
 2001 Prentice Hall, Inc. All rights reserved. Chapter 5 – Creating Markup with XML Outline 5.1Introduction 5.2Introduction to XML Markup 5.3Parsers and.
COS 381 Day 16. Agenda Assignment 4 posted Due April 1 There was no resubmits of Assignment Capstone Progress report Due March 24 Today we will discuss.
September 15, 2003Houssam Haitof1 XSL Transformation Houssam Haitof.
8/6/2015Comp Sci 3461 XML_1 Ch. 7 Fall /6/2015Comp Sci 3462 Bibliography  W3C Recommendations  XML online tutorials.
Manohar – Why XML is Required Problem: We want to save the data and retrieve it further or to transfer over the network. This.
By: Shawn Li. OUTLINE XML Definition HTML vs. XML Advantage of XML Facts Utilization SAX Definition DOM Definition History Comparison between SAX and.
 2008 Pearson Education, Inc. All rights reserved XML.
 2001 Deitel & Associates, Inc. All rights reserved. 1 Chapter 27 – XML (Extensible Markup Language) Outline 27.1Introduction 27.2Structuring Data 27.3Document.
Introduction to XML cs3505. References –I got most of this presentation from this site –O’reilly tutorials.
Why XML ? Problems with HTML HTML design - HTML is intended for presentation of information as Web pages. - HTML contains a fixed set of markup tags. This.
1Computer Sciences Department Princess Nourah bint Abdulrahman University.
 2003 Prentice Hall, Inc. All rights reserved. Chapter 20 – Extensible Markup Language (XML) Outline 20.1 Introduction 20.2 Structuring Data 20.3 XML.
 2003 Prentice Hall, Inc. All rights reserved. 3 rd Edition Slide 1 Chapter 20 – Extensible Markup Language (XML) Outline 20.1 Introduction 20.2 Structuring.
 2002 Prentice Hall, Inc. All rights reserved. 1 Chapter 7 – Schemas Outline 7.1Introduction 7.2Schemas vs. DTDs 7.3Microsoft XML Schema: Describing Elements.
XML What is XML? XML v.s. HTML XML Components Well-formed and Valid Document Type Definition (DTD) Extensible Style Language (XSL) SAX and DOM.
1 © Netskills Quality Internet Training, University of Newcastle Introducing XML © Netskills, Quality Internet Training University.
XML 1 Enterprise Applications CE00465-M XML. 2 Enterprise Applications CE00465-M XML Overview Extensible Mark-up Language (XML) is a meta-language that.
Lecture 13 – XML and JSON SFDV3011 – Advanced Web Development Reference: 1.
CSCI/CMPE 4341 Topic: Programming in Python Chapter 9: Python XML Processing Xiang Lian The University of Texas – Pan American Edinburg, TX 78539
XP 1 DECLARING A DTD A DTD can be used to: –Ensure all required elements are present in the document –Prevent undefined elements from being used –Enforce.
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.
Intro. to XML & XML DB Bun Yue Professor, CS/CIS UHCL.
XML TUTORIAL Portions from w3 schools By Dr. John Abraham.
1 Tutorial 13 Validating Documents with DTDs Working with Document Type Definitions.
XML Extensible Markup Language
Web-based Programming Lanjut Pertemuan 9 Matakuliah: M0492 / Web-based Programming Lanjut Tahun: 2007.
Softsmith Infotech XML. Softsmith Infotech XML EXtensible Markup Language XML is a markup language much like HTML Designed to carry data, not to display.
Of 33 lecture 3: xml and xml schema. of 33 XML, RDF, RDF Schema overview XML – simple introduction and XML Schema RDF – basics, language RDF Schema –
McGraw-Hill/Irwin © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. Scripting with the DOM Ellen Pearlman Eileen Mullin Programming the Web.
 2004 Prentice Hall, Inc. All rights reserved. Chapter 20 – Extensible Markup Language (XML) Outline 20.1 Introduction 20.2 Structuring Data 20.3 XML.
Præsentation 3: Opsummering af Client-Side Teknologier del 2 Internetteknologi 2 (ITNET2)
 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 20 - Extensible Markup Language (XML) Outline 20.1 Introduction 20.2 Structuring Data 20.3 XML.
Introduction to XML This presentation covers introductory features of XML. What XML is and what it is not? What does it do? Put different related technologies.
XML Instructor: Charles Moen CSCI/CINF XML  Extensible Markup Language  A set of rules that allow you to create your own markup language  Designed.
Sheet 1XML Technology in E-Commerce 2001Lecture 2 XML Technology in E-Commerce Lecture 2 Logical and Physical Structure, Validity, DTD, XML Schema.
1 Tutorial 14 Validating Documents with Schemas Exploring the XML Schema Vocabulary.
Tutorial 13 Validating Documents with Schemas
C# and Windows Programming XML Processing. 2 Contents Markup XML DTDs XML Parsers DOM.
INFSY 547: WEB-Based Technologies Gayle J Yaverbaum, PhD Professor of Information Systems Penn State Harrisburg.
Internet & World Wide Web How to Program, 5/e. © by Pearson Education, Inc. All Rights Reserved.2.
When we create.rtf document apart from saving the actual info the tool saves additional info like start of a paragraph, bold, size of the font.. Etc. This.
What is XML? eXtensible Markup Language eXtensible Markup Language A subset of SGML (Standard Generalized Markup Language) A subset of SGML (Standard Generalized.
Computing & Information Sciences Kansas State University Friday, 20 Oct 2006CIS 560: Database System Concepts Lecture 24 of 42 Friday, 20 October 2006.
CO1552 – Web Application Development Further JavaScript: Part 1: The Document Object Model Part 2: Functions and Events.
XML CSC1310 Fall HTML (TIM BERNERS-LEE) HyperText Markup Language  HTML (HyperText Markup Language): December  Markup  Markup is a symbol.
Presentation 6: Introduction to XML and related technologies – for use with SOAP / WSDL = Web services.
CIS 228 The Internet 9/20/11 XHTML 1.0. “Quirks” Mode Today, all browsers support standards Compliant pages are displayed similarly There are multiple.
 XML derives its strength from a variety of supporting technologies.  Structure and data types: When using XML to exchange data among clients, partners,
Jackson, Web Technologies: A Computer Science Perspective, © 2007 Prentice-Hall, Inc. All rights reserved Chapter 7 Representing Web Data:
XML DOM Week 11 Web site:
Extensible Markup Language (XML) Pat Morin COMP 2405.
XML_1 Ch. 7 Fall /6/2017 Comp Sci 346.
Unit 4 Representing Web Data: XML
CIS 228 The Internet 9/20/11 XHTML 1.0.
XML in Web Technologies
Chapter 7 Representing Web Data: XML
Chapter 20 – Extensible Markup Language (XML)
Presentation transcript:

Presentation 6: Introduction to XML and related technologies

Ingeniørhøjskolen i Århus Slide 2 af 31 Outline Why an XML presentation? W3C & legacy of XML – ultra short XML markup and Namespaces DTD’s XML Schemas DOM/SAX The SOAP connection

Ingeniørhøjskolen i Århus Slide 3 af 31 Why do we need an XML presentation? Because SOAP, WSDL & UDDI is based on XML technologies Important to understand how the API’s work –Parsing mechanisms DOM SAX Why its slow ;)

Ingeniørhøjskolen i Århus Slide 4 af 31 W3C & the legacy of XML World Wide Consortium –Founded 1994 to lead the WWW into the future –For standardizations on the Internet –First Chairman: Tim Berners-Lee – founder of HTML & HTTP (or World Wide Web as we know it) –Run by Chairman, Director & Staff –Boards of members submits proposals and work to formulate –Ensures standardization of WWW technologies Like: XHTML, XML, XSL, CSS, SOAP, WAP etc. Members: Microsoft, IBM, SUN, Oracle and many others – Legacy: –Standard Generalized Markup Language (SGML) HTML has the same legacy - in fact / tightly coupled

Ingeniørhøjskolen i Århus Slide 5 af 31 XML markup eXtended Markup Language XML based on SGML (subset of) Like SGML for structure not layout (as HTML) XML targets the Internet – but is also being used for application exchange formats (Open Office, XMI) – CSVs XML is an W3C Recommendation – Structure decided by DTD or Schema (more later) Wide spread support for XML (hype agtig)

Ingeniørhøjskolen i Århus Slide 6 af 31 Presenting XML documents Examples fetched from DEITEL First we will look at a standalone XML document and its components (elements) –Note: XML document needs to be Wellformed

Ingeniørhøjskolen i Århus Slide 7 af 31 Article.xml Simple XML 9 10 September 19, Tem 14 Nieto XML is pretty easy Once you have mastered XHTML, XML is easily 20 learned. You must remember that XML is not for 21 displaying information but for managing information Optional XML declaration. Element article is the root element. Elements title, date, author, summary and content are child elements of article.

Ingeniørhøjskolen i Århus Slide 8 af 31 Browser displaying XML (unformatted) IE5.5 displaying article.xml.

Ingeniørhøjskolen i Århus Slide 9 af 31 Use of XML Namespaces XML namespaces used to avoid naming conflicts When several different elements are involved isnt always a book Keyword ”xmlns”

Ingeniørhøjskolen i Århus Slide 10 af 31 Namespace.xml <text:directory xmlns:text = "urn:deitel:textInfo" 7 xmlns:image = "urn:deitel:imageInfo"> A book list A funny picture Keyword xmlns creates two namespace prefixes, text and image. URIs ensure that a namespace is unique.

Ingeniørhøjskolen i Århus Slide 11 af 31 Defaultnamespace.xml <directory xmlns = "urn:deitel:textInfo" 7 xmlns:image = "urn:deitel:imageInfo"> A book list A funny picture Default namespace. Element file uses the default namespace. Element file uses the namespace prefix image.

Ingeniørhøjskolen i Århus Slide 12 af 31 DTDs Document Type Definition Extended Backus-Naur Form Defines how an XML document is structured –Required elements –Nesting of elements –Does not define types or behaviour If DTD is used – some parsers can decide if XML document is “valid” – which is more than just “wellformed”

Ingeniørhøjskolen i Århus Slide 13 af 31 Letter.dtd <!ELEMENT letter ( contact+, salutation, paragraph+, 5 closing, signature )> 6 7 <!ELEMENT contact ( name, address1, address2, city, state, 8 zip, phone, flag )> The ELEMENT element type declaration defines the rules for element letter. The plus sign ( + ) occurrence indicator specifies that the DTD allows one or more occurrences of an element. (2 contacs in our example) The contact element definition specifies that element contact contains child elements name, address1, address2, city, state, zip, phone and flag — in that order.

Ingeniørhøjskolen i Århus Slide 14 af 31 Letter.dtd <!ELEMENT letter ( contact+, salutation, paragraph+, 5 closing, signature )> 6 7 <!ELEMENT contact ( name, address1, address2, city, state, 8 zip, phone, flag )> The ATTLIST element type declaration defines an attribute (i.e., type ) for the contact element. Keyword #IMPLIED specifies that if the parser finds a contact element without a type attribute, the parser can choose an arbitrary value for the attribute or ignore the attribute and the document will be valid. Flag #PCDATA specifies that the element can contain parsed character data (i.e., text). See letter.xml next page

Ingeniørhøjskolen i Århus Slide 15 af 31 Letter.xml John Doe Main St Anytown 15 Anystate Joe Schmoe 23 Box Any Ave. 25 Othertown 26 Otherstate

Ingeniørhøjskolen i Århus Slide 16 af 31 Letter.xml Program Output 32 Dear Sir: It is our privilege to inform you about our new 35 database managed with XML. This new system allows 36 you to reduce the load of your inventory list server by 37 having the client machine perform the work of sorting 38 and filtering the data. 39 Sincerely 40 Mr. Doe 41 42

Ingeniørhøjskolen i Århus Slide 17 af 31 Program Output

Ingeniørhøjskolen i Århus Slide 18 af 31 XML Schemas DTD works OK – but –Is in Ex. Backus-Naur Form – why not use XML to describe? –Cannot declare a type to of an element – hundrede kr Could give problems XML Schemas –Use XML to describe the structure of XML documents … –Possible to give type information to XML definitions Not supported by all parsers yet Will live besides DTDs for a while

Ingeniørhøjskolen i Århus Slide 19 af 31 Book.xsd <xsd:schema xmlns:xsd = " 7 xmlns:deitel = " 8 targetNamespace = " <xsd:element name = "book" type = "deitel:BookType" 14 minOccurs = "1" maxOccurs = "unbounded"/> Namespace URI.Namespace prefix. Element element defines an element to be included in the XML document structure. Attributes name and type specify the element ’s name and data type, respectively. Element complexType defines an element type that has a child element named book. Attribute minOccurs specifies that books must contain a minimum of one book element. Attribute maxOccurs, with value unbounded specifies that books may have any number of book child elements.

Ingeniørhøjskolen i Århus Slide 20 af 31 Book.xsd <xsd:schema xmlns:xsd = " 7 xmlns:deitel = " 8 targetNamespace = " <xsd:element name = "book" type = "deitel:BookType" 14 minOccurs = "1" maxOccurs = "unbounded"/> A BookType has an Element named Title of Type “xsd:string” – which is defined at “

Ingeniørhøjskolen i Århus Slide 21 af 31

Ingeniørhøjskolen i Århus Slide 22 af 31 How to use XML? Need a parser (or a parser API) to access XML (as with CSV) Two commonly used methods: –DOM (Document Object Model) W3C Recommendation Makes a tree structure representation of an XML document in memory –SAX (Simple API for XML) Supported by diff. vendors Parses document line by line and sends events to subscribers Needs to parse every time access to XML document is needed DOM is better for –Slow to load XML document (need all) –Quick access to random read or update of XML (like WWW browser - BOM) –Requires a lot of memory (need to hold entire XML in mem) SAX is better for –Applications subscribing to certain parts of XML (event subscription) –Slow for random access to XML document (must parse every time)

Ingeniørhøjskolen i Århus Slide 23 af 31 Hvad er DOM DOM: Document Object Model – / / Hos W3C: –Standard for adgang til strukturerede dokumenter –Core DOM benyttes til XML –HTML DOM benyttes til HTML –Repræsentation af et dokument som et træ af objekter –Giver et ensartet interface på tværs af programmeringssprog –Programmerings API med interface til bl.a. JavaScript

Ingeniørhøjskolen i Århus Slide 24 af 31 DOM træstruktur Træstruktur i et XML dokument … eller et HTML document …table tbdoy … …… tr td tekst tekst ….

Ingeniørhøjskolen i Århus Slide 25 af 31 Example – using DOM on Article.xml We have looked at Article.xml We Will: –Look at the Article.xml document again –Look at the Tree Structure formed by loading it into a DOM –Use JavaScript to work on it

Ingeniørhøjskolen i Århus Slide 26 af Simple XML 9 10 September 19, Tem 14 Nieto XML is pretty easy Once you have mastered XHTML, XML is easily 20 learned. You must remember that XML is not for 21 displaying information but for managing information XML document – Article.XML

Ingeniørhøjskolen i Århus Slide 27 af 31 DOM Methods firstName lastName contents summary author date title article Tree structure for article.xml.

Ingeniørhøjskolen i Århus Slide 28 af 31 DOMExample.ht ml 1 2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 3 " A DOM Example <!-- 17 var xmlDocument = new ActiveXObject( "Microsoft.XMLDOM" ); xmlDocument.load( "article.xml" ); // get the root element 22 var element = xmlDocument.documentElement; document.writeln( 25 " Here is the root node of the document: " + 26 " " + element.nodeName + " " + 27 " The following are its child elements:" + 28 " " ); // traverse all child nodes of root element 31 for ( var i = 0; i < element.childNodes.length; i++ ) { 32 var curNode = element.childNodes.item( i ); 33 Instantiate a Microsoft XML Document Object Model object and assign it to reference xmlDocument. method load loads article.xml (Fig. 20.1) into memory.Property documentElement corresponds to the root element in the document (e.g., article ). Property nodeName corresponds to the name of an element, attribute, etc. Iterates through the root node’s children using property childNodes.Method item to obtain the child node at index i.

Ingeniørhøjskolen i Århus Slide 29 af 31 DOMExample.html 34 // print node name of each child element 35 document.writeln( " " + curNode.nodeName 36 + " " ); 37 } document.writeln( " " ); // get the first child node of root element 42 var currentNode = element.firstChild; document.writeln( " The first child of root node is: " + 45 " " + currentNode.nodeName + " " + 46 " whose next sibling is:" ); // get the next sibling of first child 49 var nextSib = currentNode.nextSibling; document.writeln( " " + nextSib.nodeName + 52 ". Value of " + 53 nextSib.nodeName + " element is: " ); var value = nextSib.firstChild; // print the text value of the sibling 58 document.writeln( " " + value.nodeValue + " " + 59 " Parent node of " + nextSib.nodeName + 60 " is: " + 61 nextSib.parentNode.nodeName + ". " ); 62 --> Retrieve the root node’s first child node (i.e., title ) using property firstChild. Property parentNode returns a node’s parent node.

Ingeniørhøjskolen i Århus Slide 30 af 31 Program Output

Ingeniørhøjskolen i Århus Slide 31 af 31 The SOAP Connection SOAP, WSDL, UDDI uses: – XML –Namespaces –and Schemas Original idea behind Webservices –Connection through the Internet –Good sense to use XML – W3C child –Everyone loves W3C practical solutions “that work”