|
Function
The Java API for XML Processing API (JAXP) enables applications to parse and transform XML documents using an API that is independent of a
particular XML processor implementation. The Document Object Model (DOM) is available as part of the Java API for XML Processing (JAXP). Along
with Simple API for XML (SAX), DOM is one of two common ways to write software that accesses XML data.
Using DOM with JAXP, developers can create a representation of an XML document in runtime memory either by parsing the data from an existing XML source or constructing the document using the DOM API. Once the document exists in memory, it is possible to access or modify any element in random order.
For very large sets of XML data, using DOM may not be practical because it may demand too much runtime memory. In such cases developers
should use SAX, which gives more constrained access to the XML data but is more efficient.
Topics Covered
This sample performs several functions common to software used to process orders represented in XML format. After constructing an order in memory, it counts the total number of items in the order, applies a volume discount, and calculates sales tax.
It uses the standard Java API for XML available with the Java 2 Platform Software
Developer Kit (J2SDK), version 1.4.
The code in this sample illustrates the following JAXP-DOM concepts:
Requirements
This sample requires the following products:
Source Files
Download the Java source code files or click on the links below to view individual files.
root Order element and subsequently creates components of the order by inserting nodes to the root element.
Its private methods perform the following:
Instructions
Follow these steps to run the sample:
See Also
JAX API for XML Processing (JAXP) Documentation
(http://java.sun.com/xml/jaxp/docs.html) | |||||||||||
Oracle is reviewing the Sun product roadmap and will provide guidance to customers in accordance with Oracle's standard product communication policies. Any resulting features and timing of release of such features as determined by Oracle's review of roadmaps, are at the sole discretion of Oracle. All product roadmap information, whether communicated by Sun Microsystems or by Oracle, does not represent a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. It is intended for information purposes only, and may not be incorporated into any contract.
Oracle is reviewing the Sun product roadmap and will provide guidance to customers in accordance with Oracle's standard product communication policies. Any resulting features and timing of release of such features as determined by Oracle's review of roadmaps, are at the sole discretion of Oracle. All product roadmap information, whether communicated by Sun Microsystems or by Oracle, does not represent a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. It is intended for information purposes only, and may not be incorporated into any contract.
|
| ||||||||||||