javadtd-parsing

wutka dtdparser library -- can I retrieve elements in the order defined?


I am modifying some old code that parses a DTD using the Wutka DTDParser (http://mvnrepository.com/artifact/com.wutka/dtdparser/1.21). I need to be able to retrieve the elements in the order they appeared in the DTD file. But the DTDParser stores the elements in a Hashtable, so I'm pretty sure I'm out of luck. Does anyone know if there's any trick to doing what I need here, or if there's another DTD parsing library for java that would support that functionality (preferably that would be easy to swap into code that currently uses Wutka)? Thanks!


Solution

  • Looks like the best solution is to create a modified version of the Wutka library, since it's open source. I replaced the Hashtables with LinkedHashMaps and replaced calls to somehashtable.elements() with Collections.enumeration(somemap.values()) for minimum disruption. It seems to do what I need it to without anything else being broken.