| | One thing you'll notice is that with DOM you don't have a standard way to create a Document. You have to either use implementation-specific commands or use Sun Microsystems' new JAXP API, which doesn't work with all parsers and doesn't yet support DOM2 and SAX 2.0. With JDOM, that is not an issue because JDOM documents are created through normal construction calls. You'll also notice that a DOM Node is always constructed through a factory method on its parent Document. That poses the strange chicken-and-egg problem that a DOM Element can only be created using a DOM Document object, but an XML Document should never exist without a root element! Again, with JDOM that is not an issue because elements can be created independently of documents. | Wherever possible, JDOM makes the programmer's job easier. The rule of thumb is that JDOM should help solve 80 percent or more of Java/XML problems with 20 percent or less of the traditional effort. That does not mean that JDOM conforms to only 80 percent of the XML specification. (In fact, we expect that JDOM will be fully compliant before the 1.0 final release.) What that rule of thumb does mean is that just because something could be added to the API doesn't mean it will. The API should remain sleek. | Elliotte Rusty Harold: I learned a hell of a lot from JDOM. Number one, I learned it is possible to fight the W3C and win. Just today I heard from one of the attendees at this conference that they couldn't really use XML until JDOM came along, because XML and the corresponding APIs were too complex. Once they got JDOM, then they could use XML. A lot of people are using JDOM. | JDOM, like DOM, is a tree-based object model. It loads the whole document in memory like DOM, but it's much simpler. JDOM uses concrete classes rather than interfaces, which DOM uses, and I saw how that made life simpler. JDOM is designed just for Java. It is not designed to support C++, Python, Perl, or any other language. The interoperability is achieved through XML, not the API. The API doesn't need to port. A Java API runs on one system. The XML document is what moves between systems and needs to be portable. JDOM is in many ways what DOM should have been. It's simple. It's mostly correct. It's easy enough for people who aren't experts in both XML and JDOM to use. To use DOM correctly, you really need to be an expert in both XML and DOM. | Many processors currently use a DOM tree as the internal document representation. For these processors, passing in a DOM tree is the best option because the processor can use that structure immediately, without any internal conversion. Converting your JDOM Document to a stream (using XMLOutputter) would waste time, as that stream is just going to be converted back into a DOM tree. So always try to find the shortest path between JDOM and the processor's internal representation. If you need to feed the processor a DOM tree, use JDOM's DOMOutputter, and if you need to feed the processor SAX, use SAXOutputter. In either case, the key is connecting the correct output format for your JDOM Document with the best solution for input to your XSLT processor. | | We have tried to show some of the capabilities of JDOM through some simple examples. Hopefully it is clear to you that JDOM takes an intuitive approach to modeling an XML document into a series of Java objects. These objects are then used like any other Java object to manipulate and modify the XML document. Although JDOM does not have the language independence quality attributed to DOM and SAX, it does provide Java programmers with a simple way to write code for reading, writing and manipulating XML documents. Furthermore, by providing its output in XML, DOM tree and SAX event streams, JDOM does provide a bridge in cases where using a specific standard-based API is necessary. JDOM is evolving and future releases could include support for XSLT and XPath. | | The main purpose of this program is to teach you how to create an SVG file using raw JDOM commands. The program named Svg16 that I will present later in this lesson will show how to write a Java/JDOM/SVG graphics library that eliminates much of the effort of SVG programming using raw JDOM commands. | Java API for XML Processing (JAXP) 2200 Java API for XML Processing (JAXP), Getting Started 2202 Getting Started with Java JAXP and XSL Transformations (XSLT) 2204 Java JAXP, Exposing a DOM Tree 2206 Java JAXP, Implementing Default XSLT Behavior in Java 2208 Java JAXP, Writing Java Code to Emulate an XSLT Transformation 2210 Java JAXP, Transforming XML to XHTML Links to numerous XML tutorials by Richard G. Baldwin Scalable Vector Graphics (SVG) 2212 Java JAXP, Creating graphics using Java and SVG 2214 An improved approach for creating SVG/XML code and SVG/XML DOM nodes using Java 2216 Using Java to produce SVG code in XHTML data 2218 Writing Java servlets to produce XHTML code that references external SVG files 2220 Drawing grids, Bézier curves and elliptical arcs using Java and SVG 2222 Graphics, using Java and JDOM with SVG, Part 1 Scalable Vector Graphics (SVG) 1.1 Specification Adobe SVG Viewer plug-in Create vector graphics in the browser with SVG by Uche Ogbuji SVG Tutorial SVG Basics SVG in HTML pages |
|