Introduction to XML. M2 MIA, Grenoble Université. François Faure

Similar documents
The <schema> Element. <?xml version="1.0"?> <xs:schema>... </xs:schema>

The components of a basic XML system.

What is XML? XML is designed to transport and store data.

XML. Marie Dubremetz Uppsala, April 2014

markup language carry data define your own tags self-descriptive W3C Recommendation

11. EXTENSIBLE MARKUP LANGUAGE (XML)

Delivery Options: Attend face-to-face in the classroom or via remote-live attendance.

XSL Languages. Adding styles to HTML elements are simple. Telling a browser to display an element in a special font or color, is easy with CSS.

Delivery Options: Attend face-to-face in the classroom or remote-live attendance.

but XML goes far beyond HTML: it describes data

COMP9321 Web Application Engineering

Start learning XML! Learn by examples! With our editor, you can edit XML and click on a test button to view the result.

Copyright 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley. Chapter 7 XML

Extensible Markup Language (XML) Hamid Zarrabi-Zadeh Web Programming Fall 2013

From (Copyright Refsnes Data) XML stands for EXtensible Markup Language.

Solutions. a. Yes b. No c. Cannot be determined without the DTD. d. Schema. 9. Explain the term extensible. 10. What is an attribute?

7.1 Introduction. extensible Markup Language Developed from SGML A meta-markup language Deficiencies of HTML and SGML

User Interaction: XML and JSON


EXtensible Markup Language XML

Introduction to XML. An Example XML Document. The following is a very simple XML document.

XML. Presented by : Guerreiro João Thanh Truong Cong

INTERNET PROGRAMMING XML

XML extensible Markup Language

MANAGING INFORMATION (CSCU9T4) LECTURE 2: XML STRUCTURE

Software Engineering Methods, XML extensible Markup Language. Tutorial Outline. An Example File: Note.xml XML 1

XML: Introduction. !important Declaration... 9:11 #FIXED... 7:5 #IMPLIED... 7:5 #REQUIRED... Directive... 9:11

User Interaction: XML and JSON

EXtensible Markup Language XML

COMP9321 Web Application Engineering. Extensible Markup Language (XML)

Introduction Syntax and Usage XML Databases Java Tutorial XML. November 5, 2008 XML

User Interaction: XML and JSON

XML. Objectives. Duration. Audience. Pre-Requisites

COMP20008 Elements of Data Processing. Week 1: Lecture 2. Data format and storage

