1 Dr Alexiei Dingli XML Technologies XML Advanced.

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

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.
SPECIAL TOPIC XML. Introducing XML XML (eXtensible Markup Language) ◦A language used to create structured documents XML vs HTML ◦XML is designed to transport.
An Introduction to XML Based on the W3C XML Recommendations.
XHTML1 Building Document Structure. XHTML2 Objectives In this chapter, you will: Learn how to create Extensible Hypertext Markup Language (XHTML) documents.
Tutorial 16 Working with Dynamic Content and Styles.
Tutorial 9 Working with XHTML. XP Objectives Describe the history and theory of XHTML Understand the rules for creating valid XHTML documents Apply a.
Creating a Well-Formed Valid Document. 2 Objectives Introducing XHTML Creating a Well-Formed Document Creating a Valid Document Creating an XHTML Document.
XML Session 3 Data Islands Document Object Model ParsingNamespaces.
Jackson, Web Technologies: A Computer Science Perspective, © 2007 Prentice-Hall, Inc. All rights reserved Chapter 7 Representing Web Data:
Introduction to XML This material is based heavily on the tutorial by the same name at
Working with Namespaces Combining XML Vocabularies in a Compound Document.
WORKING WITH NAMESPACES
Pemrograman Berbasis WEB XML part 2 -Aurelio Rahmadian- Sumber: w3cschools.com.
JavaScript & jQuery the missing manual Chapter 11
XML introduction to Ahmed I. Deeb Dr. Anwar Mousa  presenter  instructor University Of Palestine-2009.
JavaScript, Fifth Edition Chapter 1 Introduction to JavaScript.
XP Tutorial 9New Perspectives on Creating Web Pages with HTML, XHTML, and XML 1 Working with XHTML Creating a Well-Formed Valid Document Tutorial 9.
XP The University of Akron Summit College Business Technology Department Computer Information Systems 2440: 140 Internet Tools Instructor: Enoch E. Damson.
1 Fall 2006 Florida Atlantic University Department of Computer Science & Engineering COT 6930 Advanced Internet Programming Dr. Roy Levow Day 2.
HTML DOM.  The HTML DOM defines a standard way for accessing and manipulating HTML documents.  The DOM presents an HTML document as a tree- structure.
E X TENSIBLE M ARKUP L ANGUAGE (XML). What is XML?  XML stands for EXtensible Markup Language  XML is mainly designed to carry (or transmit) data, not.
XML CPSC 315 – Programming Studio Fall 2008 Project 3, Lecture 1.
JavaScript, Fourth Edition Chapter 12 Updating Web Pages with AJAX.
Representing Web Data: XML CSI 3140 WWW Structures, Techniques and Standards.
CSC 330 E-Commerce Teacher Ahmed Mumtaz Mustehsan Ahmed Mumtaz Mustehsan GM-IT CIIT Islamabad GM-IT CIIT Islamabad CIIT Virtual Campus, CIIT COMSATS Institute.
XP New Perspectives on XML, 2 nd Edition Tutorial 10 1 WORKING WITH THE DOCUMENT OBJECT MODEL TUTORIAL 10.
Introduction to XML History of XML Advantages of XML
Posting XML Data From the Client to a Server Eugenia Fernandez IUPUI.
Introduction to XML. What is XML? Extensible Markup Language XML Easier-to-use subset of SGML (Standard Generalized Markup Language) XML is a.
XHTML1 Building Document Structure Chapter 2. XHTML2 Objectives In this chapter, you will: Learn how to create Extensible Hypertext Markup Language (XHTML)
Representing Web Data: XML CSI 3140 WWW Structures, Techniques and Standards.
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 is designed to describe data and to focus on what data is. HTML is designed to display data and to focus on how data looks.  XML is created to structure,
Working with the XML Document Object Model ©NIITeXtensible Markup Language/Lesson 7/Slide 1 of 44 Objectives In this lesson, you will learn to: *Identify.
 2004 Prentice Hall, Inc. All rights reserved. 1 Chapter 34 - Case Study: Active Server Pages and XML Outline 34.1 Introduction 34.2 Setup and Message.
