Introduction to XML.

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.
An Introduction to XML Based on the W3C XML Recommendations.
History Leading to XHTML
Tutorial 9 Working with XHTML
Chapter 10 © 2001 by Addison Wesley Longman, Inc. 1 Chapter 10 Sebesta: Programming the World Wide Web.
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.
Tutorial 11 Creating XML Document
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.
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.
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.
1Computer Sciences Department Princess Nourah bint Abdulrahman University.
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.
XML Extensible Markup Language. What is XML? ● meta-markup language ● a language for defining a family of languages ● semantic/structured mark-up language.
XHTML. Introduction to XHTML What Is XHTML? – XHTML stands for EXtensible HyperText Markup Language – XHTML is almost identical to HTML 4.01 – XHTML is.
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.
Tutorial 1: XML Creating an XML Document. 2 Introducing XML XML stands for Extensible Markup Language. A markup language specifies the structure and content.
XML TUTORIAL Portions from w3 schools By Dr. John Abraham.
1 Tutorial 13 Validating Documents with DTDs Working with Document Type Definitions.
Windows Presentation Foundation (WPF) Chapter 16 Dr. Abraham.
XML Instructor: Charles Moen CSCI/CINF XML  Extensible Markup Language  A set of rules that allow you to create your own markup language  Designed.
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.
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 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
Well Formed XML The basics. A Simple XML Document Smith Alice.
XML DTD. XML Validation XML with correct syntax is "Well Formed" XML. XML validated against a DTD is "Valid" XML.
XP Tutorial 9New Perspectives on HTML and XHTML, Comprehensive 1 Working with XHTML Creating a Well-Formed Valid Document Tutorial 9.
Tutorial 9 Working with XHTML. New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition 2 Objectives Describe the history and theory of XHTML.
C Copyright © 2011, Oracle and/or its affiliates. All rights reserved. Introduction to XML Standards.
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.
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 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.
Extensible Markup Language (XML) Pat Morin COMP 2405.
XML University Of Benghazi IT Faculty Computer Networks and Communications Department Introduction to Internet Programming(CN281)
Unit 4 Representing Web Data: XML
CIS 228 The Internet 9/20/11 XHTML 1.0.
Creating a Well-Formed Valid Document
Tutorial 9 Working with XHTML
Tutorial 9 Working with XHTML
Extensible Markup Language XML
Database Systems Week 12 by Zohaib Jan.
2017, Fall Pusan National University Ki-Joune Li
Extensible Markup Language XML
Paul Gustavson SISO XML Namespaces Paul Gustavson
Introduction to XML Mr. Majed Bouchahma
Chapter 7 Representing Web Data: XML
Chapter X IXXXXXXXXXXXXXXXX.
دانشكده مهندسي كامپيوتر
Tutorial 9 Working with XHTML
XML – Basic Concepts (modified version from Dr. Praveen Madiraju)
Web Based Applications
7. מבוא למסמכי XML ו-DTD (מבוסס על שקפים של אלדר פישר)
ece 720 intelligent web: ontology and beyond
Introduction to XML Mr. Majed Bouchahma
New Perspectives on XML
CMP 051 XML Introduction Session IV Chapter 12 – XML Namespaces
محمد احمدی نیا XHTML محمد احمدی نیا
Allyson Falkner Spokane County ISD
CMP 051 XML Introduction Session IV Chapter 12 – XML Namespaces
eXtensible Markup Language XML
XML: The new standard -Eric Taylor.
Creating Web Documents
Presentation transcript:

Introduction to XML

What is XML? Extensible Markup Language XML 1.0 1998 Easier-to-use subset of SGML (Standard Generalized Markup Language) XML is a text-based markup language Standard for data interchange on the web Set of rules for designing semantic tags Meta-markup language to define other languages XML 1.0 Specification
http://www.w3.org/TR/REC-xml

XML File Sample <?xml version="1.0"?> <dining-room> <manufacturer>The Wood Shop</manufacturer> <table type="round" wood="maple"> <price>$199.99</price> </table> <chair wood="maple"> <quantity>6</quantity> <price>$39.99</price> </chair> </dining-room>

HTML Example <DL> <DT>Mambo <DD>by Enrique Garcia <UL> <LI>Producer: Enrique Garcia <LI>Publisher: Sony Music Entertainment <LI>Length: 3:46 <LI>Written: 1991 <LI>Artist: Azucar Moreno </UL>

XML Describes Structure and Semantics, Not Format <SONG> <TITLE>Mambo</TITLE> <COMPOSER>Enrique Garcia</COMPOSER> <PRODUCER>Enrique Garcia</PRODUCER> <PUBLISHER>Sony Music Entertainment</PUBLISHER> <LENGTH>3:46</LENGTH> <YEAR>1991</YEAR> <ARTIST>Azucar Moreno</ARTIST> </SONG>

