Online Training Spring Hibernate Training in Delhi R Programming Training Course Big Data and Hadoop Training Java Training


In this section, you will learn about the JAXP APIs.


JAXB Create XML File And Get Data From XML XML,XML Tutorials,Online XML Tutorial,XML Help Tutorials The Simple API for XML (SAX) APIs Part I XML,XML Tutorials,Online XML Tutorial,XML Help Tutorials XML Tutorial Ignoring Comments While Parsing an XML File Accessing XML file from Java Preventing Expansion of Entity References Getting next Tag in the XML File Replacing a Node with a New One Reading XML Data from a Stream Reading an XML document using JDOM Query XML with an XPath expression Normalize All of the Text in a Document Modifying Text by Replacement Insert a Processing Instruction and a Comment Node Getting text values from a NodeList Finding an ID Value and Print the Element Text Edit Text by Insertion and Replacement Duplicating a Subtree Deleting Two Attributes Delete the First Child of the Root Node Creating XML Tree Creating a DocumentFragment Subtree and Appending it to the Document Creates element node, attribute node, comment node, processing instruction and a CDATA section Creates a New DOM Parse Tree Replacing a Text Node with a New CDATA Section Node Create an Empty DOM Document Adding an Attribute in DOM Document Transforming XML with XSLT Transforming an XML File with XSL Transforming XML with SAXFilters Storing properties in XML file Testing EntityReferences in Xml Splitting One Text Node into Three Reading XML from a File Modifying Text by Cutting and Pasting Locating a Node by Using Siblings Locate a Node and Change Its Content Loading properties from a XML file Listing nodes used in a document Inserting a New Entry in a List Creating an InlineStreamFilter Ignoring Comments While Parsing an XML File Handling Errors While Parsing an XML File Emitting DOCTYPE Declaration while writing XML File Converting CDATA Nodes into Text Nodes Java DOM Tutorial Creating Blank DOM Document



JAXP doesn't do any kind of processing  instead it provides a mechanism to obtain parsed XML documents employing SAX and DOM parsers . JAXP provides a mechanism to plug-in with various providers (supporting standard specifications for DOM, SAX and XSLT ). JAXP also specifies which provider to use.

Overview of the main JAXP API Packages




The libraries that define needed JAXP APIs are:

javax.xml.parsers  The JAXP APIs provide a common interface for different vendors' to use SAX and DOM parsers.
org.w3c.dom Defines the Document class (a DOM) along with the classes for all of the components of a DOM.
org.xml.sax Defines the basic SAX APIs.
javax.xml.transform Defines the XSLT APIs that let's to transform XML into other forms.

The SAX API is defined in org.xml.sax  package of JAXP-APIs. The "Simple API" for XML (SAX) is the event-driven, serial-access mechanism that does element-by-element processing. The API for this level reads and writes XML to a data repository or the Web. 

The DOM API is defined in org.w3c.dom package of JAXP-APIs. The DOM API is easier to use. It provides a  tree structure of objects. The DOM API are used to manipulate the hierarchy of application objects it encapsulates. 

The XSLT APIs defined in javax.xml.transform package of JAXP-APIs. The XSLT APIs let you convert XML data to into other forms. 

javax.xml.parsers --Description

Provides classes to  process  XML documents and supports two types of plugable parsers ie..SAX and DOM Here are the following classses defined in javax.xml.parsers package:

DocumentBuilder Defines the API to obtain DOM Document instances from an XML document.
DocumentBuilderFactory Defines a factory API that enables applications to obtain a parser that produces DOM object trees from XML documents
SAXParser Defines the API that wraps an XMLReader implementation class
SAXParserFactory Defines a factory API that enables applications to configure and obtain a SAX based parser to parse XML documents

This package contains two vendor-neutral factory classes:SAXParserFactory (builds a SAXParser) and DocumentBuilderFactory (builds a  DocumentBuilder). 

TheDocumentBuilder further creates a DOM-compliant document object.

The factory APIs  enables to plug-in with the  XML implementation (provided by  any vendor without changing the source code). The obtained implementation  depends on the setting of the system properties of these factory classes javax.xml.parsers.SAXParserFactory and javax.xml.parsers.DocumentBuilderFactory . The default values (unless overridden at runtime) point to the reference implementation.

JAXP1.4 supports:

SAX 2.0
The Simple API for XML (SAX) specification provides an event-based mechanism for parsing XML documents. Various interfaces are defined in JAXP to handle different kind of events. SAX 2.0 supports  name spaces and custom event filters. 
DOM Core Level II 
The Document Object Model (DOM) specification provides mechanisms to build and traverse  tree-based representation of a XML document. 
DOM Level I provided core mechanisms for traversing a tree and adding, deleting, and updating content. 
DOM Level II provides support for events, namespaces, etc. 
XSLT 2.0
The Extensible Stylesheet Transformation(XSLT) specification defines various scripting mechanisms to transform one XML document into another.



Share on Google+Share on Google+


Posted on: May 25, 2007 If you enjoyed this post then why not add us on Google+? Add us to your Circles



Discuss: The JAXP APIs   View All Comments

Post your Comment

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image