Courses
Custom Advanced Java Topic
Home
Corporate
Consulting
Contact Us
Courses
Jobs
Custom Topics

Customize this course,
choose your topics

Building Your Course
Custom Order Page
Building Guidelines

Selectable Topics
Advanced Applets
Advanced AWT
Collections
CORBA
Custom Components
Drag'n Drop
Enterprise JavaBeans
Event Delegation
GridbagLayout
InfoBus
Inner Classes
Internationalization
Java 2 Overview
JavaBeans
JFC Overview
JSP (Java Server Pages)
JSP Tag Libraries (taglib)
JDBC
JNI
RMI
Security
Serialization
Servlets
Struts
Swing
WebServices Overview
XML

XML

What is XML?

XML (eXtensible Markup Language) is a scaled-down version of SGML (Standard Generalized Markup Language). It is currently being standardized by the World Wide Web Consortium (W3C), the same group responsible for the HTML standard.

Like HTML, XML is a text-based markup language. It is becoming very popular and it appears that it will soon become the standard for exchanging information between applications, including applications on the web. It is being adopted by major corporations including Microsoft, Oracle, and Sun, to name only a few.

Unlike HTML, an XML document can define the tags that it uses. It can also define what a tag represents (semantically), and how that tag can be processed. Applications that use the same XML data need to agree on the tag names.

An XML document may or may not be accompanied by other files:

  • A stylesheet describes how an XML document should be displayed or formatted. It allows you to separate content from style. XSL (eXtensible Style Language) is an advanced style-sheet language. In addition to defining presentation style, XSL can also specify how to transform an XML document into another representation (such as XML or HTML). Such transformations may include retagging data, restructuring sections, or removing information.
  • A Document Type Definition (DTD) file defines the meanings of tags you have used. DTDs provide definition information about the tags, elements, and attributes found in the corresponding XML document, and their relationships to one another. DTDs also provides information that can be used to validate that a XML document is well-formed.

How is an XML document processed?

An XML parser reads the XML document, may or may not verify that it is well-formed (syntactically legal), and then creates a tree representing the document. The leafs contain the data. The nodes represent the tags that were used. The tree can processed either after it has been built, or while it is being built.

How is XML used in conjunction with Java?

Sun's provides two different Java APIs that allow you to work with XML:

  • The DOM (Document Object Model) API makes it easy for you to create a tree representation of an XML document. After creating the tree, you can process it. It is also called the "random access" protocol, because you can visit any portion of the tree in any order.
  • SAX (Simple API for XML) provides an alternate way of processing an XML document. It processes the tree as it is being built. It is a faster technique for processing the document, but it requires more complex programming. Servlets and other server/network applications tend to favor this API because of its speed. A callback (event-handler) is registered with a parser so that when the parser encounters a certain tag, the callback is invoked. The event handler processes the data marked by the tag. This is also referred to as the "serial access" protocol for XML since the data in the XML document is processed serially.

Objectives

  • Know the benefits and drawbacks of XML.
  • Know the structure and syntax of an XML document, including elements, attributes, comments, etc.
  • Create well-formed XML documents and DTDs. Employ several design considerations when creating an XML document. Choose between using attributes and elements, make stylistic decisions, normalize data and DTD.
  • Convert an XML document into a tree using the DOM API. Access the tree. Manipulate it by modifying, deleting, and inserting data. Pass the tree to a Jtree swing component.
  • Read and write XML documents serially using the SAX API. Register your event handlers with a SAX parser. Use validating and non-validating parsers.
  • Know when to use the DOM API or the SAX API.
  • Utilize the following related technologies:
    • XSL (Extensible Stylesheet Language) transformations
    • XML Link Language (XLinks, and XPointers)
    • Namespaces
    • DTD
  • Know about several document standard proposals, including
    • SMIL
    • MathML
    • eXML
    • CBL

Specifications

  • Duration (total): 2 days
  • Duration of Exercises:
  • approximately .75 day - 1 day

Pre-requisites

It is assumed that the attendee has good working knowledge of Java, including the use of exception handling, threads, full use of all the language constructs (including all the object-oriented features), and familiarity with the core Java 1.1 APIs. Basic event-handling, and GUI development with either AWT or Swing, are assumed.

Those without these pre-requisites should consider one of our Ultimate Java Programming Workshops.

A detailed "table of contents" corresponding to the coverage of this topic is available upon request.

Copyright ©2007 by Petronio Technology Group, Inc. All rights reserved. Petronio, "Targeted Technology Training", "T3" and "Turning new technologies into your competitive advantage" are trademarks of Petronio Technology Group. All other trademarks are the properties of their respective companies.