Java + XML = JDOM by Jason Hunter with Brett McLaughlin Sun HQ Briefing January, 2001.

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

Advanced XSLT II. Iteration in XSLT we sometimes wish to apply the same transform to a set of nodes we iterate through a node set the node set is defined.
Internet Technologies1 1 Lecture 4: Programming with XSLT.
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.
JDOM: How It Works, and How It Opened the Java Process by Jason Hunter O'Reilly Open Source Convention 2001 July, 2001.
Java + XML = JDOM by Jason Hunter and Brett McLaughlin XML DevCon November, 2000.
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.
1 CP3024 Lecture 9 XML revisited, XSL, XSLT, XPath, XSL Formatting Objects.
Document Type Definitions
Processing XML Processing XML using XSLT Processing XML documents with Java (DOM) Next week -- Processing XML documents with Java (SAX)
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.
Java API for XML Processing (JAXP) CSE 4/586: Distributed Systems Department of Computer Science and Engineering University at Buffalo, New York Jia Zhao.
Internet Technologies XSLT Processing XML using XSLT Using XPath Escaping to Java.
Declare A DTD File. Declare A DTD Inline File For example, use DTD to restrict the value of an XML document to contain only character data.
XML: What, Why, When & How? Hope Greenberg Center for Teaching & Learning June 11 & 18.
Document Type Definitions. XML and DTDs A DTD (Document Type Definition) describes the structure of one or more XML documents. Specifically, a DTD describes:
Java + XML = JDOM by Jason Hunter and Brett McLaughlin co-creators of JDOM Mountain View Java User's Group April 26, 2000.
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.
XML processing in ColdFusion MX Everything you wanted to know about XML, but were afraid to ask October 2006 Jaxfusion User Group.
1 XML at a neighborhood university near you Innovation 2005 September 16, 2005 Kwok-Bun Yue University of Houston-Clear Lake.
Comparing XSLT and XQuery Michael Kay XTech 2005.
XML eXtensible Markup Language w3c standard Why? Store and transport data Easy data exchange Create more languages WSDL (Web Service Description Language)
Representing Web Data: XML CSI 3140 WWW Structures, Techniques and Standards.
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.
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.
Java + XML = JDOM by Jason Hunter and Brett McLaughlin Enterprise Java O’Reilly Conference March, 2001.
Representing Web Data: XML CSI 3140 WWW Structures, Techniques and Standards.
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.
XML Parsers Overview  Types of parsers  Using XML parsers  SAX  DOM  DOM versus SAX  Products  Conclusion.
DOM Robin Burke ECT 360. Outline XHTML in Schema JavaScript DOM (MSXML) Loading/Parsing Transforming parameter passing DOM operations extracting data.
Intro to XML Originally Presented by Clifford Lemoine Modified by Box.
Consuming eXtensible Markup Language (XML) feeds.
IS432 Semi-Structured Data Lecture 2: DTD Dr. Gamal Al-Shorbagy.
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.
School of Computing and Information Systems CS 371 Web Application Programming XML and JSON Encoding Data.
Internet Technologies Review Week 1 How does Jigsaw differ from EchoServer.java? What abstractions are made available to the servlet writer (under.
The eXtensible Markup Language (XML). Presentation Outline Part 1: The basics of creating an XML document Part 2: Developing constraints for a well formed.
C# and Windows Programming XML Processing. 2 Contents Markup XML DTDs XML Parsers DOM.
XML Refresher Course Bálint Joó School of Physics University of Edinburgh May 02, 2003.
AxKit A member of the Apache XML project Ryan Maslyn Kyle Bechtel.
This PowerPoint is based on slides from: Jason Hunter and Brett McLaughlin.
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.
COSC617 Project XML Tools Mark Liu Sanjay Srivastava Junping Zhang.
CS 157B: Database Management Systems II February 13 Class Meeting Department of Computer Science San Jose State University Spring 2013 Instructor: Ron.
Dom and XSLT Dom – document object model DOM – collection of nodes in a tree.
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.
XML and Object Serialization. Structure of an XML Document Header Root Element Start Tags / End Tags Element Contents – Child Elements – Text – Both (mixed.
1 Introduction JAXP. Objectives  XML Parser  Parsing and Parsers  JAXP interfaces  Workshops 2.
XP New Perspectives on XML, 2 nd Edition Tutorial 7 1 TUTORIAL 7 CREATING A COMPUTATIONAL STYLESHEET.
XPath --XML Path Language Motivation of XPath Data Model and Data Types Node Types Location Steps Functions XPath 2.0 Additional Functionality and its.
Document Object Model.  The XML DOM (Document Object Model) defines a standard way for accessing and manipulating XML documents.  The DOM presents an.
7-Mar-16 Simple API XML.  SAX and DOM are standards for XML parsers-- program APIs to read and interpret XML files  DOM is a W3C standard  SAX is an.
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.
Week-9 (Lecture-1) XML DTD (Data Type Document): An XML document with correct syntax is called "Well Formed". An XML document validated against a DTD is.
XML Parsers Overview Types of parsers Using XML parsers SAX DOM
Unit 4 Representing Web Data: XML
Intro to XML.
Chapter 7 Representing Web Data: XML
XML Parsers Overview Types of parsers Using XML parsers SAX DOM
XML: eXtensible Markup Language
XML Parsers.
XML Programming in Java
Presentation transcript:

Java + XML = JDOM by Jason Hunter with Brett McLaughlin Sun HQ Briefing January, 2001

Introductions Jason Hunter Author of "Java Servlet Programming" (O'Reilly)

Introductions Brett McLaughlin Lutris Technologies Author of "Java and XML" (O'Reilly)

What is JDOM? JDOM is a way to represent an XML document for easy and efficient reading, manipulation, and writingJDOM is a way to represent an XML document for easy and efficient reading, manipulation, and writing –Straightforward API –Lightweight and fast –Java-optimized Despite the name similarity, it's not built on DOM or modeled after DOMDespite the name similarity, it's not built on DOM or modeled after DOM An open source project with an Apache-style licenseAn open source project with an Apache-style license –950 developers on jdom-interest (high traffic) –800 lurkers on jdom-announce (low traffic)

The JDOM Philosophy JDOM should be straightforward for Java programmersJDOM should be straightforward for Java programmers –Use the power of the language (Java 2) –Take advantage of method overloading, the Collections APIs, reflection, weak references –Provide conveniences like type conversions JDOM should hide the complexities of XML wherever possibleJDOM should hide the complexities of XML wherever possible –An Element has text content, not a child Text node with content –Exceptions should contain useful error messages –Give line numbers and specifics, use no SAX or DOM specifics

More JDOM Philosophy JDOM should integrate with DOM and SAXJDOM should integrate with DOM and SAX –Reads and writes DOM docs and SAX events –Can use any DOM or SAX parser (uses adapter model or can use JAXP) Why not use DOM:Why not use DOM: –Same API on multiple languages, defined using IDL –Foreign to the Java environment, Java programmer –Fairly heavyweight in memory Why not use SAX:Why not use SAX: –No document modification, random access, or output –Fairly steep learning curve to use correctly JDOM is to DOM/SAX as RMI is to CORBAJDOM is to DOM/SAX as RMI is to CORBA –Java optimized, plays well with the other

Package Structure JDOM consists of four packagesJDOM consists of four packages org.jdom org.jdom.adapters org.jdom.input org.jdom.output

The org.jdom Package These classes represent an XML document and XML constructs:These classes represent an XML document and XML constructs: –Attribute –CDATA –Comment –DocType –Document –Element –Entity –Namespace –ProcessingInstruction –( PartialList ) –( Verifier ) –(Assorted Exceptions)

The org.jdom.input Package Classes for reading XML from existing sources:Classes for reading XML from existing sources: –DOMBuilder –SAXBuilder Also, outside contributions in jdom-contrib:Also, outside contributions in jdom-contrib: –ResultSetBuilder –SpitfireBuilder

The org.jdom.output Package Classes for writing XML to various forms of output:Classes for writing XML to various forms of output: –DOMOutputter –SAXOutputter –XMLOutputter Also, outside contributions in jdom-contrib:Also, outside contributions in jdom-contrib: –JTreeOutputter

General Program Flow Normally XML Document -> SAXBuilder -> XMLOutputterNormally XML Document -> SAXBuilder -> XMLOutputter DOM Node(s) JDOM Document SAXBuilder DOMBuilder XMLOutputter SAXOutputter DOMOutputter XML Document Direct Build

The Document lifecycle Documents are represented by the org.jdom.Document classDocuments are represented by the org.jdom.Document class –A lightweight object holding a DocType, ProcessingInstruction s, a root Element (containing other Element s), and Comment s A document can be constructed from scratch:A document can be constructed from scratch: Or it can be constructed from a file, stream, or URL:Or it can be constructed from a file, stream, or URL: Then it can be output as XML, or SAX, or DOM:Then it can be output as XML, or SAX, or DOM: Document doc = new Document( new Element("root").setText("hi")); SAXBuilder builder = new SAXBuilder(); Document doc = builder.build(url); XMLOutputter outputter = new XMLOutputter(); outputter.output(doc, System.out);

Ensuring Well-Formedness The Element constructor (and all other object constructors) check to make sure the element is legalThe Element constructor (and all other object constructors) check to make sure the element is legal –i.e. the name and content don't contain inappropriate characters The add and remove methods also check document structureThe add and remove methods also check document structure –An element may only exist at one point in the tree –Only one value can be returned by getParent() –No loops in the graph are allowed –Exactly one root element must exist

JDOM Namespaces Namespace prefix to URI mappings are held statically in the Namespace classNamespace prefix to URI mappings are held statically in the Namespace class They're declared in JDOM like this:They're declared in JDOM like this: They're passed as optional parameters to most element and attribute manipulation methods:They're passed as optional parameters to most element and attribute manipulation methods: List kids = element.getChildren("p", xhtml); Element kid = element.getChild("title", xhtml); Attribute height = element.getAttribute( "height", xhtml); Namespace xhtml = Namespace.getNamespace( "xhtml", "

The Push to 1.0 Currently JDOM is at Beta 5Currently JDOM is at Beta 5 95% of XML vocabularies compliance95% of XML vocabularies compliance –Some work to be done for IDs and IDREFs –Discussion about Namespace re-factoring –Inline DTDs still in progress –In-memory validation and well-formedness in progress Speed and memory optimizations yet to be doneSpeed and memory optimizations yet to be done

Extending JDOM Some possible extensions to JDOM:Some possible extensions to JDOM: –XPath (already quite far along, and usable) –XLink/XPointer (follows XPath) –XSLT (natively, now uses Xalan) –JAXP

API Standardization JDOM is being submitted as a Java Specification Request (JSR)JDOM is being submitted as a Java Specification Request (JSR) –Hoping for inclusion in JAXP 1.2+ (or 2.0+) Possible standardization by OASIS or related technical ratification groupPossible standardization by OASIS or related technical ratification group

Get Involved Download the softwareDownload the software – Read the docsRead the docs – Sign up for the mailing lists (see jdom.org )Sign up for the mailing lists (see jdom.org ) –jdom-announce –jdom-interest Java and XML, by Brett McLaughlinJava and XML, by Brett McLaughlin – Help improve the software!Help improve the software!