Presentation is loading. Please wait.

Presentation is loading. Please wait.

The Java Platform and XML Portable Code, Portable Data James Duncan Davidson Staff Engineer, Sun Microsystems, Inc.

Similar presentations


Presentation on theme: "The Java Platform and XML Portable Code, Portable Data James Duncan Davidson Staff Engineer, Sun Microsystems, Inc."— Presentation transcript:

1 The Java Platform and XML Portable Code, Portable Data James Duncan Davidson Staff Engineer, Sun Microsystems, Inc.

2 Our Overall Goals Adopt existing open standards allowing the use of XML by Java developers Participate in the various XML groups such as W3C and OASIS Integrate XML technologies into the Core Platform as appropriate

3 Our Activities W3C Participation XML Working Group DOM Working Group XSL Working Group Developing APIs JAXP Data Bindings Experimenting / Implementing Project X

4 Java API for XML Parsers (JAXP) A thin and lightweight API for parsing XML documents Allows for pluggable parsers Allows processing of XML documents using the predominant methods: –Callback Driving (SAX) –Tree Based (DOM)

5 JAXP Illustration JAXP Reference Parser Other Parser User Application Java Runtime

6 SAX 1.0 Simple API for XML Accesses Document Serially Fast and Lightweight Harder to Program Sequential Access Only API in packages org.xml.sax.*

7 SAX in Action

8 Using SAX via JAXP import java.xml.parsers.*; import org.xml.sax.*; String uri = SAXParserFactory spf; SAXParser parser; HandlerBase handler; spf = SAXParserFactory.newInstance(); spf.setValidating(true); parser = spf.newSAXParser(); parser.parse(uri, handler); // can also parse InputStreams, Files, and SAX // input sources

9 DOM Level 1 Document Object Model Access XML Documents via a tree structure Composed of element nodes and text nodes Can walk the tree back and forth Larger memory requirements Package: org.w3c.dom.*

10 DOM in Action

11 Using DOM with JAXP import java.xml.parsers.*; import org.w3c.dom.*; String uri = DocumentBuilderFactory dbf; DocumentBuilder builder; Document document; dbf = DocumentBuilderFactory.newInstance(); dbf.setValidating(true); builder = dbf.newDocmentBuilder(); document = builder.parse(uri); // can also parse InputStreams, Files, and SAX // input sources

12 Namespaces Defines a distinct set of XML markup elements Associates a URI with a prefix Allows multiple vocabularies to be combined in a single XML document

13 Namespace Example Cheaper by the Dozen

14 Namespaces in JAXP // SAX Case spf = SAXParserFactory.newInstance(); spf.setValidating(true); spf.setNamespaceAware(true); parser = spf.newSAXParser(); parser.parse(uri, handler); // DOM Case dbf = DocumentBuilderFactory.newInstance(); dbf.setValidating(true); dbf.setNamespaceAware(true); builder = dbf.newDocmentBuilder(); document = builder.parse(uri);

15 Using a Compliant Parser Factories are looked up using System properties javax.xml.parsers.SAXParserFactory javax.xml.parsers.DocumentBuilderFactory Change the property and you can use any parser

16 JAXP Schedule Spec 1.0 Final Release –Available REAL SOON NOW Reference Implementation –Final Version REAL SOON NOW 1.1 –Starting now –Preliminary specs by Summer time

17 XML Futures Participate in spec evolution –XSL/XSLT –Schemas –Xlink / Xpointer –XQL Code –JAXP under consideration for Core –Work with Apache –Work with OASIS

18 Summary XML, What it is: –Portable Data XML and the Java Platform –Portable Code + Portable Data JAXP Overview Roadmap

19


Download ppt "The Java Platform and XML Portable Code, Portable Data James Duncan Davidson Staff Engineer, Sun Microsystems, Inc."

Similar presentations


Ads by Google