XML An introduction. xml XML like HTML is created from the Standard Generalized Markup Language, SGML.

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)
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.
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.
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.
History Leading to XHTML
Tutorial 9 Working with XHTML
CS 898N – Advanced World Wide Web Technologies Lecture 21: XML Chin-Chih Chang
Document Type Definitions
eXtensible Markup Language (XML)
Introduction to XLink Transparency No. 1 XML Information Set W3C Recommendation 24 October 2001 (1stEdition) 4 February 2004 (2ndEdition) Cheng-Chia Chen.
 2002 Prentice Hall, Inc. All rights reserved. ISQA 407 XML/WML Winter 2002 Dr. Sergio Davalos.
26-Jun-15 XML. 2 HTML and XML, I XML stands for eXtensible Markup Language HTML is used to mark up text so it can be displayed to users XML is used to.
 2001 Prentice Hall, Inc. All rights reserved. Chapter 5 – Creating Markup with XML Outline 5.1Introduction 5.2Introduction to XML Markup 5.3Parsers and.
Jackson, Web Technologies: A Computer Science Perspective, © 2007 Prentice-Hall, Inc. All rights reserved Chapter 7 Representing Web Data:
Tutorial 11 Creating XML Document
COS 381 Day 14. Agenda Questions?? Resources Source Code Available for examples in Text Book in Blackboard
Document Type Definitions. XML and DTDs A DTD (Document Type Definition) describes the structure of one or more XML documents. Specifically, a DTD describes:
Introduction to XML This material is based heavily on the tutorial by the same name at
8/6/2015Comp Sci 3461 XML_1 Ch. 7 Fall /6/2015Comp Sci 3462 Bibliography  W3C Recommendations  XML online tutorials.
Chapter 2 Introduction to HTML5 Internet & World Wide Web How to Program, 5/e Copyright © Pearson, Inc All Rights Reserved.
Chapter 13 XML Concept of XML Simple Example of XML XML vs. HTML in Syntax XML Structure DTD and CDATA Sections Concept of SAX Processing Download and.
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.
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.
XML eXtensible Markup Language by Darrell Payne. Experience Logicon / Sterling Federal C, C++, JavaScript/Jscript, Shell Script, Perl XML Training XML.
E0262 – MIS – Multimedia Storage Techniques XML (Extensible Markup Language)  XML is a markup language for creating documents containing structured information.
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 Syntax - Writing XML and Designing DTD's
CSCI/CMPE 4341 Topic: Programming in Python Chapter 9: Python XML Processing Xiang Lian The University of Texas – Pan American Edinburg, TX 78539
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 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,
Session IV Chapter 9 – XML Schemas
Processing of structured documents Spring 2002, Part 2 Helena Ahonen-Myka.
Tutorial 1: XML Creating an XML Document. 2 Introducing XML XML stands for Extensible Markup Language. A markup language specifies the structure and content.
Electronic Commerce COMP3210 Session 4: Designing, Building and Evaluating e-Commerce Initiatives – Part II Dr. Paul Walcott Department of Computer Science,
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.
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.
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
Accessing Data Using XML CHAPTER NINE Matakuliah: T0063 – Pemrograman Visual Tahun: 2009.
School of Computing and Information Systems CS 371 Web Application Programming XML and JSON Encoding Data.
Web Technologies COMP6115 Session 4: Adding a Database to a Web Site Dr. Paul Walcott Department of Computer Science, Mathematics and Physics University.
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.
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.
An Introduction to XML Paul Donohue May 8th 2002 Hotel Senator Zürich.
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.
C# and Windows Programming XML Processing. 2 Contents Markup XML DTDs XML Parsers DOM.
Unit 10 Schema Data Processing. Key Concepts XML fundamentals XML document format Document declaration XML elements and attributes Parsing Reserved characters.
Internet & World Wide Web How to Program, 5/e. © by Pearson Education, Inc. All Rights Reserved.2.
225 City Avenue, Suite 106 Bala Cynwyd, PA , phone , fax presents… XML Syntax v2.0.
Well Formed XML The basics. A Simple XML Document Smith Alice.
When we create.rtf document apart from saving the actual info the tool saves additional info like start of a paragraph, bold, size of the font.. Etc. This.
What is XML? eXtensible Markup Language eXtensible Markup Language A subset of SGML (Standard Generalized Markup Language) A subset of SGML (Standard Generalized.
XP Tutorial 9New Perspectives on HTML and XHTML, Comprehensive 1 Working with XHTML Creating a Well-Formed Valid Document Tutorial 9.
Unit 8 XML Documents. Key Concepts XML fundamentals XML document format Document declaration XML elements and attributes Parsing Characters and white.
XML CORE CSC1310 Fall XML DOCUMENT XML document XML document is a convenient way for parsers to archive data. In other words, it is a way to describe.
C Copyright © 2011, Oracle and/or its affiliates. All rights reserved. Introduction to XML Standards.
Jackson, Web Technologies: A Computer Science Perspective, © 2007 Prentice-Hall, Inc. All rights reserved Chapter 7 Representing Web Data:
CHAPTER NINE Accessing Data Using XML. McGraw Hill/Irwin ©2002 by The McGraw-Hill Companies, Inc. All rights reserved Introduction The eXtensible.
Unit 4 Representing Web Data: XML
Extensible Markup Language XML
Extensible Markup Language XML
Chapter 7 Representing Web Data: XML
Presentation transcript:

XML An introduction

xml XML like HTML is created from the Standard Generalized Markup Language, SGML

A brief introduction to XML: A simple xml doc Welcome to XML!

In validator: file is in examples\ch05\intro.xml

XML documents and format An XML document contains data, not formatting information. As we’ll learn, there are ways (xsl and fo files, for example) to provide formatting for xml analogous to that in which css provided formatting for html.

XML XML are typically stored in a file with suffix.xml, though this is not required. They can be created with any editor (save as ASCII text). Many packages like MS Word can save files as type.xml An xml document contains a single root which contains other elements, Anything appearing before the root is called the prolog. Elements directly under the root are its children. The structure is recursive. In the example, the root’s child message contains the text “Here is some message”.

The character set XML characters are CR, LF and Unicode. An XML document consists of markup and character data. Markup is enclosed in angle brackets (like html): <> Character data appears between the start and end tag. An xml parser passes whitespace characters to the application. Insignificant whitespace can be collapsed in a process called normalization. It is a good idea to add whitespace to an xml document for readability. &,, ‘ and “ are reserved characters. An “entity reference” makes it possible to use these as characters in the character data part of an xml document. Entity references begin with & and end with ; In this way character data is not confused with markup. Single and double quote are used to delimit attribute values.

More on syntax There must be exactly one root. Proper nesting of elements is required. Start tags require close tags. Unlike HTML, the author can define her own tags in XML. Tags are case sensitive Parser needs to distinguish markup from character data Typically, whitespace is normalized – reduced to 1 whitespace char. Entity references are marked with an ampersand and allow us to use meta characters (‘ ’ and so on) which are part of the language syntax. Entity references (for example, “&lt”) allow us to represent and distinguish the reserved characters,& in XML. They may only appear as an entity reference in character data

XML intro continued A DOM-based parser returns a tree structure. A DOM parser must process the entire document to create a (java) object which may be 3 or 4X the size of the original. Not advisable if there are storage size constraints. A SAX (Simple-API for XML) -based parser returns events. SAX parsers have a smaller footprint. Many parsers can be downloaded for free and several come with java 1.4+

A brief introduction to XML An xml validator parses an XML document and indicates if it is correct. A number of free “Validators” are available, including one from MS which I downloaded and used in this ppt.

Validator Microsoft provides a validating program free for download (with javascript and VBscript versions) at us/samples/internet/xml/xml_validator/default.asp Or search MSDN+validator There are others out there:

Link to validator program on my w drive %20programming/validate_js.htmhttp://employees.oneonta.edu/higgindm/internet %20programming/validate_js.htm This is a link for javascript validator %20programming/validate_vbs.htmhttp://employees.oneonta.edu/higgindm/internet %20programming/validate_vbs.htm This is a link for vbscript validator

MS Validator: 0programming/validate_js.htm 0programming/validate_js.htm

Parser continued The parser will indicate if the document is well-formed. In DOM-based parsing, a ‘+’ in the left margin indicates a node has children and a’ –’ indicates all child nodes have been expanded. The MS Validator uses color coding to indicate child nodes can be expanded An element that stores other elements is called a container element. The parser makes the document content available for further processing if it is well-formed.

Validator example

Validator

Reserved characters <>& would enable a character data message to contain characters: <>&

DTD: document type definition a dtd file may contain the definition of an xml structure. XML files may refer back to a dtd. If an XML document has a DTD or Schema, a validating parser can determine not merely if it is well-formed XML, but whether it is valid. Valid means conforming to a dtd or schema.

Another example: Unicode Lang.xml (next slide) uses unicode entity references to represent arabic words. lang.dtd (also shown in a later slide) is used to generate unicode characters (arabic) for some entity references in the XML file.

DTD: document type definition: a dtd file may contain the definition of an xml structure. دايتَل أند &assoc; أهلاً بكم فيِ عالم &text;

Lang.dtd

Lang.xml in validator

Lang.xml in IE

About the example The DTD reference contains: DOCTYPE, the name of the root, the SYSTEM flag indicating the DTD file is external, and the name of that file. Root element welcome contains two elements: from and subject. Some lines contain entity references for unicode. The DTD also defines some other entity references.

More about markup XML end tags may consist of /> if there is an empty element as in but otherwise must consist of a complete end-tag as in: xxxxxxxxxxx Elements may or may not have content (child elements or character data) Elements may have 0 or more attributes associated with them. Attributes appear in the element’s start tag: Attribute values must appear in single or double quotes. Element and attribute names may not contain blanks. Here, element car has attribute doors with value 4. Attributes may contain any characters and be of any length but must start with a letter or underscore.

Usage.xml uses a stylesheet Deitel&apos;s XML Primer Paul Deitel Welcome Easy XML XML Elements? Entities

Usage.xls In notes in usage.xml represents a pi (that is, a processing instruction). PI consist of a PI target (xml:stylesheet, in this example) and a PI value. Note syntax. PI can be used to help authors embed application- specific data in an xml document. If the application processing the xml doesn’t use the PI, then it has no effect on the xml document content.

Usage.xml in validator

Usage.XML document loaded into IE: Browser uses stylesheet to generate HTML

CData The character data appearing in CData sections is ignored by the xml parser. CData might be used for JavaScript or VBScript. CData starts with CData may contain reserved characters, but not the text: “]]>”

