Summary

This chapter covered the concepts behind parsing, SAX, JAXP, and AElfred. You can now use the available XML parsers to ingest and break down XML documents to extract the pertinent information for your application.

The two activities involved in parsing are lexical analysis and grammatical analysis. Lexical analysis was examined in detail with two sample programs: an initial obvious but incorrect tokenizer and then a refined approach. Additionally, this section included the requirements the XML specification levies on all XML processors.

The Simple API for XML (SAX) is a simple, event-based API for parsing XML documents. This was the largest section in the chapter because it explained and demonstrated every interface and class in the API. The four steps to parsing a document with SAX are

  • Create an input source to the XML document

  • Instantiate a SAX Parser (also known as a SAX Driver)

  • Register the classes that will handle SAX events (known as handlers)

  • Tell the SAX Parser to start parsing

The Java API for XML Parsing (JAXP) provides Factory objects for both styles of XML parsing: event-based (like SAX) and DOM-based. These Factory objects allow you to plug and play any compliant Java implementation into your applications. Sun Microsystems provides a default implementation.

The chapter concluded with a section on alternative parsers, featuring AElfred. AElfred is an XML Parser optimized for use in Java applets. The section walked through a non-trivial applet that downloads, parses (via AElfred), and displays bookmarks from a Bookmark List Markup Language.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.133.159.224