Java XML IS 313 6.3.2003.

Slides:



Advertisements
Similar presentations
XML: Extensible Markup Language
Advertisements

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
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.
Document Type Definitions
31 Signs That Technology Has Taken Over Your Life: #6. When you go into a computer store, you eavesdrop on a salesperson talking with customers -- and.
Document Type Definitions. XML and DTDs A DTD (Document Type Definition) describes the structure of one or more XML documents. Specifically, a DTD describes:
1 CS122B: Projects in Databases and Web Applications Spring 2015 Notes 05: XML Professor Chen Li Department of Computer Science UC Irvine CS122BNotes 05:
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.
1 XML at a neighborhood university near you Innovation 2005 September 16, 2005 Kwok-Bun Yue University of Houston-Clear Lake.
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.
XML - DTD. The building blocks of XML documents Elements, Tags, Attributes, Entities, PCDATA, and CDATA.
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.
XML 1 Enterprise Applications CE00465-M XML. 2 Enterprise Applications CE00465-M XML Overview Extensible Mark-up Language (XML) is a meta-language that.
SAX Parsing Presented by Clifford Lemoine CSC 436 Compiler Design.
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.
Advanced Java Session 9 New York University School of Continuing and Professional Studies.
 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,
Intro. to XML & XML DB Bun Yue Professor, CS/CIS UHCL.
Session IV Chapter 9 – XML Schemas
1 XML - Extensible Markup Language. 2 HTML - Hypertext Markup Language n HTML has a fixed tag set. n Use these tags to describe how information is to.
Processing of structured documents Spring 2002, Part 2 Helena Ahonen-Myka.
XML Parsers Overview  Types of parsers  Using XML parsers  SAX  DOM  DOM versus SAX  Products  Conclusion.
Tutorial 1: XML Creating an XML Document. 2 Introducing XML XML stands for Extensible Markup Language. A markup language specifies the structure and content.
1 Tutorial 13 Validating Documents with DTDs Working with Document Type Definitions.
XML A web enabled data description language 4/22/2001 By Mark Lawson & Edward Ryan L’Herault.
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.
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
School of Computing and Information Systems CS 371 Web Application Programming XML and JSON Encoding Data.
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
1/11 ITApplications XML Module Session 3: Document Type Definition (DTD) Part 1.
The eXtensible Markup Language (XML). Presentation Outline Part 1: The basics of creating an XML document Part 2: Developing constraints for a well formed.
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.
XML eXtensible Markup Language. XML A method of defining a format for exchanging documents and data. –Allows one to define a dialect of XML –A library.
XML and SAX (A quick overview) ● What is XML? ● What are SAX and DOM? ● Using SAX.
COMP9321 Web Application Engineering Semester 2, 2015 Dr. Amin Beheshti Service Oriented Computing Group, CSE, UNSW Australia Week 4 1COMP9321, 15s2, Week.
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 –
QUALITY CONTROL WITH SCHEMAS CSC1310 Fall BASIS CONCEPTS SchemaSchema is a pass-or-fail test for document Schema is a minimum set of requirements.
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.
Representing data with XML SE-2030 Dr. Mark L. Hornick 1.
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.
Martin Kruliš by Martin Kruliš (v1.1)1.
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:
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.
1 Introduction to XML Babak Esfandiari. 2 What is XML? introduced by W3C in 98 Stands for eXtensible Markup Language it is more general than HTML, but.
X M L Extensible Markup Language It is a cross platform tool or a language to achieve data transfer between the cross platform. Note  1.XML is not a replacement.
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.
XML Parsers Overview Types of parsers Using XML parsers SAX DOM
Unit 4 Representing Web Data: XML
CS122B: Projects in Databases and Web Applications Spring 2017
XML in Web Technologies
Database Processing with XML
CHAPTER 9 JAVA AND XML.
Chapter 7 Representing Web Data: XML
Chapter X IXXXXXXXXXXXXXXXX.
XML Parsers Overview Types of parsers Using XML parsers SAX DOM
Extensible Markup Language (XML)
Presentation transcript:

Java XML IS 313 6.3.2003

Outline XML documents XML in Java DOM SAX XML Output

XML HTML-like markup Semantic meaning

Example HTML <html> <h3>Message</h3> <b>To:</b> you@yourAddress.com<br> <b>From:</b> me@myAddress.com<br> <b>Subject:</b>XML Is Really Cool<p> <hr> How many ways is XML cool? Let me count the ways...<p> </html>

Example <message> <to>you@yourAddress.com</to> <from>me@myAddress.com</from> <subject>XML Is Really Cool</subject> <text> How many ways is XML cool? Let me count the ways... </text> </message>

XML is not a language It is a standard for creating task-specific formal languages In the past every application has its own representation difficult for applications to interoperate

XML is human readable not platform-specific not presentational fixed syntax validity separate from interpretation

Differences from HTML case-sensitive end tags not optional empty tags have special syntax attribute values must be in quotes XHTML

Examples members flights

Vocabulary Header Elements Attributes Entities <?xml version=“1.0”?> Elements member members Attributes level=“standard” Entities &

Document Types A document type is specification for a family of documents email messages member account data files Defining a document type deciding what can be said how it can be said attaching meaningful labels

DTD Document Type Definition DTDs Easiest to learn one of many proposals for defining XML languages others XML Schema, Schematron, DSD, Relax DTDs based on the original SGML DTDs not written in XML limited in certain respects Easiest to learn

Reading a DTD <!ELEMENT <!ATTLIST <!ENTITY defines an element associates elements and attributes <!ENTITY defines entities

Element Element name content model text or other data elements sequences choices

Attribute Lists Name of element For each attribute name content type values presence default

Examples Element Attlist <!ELEMENT members (member*)> <!ELEMENT member (name, enroll-date, last-flight-date?, miles, benefit-level)> Attlist <!ATTLIST member id CDATA #REQUIRED> <!ATTLIST benefit-level level (standard | silver | gold | platinum) "standard">

Examples flights.dtd members.dtd

Conformity If I just have an XML document I have some data If I have XML document and DTD I have some idea what the document is supposed to represent If I have XML document validated by DTD I know that the document is organized as the DTD says

DTD Limitations No way to specify types of things id must be a number origin must be a three-character string Default values only for attributes Must have a separate DTD parser not XML No import or include No inheritance OO element declaration

Programming with XML Basic problem Two ways use an XML document in a Java program Two ways Build an internal representation of the whole thing Extract just the parts you want

DOM Document Object Model Model Think of the document as a tree of the XML document composed of objects Think of the document as a tree

DOM Representation

DOM Representation Nodes List of children text nodes element nodes whitespace nodes List of children ordered top to bottom

Working with the DOM Navigate from node to node Easier with XPath from Node to ChildList from ChildList to Node Easier with XPath /member[0]/name/last

Example DOMExtract Extract last name miles benefit level

Better with Validation If we validate the document we know that the document obeys the structure simpler destructuring

Example DOMExtract2

Problems with DOM May not want the whole document Too big Only interested in certain parts Memory intensive Slow

SAX Simple API for XML Watch the parser parse Parsing = a stream of events each event calls a method like GUI event handling

SAX Events startDocument endDocument startElement endElement characters errors

Example members.xml

How to write state machine in each state beginnings and ends of elements change state in each state process relevant information

Example SAXExtract

XML Output Rather awkward Use XML transformations but don’t do any transforming provides an output stream

Example DOMOutput Reads in the file Then adds 1000 to each miles entry Outputs the file