Java Reference
In-Depth Information
XOM is available for download from the web address http://www.cafeconleche.org/
XOM. The most current version at this writing is 1.1, which includes Xerces 2.7.1 in its
distribution.
XOM is released according to the terms of the open source GNU
Lesser General Public License (LGPL). The license grants permis-
sion to distribute the library without modification with Java pro-
grams that use it.
You also can make changes to the XOM class library as long as
you offer them under the LGPL. The full license is published online
at http://www.cafeconleche.org/XOM/license.xhtml.
CAUTION
After you have downloaded XOM and added its packages to your system's Classpath ,
you're ready to begin using XOM.
The full installation instructions are available from the XOM and Xerces websites. The
classes are distributed as JAR archive files— xom-1.1.jar , xercesImpl.jar , and xml-
apis.jar . These files should be added to your system's Classpath environment variable
so that your Java programs can use XOM classes.
Creating an XML Document
The first application you will create, RssWriter , creates an XML document that contains
the start of an RSS feed. The document is shown in Listing 19.2.
LISTING 19.2
The Full Text of feed.rss
1: <?xml version=”1.0”?>
2: <rss version=”2.0”>
3: <channel>
4: <title>Workbench</title>
5: <link>http://www.cadenhead.org/workbench/</link>
6: </channel>
7: </rss>
The base nu.xom package contains classes for a complete XML document ( Document )
and the nodes a document can contain ( Attribute , Comment , DocType , Element ,
ProcessingInstruction , and Text ).
The RssStarter application uses several of these classes. First, an Element object is cre-
ated by specifying the element's name as an argument:
Element rss = new Element(“rss”);
 
Search WWH ::




Custom Search