1 / 19

The Java™ Platform and XML

The Java™ Platform and XML. Portable Code, Portable Data. James Duncan Davidson Staff Engineer, Sun Microsystems, Inc. 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

verda
Download Presentation

The Java™ Platform and XML

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

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 User Application JAXP Reference Other Parser Parser 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 <?xml version=“1.0”?><book xmlns=“http://server/book” xmlns:isbn=“http://other.gov/isbn”> <title>Cheaper by the Dozen</title> <isbn:number>1568491379</isbn:number></book>

  14. Namespaces in JAXP // SAX Casespf = SAXParserFactory.newInstance();spf.setValidating(true);spf.setNamespaceAware(true);parser = spf.newSAXParser();parser.parse(uri, handler);// DOM Casedbf = 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. </presentation><?q&a?> 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

More Related