Data formats. { "firstname": "John", "lastname" : "Smith", "age" : 25, "address" : { "streetaddress": "21 2nd Street",

Introduction to XML. XML: basic elements

Translating XSLT into XQuery

Web Programming. Meta-markup Languages

XML (Extensible Markup Language

Data Presentation and Markup Languages

XML. extensible Markup Language. Overview. Overview. Overview XML Components Document Type Definition (DTD) Attributes and Tags An XML schema

Chapter 1: Getting Started. You will learn:

XML: Extensible Markup Language

<?xml version = 1.0 encoding= windows-874?> <?xml-stylesheet type= text/css href= #xmldocs?> <style id= xmldocs > element-name{ } </style>

XML Extensible Markup Language

Web Services Part I. XML Web Services. Instructor: Dr. Wei Ding Fall 2009

Web Programming Paper Solution (Chapter wise)

AIM. 10 September

Web Programming Pre-01A Web Programming Technologies. Aryo Pinandito, ST, M.MT

Internet Technologies 11-XML. F. Ricci 2010/2011

Semantic Web. XML and XML Schema. Morteza Amini. Sharif University of Technology Fall 94-95

CSI 3140 WWW Structures, Techniques and Standards. Representing Web Data: XML

XML. extensible Markup Language. ... and its usefulness for linguists

The concept of DTD. DTD(Document Type Definition) Why we need DTD

Structured documents

Markup Languages SGML, HTML, XML, XHTML. CS 431 February 13, 2006 Carl Lagoze Cornell University

W3C XML XML Overview

Data Exchange. Hyper-Text Markup Language. Contents: HTML Sample. HTML Motivation. Cascading Style Sheets (CSS) Problems w/html

Extensible Markup Stylesheet Transformation (XSLT)

Introduction to XML Zdeněk Žabokrtský, Rudolf Rosa

HTML and XML. XML stands for extensible Markup Language

COMP9321 Web Application Engineering

XML (Extensible Markup Language)

Languages in WEB. E-Business Technologies. Summer Semester Submitted to. Prof. Dr. Eduard Heindl. Prepared by

Part 2: XML and Data Management Chapter 6: Overview of XML

XML: some structural principles

Bioinforma)cs Resources XML / Web Access

EAE-2037 Loading transactions into your EAE/ABSuite system. Unite 2012 Mike Bardell

Introduction to XML. Chapter 133

Author: Irena Holubová Lecturer: Martin Svoboda

CLASS DISCUSSION AND NOTES

Chapter 13: Introduction to XML. Informatics Practices Class XII. By- Deepak Bhinde

Introduction to XML. University of California, Santa Cruz Extension Computer and Information Technology

xmlns:gu=" xmlns:uky="

XML. Rodrigo García Carmona Universidad San Pablo-CEU Escuela Politécnica Superior

XML. Jonathan Geisler. April 18, 2008

Comp 336/436 - Markup Languages. Fall Semester Week 4. Dr Nick Hayward

Notes. Submit homework on Blackboard The first homework deadline is the end of Sunday, Feb 11 th. Final slides have 'Spring 2018' in chapter title

HTML. Mohammed Alhessi M.Sc. Geomatics Engineering. Internet GIS Technologies كلية اآلداب - قسم الجغرافيا نظم المعلومات الجغرافية

PASS4TEST. IT Certification Guaranteed, The Easy Way! We offer free update service for one year

extensible Markup Language (XML) Basic Concepts

Shankersinh Vaghela Bapu Institue of Technology

Comp 336/436 - Markup Languages. Fall Semester Week 4. Dr Nick Hayward

Chapter 13 XML: Extensible Markup Language

8/1/2016. XSL stands for EXtensible Stylesheet Language. CSS = Style Sheets for HTML XSL = Style Sheets for XML. XSL consists of four parts:

XML: and related technologies

XML. Document Type Definitions XML Schema. Database Systems and Concepts, CSCI 3030U, UOIT, Course Instructor: Jarek Szlichta

Chapter 10: Understanding the Standards

XML: Managing with the Java Platform

SDPL : XML Basics 2. SDPL : XML Basics 1. SDPL : XML Basics 4. SDPL : XML Basics 3. SDPL : XML Basics 5

TagSoup: A SAX parser in Java for nasty, ugly HTML. John Cowan

CSS, Cascading Style Sheets

XML and DTD. Mario Alviano A.Y. 2017/2018. University of Calabria, Italy 1 / 28

1.264 Lecture 13 XML

XSL Transformation (XSLT) XSLT Processors. Example XSLT Stylesheet. Calling XSLT Processor. XSLT Structure

CS6501 IP Unit IV Page 1

IT2353 WEB TECHNOLOGY Question Bank UNIT I 1. What is the difference between node and host? 2. What is the purpose of routers? 3. Define protocol. 4.

M359 Block5 - Lecture12 Eng/ Waleed Omar

Overview. Introduction. Introduction XML XML. Lecture 16 Introduction to XML. Boriana Koleva Room: C54

.. Cal Poly CPE/CSC 366: Database Modeling, Design and Implementation Alexander Dekhtyar..

Transcription:

M2 MIA, Grenoble Université

Example <?xml version="1.0" encoding="iso-8859-1"?> <note> <to>tove</to> <from>jani</from> <heading>reminder</heading> <body>dont forget me this weekend!</body> </note> <!-- This is a comment -->

What is it? 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. You must define your own tags XML is a W3C Recommendation

Examples of uses Store data, or exchange data between applications XHTML WSDL for describing available web services WAP and WML as markup languages for handheld devices RSS languages for news feeds RDF and OWL for describing resources and ontology SMIL for describing multimedia for the web X3D for describing graphical scene graphs

Document structure Example At lower level: hierarchy of nodes (Document, Element, Attr, CDATASection, Comment, etc.) At higher level: a declaration a tree structure composed of a root element and child elements comments anywhere, not nested <?xml version="1.0" encoding="iso-8859-1"?> <note> <to>tove</to> <from>jani</from> <heading>reminder</heading> <body>dont forget me this weekend!</body> </note> <!-- This is a comment -->

Elements Example <Message priority="1"> some text <to>tove</to> continues <from>jani</from> </Message> Elements are the building blocks of a document. They are composed of: an opening and a closing tag possibly nested sub-elements defining a tree structure text chunks Empty elements can be defined using a single tag: Example <Logo />

Attributes Example <MyTabWidget id="widget3" width="100px" height="100px"></mytabwidget> Attributes provide additional information about the elements. They are composed of: a name, e.g. id a type, typically CDATA i.e raw text a value, e.g. widget3 convert text to numerical values if needed special characters,,,, & are encoded like in html, e.g. <

Elements or attributes? Data can be modeled as nodes or attributes. There is no rule. Data in attribute <person gender="female"> <firstname>anna</firstname> <lastname>smith</lastname> </person> Data in element <person> <gender>female</gender> <firstname>anna</firstname> <lastname>smith</lastname> </person>

SAX/DOM models DOM: tree-based document is fully loaded and a tree is created read - edit - write difficult for large documents SAX: event-driven read one line at a time and send data to callback functions memory-efficient (streaming) only for reading

Example: SAX Parsing Parsers sends data to callback functions (event-driven) Example: file to parse <Equation size="10"> <Constraint index="2" value="3.5"> </Constraint> </Equation> Example: parser virtual bool startelement(const QString & namespaceuri, const QStrin const QString & qname, const QXmlAttributes & { if( localname.tostdstring()=="equation") for(int index = 0 ; index<atts.length();index++) { if( atts.qname(index).tostdstring()=="size" ) { size = atoi( atts.value(index).tostdstring().c_str() ) } } else...

Validation How to check the validity of a document? Example: a file to validate <?xml version="1.0" encoding="utf-8"?> <xlaplacian version="1.0" size="10"> <constraint index="0" value="-100"/> <constraint index="5" value="100"/> <constraint index="9" value="20"/> </xlaplacian> We need: 1 to define a dialect 2 validation tools

A dialect definition tool: DTD Files can be checked against a Documentation Type Definition (DTD). Example: a file including a DTD <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE xlaplacian [ <!ELEMENT xlaplacian (constraint*)> <!ATTLIST xlaplacian size CDATA #REQUIRED> <!ATTLIST xlaplacian version CDATA #REQUIRED> <!ELEMENT constraint EMPTY> <!ATTLIST constraint index CDATA #REQUIRED> <!ATTLIST constraint value CDATA #REQUIRED> ]> <xlaplacian version="1.0" size="10"> <constraint index="0" value="-100"/> <constraint index="5" value="100"/> <constraint index="9" value="20"/> </xlaplacian>

Using an external DTD Example: a file refering to an external DTD <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE xlaplacian SYSTEM "xlaplacian.dtd"> <xlaplacian version="1.0" size="10"> <constraint index="0" value="-100"/> <constraint index="5" value="100"/> <constraint index="9" value="20"/> </xlaplacian> External DTD: xlaplacian.dtd <!ELEMENT xlaplacian (constraint*)> <!ATTLIST xlaplacian size CDATA #REQUIRED> <!ATTLIST xlaplacian version CDATA #REQUIRED> <!ELEMENT constraint EMPTY> <!ATTLIST constraint index CDATA #REQUIRED> <!ATTLIST constraint value CDATA #REQUIRED>

Validation tools Validation can be performed: by the parser using libraries (C++: libxml2, Xerces; Java; Python;... ) using xmllint in a Unix command line Example xmllint --noout --valid myfiletocheck.xml online XML Schema is a more powerful alternative to DTD

Viewing in a browser Default viewing looks like this:

Using a style sheet catalog.xml catalog.css CATALOG { <?xml version="1.0" encoding="iso-8859-1"?> background-color: #ffffff; <?xml-stylesheet type="text/css" href="catalog.css"?> width: 100%; <CATALOG> } <CD> CD <TITLE>Empire Burlesque</TITLE> { <ARTIST>Bob Dylan</ARTIST> display: block; <COUNTRY>USA</COUNTRY> margin-bottom: 30pt; <COMPANY>Columbia</COMPANY> margin-left: 0; <PRICE>10.90</PRICE> } <YEAR>1985</YEAR> TITLE </CD> { <CD> color: #FF0000; <TITLE>Hide your heart</title> font-size: 20pt; <ARTIST>Bonnie Tyler</ARTIST> } <COUNTRY>UK</COUNTRY> ARTIST <COMPANY>CBS Records</COMPANY> { <PRICE>9.90</PRICE> color: #0000FF; <YEAR>1988</YEAR> font-size: 20pt; </CD> }. COUNTRY,PRICE,YEAR,COMPANY. {. display: block; </CATALOG> color: #000000; margin-left: 20pt; }

CSS-formated viewing An example of formatted viewing :

Conclusion Never create your own text file format! Use XML! See also: Transforming XML documents using XSLT Query data in big XML documents using XQuery http://www.w3schools.com/xml/