Java's verbose XML API

It feels like it takes me too many lines of code in Java to create a new XML document, transform it, and then validate the result. At every company I've worked at we've ended up with an XML utility class we wrote with various methods to make this process easier. Utility classes that I see regularly reimplemented to make an API more accessible always set off warning flags for me that the API needs improvement.

I understand there's a lot of flexibility with the Java XML API but I'd like a sensible defaults API to use when I don't need all that power.

I feel like it should take me 4 lines to do this basic task: Line 1 call factory to create document, Line 2 call some method I write to fill in the document with content (no gripe there), Line 3 call method to transform it passing in the XSLT to use, Line 4 call method to validate the output of the transformation against a DTD or XSD. Is that too much to ask or do I just not know about some easier way to work with XML in Java?

This entry was posted in Java. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *