I think that the reason of your issues is that required structure is NOT equivalent with input xml (and not easily relatable with SAX events). For instance, your 'name' key is the name of child element, but 'id' is attribute...
If you don't want use previously adviced tools, write handlers of SAX events, which builds some generic structure, without any ideas about xml dtd, and after that transform that structure into required one.