Introduction to XML This material is based heavily on the tutorial by the same name at www.w3schools.com.

Slides:



Advertisements
Similar presentations
XML Schema Heewon Lee. Contents 1. Introduction 2. Concepts 3. Example 4. Conclusion.
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.
XML Document Type Definitions ( DTD ). 1.Introduction to DTD An XML document may have an optional DTD, which defines the document’s grammar. Since the.
INF201 Fall2010 Intro. to Info. Technologies Department of Informatics University at Albany – SUNY Original Source: w3schools.com Prepared by Xiao Liang,
CS 898N – Advanced World Wide Web Technologies Lecture 21: XML Chin-Chih Chang
Review Writing XML  Style  Common errors 1XML Technologies David Raponi.
CSCI 7818 (Topics in Software Engineering) Web Infrastructure, Services, and Applications Document Type Definition (DTD) Author: Lukasz Kurgan.
IS 373—Web Standards Todd Will
Sistemi basati su conoscenza XML Prof. M.T. PAZIENZA a.a
DECO 3002 Advanced Technology Integrated Design Computing Studio Tutorial 5 – XML Basic School of Architecture, Design Science and Planning Faculty of.
Sistemi basati su conoscenza XML Prof. M.T. PAZIENZA a.a
XML(EXtensible Markup Language). XML XML stands for EXtensible Markup Language. XML is a markup language much like HTML. XML was designed to describe.
Introduction to XML: Yong Choi CSU Bakersfield.
Pemrograman Berbasis WEB XML part 2 -Aurelio Rahmadian- Sumber: w3cschools.com.
XML introduction to Ahmed I. Deeb Dr. Anwar Mousa  presenter  instructor University Of Palestine-2009.
 Introduction to XML Introduction to XML  Features of XML Features of XML  Syntax of XML Syntax of XML  Syntax rules of XML document Syntax rules.
XML Anisha K J Jerrin Thomas. Outline  Introduction  Structure of an XML Page  Well-formed & Valid XML Documents  DTD – Elements, Attributes, Entities.
Introduction to XML cs3505. References –I got most of this presentation from this site –O’reilly tutorials.
WPF chapter 15 Dr. John Abraham Professor UTPA. WPF –an introduction WPF provides a single platform capable of handling graphics, audio and video. WPF.
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.
CREATED BY ChanoknanChinnanon PanissaraUsanachote
1Computer Sciences Department Princess Nourah bint Abdulrahman University.
XML - DTD. The building blocks of XML documents Elements, Tags, Attributes, Entities, PCDATA, and CDATA.
Introduction to XML. What is XML? Extensible Markup Language XML Easier-to-use subset of SGML (Standard Generalized Markup Language) XML is a.
XML 1 Enterprise Applications CE00465-M XML. 2 Enterprise Applications CE00465-M XML Overview Extensible Mark-up Language (XML) is a meta-language that.
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.
These Questions are copied from
 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,
