Download presentation
Presentation is loading. Please wait.
Published byDiego Reese Modified over 11 years ago
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 = http://server/resource.xml; 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 = http://server/resource.xml; 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 1568491379
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
http://java.sun.com/xml james.davidson@sun.com http://www.xml.org http://xml.apache.org http://www.xml.com xml-announce@java.sun.com xml-interest@java.sun.com xml-feedback@java.sun.com
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.