With SAX and DOM, there aren’t a whole lot of XML problems you run into that you can’t solve. Loading, reading, and writing XML are all handled by these APIs, and you can even avoid vendor-specific code with the tricks you’ve already seen in previous chapters. However, Java remains a Sun creation (as much as I’d love to see the language go open source), and as a rule, Sun is going to provide an API for anything it sees as common—the thinking, I suppose, is that if a programmer is going to work with Java, he should be using Sun software as much as possible.
Along those lines, Sun provides JAXP for working with XML. Although initially a very small API that handled only parsing, the latest version of JAXP provides everything you find in SAX and DOM, as well as a few extras, and JAXP makes vendor neutrality much easier than using DOM or SAX directly. In this chapter, I’ll walk you through JAXP piece by piece, from parsing to validation to transformations.
Before you get too far into working with JAXP, you need to understand a little bit about exactly what JAXP is. Sun calls it the Java API for XML Processing, although it might better be known as the Java Abstraction Layer for XML Processing. JAXP doesn’t provide any original functionality, but instead sits on top of existing APIs—most notably SAX and DOM, which of course you’re already familiar with, as well as TrAX and a few other APIs which you’ll learn about in this chapter.