O'Reilly logo

Building Oracle XML Applications by Steve Muench

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Building an XMLLoader Utility

Since many of the XML datagrams you encounter will have been produced by formatting rows of database query results as XML, it will be quite common for the XML datagrams to have a “List of Something” format like this one:

<ListOfSomething>
  <Something>
      :
  </Something>
  <Something>
      :
  </Something>
      :
    <!-- repeating potentially thousands of times -->
      :
  <Something>
      :
  </Something>
</ListOfSomething>

In the case of our <DepartmentList> example in the previous section, we might encounter a <DepartmentList> datagram that looks like this:

<DepartmentList>
  <Department>
      :
  </Department>
  <Department>
      :
  </Department>
      :
    <!-- repeating potentially thousands of times -->
      :
  <Department>
      :
  </Department>
</DepartmentList>

If the <DepartmentList> datagram contains hundreds or thousands of <Department> elements, parsing the document into a tree of nodes in memory can become a problem. This is where our XMLDocumentSplitter class from Chapter 6, will come in handy.

Recall that XMLDocumentSplitter uses the stream-based SAXParser to process the XML datagram in question as a sequential stream of tags. It takes a divide and conquer approach to processing large XML documents that have the “List of Something” format by splitting the stream of incoming tags into a sequence of incoming documents based on the tag name of the <Something> element that repeats inside the <ListOfSomething> document element. The net effect is that all of the <Something> “sub-datagrams” are processed and the amount ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required