The eXtensible Markup Language (XML) An Applied Tutorial Kevin Thomas.

Slides:



Advertisements
Similar presentations
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.
Advertisements

XML/EDI Overview West Chester Electronic Commerce Resource Center (ECRC)
Getting a Taste of Cascading Stylesheets Steve Mooradian December 14, 2005.
1 HTML Documents and JavaScript Tom Horton Alfred C. Weaver CS453 Electronic Commerce.
SPECIAL TOPIC XML. Introducing XML XML (eXtensible Markup Language) ◦A language used to create structured documents XML vs HTML ◦XML is designed to transport.
© De Montfort University, XML – a meta language Howell Istance and Peter Norris School of Computing De Montfort University.
Extensible Markup Language Natawut Nupairoj, Ph.D. Department of Computer Engineering Chulalongkorn University.
3/5/2009Computer systems1 Analyzing System Using Data Dictionaries Computer System: 1. Data Dictionary 2. Data Dictionary Categories 3. Creating Data Dictionary.
Introduction to XML John Arnett, MSc Standards Modeller Information and Statistics Division NHSScotland Tel: (x2073)
XML Extensible Markup Language Standard supported by W3C (World Wide Web Consortium) HTML – End user oriented (presentation) XML – Application oriented.
Thayer School of Engineering Dartmouth Lecture 2 Overview Web Services concept XML introduction Visual Studio.net.
Outline IS400: Development of Business Applications on the Internet Fall 2004 Instructor: Dr. Boris Jukic XML.
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 Primer. 2 History: SGML vs. HTML vs. XML SGML (1960) XML(1996) HTML(1990) XHTML(2000)
Developing a Basic Web Page Posting Files on UMBC
Semi-Structured Data Tutorial # 1- Introduction to XML.
XML – Extensible Markup Language Sivakumar Kuttuva & Janusz Zalewski.
Working with XHTML Creating a Well-Formed Valid Document.
ColdFusion’s XML Capabilities Maryland CFUG April 12, 2005 Presented by Doug Ward.
School of Computing and Management Sciences © Sheffield Hallam University To understand the Oracle XML notes you need to have an understanding of all these.
An Introduction to XML Presented by Scott Nemec at the UniForum Chicago meeting on 7/25/2006.
Introduction to XML. XML - Connectivity is Key Need for customized page layout – e.g. filter to display only recent data Downloadable product comparisons.
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.
XML Extensible Markup Language. What is XML? An infrastructure for describing text and data Developed by W3C(the World Wide Web Consortium)
WHAT THE HELL IS XML?. What the Hell is XML? What the hell is XML?  Markup Language  Derived from SGML (Standardized General Markup Language)  Describes.
Intro. to XML & XML DB Bun Yue Professor, CS/CIS UHCL.
Session IV Chapter 9 – XML Schemas
1 What is HTML? Standardized codes Web pages SGML Descriptive markup Tags.
10/15/20151 XML. 10/15/20152 Mark-up Languages Digitalizing information Content Format SGML HTML XML RDF OWL …
1 Chapter 10: XML What is XML What is XML Basic Components of XML Basic Components of XML XPath XPath XQuery XQuery.
XP 2 HTML Tutorial 1: Developing a Basic Web Page.
IT Engineering I Instructor: Rezvan Shiravi
HTML Basics Let’s Make a Web Page. What is HTML? HTML is a language for describing web pages. HTML stands for Hyper Text Markup Language HTML is not a.
1 Credits Prepared by: Rajendra P. Srivastava Ernst & Young Professor University of Kansas Sponsored by: Ernst & Young, LLP (August 2005) XBRL Module Part.
The eXtensible Markup Language (XML). Presentation Outline Part 1: The basics of creating an XML document Part 2: Developing constraints for a well formed.
Sheet 1XML Technology in E-Commerce 2001Lecture 2 XML Technology in E-Commerce Lecture 2 Logical and Physical Structure, Validity, DTD, XML Schema.
XML for Text Markup An introduction to XML markup.
Jennifer Widom XML Data Introduction, Well-formed XML.
XML Alyssa Roberts. What is XML? Extensible Markup Language Specification to creating custom mark-up languages Simplified version of SGML, originally.
Web Application Programming Presented by: Mehwish Shafiq.
EXtensible Markup Language XML Question: What is the most common use of XML Answer: As a buzzword to spice up a resume.
XML A Language Presentation. Outline 1. Introduction 2. XML 2.1 Background 2.2 Structure 2.3 Advantages 3. Related Technologies 3.1 DTD 3.2 Schemas and.
What is XML? eXtensible Markup Language eXtensible Markup Language A subset of SGML (Standard Generalized Markup Language) A subset of SGML (Standard Generalized.
XML The Extensible Markup Language (XML ), which is comparable to SGML and modeled on it, describes how to describe a collection of data. A standard way.
XP Tutorial 9New Perspectives on HTML and XHTML, Comprehensive 1 Working with XHTML Creating a Well-Formed Valid Document Tutorial 9.
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.
INTRODUCTION JavaScript can make websites more interactive, interesting, and user-friendly.
Working with XML. Markup Languages Text-based languages based on SGML Text-based languages based on SGML SGML = Standard Generalized Markup Language SGML.
Evaluation Biztalk Table of Contents Introduction to XML. Anatomy of an XML document. What is an XML Schema? What is SOAP? XML Web Services overview.
Creating User Interfaces XML, MathML, ChomeVox. XML eXtended Markup Language Tags and text Tags are singletons and paired. Tags have types and, generally,
XP 2 HTML Tutorial 1: Developing a Basic Web Page.
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.
Introduction to XML Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.
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 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.
ITSE 1456 – 01 Extensible Markup Language(XML) 1 Ade Buraimoh.
Geospatial metadata Prof. Wenwen Li School of Geographical Sciences and Urban Planning 5644 Coor Hall
XML Databases Presented By: Pardeep MT15042 Anurag Goel MT15006.
Mark-up Languages Compare and describe at least 3 mark-up languages and what they do.
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.
Chapter 1 HTML, XHTML, and the World Wide Web
Chapter 1 HTML, XHTML, and the World Wide Web
Web Programming Maymester 2004
XML Data Introduction, Well-formed XML.
Javascript & jQuery XML.
WEB & HTML Background Info.
14 XML.
Class 4: Building Interactive Web Pages
Presentation transcript:

The eXtensible Markup Language (XML) An Applied Tutorial Kevin Thomas

Presentation Outline Part 1: The basics of creating an XML document Part 2: Developing constraints for a well formed XML document Part 3: XML and supplementary technologies

Part 1: Background for XML An Extensible Markup Language (XML) document describes the structure of data XML and HTML have a similar syntax … both derived from SGML XML has no mechanism to specify the format for presenting data to the user An XML document resides in its own file with an ‘.xml’ extension

Main Components of an XML Document Elements: Attributes: Entities: < (<) Advanced Components – CData Sections – Processing Instructions

An Example XML Document An example of an well-commented XML document

The Basic Rules XML is case sensitive All start tags must have end tags Elements must be properly nested XML declaration is the first statement Every document must contain a root element Attribute values must have quotation marks Certain characters are reserved for parsing

Common Errors for Element Naming Do not use white space when creating names for elements Element names cannot begin with a digit, although names can contain digits Only certain punctuation allowed – periods, colons, and hyphens

Walking through an Example Modify the computer.xml document – Add a new element named “software” with an attribute named “language” – The attribute’s value should be the name of a programming language – Create another XML element called “IFStatment” – Use the IFStatment element to tag the following data: if (a = 0) – Close the “software” tag After you have added these new items into the XML document, parse it again to ensure that it is still well formed. Use the feedback to correct any errors.

Part 2: Legal Building Blocks of XML A Document Type Definition (DTD) allows the developer to create a set of rules to specify legal content and place restrictions on an XML file If the XML document does not follow the rules contained within the DTD, a parser generates an error An XML document that conforms to the rules within a DTD is said to be valid

Why Use a DTD? – A single DTD ensures a common format for each XML document that references it – An application can use a standard DTD to verify that data that it receives from the outside world is valid – A description of legal, valid data further contributes to the interoperability and efficiency of using XML

Some Example DTD Declarations Example 1: The Empty Element Example 2: Elements with Data April This is a month Jan March

Some Example DTD Declarations Example 3: Elements with Children To specify that an element must have a single child element, include the element name within the parenthesis Preston Ave Charlottesville Va An element can have multiple children. A DTD describes multiple children using a sequence, or a list of elements separated by commas. The XML file must contain one of each element in the specified order. John Doe 1234 Preston Ave. Charlottesville, Va 22903

Cautions concerning DTDs All element declarations begin with The ELEMENT declaration is case sensitive The programmer must declare all elements within an XML file Elements declared with the #PCDATA content model can not have children When describing sequences, the XML document must contain exactly those elements in exactly that order.

Walking Through an Example Using the file “music.xml” contained in the extras folder, create a Document Type Definition that describes all of the elements. The goals for this exercise are to: – map out the elements – define each element – pick the best content model for each element – correctly order the elements using sequences Internally embed the DTD within the XML document

Part 3: XML and Supplementary Technologies The W3C Document Object Model (DOM) – an API that allows developers to programmatically manage and access XML nodes – allows programmers to update and change XML documents within an application – reads the whole XML file and then stores a hierarchical tree structure containing all elements within the document – This tree has a single root node, which is the root element, and may contain many children, each of which represents an XML element

W3C DOM with JavaScript Example 1: Loading the XML document: DOMDocument  The programmer can use a Microsoft Active X object to parse an XML file //Instantiate DOMDocument object var XMLfile = new ActiveXObject("Msxml2.DOMDocument"); XMLfile.load("newspaper.xml"); var rootElement = XMLfile.documentElement; document.write("The root node of the XML file is: "); document.writeln(" " + rootElement.nodeName +" ");

W3C DOM with JavaScript Example 2: Accessing the Children Elements  The childNodes member of any element node gives the programmer access to all of the sibling nodes of that element //traverse through each child of the root element //and print out its name for (i=0; i<rootElement.childNodes.length; i++) { var node = rootElement.childNodes.item(i); document.write("The name of the node is "); document.write(" " + node.nodeName + " "); }

W3C DOM with JavaScript Example 3: Getting Element Attributes //traverse through each child of the root element //and print out its name for (i=0; i<rootElement.childNodes.length; i++) { //get the current element var elementNode = rootElement.childNodes.item(i); document.writeln("Processing Node: " + elementNode.nodeName + " "); var attributeValue; //get an attribute value by specific name attributeValue = elementNode.getAttribute("articleID"); //print it out document.writeln("Attribute value: " + attributeValue + " "); }

Cautions with DOM Make sure that the XML file resides in the same directory as the html file with the JavaScript code The Attribute node does not appear as the child node of any other node type; it is not considered a child node of an element Use caution when outputting raw XML to Internet Explorer.If the programmer uses the document.writeln method, IE attempts to interpret the XML tags and jumbles the text. Instead, use an alert box when debugging.

Walking through an Example 1. Create an HTML file with notepad. Insert some JavaScript code that will parse newspaper.xml into a DOM tree. Print out the attribute values for each articleID.

Questions