From: Tom Anderson on
On Wed, 24 Mar 2010, Mayeul wrote:

> (Confession: I don't have a clue about StAX. It might be good.)

It's pretty good.

tom

--
life finds a way
From: Tom Anderson on
On Wed, 24 Mar 2010, Arne Vajh?j wrote:

> On 24-03-2010 20:10, Lew wrote:
>> Arne Vajh?j wrote:
>>> But you still need a bunch of if statements [for SAX parsing].
>>
>> I've written a handful of SAX-parser based applications, starting with
>> my first paid Java gig eleven years ago. There really weren't many 'if'
>> statements in them; mostly I just instantiated an object based on the
>> tag being processed, using a Map to look up the appropriate handler. In
>> this it was similar to MVC code for servlets where you look up the
>> handler based on a request parameter.
>
> But in the case we are discussing, then the same tag appears in
> multiple contexts. That requires if statements.

Nope. Maintain a tag stack as a List<String>. Use the stack as a key into
a Map<List<String>, Handler> to retrieve a handler specific to the tag in
its context. I've written code like this, works quite nicely.

If i had to do it again, i'd use StAX instead.

tom

--
life finds a way