Self-Decribing Data <?xml version="1.0" encoding="UTF-8"?> <DOCUMENT> <GREETING>Hello from XML</GREETING> <MESSAGE>Welcome to Programing XML in Java</MESSAGE> </DOCUMENT>

Structured and Integrated Data <?xml version="1.0"?> <SCHOOL> <CLASS type="seminar"> <CLASS_TITLE>XML In The Real World</CLASS_TITLE> <CLASS_NUMBER>6.031</CLASS_NUMBER> <SUBJECT>XML</SUBJECT> <START_DATE>6/1/2002</START_DATE> <STUDENTS> <STUDENT status="attending"> <FIRST_NAME>Edward</FIRST_NAME> <LAST_NAME>Samson</LAST_NAME> </STUDENT> <STUDENT status="withdrawn"> <FIRST_NAME>Ernestine</FIRST_NAME> <LAST_NAME>Johnson</LAST_NAME> </STUDENTS> </CLASS> </SCHOOL>

Creating XML Documents HTML, about 100 elements XML, you define your own elements HTML Browsers try to fix bad HTML code XML Processors do not make any guess about the structure of the document Well-formed XML Document is the minimal requirement Valid XML Document (DTD or XML Schema)

What is a well-formed XML Doc? A textual object is a well-formed XML Document if: Taken as a whole, it matches the production labeled document It meets all the well-formedness contraints given in this specification:
http://www.w3.org/TR/REC-xml Each of the parsed entities which is referenced directly or indirectly whitin the document is well-formed

document ::= prolog element Misc* <?xml version="1.0"?> Comments -> <!-- This is a Comment --> Processing Instructions:
<?xml-stylesheet href="JavaXML.html.xsl" type="text/xsl"?>
<?xml-stylesheet href="greeting.css" type="text/css"?> Element: Root Element contains more elements Exactly one root element Misc: Comments Processing Instructions Whitespaces

Entities Part of an XML Document Hold text or binary data May refer to other entities Parsed entities are character data Unparsed entities are binary data

Tags and Elements XML Element consists of a start tag and an end tag
<document> ... </document> Tag Names Start with a letter <document>, an underscore <_record> or a colon (avoid using a colon) Next characters may be letters, digits, underscore, hyphens, periods and colons (but no whitespaces) XML Processors are case sensitive
Different tags: <document>, <DOCUMENT>, <Document> Empty Elements have only one tag:
HTML : <img>, <li>, <hr>
XHTML : <img/>, <li/>, <hr/>

Attributes Name-value pairs: {STATUS, "Good Credit"} Specify additional data in start tags
<CUSTOMER STATUS="Good credit"> Attribute Names same rules as tag names Attribute Values are strings enclosed in quotation marks

Too many attributes make documents hard to read: <CUSTOMER LAST_NAME="Smith" FIRST_NAME="Sam" DATE="October 15, 2001" PURCHASE="Tomatoes" PRICE="$1.25" NUMBER="8" /> <CUSTOMER> <NAME> <LAST_NAME>Smith</LAST_NAME> <FIRST_NAME>Sam</FIRST_NAME> </NAME> <DATE>October 15, 2001</DATE> <ORDERS> <ITEM> <PRODUCT>Tomatoes</PRODUCT> <NUMBER>8</NUMBER> <PRICE>$1.25</PRICE> </ITEM> </ORDERS> </CUSTOMER>

CDATA Hold character data that remains unparsed by the XML Processor Start a CDATA section: <![CDATA[ End a CDATA section: ]]>

<?xml version="1.0"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/tr/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>Using The if Statement In JavaScript</title> </head> <body> <script language="javascript"> <![CDATA[ var budget budget = 234.77 if (budget < 0){ document.writeln("Uh oh.")} ]]> </script> <center> <h1>Using The if Statement In JavaScript</h1> </center> </body> </html>

