URI in DOM Level2 methods. Applications must use the value null as the namespace URI parameter for methods if they wish to have no namespace.

3.5 JAXP

The Java API for XML Processing (JAXP) supports processing of XML documents using DOM, SAX, and XSLT. JAXP enables applications to parse and transform XML documents independent of a particular XML processing implementation. Depending on the needs of the application, developers have the flexibility to swap between XML Processors (such as high performance vs. memory conservative parsers) without making application code changes. Thus, application and tools developers can rapidly and easily XML-enable their Java applications for e-commerce, application integration, and dynamic Web publishing. Just added into the JAXP 1.2 reference implementation is support for XML Schema and an XML compiler (XSLTC).

First released in March 2000, Sun’s JAXP 1.0 utilized XML 1.0, XML Namespaces 1.0, SAX 1.0, and DOM Level 1. JAXP is a standard extension to Java, meaning that SUn provides a specification through its Java Community Process (JCP) as well as a reference implementation. JAXP 1.1 follows the same basic design philosophies of JAXP 1.0, adding support for DOM Level2, SAX2, and XSLT 1.0. A tool like JAXP is necessary because the XSLT specification defines only a transformation language; it says nothing about how to write a Java XSLT processor. Although they all perform the same basic tasks, every processor uses a different API and has its own set of programming conventions.

So simply JAXP is an API, but it is more accurately an abstraction layer. It does not provide a new means for parsing XML, add to SAX or DOM, or provide new functionary to Java and XML handling. Instead, it makes it easier to deal with some difficult tasks with DOM and SAX. Without SAX, DOM, or another XML parsing API, you cannot parse XML.

The key to JAXP’s design is the concept of plug-ability. Figure 3-5 on page 66 illustrates the high-level architecture of JAXP. These layers provide consistent Java interfaces to the underlying SAX, DOM, and XSLT implementations. In order to utilize one of these APIs, you must obtain a factory class without hard-coding Xalan or any other processor code in your application. This is achieved via a lookup mechanism that relies on Java system properties. Since three separate plug-ability layers are used, you can use a DOM parser from one vendor, a SAX parser from another vendor, and yet another XSLT processor from someone else. In reality, you will probably need to use a DOM parser compatible with your XSLT processor if you try to transform the DOM tree directly.

Chapter 3. Processing XML 65

Page 81
Image 81
IBM Version 5 manual Jaxp