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 ...
Get Building Oracle XML Applications now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.