[jdom-interest] Null pointer exception parsing XML document.

Tasso Angelidis TassoA at trustmarque.ca
Tue Jul 3 12:49:24 PDT 2001


I was using JDOM a while back and I wrote a small app that reads an XML doc
parses it and prints out the information.

Here is the code:

SAXBuilder builder = new SAXBuilder(false);
Document doc = builder.build("Data/STLinkTransaction.xml");

System.out.println("SAX: Document successfully read");

Element root = doc.getRootElement();

String version = root.getAttribute("Version").getValue();

System.out.println(version);

String merchantID = new String();

Namespace ns = Namespace.getNamespace("yyyyy");

System.out.println(root.getChild("Merchant", ns).getChild("ID",
ns).getText());
System.out.println(root.getChild("Merchant", ns).getChild("Username",
ns).getText());
System.out.println(root.getChild("Merchant", ns).getChild("Password",
ns).getText());

System.out.println(merchantID);

Here is the XML data:

<?xml version="1.0"?>

<!--
*********************************************************************
xmlns is used for name spaces. A namespace must be attached to some 
sort of string. The string is my computer name.
*********************************************************************
-->

<!DOCTYPE SomeName:Transaction SYSTEM "../Data/STLinkTransaction.dtd">

<SomeName:Transaction xmlns:STLink="yyyyy" Version="yyy" Service="yyyy"
Test="true" TimeOut="10">
	<SomeName:Merchant>	
		<SomeName:ID>yyyyyyyy</STLink:ID>
		<SomeName:Username>yyyyyyy</STLink:Username>
		<SomeName:Password>yyyyyyy</STLink:Password>	
	</SomeName:Merchant>
</SomeName:Transaction>

This is the output:

SAX: Document successfully read
yyy
java.lang.NullPointerException
	at jdomtest.main(jdomtest.java:89)
Exception in thread "main"

Line 89 is the following: System.out.println(root.getChild("Merchant",
ns).getChild("ID", ns).getText());

The above used to work fine.
I guess it has been changed around with newer versions of JDOM.

I replaced all sensitive information with yyyyyyyyy.

-----Original Message-----
From: jdom-interest-admin at jdom.org [mailto:jdom-interest-admin at jdom.org]
Sent: Tuesday, July 03, 2001 2:19 AM
To: jdom-interest at jdom.org
Subject: jdom-interest digest, Vol 1 #641 - 20 msgs


Send jdom-interest mailing list submissions to
	jdom-interest at jdom.org

To subscribe or unsubscribe via the World Wide Web, visit
	http://lists.denveronline.net/mailman/listinfo/jdom-interest
or, via email, send a message with subject or body 'help' to
	jdom-interest-request at jdom.org

You can reach the person managing the list at
	jdom-interest-admin at jdom.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of jdom-interest digest..."


Today's Topics:

   1. Re: Getting Started...and stalled by SAXBuilder error.   Help?
(Steffen Gransow)
   2. Re: Re: JDOM events (Markus Bernhardt)
   3. Re: XPath status?? (Markus Bernhardt)
   4. Re: document encoding (Andy Clark)
   5. Is reverse XPath possible (Markus Bernhardt)
   6. Re: Is reverse XPath possible (bob mcwhirter)
   7. SAX/IE VM stuff - Thanks for all the help! (Jake Latham)
   8. More runtime class-finding problems - java/util/LinkedList ? (Jake
Latham)
   9. Re: More runtime class-finding problems - java/util/LinkedList ?
(Robert r. Sanders)
  10. Re: Parents - why do we need them? (Noam Tamim)
  11. SAXBuilder Not Found??? (Sands Fish)
  12. Re: More runtime class-finding problems -
       java/util/LinkedList ? (Ian Lea)
  13. namespace nit in B6 (Kyle F. Downey)
  14. Re: document encoding (Jason Hunter)
  15. Re: namespace nit in B6 (Jason Hunter)
  16. Re: document encoding (Andy Clark)
  17. grammar not found (Dushyandan Kanagaratnam)
  18. grammar not found (Dushyandan Kanagaratnam)
  19. Re: document encoding (Jason Hunter)

--__--__--

Message: 1
Date: Mon, 2 Jul 2001 08:28:41 +0200 (MEST)
From: Steffen Gransow <graste at gmx.de>
To: jdom-interest at jdom.org
Subject: Re: [jdom-interest] Getting Started...and stalled by SAXBuilder
error.   Help?

