Tuesday, July 29, 2008

A Decent XML Parser

Since there isn't one, I've started writing one myself. Main features:

  • Allows 100% round-tripping, even for weird whitespace between attributes in elements
  • Suitable for building editors and filters which want to preserve the original file layout
  • Error messages have line and column information
  • Easy to reuse
  • XML 1.0 compatible

You can download the latest sources here as a Maven 2 project.

2 comments:

Arik Kfir said...

Hi,

Does it support schema (or others) validations?

Aaron Digulla said...

Not yet. For 1.2, I'm working on parsing DTD's.

As far as validation goes, I'm not yet convinced what's the best way to proceed. DTD is too limited, XML Schema is very complex and still can't cover all bases.

Right now, I lean towards a pluggable interface which allows you to add any validation you like and where you can say when you want validation (for example, after modifying the XML to make sure it's still valid).