Tutorial Normalizing XML Documents

Concepts
XML documents can contain whitespace characters, including spaces, tabs, carriage returns, and linefeeds. When comparing two XML documents, in can be useful to remove whitespace characters so you can work directly with the element and attribute values. The process of removing whitespace characters is called normalization. A normalized XML document is not the same as a canonical XML document; canonical XML is a more rigorously-defined format.

The following table shows an example of an XML document before and after normalization.

Before Normalization

<rootElement> This is the test
<childElement test=”true”>
Value
</childElement>
</rootElement>

After Normalization

<rootElement>This is the test<childElement
test="true">Value</childElement></rootElement>

Design
The Oracle XML Parsers support the DOM (Document Object Model) and SAX (Simple API for XML) interfaces. This tutorial uses the SAX API to normalize an XML document. Here’s why. XML APIs generally fall into two categories: tree-based and event-based. A tree-based API (such as DOM) builds an in-memory tree representation of the XML document. It provides classes and methods for an application to navigate and process the tree. In general, the DOM interface is most useful for structural manipulations of the XML tree, such as reordering elements, adding or deleting elements and attributes, renaming elements, and so on.

An event-based API (such as SAX) uses callbacks to report parsing events to the application. The application deals with these events through customized event handlers. Events include the start and end of elements and characters. Event-based APIs usually do not build in-memory tree representations of the XML documents. Therefore, in general, SAX is useful for applications that do not need to manipulate the XML tree, such as search operations, among others.

Download file here

Incoming Search Terms : ipad xml example

Share or Bookmark this post:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • LinkedIn
  • StumbleUpon
  • Technorati
  • Twitter
  • Yahoo! Bookmarks
  • Yahoo! Buzz

Leave a Reply

Incoming Search Terms : ipad xml example