1 Tutorial 13 Validating Documents with DTDs Working with Document Type Definitions.
Avoid using attributes? Some of the problems using attributes: Attributes cannot contain multiple values (child elements can) Attributes are not easily.
INTRODUCTION TO JAVASCRIPT AND DOM Internet Engineering Spring 2012.
XSLT Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.
XP New Perspectives on XML, 2nd Edition Tutorial 2 1 TUTORIAL 2 WORKING WITH NAMESPACES.
XP Tutorial 16 New Perspectives on HTML, XHTML, and DHTML, Comprehensive 1 Working with Dynamic Content and Styles Creating a Dynamic Table of Contents.
XML EXtensible Markup Language. Agenda Introduction to XML XML Rules XML Elements XML Attributes XML Validation XML Exercises XML Namespaces XML CDATA.
XSD Presented by Kushan Athukorala. 2 Agenda XML Namespaces XML Schema XSD Indicators XSD Data Types XSD Schema References.
1 Tutorial 12 Working with Namespaces Combining XML Vocabularies in a Compound Document.
1 Dr Alexiei Dingli XML Technologies SAX and DOM.
CISC 3140 (CIS 20.2) Design & Implementation of Software Application II Instructor : M. Meyer Address: Course Page:
Web Technologies Lecture 4 XML and XHTML. XML Extensible Markup Language Set of rules for encoding a document in a format readable – By humans, and –
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.
XML DTD. XML Validation XML with correct syntax is "Well Formed" XML. XML validated against a DTD is "Valid" XML.
SE-2840 Dr. Mark L. Hornick 1 Introduction to Ajax Asynchronous Javascript And XML.
XP Tutorial 9New Perspectives on HTML and XHTML, Comprehensive 1 Working with XHTML Creating a Well-Formed Valid Document Tutorial 9.
Dave Salinas. What is XML? XML stands for eXtensible Markup Language Markup language, like HTML HTML was designed to display data, whereas XML was designed.
Document Object Model.  The XML DOM (Document Object Model) defines a standard way for accessing and manipulating XML documents.  The DOM presents an.
Tutorial 9 Working with XHTML. New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition 2 Objectives Describe the history and theory of XHTML.
AJAX CS456 Fall Examples Where is AJAX used? Why do we care?
 XML derives its strength from a variety of supporting technologies.  Structure and data types: When using XML to exchange data among clients, partners,
1 CSC160 Chapter 1: Introduction to JavaScript Chapter 2: Placing JavaScript in an HTML File.
Jackson, Web Technologies: A Computer Science Perspective, © 2007 Prentice-Hall, Inc. All rights reserved Chapter 7 Representing Web Data:
Tutorial 9 Working with XHTML. XP Objectives Describe the history and theory of XHTML Understand the rules for creating valid XHTML documents Apply a.
XML DOM Week 11 Web site:
XP Tutorial 10 New Perspectives on JavaScript, Comprehensive 1 Working with Dynamic Content and Styles Creating a Dynamic Table of Contents.
1 Extensible Stylesheet Language (XSL) Extensible Stylesheet Language (XSL)
Unit 4 Representing Web Data: XML
Creating a Well-Formed Valid Document
Tutorial 9 Working with XHTML
WORKING WITH NAMESPACES
Chapter 7 Representing Web Data: XML
Week 11 Web site: XML DOM Week 11 Web site:
Tutorial 9 Working with XHTML
Presentation transcript:

1 Dr Alexiei Dingli XML Technologies XML Advanced

2 A Uniform Resource Identifier (URI) is a string of characters which identifies an Internet Resource The most common URI is the Uniform Resource Locator (URL) which identifies an Internet domain address Another, not so common type of URI is the Universal Resource Name (URN) –urn:isbn: URIs

3 Since XML element names can be defined by anyone, this often results in a conflict Such as … –How would you add XML related to furniture (tables and chairs) to an HTML document? Conflicts !!!

4 More conflicts !!! HTML Apples Bananas XML Coffee Table 8 10

5 If these XML fragments were added together, there would be a name conflict Both contain a element, but the elements have different content and meaning An XML parser will not know how to handle these differences Even more conflicts !!!

6 Name conflicts in XML can easily be avoided using a name prefix This XML carries information about an HTML table, and a piece of furniture: Apples Bananas Coffee Table 8 10 In the example above, there will be no conflict because the two elements have different names. Solving conflicts...

7 The namespace is defined by the xmlns attribute in the start tag of an element The namespace declaration has the following syntax xmlns:prefix="URI" XML Namespaces

8 Apples Bananas African Coffee Table Namespaces Ex 1

9 <root xmlns:h=" xmlns:f=" Apples Bananas African Coffee Table Namespaces Ex 2

10 The xmlns attribute in the tag gave the h: and f: prefixes a qualified namespace When a namespace is defined for an element, all child elements with the same prefix are associated with the same namespace Namespaces can be declared in the elements where they are used or in the XML root element The namespace URI is not used by the parser to look up information The purpose is to give the namespace a unique name, however, often companies use the namespace as a pointer to a web page containing namespace information More on Namespaces

