Thư viện tri thức trực tuyến
Kho tài liệu với 50,000+ tài liệu học thuật
© 2023 Siêu thị PDF - Kho tài liệu học thuật hàng đầu Việt Nam

Writing Enterprise Applications with Java™ 2 SDK, Enterprise Edition phần 9 potx
Nội dung xem thử
Mô tả chi tiết
LESSON 6 EXTENSIBLE MARKUP LANGUAGE (XML)
SEPTEMBER 27, 2000 95
The APIs
The j2ee.jar file that comes with your J2EE installation provides APIs for parsing and
manipulating XML data. The JAR file currently provides SAX, DOM, and J2EE XML APIs.
You can use whichever API best suits your needs because as shown in Figure 22, XML text
is independent of the platform and language of its creation..
Figure 22 Platform and Language Neutral Text
SAX and DOM
The SAX API is an event-driven, serial-access mechanism that does element by element processing.
The DOM API provides a relatively familiar tree structure of objects. You can use the DOM
API to manipulate the hierarchy of application objects it encapsulates. The DOM API is
ideal for interactive applications because the entire object model is present in memory,
where it can be accessed and manipulated by the user.
Constructing the DOM requires reading the entire XML structure and holding the object tree
in memory, so it is much more CPU and memory intensive. For that reason, the SAX API
will tend to be preferred for server-side applications and data filters that do not require an inmemory representation of the data.
Note: You can find more information on the DOM and SAX APIs at this location:
http://java.sun.com/xml/docs/tutorial/overview/3_apis.html
J2EE
The platform-independent J2EE XML APIs use a DOM tree and provide a wealth of methods for manipulating the DOM hierarchy. The J2EE XML APIs are in the package com.sun
and were used in this lesson’s example. Please note that these APIs are subject to change.
Application written in
Java programming
language running on
Unix.
Application written in
C++ running on
Windows.
DOM SAX
XML
HTTP
DTD