The Artima Developer Community
Sponsored Link

Java Community News
AXIOM: Why Another Document Model?

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Frank Sommers

Posts: 2642
Nickname: fsommers
Registered: Jan, 2002

AXIOM: Why Another Document Model? Posted: Dec 1, 2006 1:41 PM
Reply to this message Reply
Summary
AXIOM, or Apache's AXis Object Model, is the new Java XML document model at the core of the open-source Axis 2 Web services framework. In a recent IBM DeveloperWorks article, Dennis Sosnoski compares AXIOM to other document models, explains the rational behind AXIOM, and compares AXIOM's performance to that of other document models.
Advertisement

Java-based XML document models have proliferated in the past few years. At first, there was the DOM API, which proved to be overly complex due its desire to stay neutral of any programming language. Then JDOM provided a developer-friendly alternative. Later dom4j, Xerces, Xerces 2, XOM, and other models came along.

The most recent addition to this list is AXIOM, or AXis Object Model, used as the basis of Apache's latest-generation Web services framework, Axis 2. The biggest innovation of AXIOM is that is shines in those cases where a complete document tree need not be constructed in memory, and, instead, when a partial tree suffices, according to Dennis Sosnoski's latest IBM DeveloperWorks article, Digging into Axis2: AXIOM.

Such a use-case happens to be rather common when parsing SOAP documents, according to Sosnoski. For instance, the SOAP body can often be ignored by Web service frameworks, since only the header of a SOAP envelop carries metadata required in processing SOAP requests. AXIS does this by using the StAX pull-based XML parser:

While the original Axis used a standard push-style (SAX) parser for processing XML, Axis2 uses a pull-style (StAX) parser. With a push approach, the parser is in control of the parsing operation -- you give the parser a document to parse and a handler reference. It then uses the handler for call-backs into your code as it processes the input document. Your handler code can make use of the information passed by the call-backs, but cannot affect the parsing (except by throwing an exception). With a pull approach, on the other hand, the parser is effectively an iterator for going through the components of a document on demand.

Rather than parsing an entire XML tree into memory, AXIOM parses only those portions of a tree needed by an application:

AXIOM provides a virtual document model it expands on demand, building only as much of the tree structure document model representation as has been requested by the client application. This virtual document model works at the level of elements in the XML document.

An element representation is created when the parser reports the element start tag, but the initial form of that element is essentially just a shell which holds a reference to the parser. If the application needs to get the details of the element's content, it simply requests the information by calling a method of the interface (such as the org.apache.axiom.om.OMContainer.getChildren() method). The element then builds the child content from the parser in response to the method call.

Sosnoski performed several performance tests comparing AXIOM to other Java document models. When a test required building a complete document model from an XML document, AXIOM performed poorly compared with models:

However, when the objective was to construct an initial document and then parse pieces of that document on an as-needed basis, AXIOM shined:

Which of the Java document model APIs do you prefer to use when parsing XML documents?

Topic: Scripting in JDK 6 Previous Topic   Next Topic Topic: Spring's New Configuration Option

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use