FACTOID # 33: NationMaster.com is now 40 times the size of the CIA World Factbook!
 
 Home   Encyclopedia   Statistics   Countries A-Z   Flags   Maps   Education   Forum   FAQ   About 
 
WHAT'S NEW
RELATED ARTICLES
People who viewed "Stax" also viewed:
RECENT ARTICLES
More Recent Articles »
 

SEARCH ALL

FACTS & STATISTICS   

Search encyclopedia, statistics and forums:

 

 

(* = Graphable)

 

 


Encyclopedia > Stax

Streaming API for XML (StAX) is an application programming interface (API) to read and write XML documents in the Java programming language. API may refer to: In computing, application programming interface In petroleum industry, American Petroleum Institute In education, Academic Performance Index This page concerning a three-letter acronym or abbreviation is a disambiguation page — a navigational aid which lists other pages that might otherwise share the same title. ... The Extensible Markup Language (XML) is a general-purpose markup language. ... “Java language” redirects here. ...


Traditionally, XML APIs are either:

  • tree based - the entire document is read into memory as a tree structure for random access by the calling application
  • event based - the application registers to receive events as entities are encountered within the source document.

Both have advantages; the former (for example, DOM) allows for random access to the document, the latter (e.g. SAX) requires a small memory footprint and is typically much faster. // Hierarchy of Objects in the DOM - Document Object Model The Document Object Model (DOM) is a platform- and language-independent standard object model for representing HTML or XML and related formats. ... Look up sax in Wiktionary, the free dictionary. ...


These two access metaphors can be thought of as polar opposites. A tree based API allows unlimited, random, access and manipulation, while an event based API is a 'one shot' pass through the source document.


StAX was designed as a median between these two opposites. In the StAX metaphor, the programmatic entry point is a cursor that represents a point within the document. The application moves the cursor forward - 'pulling' the information from the parser as it needs. This is different from an event based API - such as SAX - which 'pushes' data to the application - requiring the application to maintain state between events as necessary to keep track of location within the document.

Contents

Origins

StAX has its roots in a number of incompatible pull APIs for XML, most notably XMLPULL, the authors of which (Stefan Haustein and Aleksandr Slominski) collaborated with, amongst others BEA Systems, Oracle, Sun, Breeze Factor and James Clark. BEA Systems, Inc. ... Oracle Corporation (NASDAQ: ORCL) is one of the major companies developing database management systems (DBMS), tools for database development, middle-tier software, enterprise resource planning software (ERP), customer relationship management software (CRM) and supply chain management (SCM) software. ... Sun Microsystems (Sun Microsystems, Inc. ... Clark, (February 23, 1964) is the author of groff and expat and has done much work with open-source software and XML. Born in London, Charterhouse School|Charterhouse]] and Merton College, Oxford, Clark has lived in Bangkok, Thailand since 1995, and is now a permanent resident. ...


Examples

From JSR-173 Specification• Final, V1.0 (used under fair use).


Quote:

The following Java API shows the main methods for reading XML in the cursor approach.
 // Java public interface XMLStreamReader { public int next() throws XMLStreamException; public boolean hasNext() throws XMLStreamException; public String getText(); public String getLocalName(); public String getNamespaceURI(); // ...othermethodsnotshown }  
The writing side of the API has methods that correspond to the reading side for “StartElement” and “EndElement” event types.
 // Java public interface XMLStreamWriter { public void writeStartElement(String localName) throws XMLStreamException; public void writeEndElement() throws XMLStreamException; public void writeCharacters(String text) throws XMLStreamException; // ...othermethodsnotshown }  
5.3.1 XMLStreamReader
This example illustrates how to instantiate an input factory, create a reader and iterate over the elements of an XML document.
 XMLInputFactory f = XMLInputFactory.newInstance(); XMLStreamReader r = f.createXMLStreamReader(... ); while (r.hasNext()) { r.next(); }  

Implementations

See also

Competing and complementary ways to process XML in Java (ordered loosely based on initial date of introduction):

  • DOM Document Object Model is the first standardized, language/platform-independent tree-based xml processing model. (note: there are also alternate Java tree models like [JDOM], [Dom4j], [XOM]).
  • SAX The standard "XML push" API
  • JAXB Java XML Binding API: works on top of another parser (usually streaming parser), binds contained data to/from Java objects.
  • Javolution provides a real-time StAX-like implementation which does not force object creation (e.g. String) and has no adverse effect on memory footprint/garbage collection (Note: To reduce object creation, regular StAX implementations have to maintain lookup tables to retrieve and reuse frequently used String objects).
  • VTD-XML A new non-extractive XML processing model supporting random access and XPath

// Hierarchy of Objects in the DOM - Document Object Model The Document Object Model (DOM) is a platform- and language-independent standard object model for representing HTML or XML and related formats. ... Look up sax in Wiktionary, the free dictionary. ... Java Architecture for XML Binding (JAXB) allows Java developers to edit and create XML using familiar Java objects. ... Javolution is a real-time library aiming to make Java applications faster and more time predictable. ... VTD-XML (http://vtd-xml. ...

External links

Download JSR specification document as a pdf here: download now

  Results from FactBites:
 
Stax - Wikipedia, the free encyclopedia (276 words)
StAX is also an acronym for Streaming API for XML (a Java based API for pull-parsing XML).
Stax is best known for their electrostatic and electret headphones, called "ear speakers." Electrostatic headphones work just like electrostatic loudspeakers, yet on a smaller scale.
To reduce costs, Stax made a line of Electret headphones, which are often confused for their better known electrostatic headphones, but which work on a different principle.
Stax Records - Wikipedia, the free encyclopedia (669 words)
Stax Records was a Memphis, Tennessee based record label that existed from 1959 to 1976.
Although Stax had lost their most valuable artists — Sam and Dave, who were signed to Atlantic, and Otis Redding, who had died shortly before the move between companies — they recovered quickly, building on such new artists as Isaac Hayes, whose Hot Buttered Soul album went triple-platinum in 1969.
Stax, along with the rest of the Fantasy label group, is now owned by Concord Records.
  More results at FactBites »

 

COMMENTARY     


Share your thoughts, questions and commentary here
Your name
Your location
Your comments
Please enter the 5-letter protection code


Lesson Plans | Student Area | Student FAQ | Reviews | Press Releases |  Feeds | Contact
The Wikipedia article included on this page is licensed under the GFDL.
Images may be subject to relevant owners' copyright.
All other elements are (c) copyright NationMaster.com 2003-5. All Rights Reserved.
Usage implies agreement with terms.