[jdom-interest] Re: jdom 1.0 XMLOutputter -- problems

Tatu Saloranta cowtowncoder at yahoo.com
Wed May 10 16:39:40 PDT 2006


--- Frances <fdr58 at yahoo.com> wrote:

...
> I see various packages that come w/jdom download,
> however can find only 
> docs for jdom.jar, where are docs for all other jars
> in this download 
> (xalan.jar, xerces.jar, xml-apis.jar, etc... I have

Xalan and Xerces are separate projects (for XSLT and
actual XML parsing, respectively -- JDOM is not a
parser, but a tree model built from data parser
provides). So their documentation would be found
starting from their home pages. As usual, try googling
for those keywords -- as usual it shows you where to
look. But most likely you don't really need docs for
those, as they are only internally used by JDOM, or
used via standard JAXP (JDK 1.4 and up) APIs,
javax.xml.parser.*.

> never been able to 
> find docs for xml-apis.jar, it comes also with
> Tomcat, why no docs..) 

That probably contains SAX, DOM and perhaps JAXP
interfaces. As such, it's not even needed with JDK 1.4
and above, which includes these by default.

-+ Tatu +-

> thanks..
> 
> 
> 
> Edelson, Justin wrote:
> > Here's some basic document creation code:
> > 	Document document = new Document();
> > 	Element rootElement = new Element("root");
> > 	document.setRootElement(rootElement);
> > 	Element childElement = new Element("child");
> > 	rootElement.addContent(childElement);
> > 	childElement.setText("some text"); 
> > 
> > Same code all on one line:
> > 	Document doc2 = new Document().setRootElement(new
> > Element("root").addContent(new
> Element("child").setText("some text")));
> > 
> > As for your other issues, these really don't have
> anything to do with
> > jdom. I suggest you read up on the importance of
> the classpath to figure
> > out why your are getting a ClassNotFoundException.
> Comparing
> > command-line Java with Tomcat isn't really a valid
> comparison as Tomcat
> > is a container that uses custom classloaders based
> on a directory
> > structure.
> > 
> > As for your FileNotFoundException, any reason to
> think this isn't just
> > because this file doesn't exist?
> > 
> > Justin
> > 
> > -----Original Message-----
> > From: jdom-interest-bounces at jdom.org
> > [mailto:jdom-interest-bounces at jdom.org] On Behalf
> Of Frances
> > Sent: Monday, April 03, 2006 4:52 PM
> > To: jdom-interest at jdom.org
> > Subject: [jdom-interest] Re: jdom 1.0 XMLOutputter
> -- problems
> > 
> > Bradley S. Huffman wrote:
> > 
> >>>Exception in thread "main"
> java.lang.NoClassDefFoundError: 
> >>>org/jdom/input/SAXBuilder..
> >>>
> >>>I downloaded jdom this weekend, put jdom.jar and
> all other jars that 
> >>>come with the download in the classpath...  but
> get many errors when 
> >>>trying to compile stuff (deprecated methods (like
> addAttribute(), 
> >>>which I change to setAttribute() but still get
> errors..  errors that 
> >>>SAXBuilder and XMLOutputter can't be found.. I
> looked in jar, I looked
> > 
> > 
> >>>in docs, these classes are there..) what is the
> problem pls, thank
> > 
> > you...
> > 
> >>
> >>addAttribute?  Sounds like there's a very old jar
> in your classpath. 
> >>Did you download from
> http://www.jdom.org/dist/binary either 
> >>jdom-1.0.tar.gz or jdom-1.0.zip, and are you sure
> it's in your
> > 
> > classpath?
> > 
> >>Brad
> >>_______________________________________________
> >>To control your jdom-interest membership:
>
>>http://www.jdom.org/mailman/options/jdom-interest/youraddr@yourhost.co
> >>m
> >>
> > 
> > yes and yes....
> > 
> > downloaded just this weekend, downloaded
> jdom-1.0.zip...
> > 
> > ok, look at this small example, from
> >
>
http://www.javaworld.com/javaworld/jw-05-2000/jw-0518-jdom-p2.html
> > 
> > import java.io.*;
> > import org.jdom.*;
> > import org.jdom.input.SAXBuilder;
> > import org.jdom.input.*;
> > import org.jdom.output.*;
> > 
> > public class PrettyPrinter {
> >     public static void main(String[] args) {
> >      //    Assume filename argument
> >      //    String filename = args[0];
> > 	  String filename = "myFile";
> > 
> >          try {
> >              // Build the document with SAX and
> Xerces, no validation
> >              SAXBuilder builder = new
> SAXBuilder();
> >              // Create the document
> >              Document doc = builder.build(new
> File(filename));
> > 
> >              // Output the document, use standard
> formatter
> >              XMLOutputter fmt = new
> XMLOutputter();
> >              fmt.output(doc, System.out);
> >          } catch (Exception e) {
> >              e.printStackTrace();
> >          }
> >      }
> > }
> > 
> > this compiles fine but when run it with just this
> command:
> > 
> >      java PrettyPrinter
> > 
> > get following error: Exception in thread "main" 
> > java.lang.NoClassDefFoundError:
> org/jdom/input/SAXBui lder (I don't get
> > this.. if this class cannot be found how come it
> compiled fine?  do you
> > need to always indicate cp when running classes
> with third-party API's?
> > I don't have to do this w/Tomcat..)
> > 
> > if I run it like this:  java -cp jdom.jar;.
> PrettyPrinter
> > 
> > get this error:
> > 
> > java.io.FileNotFoundException: C:\Documents and
> Settings\fdelrio\My
> > Documents\xslt\myFile (The system cannot find the
> file specified)
> >          at java.io.FileInputStream.open(Native
> Method)
> >          at java.io.FileInputStream.<init>(Unknown
> Source)
> >          at java.io.FileInputStream.<init>(Unknown
> Source)
> >          at
>
sun.net.www.protocol.file.FileURLConnection.connect(Unknown
> > Source)
> >          at
> >
>
sun.net.www.protocol.file.FileURLConnection.getInputStream(Unknown
> So
> > urce)
> >          at java.net.URL.openStream(Unknown
> Source)
> >          at
> org.apache.crimson.parser.InputEntity.init(Unknown
> Source)
> >          at
>
org.apache.crimson.parser.Parser2.parseInternal(Unknown
> > Source)
> >          at
> org.apache.crimson.parser.Parser2.parse(Unknown
> Source)
> >          at
>
org.apache.crimson.parser.XMLReaderImpl.parse(Unknown
> > Source)
> >          at
> org.jdom.input.SAXBuilder.build(SAXBuilder.java:453)
> >          at
> org.jdom.input.SAXBuilder.build(SAXBuilder.java:810)
> >          at
> org.jdom.input.SAXBuilder.build(SAXBuilder.java:789)
> >          at
> PrettyPrinter.main(PrettyPrinter.java:20)
> > 
> > 
> 
=== message truncated ===


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


More information about the jdom-interest mailing list