XML TUTORIAL Portions from w3 schools By Dr. John Abraham.
How do I use HTML and XML to present information?.
XP Tutorial 9 1 Working with XHTML. XP SGML 2 Standard Generalized Markup Language (SGML) A standard for specifying markup languages. Large, complex standard.
CIS 275—Web App Dev I XML. 2 Introduction to XMLXML XML stands for ________________________. HTML was designed to display data. XML was designed to _________.
XML - DTD Week 4 Anthony Borquez. What can XML do? provides an application independent way of sharing data. independent groups of people can agree to.
Windows Presentation Foundation (WPF) Chapter 16 Dr. Abraham.
Waqas Anwar Next SlidePrevious Slide. Waqas Anwar Next SlidePrevious Slide XML XML stands for EXtensible Markup Language.
XML Documents Chao-Hsien Chu, Ph.D. School of Information Sciences and Technology The Pennsylvania State University Elements Attributes Comments PI Document.
WEB APPLICATION DEVELOPMENT For More visit:
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.
XML EXtensible Markup Language. Agenda Introduction to XML XML Rules XML Elements XML Attributes XML Validation XML Exercises XML Namespaces XML CDATA.
1 Introduction to XML XML stands for Extensible Markup Language. Because it is extensible, XML has been used to create a wide variety of different markup.
An Introduction to XML Sandeep Bhattaram
XML Introduction. What is XML? XML stands for eXtensible Markup Language XML stands for eXtensible Markup Language XML is a markup language much like.
The eXtensible Markup Language (XML). Presentation Outline Part 1: The basics of creating an XML document Part 2: Developing constraints for a well formed.
What it is and how it works
XML Introduction. Markup Language A markup language must specify What markup is allowed What markup is required How markup is to be distinguished from.
XSD Presented by Kushan Athukorala. 2 Agenda XML Namespaces XML Schema XSD Indicators XSD Data Types XSD Schema References.
INFSY 547: WEB-Based Technologies Gayle J Yaverbaum, PhD Professor of Information Systems Penn State Harrisburg.
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 –
CIS 375—Web App Dev II DTD. 2 Introduction to DTD DTD stands for ______________________. The purpose of a DTD is to define the legal building blocks of.
XSD: XML Schema Language Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.
ASHIMA KALRA  INTRODUCTION OF XML INTRODUCTION OF XML  XML FEATURES XML FEATURES  XML SYNTAX XML SYNTAX  XML ELEMENTS XML ELEMENTS  XML ATTRIBUTES.
Introduction to DTD A Document Type Definition (DTD) defines the legal building blocks of an XML document. It defines the document structure with a list.
XML CSC1310 Fall HTML (TIM BERNERS-LEE) HyperText Markup Language  HTML (HyperText Markup Language): December  Markup  Markup is a symbol.
XML DTD. XML Validation XML with correct syntax is "Well Formed" XML. XML validated against a DTD is "Valid" XML.
XML. HTML Before you continue you should have a basic understanding of the following: HTML HTML was designed to display data and to focus on how data.
DTD Document Type Definition. Agenda Introduction to DTD DTD Building Blocks DTD Elements DTD Attributes DTD Entities DTD Exercises DTD Q&A.
Introduction to XML Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.
XML – Basic Concepts (modified version from Dr. Praveen Madiraju) 2015, Fall Pusan National University Ki-Joune Li.
XML Introduction to XML Extensible Markup Language.
XML Notes taken from w3schools. What is XML? XML stands for EXtensible Markup Language. XML was designed to store and transport data. XML was designed.
XSD 2015, Fall Pusan National University HyungGyu Ryoo 1.
CITA 330 Section 2 DTD. Defining XML Dialects “Well-formedness” is the minimal requirement for an XML document; all XML parsers can check it Any useful.
Extensible Markup Language (XML) Pat Morin COMP 2405.
XML Schemas Dr. Awad Khalil Computer Science Department AUC.
XML intro. 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.
XML BASICS and more…. What is XML? In common:  XML is a standard, simple, self-describing way of encoding both text and data so that content can be processed.
XML QUESTIONS AND ANSWERS
What is XML?.
Presentation transcript:

Introduction to XML This material is based heavily on the tutorial by the same name at

XML is… eXtensible Markup Language A language for describing data A tool for building new data description languages Open to define in any way you want Not a program or a process or a function –It does not do anything A markup language. That means that “marks” or tags are used to identify the data elements. Data and tags are generally stored as plain text.

HTML is… HyperText Markup Language –Note the early emphasis on text A language for describing how information is to be displayed or rendered Strictly defined Used for formatting pages and presenting information, not for describing what the information is.

Expected use “XML is going to be the main language for exchanging financial information between businesses over the Internet. A lot of interesting B2B applications are under development.” – –W3schools.com

XML uses A Document Type Definition or an XML Schema to specify what tags are allowed or required A validation service to confirm that a given XML document is syntactically correct

An XML file Easy rules, but very strict First line is the version and character set used: – The rest is user defined tags Every tag has an opening and a closing

An example (from W3school.com) Book Title: My First XML Chapter 1: Introduction to XML What is HTML What is XML Chapter 2: XML Syntax Elements must have a closing tag Elements must be properly nested My First XML Introduction to XML What is HTML What is XML XML Syntax Elements must have a closing tag Elements must be properly nested

XML Elements Elements have Content Elements can have different content types. An XML element is everything from (including) the element's start tag to (including) the element's end tag. An element can have element content, mixed content, simple content, or empty content. An element can also have attributes. In the example above, book has element content, because it contains other elements. Chapter has mixed content because it contains both text and other elements. Para has simple content (or text content) because it contains only text. Prod has empty content, because it carries no information. In the example above only the prod element has attributes. The attribute named id has the value "33-657". The attribute named media has the value "paper".

Element naming XML elements must follow these naming rules: Names can contain letters, numbers, and other characters Names must not start with a number or punctuation character Names must not start with the letters xml (or XML or Xml..) Names cannot contain spaces

Elements and Attributes Check these examples from W3schools.com: Tove Jani Reminder Don't forget me this weekend!