> > This code is being executed as an applet from internet explorer - is
> there a
> > setting for Explorer's Java VM runtime?  I'll see if I can't find
> something
> > like that in the registry, and if I do, I'll post it here for archive's
> > sake.
> 
> Applets suck.  You have to use the ARCHIVE attribute in the APPLET tag
> to make it download a class archive, and I'm not sure it works for
> JARs in IE.  Alternately, you could unjar jdom.jar (jar xf jdom.jar)
> into the code base where your applet is.  Since your applet class is
> in a package called "applet" (bad idea, by the way -- use your company
> name, like com.rockysoft.MyApplet), you'd end up with
> 
> applet/MyApplet.class
> org/jdom/Element.class
> 
> etc.
> 
> You can put all these together in a separate directory on your web
> server if you use the CODEBASE attribute.
> 
> Read the docs for the APPLET tag for more information.
> 
> You should also know that you probably need to use the 1.1 JVM version
> of JDOM.
> 
> -- 
> Alex Chaffee                       mailto:alex at jguru.com
> jGuru - Java News and FAQs         http://www.jguru.com/alex/
> Creator of Gamelan                 http://www.gamelan.com/
> Founder of Purple Technology       http://www.purpletech.com/
> Curator of Stinky Art Collective   http://www.stinky.com/
> _______________________________________________


With IE you can use something like this:

<object id="SerialApplet" height="0" width="0"
classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93">
<param name="name" value="SerialApplet"/>
<param name="code" value="de.ixware.medpack.cardpack.SerialApplet" />
<param name="codebase" value="http://pc11:8080/MedDok/applets"/>
<param name="scriptable" value="true"/>
</object>

All the classes you want to use can then be "unjared" to the path given by
the codebase parameter. The scriptable parameter only says, that public
methods of the applet can be accessed using javascript.
For a more detailed description on using the java plugin look at

http://www.java.sun.com/products/plugin/1.3/docs/index.docs.html

Under http://www.java.sun.com/products/plugin/1.3/docs/tags.html you'll find
ways of implementing applets cross-browser compatible.

Hope this helps a bit.

Regards,

Steffen Gransow

-- 
GMX - Die Kommunikationsplattform im Internet.
http://www.gmx.net

--
GMX Tipp:

Machen Sie Ihr Hobby zu Geld bei unserem Partner 1&1!
http://profiseller.de/info/index.php3?ac=OM.PS.PS003K00596T0409a


--__--__--

Message: 2
Date: Mon, 02 Jul 2001 10:36:03 +0100
From: Markus Bernhardt <mbernhardt at swsgmbh.de>
To: philip.nelson at omniresources.com,
        "jdom-interest at jdom.org" <jdom-interest at jdom.org>
Subject: Re: [jdom-interest] Re: JDOM events

This is a multi-part message in MIME format.
--------------D2746C559D04B2AF14F35DBA
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

philip.nelson at omniresources.com wrote:

> I just want to say that I hope you don't think I'm discouraging you from
> trying this.

Didn't thought that.
Had you time to look at my implementation ?

> There's only a few left that may remember that when I first
> appeared on this list, adding listeners was one of my primary motivations.
> This was based on less than optimal experiences with other api's that
tried
> it and didn't get it quite right,

Could you please point out the kind of problems you encountered
trying to build a event system ?

At the moment I have 'only' two problems:
1. FilterList
    FilterList is final so I can't subclass it, and the Filter interface
    is to narrow to fire events.
2. Design decision: Do bubbling ???
    The decision is: Having a hierarchic or a delegation type event system.
    Have both ? There are pros and cons on both types.
    At the moment I have implemeneted delegation type events.
    A listener has to register itself at each element, attribute, etc. to
    get notified of changes of THIS object. The listener will NOT be
    notified of any changes in child or parent objects.
    But there are some use cases where a hierarchic type would rock.
    Example:
        You have table style data:
            <data>
                <row .../>
                <row .../>
                <row .../>
            </data>
        Let' say 1000 rows, 50 columns.
        Now I want to show this data in a JTable via a TableModel.
        That means I have to navigate through 50000 objects and
        call addJDOMListener. There are some optimizations possible,
        but it's simply ugly.
    Registring at an element with xpath would be nice.
    Something like: data.addJDOMListener(listener, "./row/*").
    I have also implemented that stuff, but the performance is terrible
    poor, because of one big problem. All to me known xpath implementations
    are of the type: Take a start node and find the result nodes.
    So I get a list of objects and have to scroll through the list, to find
    (perhaps) the object which fired the event.
    What I need is a xpath implementation which can do something like:
    Is this object part of the result of this xpath applied to this object ?
    I tried to integrate this into the werken.xpath package, but it never
    worked stable.

> like ibm's XML Master (at the time) and on
> a note similar to what you seem to be doing, an xml based swing builder,
> Bluestone's XSwing and yet another presented by <I don't remember his
name>
> at SDExpo a couple of years ago.

I don't know XML Master very much and XSwing at all. But I think it's not
what we are doing.