Text example 5.7 // C++ comment if ( this->getX() < 5 && value[ 0 ] != 3 ) cerr << this->displayError(); <![CDATA[ // C++ comment if ( this->getX() < 5 && value[ 0 ] != 3 ) cerr displayError(); ]]> C++ How to Program by Deitel & Deitel

CData example from text 5.7

Cdata.xml in MS validator (file is in examples\ch05)

letter.xml - I removed blank lines to get it to fit here Jane Doe Box Any Ave. Othertown Otherstate John Doe 123 Main St. Anytown Anystate Dear Sir: It is our privilege to inform you about our new database managed with XML. This new system allows you to reduce the load on your inventory list server by having the client machine perform the work of sorting and filtering the data. The data in an XML element is normalized, so plain-text diagrams such as /---\ | | \---/ will become gibberish. Sincerely Ms. Doe

letter.xml in Validator

namespaces Naming collisions can occur when xml authors use the same tag names Namespaces provide a mechanism for making tag references unambiguous. A namespace reference appears with the start and end tags followed by a colon. So, Scrooge can be differentiated from colon Namespace prefixes are tied to unique URI in the xml document. Almost any name can be used to create a namespace prefix. In this example ascii and movie are namespace prefixes. Namespace prefixes can precede element and attribute values to avoid collisions. A URL may be used for a URI. The only requirement though is uniqueness as the URLs are not visited by the parser.

Namespace example 5.8 <text:directory xmlns:text = "urn:deitel:textInfo" xmlns:image = "urn:deitel:imageInfo"> A book list A funny picture

Namespace.xml in validator: file is in examples\ch05

Namespace.xml example 5.8 in IE

Namespaces continued Providing a prefix can be tedious. A default namespace can be created and elements and attributes used in the xml document from this namespace do not need prefixes.

Default namespaces <directory xmlns = "urn:deitel:textInfo" xmlns:image = "urn:deitel:imageInfo"> A book list A funny picture

Default namespaces Now, file is in the default namespace. Compare this example to the earlier namespace example where text and image were distinct namespaces.

Defaultnamespace.xml in IE

Day planner case study…to be continued… Doctor&apos;s appointment Physics class at BH291C Independence Day General Meeting in room 32-A Party at Joe&apos;s Financial Meeting in room 14-C

Planner.xml in validator

day planner using a java GUI. SAX parser is used to parse the document. (in text chapter 8)

Homework on this section Install an xml validator Create your own xml file and validate it. Post screenshots of your XML file and what validator.