Document Type Definition: Specify Structure and Syntax of XML Document <!ELEMENT DOCUMENT (CUSTOMER)*> <!ELEMENT CUSTOMER (NAME,DATE,ORDERS)> <!ELEMENT NAME (LAST_NAME,FIRST_NAME)> <!ELEMENT LAST_NAME (#PCDATA)> <!ELEMENT FIRST_NAME (#PCDATA)> <!ELEMENT DATE (#PCDATA)> <!ELEMENT ORDERS (ITEM)*> <!ELEMENT ITEM (PRODUCT,NUMBER,PRICE)> <!ELEMENT PRODUCT (#PCDATA)> <!ELEMENT NUMBER (#PCDATA)> <!ELEMENT PRICE (#PCDATA)>

<?xml version="1.0"?> <!DOCTYPE BOOK [ <!ELEMENT BOOK (P*)> <!ELEMENT P (#PCDATA)> ]> <BOOK> <P>chapter 1 - Intro</P> <P>chapter 2 - Conclusion</P> <P>Index</P> </BOOK>

Creating Document Type Declarations <!DOCTYPE rootname [DTD]> <!DOCTYPE rootname SYSTEM URL> <!DOCTYPE rootname SYSTEM URL [DTD]> <!DOCTYPE rootname PUBLIC identifier URL> <!DOCTYPE rootname PUBLIC identifier URL [DTD]>

Element Definition <!ELEMENT direction (left, right, top?)> <!ELEMENT CHAPTER (INTRODUCTION, (P | QUOTE | NOTE)*, DIV*)> <!ELEMENT HR EMPTY>・<!ELEMENT p (#PCDATA | I)* > <!ELEMENT %title; %content; > <!ELEMENT DOCUMENT ANY>

Content_model ANY Child Element Lists #PCDATA (Parsed Character Data) Any type of content - Elements or PCDATA
<!ELEMENT DOCUMENT ANY> Child Element Lists Name of elements in parentheses
<!ELEMENT direction (left, right, top?)> #PCDATA (Parsed Character Data) Nonmarkup text
<!ELEMENT First_Name (#PCDATA)>

Example 1: Example 2: <!ELEMENT PRODUCT (#PCDATA | PRODUCT_ID)*> <PRODUCT>Tomatoes</PRODUCT> <PRODUCT> <PRODUCT_ID>124829548702121</PRODUCT_ID> </PRODUCT> Example 2: <!ELEMENT p (#PCDATA | b)*> <!ELEMENT b (#PCDATA)> <p>This is <b>bold</b> text</p>

Entities XML's way of referring to a data item. Text or Binary data. General Entity Use in the content of XML document References start with '&' and end with ';’ Parameter Entity Use in a DTD References start with '%' and end with ';’ Internal Entity - Defined in XML Document External Entity - Defined in a external source: file, URI.

Example 1: Example 2: <!ENTITY name definition> <!ELEMENT DATE (#PCDATA)> <!ENTITY TODAY "February 7, 2001"> <DATE>&TODAY;</DATE> Example 2: <!ENTITY NAME "John Punin"> <!ENTITY CNAME "&NAME; Palacios">

Namespaces XML namespaces provide a simple method for qualifying element and attribute names used in Extensible Markup Language documents by associating them with namespaces identified by URI references. Definition: A namespace (or more precisely, a namespace binding) is declared using a family of reserved attributes. Such an attribute's name must either be xmlns or begin xmlns:. These attributes, like any other XML attributes, may be provided directly or by default.

XML Document with one namespace Namespace is defined by xmlns:prefix prefix is used for the namespace The xmlns:prefix attribute is assigned to a URI. A Uniform Resource Identifier (URI) is a string of characters which identifies an Internet Resource. Every tag is prefaced with the prefix name <?xml version="1.0"?> <!-- both namespace prefixes are available throughout --> <bk:book xmlns:bk='http://www.books.org/books'> <bk:title>Programing XML in Java</bk:title> </bk:book>

Using Namespaces This XML document carries information in a table: <h:table xmlns:h="http://www.w3.org/TR/html4/"> <h:tr> <h:td>Apples</h:td> <h:td>Bananas</h:td> </h:tr> </h:table> This XML document carries information about a piece of furniture: <f:table xmlns:f="http://www.w3schools.com/furniture"> <f:name>African Coffee Table</f:name> <f:width>80</f:width> <f:length>120</f:length> </f:table> Instead of using only prefixes, we have added an xmlns attribute to the <table> tag to give the prefix a qualified name associated with a namespace.

XML Schema To define a "class" of XML Documents "instance document" - XML document that conforms to a particular schema An XML alternative to DTDs

A Simple XML Document Look at this simple XML document called "note.xml": <?xml version="1.0"?> <note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body> </note>

A DTD File The following example is a DTD file called "note.dtd" that defines the elements of the XML document above ("note.xml"): <!ELEMENT note (to, from, heading, body)> <!ELEMENT to (#PCDATA)> <!ELEMENT from (#PCDATA)> <!ELEMENT heading (#PCDATA)> <!ELEMENT body (#PCDATA)> The first line defines the note element to have four child elements: "to, from, heading, body". Line 2-5 defines the to, from, heading, body elements to be of type "#PCDAT

An XML Schema The following example is an XML Schema file called "note.xsd" that defines the elements of the XML document above ("note.xml"): <?xml version="1.0"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.w3schools.com" xmlns="http://www.w3schools.com" elementFormDefault="qualified"> <xs:element name="note"> <xs:complexType> <xs:sequence> <xs:element name="to" type="xs:string"/> <xs:element name="from" type="xs:string"/> <xs:element name="heading" type="xs:string"/> <xs:element name="body" type="xs:string"/> </xs:sequence> </xs:complexType> </xs:element> </xs:schema> The note element is a complex type because it contains other elements. The other elements (to, from, heading, body) are simple types because they do not contain other elements.