Java Reference
In-Depth Information
<text angle="0.0" maxascent="21">
<color B="255" G="0" R="0"/>
<position x="201" y="259"/>
<bounds height="30" width="163" x="201" y="259"/>
<font fontname="Serif" fontstyle="bold" pointsize="20"/>
<string>The Complete Set!</string>
</text>
</sketch>
This file is also available as
Sample Sketch.xml
in the code download for this topic from the Wrox
sketch.
SUMMARY
In this chapter I discussed how you can use a DOM parser to analyze XML and how JAXP supports the
synthesis and modification of XML documents using DOM. You have also seen how you can use a XSLT
T
ransformer
object to create an XML file from a
Document
object and vice versa.
If you managed to get to the end of this chapter having built your own working version of Sketcher, you
are to be congratulated, especially if you started out as a newcomer to programming. I'm sure I don't need
to tell you that it's quite a challenge to acquire the knowledge and understanding necessary to do this.
An important point I want to emphasize is that the Sketcher program is just a demonstration and test
vehicle. It is an environment in which you have been able to try out various Java programming techniques
and work with reasonably large chunks of code, but it is not a good example of how the application should
be built. Because its development has been Topsy-like, without much regard for where it would finally end
up, Sketcher contains many inconsistencies and inefficiencies that would not be there if the application had
been designed from the ground up.
At this point you have a good knowledge of the Java language and experience with some of the basic
facilities provided by the Java class libraries. I have only been able to introduce you to a small proportion of
the total available in the support libraries. There are vast tracts of capability still to explore. There are pack-
ages that provide a sound API, support for cryptography, drag-and-drop capability, networking application
support, and many more. It is well worth browsing the Java documentation.
Enjoy your Java programming!
EXERCISES
You can download the source code for the examples in the topic and the solutions to the following exer-
1.
Write a program using DOM that counts the number of occurrences of each element type in an
XML document and displays them. The document file should be identified by the first command-line
argument. The program should also accept optional, additional command-line arguments that are the