XML Instructor: Charles Moen CSCI/CINF 4230. 2 XML  Extensible Markup Language  A set of rules that allow you to create your own markup language  Designed.

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

Defining XML The Document Type Definition. Document Type Definition text syntax for defining –elements of XML –attributes (and possibly default values)
XML: text format Dr Andy Evans. Text-based data formats As data space has become cheaper, people have moved away from binary data formats. Text easier.
An Introduction to XML Based on the W3C XML Recommendations.
XML 6.3 DTD 6. XML and DTDs A DTD (Document Type Definition) describes the structure of one or more XML documents. Specifically, a DTD describes:  Elements.
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.
CS 898N – Advanced World Wide Web Technologies Lecture 21: XML Chin-Chih Chang
Chapter 10 © 2001 by Addison Wesley Longman, Inc. 1 Chapter 10 Sebesta: Programming the World Wide Web.
Sistemi basati su conoscenza XML Prof. M.T. PAZIENZA a.a
Tutorial 11 Creating XML Document
Upgrading to XHTML DECO 3001 Tutorial 1 – Part 1 Presented by Ji Soo Yoon 19 February 2004 Slides adopted from
Introducing XHTML: Module B: HTML to XHTML. Goals Understand how XHTML evolved as a language for Web delivery Understand the importance of DTDs Understand.
Introduction to XML This material is based heavily on the tutorial by the same name at
ECA 228 Internet/Intranet Design I Intro to XML. ECA 228 Internet/Intranet Design I HTML markup language very loose standards browsers adjust for non-standard.
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.
Validating DOCUMENTS with DTDs
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.
CREATED BY ChanoknanChinnanon PanissaraUsanachote
1Computer Sciences Department Princess Nourah bint Abdulrahman University.
XML CPSC 315 – Programming Studio Fall 2008 Project 3, Lecture 1.
XP 1 CREATING AN XML DOCUMENT. XP 2 INTRODUCING XML XML stands for Extensible Markup Language. A markup language specifies the structure and content of.
Document Type Definitions Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.
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.
August Chapter 2 - Markup and Core Concepts Learning XML by Erik T. Ray Slides were developed by Jack Davis College of Information Science and Technology.
XML Syntax - Writing XML and Designing DTD's
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 TUTORIAL Portions from w3 schools By Dr. John Abraham.
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.
Lecture 6 XML DTD Content of.xml fileContent of.dtd file.
1 Chapter 10: XML What is XML What is XML Basic Components of XML Basic Components of XML XPath XPath XQuery XQuery.
Softsmith Infotech XML. Softsmith Infotech XML EXtensible Markup Language XML is a markup language much like HTML Designed to carry data, not to display.
E0262 – MIS – Multimedia Storage Techniques XML (Extensible Markup Language  XML is a markup language for creating documents containing structured information.
XML 2nd EDITION Tutorial 1 Creating An Xml Document.
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.
XML Extensible Markup Language Aleksandar Bogdanovski Programing Enviroment LABoratory
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation An Introduction to XML.
XML Documents Chao-Hsien Chu, Ph.D. School of Information Sciences and Technology The Pennsylvania State University Elements Attributes Comments PI Document.
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.
XP 1 Creating an XML Document Developing an XML Document for the Jazz Warehouse XML Tutorial.
Lecture 16 Introduction to XML Boriana Koleva Room: C54
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
McGraw-Hill/Irwin © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. Understanding How XML Works Ellen Pearlman Eileen Mullin Programming the.
XML Introduction. What is XML? XML stands for eXtensible Markup Language XML stands for eXtensible Markup Language XML is a markup language much like.
1 Dr Alexiei Dingli XML Technologies DTD. 2 Document Type Definition Defines –the legal building blocks of an XML document –the document structure –The.
XML Design Goals 1.XML must be easily usable over the Internet 2.XML must support a wide variety of applications 3.XML must be compatible with SGML 4.It.
1 Tutorial 11 Creating an XML Document Developing a Document for a Cooking Web Site.
Internet & World Wide Web How to Program, 5/e. © by Pearson Education, Inc. All Rights Reserved.2.
1 herbert van de sompel CS 502 Computing Methods for Digital Libraries Cornell University – Computer Science Herbert Van de Sompel
COMP9321 Web Application Engineering Semester 2, 2015 Dr. Amin Beheshti Service Oriented Computing Group, CSE, UNSW Australia Week 4 1COMP9321, 15s2, Week.
Well Formed XML The basics. A Simple XML Document Smith Alice.
What is XML? eXtensible Markup Language eXtensible Markup Language A subset of SGML (Standard Generalized Markup Language) A subset of SGML (Standard Generalized.
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.
C Copyright © 2011, Oracle and/or its affiliates. All rights reserved. Introduction to XML Standards.
Introduction to XML Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.
Jackson, Web Technologies: A Computer Science Perspective, © 2007 Prentice-Hall, Inc. All rights reserved Chapter 7 Representing Web Data:
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.
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 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.
Unit 4 Representing Web Data: XML
Chapter 7 Representing Web Data: XML
Allyson Falkner Spokane County ISD
Presentation transcript:

XML Instructor: Charles Moen CSCI/CINF 4230

2 XML  Extensible Markup Language  A set of rules that allow you to create your own markup language  Designed for delivering data over the Web in text files that are self-describing and readable both by computer programs and by humans  The XML specification has been maintained by the World Wide Web Consortium (W3C)‏ since 1998 XML (Spainhour, Ray, W3Schools)‏

Example of an XML File XML declaration is always on the first line. XML uses markup tags, like HTML, but developers can invent their own tag names. As long as the tags follow the XML syntax rules, we can invent whatever tags and attributes are needed to describe our data. XML (Spainhour, Ray, W3Schools)‏

Problem with HTML 4 Beginning ASP.NET 3.5 in C# 2008 Matthew MacDonald It’s difficult to get the meaning of this data by looking at the HTML elements. XML (Yue)‏ HTML provides the structure of a Web page, but not the semantic meaning of its content. Beginning ASP.NET 3.5 in C# 2008 Matthew MacDonald XML can provide the semantic meaning through its markup tags.

5 XML is Portable Data  XML files are plain text files that contain markup tags  Any software that can process plain text can read XML Hardware independent Software independent XML can be used to exchange data between incompatible systems  XML-aware applications Can process XML data as long as the application “knows” the meaning of the tags Meaning of the tags depends on the application XML (Ding, W3Schools)‏

6 XML Technologies  XML  XML Namespaces  DTD (Document Type Definition) For describing your markup language  XML Schema An XML-based method of describing your markup language  XSL (Extensible Stylesheet Language) For displaying and transforming XML documents  DOM (Document Object Model) Object library for manipulating an XML document as a tree XML (Yue)‏

7 XML documents must be well-formed An XML document that conforms to the minimal XML syntax rules is well-formed  Elements must always have a closing tag  Tag names and attribute names are case-sensitive  Elements must be properly nested  All attributes must have a value  All attribute values must be surrounded with quotes or apostrophes  The XML declaration is on the first line  The document has a single root element XML (Spainhour, Ray, W3Schools)‏

Root Element Root element XML (Spainhour, Ray, W3Schools)‏ The top-level element Only one All other elements must be nested within it In an XHTML document, the root element is

9 Tag Names  There are no predefined tag names; you must invent your own (or use tags that another developer invented)  Should be descriptive, so that the document can be self- describing  Should be short and concise  Can contain letters, numbers, and other characters  Must not start with a number or punctuation character, including the dollar sign, caret, percent symbol, semicolon, etc.  Must not start with the letters “xml”  Cannot contain spaces  Should not contain the characters “:” or “.” XML (Spainhour, Ray, W3Schools)‏

10 Element Content The text between the start tag and end tag Content can be any of the following:  Empty, without content  Nested elements  Character data  Character entities  Processing instructions  Comments  CDATA sections XML (Spainhour, Ray, W3Schools)‏ 5.99 < > & " &apos; <?xml-stylesheet type="text/xsl" href="simple.xsl"?>

5.99 <![CDATA[ Bacon, lettuce, & tomato ]]> 11 CDATA  Can be inserted anywhere that character data can occur  All characters within a CDATA section are treated as a literal part of the character data Begins with these special characters All characters within are treated as literals and are not parsed as XML XML (Spainhour, Ray, W3Schools)‏ Ends with these special characters

12 Attributes ‏ Attribute  Name-value pair that describes a property of the element  Can be included in the start tag or an empty tag  A particular attribute can appear only once in the same tag XML (Spainhour, Ray, W3Schools)‏

13 Validation ‏  A DTD describes your XML markup language  Which tags can be used  What each element can contain  A document can be tested with the DTD, and if it passes then it is valid Must be well-formed Must be free of mistakes ‒ No misspelled tag names ‒ No improper nesting ‒ No missing elements  Important when used by software that expects a particular document structure; and when separate groups of people need to agree on a common language for data exchange XML (Spainhour, Ray, W3Schools)‏

14 DTD ‏  Defines the structure or grammar of an XML document by describing your markup language  Used to test whether the XML document is valid  Can be internal or external  Can contain the following types of markup declarations ELEMENT – the XML elements ATTLIST – attributes of the elements ENTITY – characters referenced using the “&...;” syntax NOTATION – description of the data format Processing instructions Comments XML (Yue, Spainhour, Ray, W3Schools)‏

15 DTD Example ‏ If we want to maintain a phone list as an XML document, the DTD might look like the following: XML (Yue, Spainhour, Young, W3Schools)‏ This DTD defines a phone list that contains the name, area code and phone number of each person in the list.

16 Element Declarations ELEMENT’s are the “building blocks” of an XML document. The first line declares that a “phonelist” element has element content, and it can contain zero or more “person” child elements. Begins the element declaration Tag name of this element Content can be zero or more “person” elements * Zero or more + One or more ? Zero or one These three characters can be used to specify the number of elements Ends the element declaration XML (Yue, Spainhour, Young, W3Schools)‏

Element Declarations 17 The second line declares that a “person” element has element content, and it must contain exactly one of each of the elements “name” and “phonenumber,” in that order. Tag name of this element When there are multiple child elements with commas separating the names, then the child elements must appear in that specific sequence XML (Yue, Spainhour, Young, W3Schools)‏

Element Declarations 18 The third line declares that the content of the “name” element is simple character data. Tag name of this element “PCDATA” stands for “parsed character data,” text that will be parsed by the XML parser. Tags inside the text will be treated as markup and entities will be expanded. It can also be empty. XML (Ding,Yue, Young, W3Schools)‏

Element Declarations 19 What can you say about the next three declarations? XML (Yue, Spainhour, Young, W3Schools)‏

Element Declarations 20 Is the following XML document valid, according to this DTD? <?xml version="1.0" encoding="UTF-8"?> Charles Moen XML (Yue, Spainhour, Young, W3Schools)‏

Using an External DTD 21 Use the DOCTYPE instruction to connect the xml document with an external DTD <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE phonelist SYSTEM "phonelist.dtd"> Charles Moen XML (Yue, Spainhour, Young, W3Schools)‏ phonelist.dtd phonelist.xml <!DOCTYPE phonelist SYSTEM "phonelist.dtd"> The root element Describes the location of the DTD, and can be relative or fully qualified, such as: " Either SYSTEM or PUBLIC (if PUBLIC, then must be followed by both a name and URI)

Using an Internal DTD An internal DTD is placed in the DOCTYPE instruction of the XML document. <!DOCTYPE phonelist [ ] > Charles Moen XML (Yue, Spainhour, Young, W3Schools)‏ phonelist.xml

23 More about Element Declarations ELEMENT content can be specified in several forms. The “choice” form specifies a series of possible child elements XML (Yue, Spainhour, Young, W3Schools)‏ The “sequence” form specifies a required sequence of child elements The “ANY” keyword means the element can have any legal content, in any order. The “EMPTY” keyword means the element must have no content.

24 Attribute-List Declarations All attributes must be explicitly declared with an “ATTLIST” declaration. Here, the “title” attribute is required; it must be CDATA; and it defaults to “Dr”. XML (Yue, Spainhour, Young, W3Schools)‏ Here, the “title” attribute is not required; it must be one of the three values that are enumerated; and it defaults to “Dr”.

XML Namespaces 25 Charles Moen CSCI/CINF 4230 XML (Yue, Spainhour, Young, W3Schools)‏ We can be sure that there is no conflict with element names by using a namespace. The namespace must be declared before using it, and the declaration is often in the root element. The identifier must be unique, and is usually a URL. (The URL does not have to be a valid URL of a Web page.) The qualified element name consists of the namespace, followed by a colon, followed by the local name.

Just for Fun XSL 26 XML An XSL (Extensible Stylesheet Language) document can be used to transform the data in an XML document to an HTML document, or a document in some other format. Charles Moen Demo XSL Phone List Name Phone number   ( )  Demo XSL Phone List Name Phone number   ( )  The XSL must be linked to the XML

27 References Ding, Wei, “XML” UHCL lecture slides, Ray, Erik T. Learning XML. O'Reilly, Spainhour, Stephen and Robert Eckstein. Webmaster in a Nutshell, 3rd Edition. O'Reilly, W3Schools Online Web Tutorials. “DTD Tutorial". [Online]. Available: W3Schools Online Web Tutorials. "XML Tutorial". [Online]. Available: Young, Michael J., XML Step by Step. Microsoft Press, Yue, Kwok-Bun, “An Introduction to XML” UHCL lecture notes, 2001.