11 Defining a default namespace for an element saves us from using prefixes in all the child elements – African Coffee Table – 80 – 120 Default Namespaces

12 Namespaces: XSLT Case Study

13 XML parsers parse all text in a document When an XML element is parsed, the text between the XML tags is also parsed: – This text is also parsed The parser does this because XML elements can contain other elements: – Bill Gates The parser will break it up into sub-elements like this: – Bill Gates – Parsed Character Data (PCDATA) is a term used about text data that will be parsed by the XML parser. Parsed Character Data

14 The term CDATA is used about text data that should not be parsed by the XML parser Characters like "<" and "&" are illegal in XML elements "<" will generate an error because the parser interprets it as the start of a new element "&" will generate an error because the parser interprets it as the start of an character entity Some text, like JavaScript code, contains a lot of "<" or "&" characters. To avoid errors script code can be defined as CDATA Everything inside a CDATA section is ignored by the parser A CDATA section starts with " " Un-Parsed Character Data (1)

15 Un-Parsed Character Data (2)

16 A CDATA section cannot contain the string "]]>" Nested CDATA sections are not allowed The "]]>" that marks the end of the CDATA section cannot contain spaces or line breaks Un-Parsed Character Data (3)

17 XML documents can contain non ASCII characters, like French ê è é. To avoid errors, specify the XML encoding Two encoding errors: –An invalid character was found in text content. –Switch from current encoding to specified encoding not supported. XML Encoding

18 Different encodings...

19 DOM (Document Object Model) defines a standard way for accessing and manipulating documents Consider XML documents as a tree-structure All elements can be accessed through the DOM tree Their content (text and attributes) can be modified or deleted, and new elements can be created The elements, their text, and their attributes are all known as nodes DOM

20 document.getElementById("to").innerHTML="" document - the HTML document getElementById("to") - the HTML element where id="to" innerHTML - the inner text of the HTML element HTML DOM example

21 xmlDoc.getElementsByTagName("to")[0].childNodes[0].nodeValue xmlDoc - the XML document created by the parser. getElementsByTagName("to")[0] - the first element childNodes[0] - the first child of the element (the text node) nodeValue - the value of the node (the text itself) XML DOM example

22 x=xmlDoc.getElementsByTagName("title")[0].childNodes[0]; Retrieves the text value of the first element txt=xmlDoc.getElementsByTagName("title")[0].getAttribute("lang"); retrieves the text value of the "lang" attribute of the first element Advanced DOM examples

23 x=xmlDoc.getElementsByTagName("book"); for(i=0;i<x.length;i++) { x[i].setAttribute("edition","first"); } Change value of attributes

24 newel=xmlDoc.createElement("edition"); newtext=xmlDoc.createTextNode("First"); newel.appendChild(newtext); x=xmlDoc.getElementsByTagName("book"); x[0].appendChild(newel); Show using trees... What is happening here... ?

25 x=xmlDoc.getElementsByTagName("book")[0]; x.removeChild(x.childNodes[0]); And what about here?

26 The CD Catalogue (XML) The CD Catalogue (Code) The CD Catalogue (HTML) XML to HTML

27 We check the browser, and load the XML using the correct parser We create an HTML table with We use getElementsByTagName() to get all XML CD nodes For each CD node, we display data from ARTIST and TITLE as table data. We end the table with XML to HTML explanation

28 Provides a way to communicate with a server after a web page has loaded Allows website to –Update a web page with new data without reloading the page –Request data from a server after the page has loaded –Receive data from a server after the page has loaded –Send data to a server in the background XMLHttpRequest Object

29 function loadXMLDoc(url) { xmlhttp=new XMLHttpRequest(); xmlhttp.onreadystatechange=state_Change; xmlhttp.open("GET",url,true); xmlhttp.send(); } function state_Change() {... x=xmlhttp.responseXML.documentElement.getElementsByTagName("CD");... } Get CD info Using XMLHttpRequest

30 xmlhttp.open("GET",url,true); Our examples use "true" in the third parameter of open() This parameter specifies whether the request should be handled asynchronously True means that the script continues to run after the send() method, without waiting for a response from the server The onreadystatechange event complicates the code. But it is the safest way if you want to prevent the code from stopping if you don't get a response from the server. By setting the parameter to "false", your can avoid the extra onreadystatechange code. Use this if it's not important to execute the rest of the code if the request fails. XMLHttpRequest Async

31 Questions?