<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2713.1100" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>What about my code here.</FONT></DIV>
<DIV><FONT face=Arial size=2>It's giving me all sorts of errors on class and
method; symbols not beign resolved and so on.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Can anyone tell where i'm wrong in
this?</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>[code]</FONT></DIV>
<DIV><FONT face=Arial size=2>import java.io.File;<BR>import
java.io.IOException;<BR>import java.io.OutputStream;</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>import org.jdom.Attribute;<BR>import
org.jdom.Comments;<BR>import org.jdom.DocType;<BR>import
org.jdom.Document;<BR>import org.jdom.Element;<BR>import
org.jdom.JDOMException;<BR>import org.jdom.Namespace;<BR>import
org.jdom.ProcessingInstruction;<BR>import org.jdom.input.DOMBuilder;<BR>import
org.jdom.input.SAXBuilder;<BR>import org.jdom.output.XMLOutputter;</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>public class JDOMTest{<BR> public
JDOMTest(){<BR> }<BR> <BR> public void newDocument(OutputStream
out)<BR> throws IOException, JDOMExcption {<BR> Namespace
ns = Namespace.getNamespace("linux","<A
href="http://www.linux.org">http://www.linux.org</A>");<BR> Document
doc = new Document (new Element("config",
ns))<BR> .setDocType(new DocType("linux:config",
"DTD/linux.dtd"))<BR> .addProcessingInstruction("cocoon-process",
"type=\"xsp\"");<BR> .addProcessingInstruction(new
ProcessingInstruction("cocoon-process",
"type=\"xslt\""));<BR> doc.getRootElement()<BR> .addAttribute("Kernel",
"2.2.14")<BR> .addAttribute(new Attribute("dist", "RedHat
6.1"))<BR> .addAttribute(new Element("gui",
ns)<BR> .setContent("No Window Manager
Installed"))<BR> .addChild(new Comment("Sound Card
Configuration"))<BR> .addChild(new
Element("sound")<BR> .addChild(new Comment("Sound Blaster
Card"))<BR> .addChild(new
Element("card")<BR> .addChild(new
Element("name")<BR> .setContent("Sound
Blaster Platinum"))));<BR> XMLOutputter fmt = new
XMLOutputter();<BR> fmt.output(doc,
out);<BR> }<BR> <BR> public void domDocument(File file,
OutputStream out)<BR> throws IOException,
JDOMException{<BR> <BR> DOMBuilder builder = new
DOMBuilder(true);<BR> Document doc =
builder.build(file);</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> XMLOutputter fmt = new
XMLOutputter();<BR> fmt.output(doc, out);<BR> }</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> public void saxDocument(File file,
OutputStream out)<BR> throws IOException,
JDOMException{<BR> <BR> SAXBuilder builder = new
SAXBuilder(true);<BR> Document doc =
builder.build(file);</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> XMLOutputter fmt = new
XMLOutputter();<BR> fmt.output(doc, out);<BR> }</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> public static void main(String[]
args){<BR> if(args.length !=
1){<BR> System.out.println("Usage: JDOMTest (filename to
parse)");<BR> System.exit(-1);<BR> }</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> try{<BR> JDOMTest test = new
JDOMTest();<BR> System.out.println("\n\n----------------------------------------------");<BR> System.out.println("Testing
creating Document from scratch
...");<BR> System.out.println("----------------------------------------------\n\n");<BR> <BR> test.newDocument(System.out);</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial
size=2> System.out.println("\n\n----------------------------------------------");<BR> System.out.println("Testing
reading Document using DOM
...");<BR> System.out.println("----------------------------------------------\n\n");<BR> <BR> test.domDocument(new
File(args[0]), System.out);</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial
size=2> System.out.println("\n\n----------------------------------------------");<BR> System.out.println("Testing
reading Document using SAX
...");<BR> System.out.println("----------------------------------------------\n\n");</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> test.saxDocument(new File(args[0]),
System.out);</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial
size=2> System.out.println("\n\n----------------------------------------------");<BR> System.out.println("Tests
complete. Successful build in place.");</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> } catch (Exception
e){<BR> e.printStackTrace();<BR> if(e
instanceof
JDOMException){<BR> System.out.println(((JDOMException)e)
.getRootCause()
<BR> .getMessage());<BR> }
else
{<BR> System.out.println(e.getMessage());<BR> }<BR> }<BR> }<BR>}</FONT></DIV>
<DIV><FONT face=Arial size=2>[/code]</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>Multispex Designs<BR>Rep.: Shant Adam<BR>Tel.:
(514) 827-4840<BR><A
href="mailto:adams@multispex.com">adams@multispex.com</A><BR><A
href="http://www.multispex.com">http://www.multispex.com</A><BR>---<BR>Visual
technology service provider.<BR>Fournisseur de service de technologie
visuel.<BR>---<BR>Copyright 1998-2002©<BR>Multispex
Designs®</FONT></DIV></BODY></HTML>