Elliotte Rusty Harold <[email protected]> wrote on 04/20/2010 08:16:02 PM:
> On Tue, Apr 20, 2010 at 4:25 PM, Ramon F Herrera <[email protected]> wrote: > > > > Subtitle 1: How to make SAX fly. > > Subtitle 2: Should I use DOM instead? > > > > My application retrieves several items (attributes and text) from large XML > > files. Such items are used to create a spreadsheet. The app is based on > > JAXP, and the code contains many lines like these: > > > > cell.cellValue = oneItemAtATime(xmlFile, "//root/creator/@user"); > > cell.cellValue = oneItemAtATime(xmlFile, "//root/creator/@project"); > > cell.cellValue = oneItemAtATime(xmlFile, "//root/creator/@projectpath"); > > cell.cellValue = oneItemAtATime(xmlFile, "//root/creator/@title"); > > cell.cellValue = oneItemAtATime(xmlFile, "//root/creator/@notes"); > > cell.cellValue = oneItemAtATime(xmlFile, "//root/creator/@computer"); > > > > [...] > > I'm not sure what you're using, but nothing in this sample is SAX. It > sounds like there's some higher level API sitting on top of SAX doing > something ill-advised. Were you to rewrite this app to use real SAX, > you could first use a single pass to grab all the values you need; and > then fill the cells. And if the queries were complex enough that you couldn't stream it then you could build a DOM and evaluate each XPath over the same instance. You certainly don't need to parse the same document N times to accomplish this. > -- > Elliotte Rusty Harold > [email protected] > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] Thanks. Michael Glavassevich XML Parser Development IBM Toronto Lab E-mail: [email protected] E-mail: [email protected]