>
>
> > > create listeners and add them to the tree at build time
> >
> > why ?
>
> Aren't you approaching this so that a modification to the xml document
fires
> an event?  Doesn't something have to be listening to the event even if it
is
> the document itself?

ok. Right.

>
>
> >
> > > extract the info needed for models
> >
> > > build and set models
> >
> > no. the tree is used as model.
>
> So you will always have a one to one relationship between each part of
your
> xml document and the model?

Yes and no. My document is much larger than one model.
I have TableModels, TreeModels, ListSelectionModels, TableColumnModels,....
represented by different trees in my document. And naturally there is
data not represented in a model.

> In your application that may be perfect, but it
> will almost certainly not be perfect in many cases.

Sure.

>
>
> >
> > > handle events
> >
> > already done
>
> see above
>
> > Question: How do you handle the 'other' direction ?
> > Somebody creates a new Element and adds it to your tree. And then ?
> > In your solution I have to use a reference to the model to do
> > programatic changes.
> > That's no option for me.
>
> I don't know what you are trying to do exactly but it sounds like what you
> basically want is a data bound ui control.

META-data bound ui control is one part of my problem.

> I still have scars on my
> forehead from trying to get that idea to work well :-).

Works quite well at the moment.

> It puts lot's of
> additional requirements on the XML document which by it's nature, already
> has a lot to do.  To me, a swing model should be maintained by an
> application which in turn gets it's information from some data source.

