1 / 14

本课件仅用于北京航空航天大学计算机学院的教学; 本课件修改采用了一些网络资源(论文、研究报告、技术报告等),在采用的时候并没有准确标注引用信息。

声明. 本课件仅用于北京航空航天大学计算机学院的教学; 本课件修改采用了一些网络资源(论文、研究报告、技术报告等),在采用的时候并没有准确标注引用信息。. 应用程序接口 API. JAXP: Java API for XML Processing JAXB: Java Architecture for XML Binding JDOM: Java DOM DOM4J: an alternative to JDOM. JAXP 1.1. Java Community Process initiative JSR-000063

howard
Download Presentation

本课件仅用于北京航空航天大学计算机学院的教学; 本课件修改采用了一些网络资源(论文、研究报告、技术报告等),在采用的时候并没有准确标注引用信息。

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. 声明 • 本课件仅用于北京航空航天大学计算机学院的教学; • 本课件修改采用了一些网络资源(论文、研究报告、技术报告等),在采用的时候并没有准确标注引用信息。

  2. 应用程序接口API • JAXP: Java API for XML Processing • JAXB: Java Architecture for XML Binding • JDOM: Java DOM • DOM4J: an alternative to JDOM

  3. JAXP 1.1 • Java Community Process initiative JSR-000063 • A thin and lightweight Java API for parsing and transforming XML documents • Allows for pluggable parsers and transformers • Allows parsing of XML document using: • . Event-drive (SAX 2.0) • . Tree based (DOM Level 2) • Allows transforming XML document using: • . XSL and XSLT • JAXP Specification 1.1 • . http://java.sun.com/Download4

  4. SAX.Simple API for XML • Parsing • Reading and well-formed'ness checking and validating • Event-driven Parser • . You provide the event Handler • . Sequential read access only => one-time access • Fast and Lightweight • . Documents does not have to be entirely in memory • . Does not support modification of document • Started as a Community-driven project • . Org.xml.sax • SAX is free!

  5. SAX Example • <?xml version="1.0"?> • <doc> • <para>Hello, world!</para> • </doc> • An event-based interface will break the structure of this document down into a series of linear events: • start document • start element: doc • start element: para • characters: Hello, world! • end element: para • end element: doc • end document

  6. DOM: Document Object Model • The Document Object Model (DOM) is an application programming interface (API) for processing well-formed and valid XML documents • " It defines the logical structure of documents and the way a document is accessed and manipulated • " With the Document Object Model, programmers can build documents, navigate their structure, and add, modify, or delete elements and content

  7. DOM Example:Example table, taken from an HTML document • <TABLE> • <TBODY> • <TR> • <TD>Shady Grove</TD> • <TD>Aeolian</TD> • </TR> • <TR> • <TD>Over the River, Charlie</TD> • <TD>Dorian</TD> • </TR> • </TBODY> • </TABLE>

  8. JAXB • Java Architecture for XML Binding • " JAXB provides a fast and convenient way to create a two-way mapping between XML documents and Java objects • " WARNING: Significant changes could occur between the current working draft and the final 1.0 specification

  9. Motivations of JAXB • SAX and DOM • . Too low-level APIs • " Requires XML knowledge • . Hard to program • " You have to build your high-level Java objects yourself • . Hard to maintain • " Schema change forces reprogramming • . Forces a lot of coding • " Need for APIs that provide higher-level abstraction

  10. XML Binding.What Is It? • Map components of an XML document to in-memory objects • " Object should represent intended meaning of document according to its schema • " What should the classes be? • " Some cases obvious: String, Date, Vector. • " In general, classes should be generated directly from the schema, i.e.: • . A Java. technology-level binding of the schema

  11. Schema vs. Class

  12. The Binding Framework Cycle

More Related