Elements & Attributes – 2, 3 12/11/99 Tove Jani Reminder Don't forget me this weekend! Tove Jani Reminder Don't forget me this weekend!

Attributes & Elements rule Use elements to describe data Use attributes to present information that is not part of the data –For example, the file type or some other information that would be useful in processing the data, but is not part of the data.

Defining the structure of the data A Document Type Definition, or an XML Schema defines the tags and their organization. XML files can be validated against the definition before a program tries to process the data. –Then you don’t have to worry about accounting for all kinds of error conditions.

DTD Internal –Put the dtd right into the XML file <!DOCTYPE note [ ]> Tove Jani Reminder Don't forget me this weekend First, there is the definition of the file structure, then the actual data comes later

External Tove Jani Reminder Don't forget me this weekend! Where the note.dtd file=

Why use a DTD? With DTD, each of your XML files can carry a description of its own format with it. With a DTD, independent groups of people can agree to use a common DTD for interchanging data. Your application can use a standard DTD to verify that the data you receive from the outside world is valid. You can also use a DTD to verify your own data.

The building blocks of XML documents Elements Tags Attributes Entities PCDATA CDATA

XML document components Elements can contain text, other elements, or be empty. Examples of empty HTML elements are "hr", "br" and "img". Tags are used to markup elements. Attributes provide extra information about elements. Entities are variables used to define common text. Entity references are references to entities. PCDATA - Parsed Character Data CDATA - Text that will not be parsed (Think comment)

Syntax Element with only character data: example: Element with any data: example: Elements with children or example: Full declaration of note

Repeating elements Naming an element means it appears exactly once. Name+ means it appears one or more times Name* means it appears 0 or more times. Name? Means it appears 0 or one time.

Mixed content example: The example above declares that the "note" element can contain parsed character data and any number of "to", "from", "header", and/or "message" elements.

XML organization Organization in structured logical way –XML- XML Schema Standard syntax Guarantee quality, correctness Rich set of basic types help standardization Abundance of XML parsers helps construction of analysis tools

Let’s try it Make up an XML definition for some data you want to work with. –An address book, perhaps? –What would you put into an address book? –How would you define an address? –What would you do with an address book definition once you had it?

The purpose of XML Is to describe data Is to facilitate the cross platform sharing of information Is independent of any hardware, software, operating system, programming language…

Namespaces Conflicting names make consistent interpretation impossible XML identifies namespaces to make the usage clear.

An example from w3schools: Apples Bananas African Coffee Table The two different uses of the tag “table” lead to conflicts.

Namespace use Apples Bananas African Coffee Table The use of a prefix (h or f here) clearly separates the two meanings of the tag “table.” Tag attribute xmlns (xml name space) identifies each prefix with a unique name. The link is not used by the parser to check the definition. The link may contain information about the namespace.

Default name space Using a default namespace in an element avoids the need to repeat the prefix on each child element. Apples Bananas Here, all subelements of “table” have the name related to the namespace indicated in the xmlns attribute.

XML Schema Alternative to DTD –More data types –Syntax based on XML –Ability to reuse and redefine existing schema Defines the elements, attributes that can appear in a document -- and their data types Defines relationships (parent-child) and order and number of child elements Defines fixed and default values for elements and attributes

Schema use Use of a schema assures that the communicating entities have the same understanding of how data is represented and how it should be interpreted. Classic case: dates. Is February 1, 2006 or January 2, 2006? –Schema specifies how the data values are to be interpreted.

Syntax and semantics Syntax determines the rules for a well- formed statement. Semantics determines how a well- formed statement will be used. Use of a schema can help detect errors in use within a well-formed statement. –Ex: May include a range of legal values.

Schema example for “note” <xs:schema xmlns:xs=" targetNamespace=" xmlns=" elementFormDefault="qualified"> Elements and data types come from that namespace Elements defined by this schema come from this namespace. All elements must be qualified

Reference to a schema <note xmlns=" xmlns:xsi=" instance" xsi:schemaLocation=" note.xsd"> Tove Jani Reminder Don't forget me this weekend! A document using the note schema Default namespace. All elements used in this XML doc are declared here.

Common simple data types xs:string xs:decimal xs:integer xs:boolean xs:date xs:time Default or fixed values:

Attributes All attributes are declared as simple types. Elements with attributes are considered complex type. Syntax for defining an attribute: Defining an attribute for an element: Smith Corresponding attribute definition:

Reference See For this material and more