I don't have one application. I am building a software production
environment.
A redesign of our 3 year old framework. We produced about 450 applications
for 12 major projects with this environment. There is almost no application
specific
code. Everything is stored in metadata.
We have a generic client, which works like you have written.
Swing models created and maintained by the client application based on
meta data (not xml in our old client, but I think that don't matters).
After 3 years this has lead into complete chaos.
That's why we try somthing new (for us).
Write a client with only one central (xml) document.
Everything has to be stored in it. Perhaps it works. We'll see.

>
> These are all separate issues.  In your case it may be fine because the
data
> is for the gui but in general, this is not the case.  With this sort of
> binding you have other problems as well: validation, threads come to mind.

Why you dont have this problems with wrappers ?
The problems are not that obvios, but they are still there.

>
>
> with a wrapper, handling an insertion probably would work pretty much like
> it does in your case.  I have a selected node, the user clicks an insert
> button, I call the insert method on my node which updates the model
> intrinsically because it's in the model and adds the element to the
> document.
>
> >
> > I am not writing an application to just show and modify a jdom tree,
> > but a client with trees, buttons, tables, comboboxes and ONE central
> > jdom tree.
> > If a command for example adds the following element
> >     <gui type="frame" size="max;600" location="center;center"
> > visible="true" />
> > to my guimanager element a new JFrame will open immediatly.
> > Remove the element and the frame is history.
> > (That's working already !!)
>
> :-)
>
> > I think its worth to have a set of event enabled subclasses.
>
> I guess at this point I'm more interested in a clear idea about how to
> support swing gui's with jdom documents.  An event enabled subclass is
> certainly on the top ten requests list.  Having to watch every constructor
> and and every possible list implementation for changes looks pretty hard.
>
> _______________________________________________
> To control your jdom-interest membership:
>
http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhos
t.com

- markus

--------------D2746C559D04B2AF14F35DBA
Content-Type: text/x-vcard; charset=us-ascii;
 name="mbernhardt.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Markus Bernhardt
Content-Disposition: attachment;
 filename="mbernhardt.vcf"

begin:vcard 
n:Bernhardt;Markus
tel;cell:0171-5770462
tel;fax:089-420903-20
tel;home:089-6378949
tel;work:089-420903-14
x-mozilla-html:FALSE
url:www.swsgmbh.de
org:Software Service Wulf Schupp GmbH;Spieljoch
adr:;;Spieljochstr. 34;München;;81825;Germany
version:2.1
email;internet:mbernhardt at swsgmbh.de
title:Entwicklungsleiter
note;quoted-printable:[dF]Quisam=0D=0Awww.discordian-Front.de=0D=0AHail Eris
!!!=0D=0AHappy Frag !!!
fn:Markus Bernhardt
end:vcard

--------------D2746C559D04B2AF14F35DBA--


--__--__--

Message: 3
Date: Mon, 02 Jul 2001 10:38:09 +0100
From: Markus Bernhardt <mbernhardt at swsgmbh.de>
To: Colin Brumelle <cbrumelle at home.com>,
        "jdom-interest at jdom.org" <jdom-interest at jdom.org>
Subject: Re: [jdom-interest] XPath status??

This is a multi-part message in MIME format.
--------------13FAE99343A7BA8972F223C7
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

There is already a functional library for xpath with jdom.
Try:
http://code.werken.com

-markus

Colin Brumelle wrote:

> Hi all,
>         I'm new to this list, although I've been using (and loving!) jdom
since the
> beginning. I heard that the next JDOM release is going to include XPATH
> support. Are these rumors true?(I think I read about in the Enquirer)
Where
> would I find more info out on the status of the XPATH implementation?
>
> Thanks alot,
>
> Colin Brumelle
>
> _______________________________________________
> To control your jdom-interest membership:
>
http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhos
t.com

--------------13FAE99343A7BA8972F223C7
Content-Type: text/x-vcard; charset=us-ascii;
 name="mbernhardt.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Markus Bernhardt
Content-Disposition: attachment;
 filename="mbernhardt.vcf"

begin:vcard 
n:Bernhardt;Markus
tel;cell:0171-5770462
tel;fax:089-420903-20
tel;home:089-6378949
tel;work:089-420903-14
x-mozilla-html:FALSE
url:www.swsgmbh.de
org:Software Service Wulf Schupp GmbH;Spieljoch
adr:;;Spieljochstr. 34;München;;81825;Germany
version:2.1
email;internet:mbernhardt at swsgmbh.de
title:Entwicklungsleiter
note;quoted-printable:[dF]Quisam=0D=0Awww.discordian-Front.de=0D=0AHail Eris
!!!=0D=0AHappy Frag !!!
fn:Markus Bernhardt
end:vcard

--------------13FAE99343A7BA8972F223C7--


--__--__--

Message: 4
Date: Mon, 02 Jul 2001 18:50:34 +0900
From: Andy Clark <andyc at apache.org>
To: JDOM <jdom-interest at jdom.org>
Subject: Re: [jdom-interest] document encoding

Jason Hunter wrote:
> SAX doesn't report the encoding, unfortunately.

Xerces2 reports the auto-detected encoding of all entities
(including the document) as well as the specified encoding
in the XMLDecl/TextDecl through the Xerces Native Interface
(XNI). So while we can't push that information out through
DOM or SAX (or JDOM for that matter), you can access that
info if you program straight to XNI (or just extend the
DOMParser or SAXParser to catch that information).

-- 
Andy Clark * IBM, TRL - Japan * andyc at apache.org

--__--__--

Message: 5
Date: Mon, 02 Jul 2001 17:03:05 +0100
From: Markus Bernhardt <mbernhardt at swsgmbh.de>
To: "jdom-interest at jdom.org" <jdom-interest at jdom.org>,
        bob mcwhirter <bob at werken.com>
Subject: [jdom-interest] Is reverse XPath possible

This is a multi-part message in MIME format.
--------------0B17D6C2B29ADAA7D9741CB7
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Hi !

What I need is a xpath implementation which can do something like:
Is this object part of the result of this xpath applied to this object ?

All to me known xpath implementations are of the type:
    Take a start node and find the result nodes.
So I get a list of objects and have to scroll through the list, to find
(perhaps) my object.

Question:
Is it possible to extend the werken.xpath package to accomplish this
task ?
Is it possible at all to write such a xpath algorithm ?

- markus

--------------0B17D6C2B29ADAA7D9741CB7
Content-Type: text/x-vcard; charset=us-ascii;
 name="mbernhardt.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Markus Bernhardt
Content-Disposition: attachment;
 filename="mbernhardt.vcf"

begin:vcard 
n:Bernhardt;Markus
tel;cell:0171-5770462
tel;fax:089-420903-20
tel;home:089-6378949
tel;work:089-420903-14
x-mozilla-html:FALSE
url:www.swsgmbh.de
org:Software Service Wulf Schupp GmbH;Spieljoch
adr:;;Spieljochstr. 34;München;;81825;Germany
version:2.1
email;internet:mbernhardt at swsgmbh.de
title:Entwicklungsleiter
note;quoted-printable:[dF]Quisam=0D=0Awww.discordian-Front.de=0D=0AHail Eris
!!!=0D=0AHappy Frag !!!
fn:Markus Bernhardt
end:vcard

--------------0B17D6C2B29ADAA7D9741CB7--


--__--__--

Message: 6
Date: Mon, 2 Jul 2001 11:01:37 -0400 (EDT)
From: bob mcwhirter <bob at werken.com>
To: Markus Bernhardt <mbernhardt at swsgmbh.de>
cc: "jdom-interest at jdom.org" <jdom-interest at jdom.org>
Subject: [jdom-interest] Re: Is reverse XPath possible


Currently, no that's not possible.

No certain how it'd be implemented either, since wacky xpaths
can require almost a complete evaluation of it to determine
membership.

You can always just eval the xpath, dump the resulitng List into
a HashSet, and then you have nearly constant-time lookup to see
if your desired element is a member.

	-bob

On Mon, 2 Jul 2001, Markus Bernhardt wrote:

> Hi !
> 
> What I need is a xpath implementation which can do something like:
> Is this object part of the result of this xpath applied to this object ?
> 
> All to me known xpath implementations are of the type:
>     Take a start node and find the result nodes.
> So I get a list of objects and have to scroll through the list, to find
> (perhaps) my object.
> 
> Question:
> Is it possible to extend the werken.xpath package to accomplish this
> task ?
> Is it possible at all to write such a xpath algorithm ?
> 
> - markus
> 


--__--__--

Message: 7
Reply-To: <jlatham at rockysoft.com>
From: "Jake Latham" <jlatham at rockysoft.com>
To: <jdom-interest at jdom.org>
Date: Mon, 2 Jul 2001 10:15:50 -0600
Subject: [jdom-interest] SAX/IE VM stuff - Thanks for all the help!

This is a multi-part message in MIME format.

------=_NextPart_000_0008_01C102DF.F8D0A370
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

I just wanted to throw out a thank-you for all of the helpful answers I got
from you folks, both individually and to the list.  Sure is nice to know
that there's some helpful folks out there for next time my dumb self can't
get past a problem...

Thanks again,

-J

------=_NextPart_000_0008_01C102DF.F8D0A370
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Diso-8859-1">


<META content=3D"MSHTML 5.50.4522.1800" name=3DGENERATOR></HEAD>
<BODY>
<DIV><SPAN class=3D091211416-02072001><FONT face=3DArial size=3D2>I just =
wanted to=20
throw out a thank-you for all of the helpful answers I got from you =
folks, both=20
individually and to the list.&nbsp; Sure is nice to know that there's =
some=20
helpful folks out there for next time my dumb self can't get past a=20
problem...</FONT></SPAN></DIV>
<DIV><SPAN class=3D091211416-02072001><FONT face=3DArial=20
size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D091211416-02072001><FONT face=3DArial size=3D2>Thanks =
again,=20
</FONT></SPAN></DIV>
<DIV><SPAN class=3D091211416-02072001><FONT face=3DArial=20
size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D091211416-02072001><FONT face=3DArial=20
size=3D2>-J</FONT></SPAN></DIV></BODY></HTML>

------=_NextPart_000_0008_01C102DF.F8D0A370--


--__--__--

Message: 8
Reply-To: <jlatham at rockysoft.com>
From: "Jake Latham" <jlatham at rockysoft.com>
To: <jdom-interest at jdom.org>
Date: Mon, 2 Jul 2001 11:00:52 -0600
Subject: [jdom-interest] More runtime class-finding problems -
java/util/LinkedList ?

OK -

having gotten past all of the applet stuff, I'm still trying to simply open
up the XML File. I'm sure once I get that far, I'll be fine, since I've
enough experience dealing with XML.  Now I'm getting this error:


Exception occurred during event dispatching:
java.lang.NoClassDefFoundError: java/util/LinkedList
 at org/jdom/Document.<init> (Document.java:117)
 at org/jdom/Document.<init> (Document.java:135)
 at org/jdom/input/SAXBuilder.build (SAXBuilder.java:257)
 at org/jdom/input/SAXBuilder.build (SAXBuilder.java:464)
 at org/jdom/input/SAXBuilder.build (SAXBuilder.java:445)


from this code:

     SAXBuilder saxBuilder = new SAXBuilder();
     Document xmlDoc = saxBuilder.build(new File("C:\\contacts.xml"));
     //System.out.println(xmlDoc.toString());

with these imports:

import java.net.*;
import java.io.*;
import java.util.*;  <-------

import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder;
import org.jdom.output.XMLOutputter;

is this another pathing thing? I'd be inclined to think so since it's a
similar error to before (compiles OK, doesn't run), but for the life of me I
can't find which .jar or path I need to have included in the classpath.  Can
you help me again?

-J


--__--__--

Message: 9
From: "Robert r. Sanders" <robert.sanders at ipov.net>
To: <jdom-interest at jdom.org>
Subject: Re: [jdom-interest] More runtime class-finding problems -
java/util/LinkedList ?
Date: Mon, 2 Jul 2001 13:57:11 -0500

You need to compile the java 1.1 version of JDOM and provide that along with
collections.jar as part of the applet's path.  Or you could require the java
plugin.  Otherwise the browser, with its java 1.1.x JRE will not be able to
find the collection classes.

Robert Sanders

----- Original Message -----
From: "Jake Latham" <jlatham at rockysoft.com>
To: <jdom-interest at jdom.org>
Sent: Monday, July 02, 2001 12:00 PM
Subject: [jdom-interest] More runtime class-finding problems -
java/util/LinkedList ?


> OK -
>
> having gotten past all of the applet stuff, I'm still trying to simply
open
> up the XML File. I'm sure once I get that far, I'll be fine, since I've
> enough experience dealing with XML.  Now I'm getting this error:
>
>
> Exception occurred during event dispatching:
> java.lang.NoClassDefFoundError: java/util/LinkedList
>  at org/jdom/Document.<init> (Document.java:117)
>  at org/jdom/Document.<init> (Document.java:135)
>  at org/jdom/input/SAXBuilder.build (SAXBuilder.java:257)
>  at org/jdom/input/SAXBuilder.build (SAXBuilder.java:464)
>  at org/jdom/input/SAXBuilder.build (SAXBuilder.java:445)
>
>
> from this code:
>
>      SAXBuilder saxBuilder = new SAXBuilder();
>      Document xmlDoc = saxBuilder.build(new File("C:\\contacts.xml"));
>      file://System.out.println(xmlDoc.toString());
>
> with these imports:
>
> import java.net.*;
> import java.io.*;
> import java.util.*;  <-------
>
> import org.jdom.Document;
> import org.jdom.Element;
> import org.jdom.JDOMException;
> import org.jdom.input.SAXBuilder;
> import org.jdom.output.XMLOutputter;
>
> is this another pathing thing? I'd be inclined to think so since it's a
> similar error to before (compiles OK, doesn't run), but for the life of me
I
> can't find which .jar or path I need to have included in the classpath.
Can
> you help me again?
>
> -J
>
> _______________________________________________
> To control your jdom-interest membership:
>
http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhos
t.com
>
>
>



--__--__--

Message: 10
From: "Noam Tamim" <noamt at yahoo.com>
To: "Amy Lewis" <amyzing at talsever.com>, <jdom-interest at jdom.org>
Subject: Re: [jdom-interest] Parents - why do we need them?
Date: Mon, 2 Jul 2001 22:32:31 +0200

> >That's the whole idea of "Shared"; my target was definitely not memory
> >optimization, but the ability to change the attributes of many elements
with
> >a single call. Another approach could be to use an Attribute that uses a
> >StringBuffer for the value, and exposes it - so I can use the same
> >StringBuffer for many Attributes, and change it later.
> That might be the most graceful of the possibilities, since it would
> provide a fairly trivial way to implement copy-on-write as well, for
> those who want that.  Feel like implementing an example?

Here:
===
import org.jdom.*;
import org.jdom.output.*;

public class SBAttribute extends Attribute {
 protected StringBuffer value;

 public SBAttribute(String name, StringBuffer value, Namespace ns) {
  super(); // avoid setting the original String value.
  setName(name);
  setValue(value);
  setNamespace(ns);
 }

 public SBAttribute(String name, StringBuffer value) {
  this(name,value,Namespace.NO_NAMESPACE);
 }

 // return the actual StringBuffer used by this attribute.
 public StringBuffer getBuffer() {
  return value;
 }

 public String getValue() {
  return value.toString();
 }

 public Attribute setValue(String value) {
  return setValue(new StringBuffer(value));
 }

 public SBAttribute setValue(StringBuffer value) {
  // here should probably come some verifications.
  this.value=value;
  return this;
 }
}
===


And here's an example of using it:
void main() throws IOException {
  Element root=new Element("root");
  StringBuffer name=new StringBuffer("noam");
  root.addContent(new Element("user").setAttribute(new
SBAttribute("name",name)));
  root.addContent(new Element("user").setAttribute(new
SBAttribute("name",name)));
  root.addContent(new Element("user").setAttribute(new
SBAttribute("name",name)));
  Document doc=new Document(root);

  XMLOutputter xout=new XMLOutputter("  ",true);

  System.out.println("name="+name);
  xout.output(doc,System.out);

  name.reverse();
  System.out.println("name="+name);
  xout.output(doc,System.out);
}


Now, I'm really not sure this is the correct way to go; I was just throwing
an idea, to see what people think of it. I'm not even sure there's use to
it.


 - Noam.





--__--__--

Message: 11
From: Sands Fish <Sands_Fish at telecomnow.com>
To: "'jdom-interest at jdom.org'" <jdom-interest at jdom.org>
Date: Mon, 2 Jul 2001 15:38:12 -0400 
Subject: [jdom-interest] SAXBuilder Not Found???

Hello,
	Has anyone else had this problem?  I have JDOM b7 c.r.3 and i've
compiled my app perfectly fine but as soon as i run it, i get a runtime
error for NoClassDefFoundError:  org/jdom/input/SAXBuilder at the line where
it is instantiated.  I've got all the jars that come with JDOM in the
/jre/lib/ext/ directory and it finds other JDOM classes, but not the
SAXBuilder!  Any suggestions?  Anyone seen this?  Thanx girls/guys.

- Sands Fish
- telecomNOW
- Sands at telecomnow.com

--__--__--

Message: 12
Date: Mon, 02 Jul 2001 20:46:01 +0100
From: Ian Lea <ian.lea at blackwell.co.uk>
To: jlatham at rockysoft.com
Cc: jdom-interest at jdom.org
Subject: Re: [jdom-interest] More runtime class-finding problems - 
 java/util/LinkedList ?

Are you running java 1.2+ on the client?  java.util.LinkedList is
part of the Collections API which came in at 1.2.  There is
a 1.1 version of jdom.jar in the build/ directory along with
lib/collections.jar and, I think, some stuff in the FAQ.


--
Ian.
ian.lea at blackwell.co.uk

Jake Latham wrote:
> 
> OK -
> 
> having gotten past all of the applet stuff, I'm still trying to simply
open
> up the XML File. I'm sure once I get that far, I'll be fine, since I've
> enough experience dealing with XML.  Now I'm getting this error:
> 
> Exception occurred during event dispatching:
> java.lang.NoClassDefFoundError: java/util/LinkedList
>  at org/jdom/Document.<init> (Document.java:117)
>  at org/jdom/Document.<init> (Document.java:135)
>  at org/jdom/input/SAXBuilder.build (SAXBuilder.java:257)
>  at org/jdom/input/SAXBuilder.build (SAXBuilder.java:464)
>  at org/jdom/input/SAXBuilder.build (SAXBuilder.java:445)
> 
> from this code:
> 
>      SAXBuilder saxBuilder = new SAXBuilder();
>      Document xmlDoc = saxBuilder.build(new File("C:\\contacts.xml"));
>      //System.out.println(xmlDoc.toString());
> 
> with these imports:
> 
> import java.net.*;
> import java.io.*;
> import java.util.*;  <-------
> 
> import org.jdom.Document;
> import org.jdom.Element;
> import org.jdom.JDOMException;
> import org.jdom.input.SAXBuilder;
> import org.jdom.output.XMLOutputter;
> 
> is this another pathing thing? I'd be inclined to think so since it's a
> similar error to before (compiles OK, doesn't run), but for the life of me
I
> can't find which .jar or path I need to have included in the classpath.
Can
> you help me again?
> 
> -J

--__--__--

Message: 13
Date: Mon, 2 Jul 2001 21:25:18 +0000 (GMT)
From: "Kyle F. Downey" <kdowney at amberarcher.com>
To: <jdom-interest at jdom.org>
Subject: [jdom-interest] namespace nit in B6


I'm using the XMLOutputter to re-output a JDOM tree I
loaded using the SAXBuilder. In between, I add a new
node whose name is in the default namespace for the
document. However, the new node gets printed with
the namespace specified explicitly:

<registry xmlns="http://schemas.a3sr.com/registry/bs/xml.xsd">
  <stdbs:key xmlns:stdbs="http://schemas.a3sr.com/registry/bs/xml.xsd"/>
</registry>

The parser should handle this fine, of course, but it
violates the Principle of Least Astonishment and it
also bulks up the document unnecessarily. Can the outputter
check whether the element name's Namespace URI matches
the document namespace URI before deciding to qualify
the name and add an xmlns tag?

--kd


--__--__--

Message: 14
Date: Mon, 02 Jul 2001 13:37:49 -0700
From: Jason Hunter <jhunter at acm.org>
To: Andy Clark <andyc at apache.org>
CC: JDOM <jdom-interest at jdom.org>
Subject: Re: [jdom-interest] document encoding

Andy Clark wrote:
> 
> Jason Hunter wrote:
> > SAX doesn't report the encoding, unfortunately.
> 
> Xerces2 reports the auto-detected encoding of all entities
> (including the document) as well as the specified encoding
> in the XMLDecl/TextDecl through the Xerces Native Interface
> (XNI). So while we can't push that information out through
> DOM or SAX (or JDOM for that matter), you can access that
> info if you program straight to XNI (or just extend the
> DOMParser or SAXParser to catch that information).

It would be very valuable to have a builder based on XNI, to provide the
extra features missing in SAX and probably to gain a little speed boost
by not going through the SAX layer.  Andy, do you think X2 is far enough
along to start an XNI builder effort?

Anyone want to volunteer?

-jh-

--__--__--

Message: 15
Date: Mon, 02 Jul 2001 14:29:34 -0700
From: Jason Hunter <jhunter at acm.org>
To: "Kyle F. Downey" <kdowney at amberarcher.com>
CC: jdom-interest at jdom.org
Subject: Re: [jdom-interest] namespace nit in B6

"Kyle F. Downey" wrote:
> 
> I'm using the XMLOutputter to re-output a JDOM tree I
> loaded using the SAXBuilder. In between, I add a new
> node whose name is in the default namespace for the
> document. However, the new node gets printed with
> the namespace specified explicitly:
> 
> <registry xmlns="http://schemas.a3sr.com/registry/bs/xml.xsd">
>   <stdbs:key xmlns:stdbs="http://schemas.a3sr.com/registry/bs/xml.xsd"/>
> </registry>
> 
> The parser should handle this fine, of course, but it
> violates the Principle of Least Astonishment and it
> also bulks up the document unnecessarily. Can the outputter
> check whether the element name's Namespace URI matches
> the document namespace URI before deciding to qualify
> the name and add an xmlns tag?

If you're using beta6 you should really jump to beta7.  Lots has
changed.

That may not affect this though because if you explicitly made a
Namespace with the prefix "stdbs" for the key element, then the
outputter is doing the right thing in preserving that prefix in the
document.

-jh-

--__--__--

Message: 16
Date: Tue, 03 Jul 2001 11:04:21 +0900
From: Andy Clark <andyc at apache.org>
To: JDOM <jdom-interest at jdom.org>
Subject: Re: [jdom-interest] document encoding

Jason Hunter wrote:
> It would be very valuable to have a builder based on XNI, to provide the
> extra features missing in SAX and probably to gain a little speed boost
> by not going through the SAX layer.  Andy, do you think X2 is far enough
> along to start an XNI builder effort?

I think it's quite usuable now and pretty stable. No Schema
support, unfortunately, though. And, just like JDOM, the XNI
API is subject to change but it if it does, it should be minor 
(knock on wood).

P.S. Is there any particular reason why the mailing list
     doesn't set the Reply-To header to be jdom-interest?

-- 
Andy Clark * IBM, TRL - Japan * andyc at apache.org

--__--__--

Message: 17
Reply-To: <dushyk at securepay.com.au>
From: "Dushyandan Kanagaratnam" <dushyk at securepay.com.au>
To: <jdom-interest at jdom.org>
Date: Tue, 3 Jul 2001 12:04:01 +1000
Subject: [jdom-interest] grammar not found

Hi all,

I am a Java developer who is new to XML. I use Java and XML by Brett
McLaughlin as my guide :) . I constructed a simple XML and DTD to test with
JDOM.

XML:

<?xml version="1.0"?>

<!DOCTYPE dvr:DataValidationRules SYSTEM "ValidationRules.dtd">

<dvr:DataValidationRules xmlns:dvr="http://www.securepay.com.au">
JDOM Test
</dvr:DataValidationRules>

DTD:

<!ELEMENT dvr:DataValidationRules (#PCDATA)>

when the document is parsed I am getting http://www.securepay.com.au grammar
not found message. Can somebody explain this message to me.

Regards,

-Dushy-


--__--__--

Message: 18
Reply-To: <dushyk at securepay.com.au>
From: "Dushyandan Kanagaratnam" <dushyk at securepay.com.au>
To: <jdom-interest at jdom.org>
Date: Tue, 3 Jul 2001 12:13:39 +1000
Subject: [jdom-interest] grammar not found

Hi all,

I am a Java developer who is new to XML. I constructed a simple XML and XSD
(Schema) to test with JDOM and XML Parser. I am using Xerces 1.4.1 XML
parser from apache (which is supposed to support XML Schema).

XML:

<?xml version="1.0"?>

<DataValidationRules xmlns:xsi="http://www.w3c.org/2001/XMLSchema-instance"
		     xmlns="http://www.securepay.com.au"
                     xsi:schemaLocation="http://www.securepay.com.au
ValidationRules.xsd">

XML Test
</DataValidationRules>

XSD:

<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3c.org/2001/XMLSchema"
	    targetNamespace="http://www.jdom.org"
            xmlns="http://www.jdom.org"
            elementFormDefault="qualified">

<xsd:element name="DataValidationRules" type="string" />
</xsd:schema>

when the document is parsed I am following 2 things happen:
1. I get 'http://www.securepay.com.au grammar not found' message.
2. An Exception org.jdom.JDOMException: Error on line 5 of document
file:/D:/Software/EBPSystem/EBPS_BSP/ValidationRules1.xml: Element type
"DataValidationRules" must be declared is thrown.

Regards,

-Dushy-


--__--__--

Message: 19
Date: Mon, 02 Jul 2001 20:15:54 -0700
From: Jason Hunter <jhunter at collab.net>
To: Andy Clark <andyc at apache.org>
CC: JDOM <jdom-interest at jdom.org>
Subject: Re: [jdom-interest] document encoding

> P.S. Is there any particular reason why the mailing list
>      doesn't set the Reply-To header to be jdom-interest?

http://www.unicom.com/pw/reply-to-harmful.html

-jh-


--__--__--

_______________________________________________
To control your jdom-interest membership:
http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhos
t.com

End of jdom-interest Digest



More information about the jdom-interest mailing list