Listing 7: XSLTWithXOM.java
import nu.xom.Document;
import nu.xom.Builder;
import nu.xom.Nodes;
import nu.xom.ParsingException;
import java.io.File;
import nu.xom.xslt.XSLTransform;
import java.io.IOException;
import nu.xom.XMLException;
import nu.xom.xslt.XSLException;
import nu.xom.Serializer;
import java.io.FileOutputStream;
public class XSLTWithXOM {
public static void main(String[] args) {
Builder builder = new Builder();
try{
Document input = builder.build(new File(".//AirWings_xml.xml"));
Document stylesheet = builder.build(new File(".//AirWings_xslt.xsl"));
XSLTransform transform = new XSLTransform(stylesheet);
Nodes output = transform.transform(input);
Document result = XSLTransform.toDocument(output);
//System.out.println(result.toXML());
//Serializer serializer = new Serializer(System.out, "ISO-8859-1");
Serializer serializer = new Serializer
(new FileOutputStream(new File(".//AirWings.html")), "ISO-8859-1");
serializer.setIndent(5);
serializer.setMaxLength(100);
serializer.write(result);
}catch (XMLException e) {System.out.println(e.getMessage());
}catch (XSLException e) {System.out.println(e.getMessage());
}catch (ParsingException e) {System.out.println(e.getMessage());
}catch (IOException e) {System.out.println(e.getMessage());}
}
}
New on the Java Boutique:
New Review:
Time Management Made Easy with the Quartz Enterprise Job Scheduler
Why not just use the Java timer API? This open source scheduling
API boasts simplicity, ease-of-integration, a well-rounded feature
set, and it's free!
New Applet:
Reverse Complement
Reverse Complement is a simple applet that converts DNA or RNA
sequences into three useful formats.
Elsewhere on internet.com:
WebDeveloper Java
Lots of Java information on webdeveloper.com
WDVL Java
Thorough Java resource at the Web Developer's Virtual Library.
ScriptSearch Java
Hundreds of free Java code files to download.
jGuru: Your View of the Java Universe
Customizable portal with online training, FAQs, regular news updates, and tutorials.