Home > Archive > Java Help > April 2004 > XML Questions
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
|
| I have a very simple XML document for settings in an program I have written.
I want to be able to read in and update these settings.
- Would I be better using DOM or SAX?
- What would be the best parser for me?
Also, as I'm new to XML in Java (and also fairly new to Java) I'm still
unsure on what effect exactly implementing XML in my program will have. It's
a very simple program (the java files are 35kb in total) - it appears to me
that if I use XML then I'll have to include a comparatively huge XML parser
with my program when distributing it - I've just downloaded the IBM one and
it's 2.6MB. Is this true or am I misunderstanding something fundamental
here?
TIA.
| |
| Bryce (Work) 2004-04-09, 12:34 pm |
| On Fri, 9 Apr 2004 10:03:36 +0100, "Jo" <jojo@spamfree.com> wrote:
>I have a very simple XML document for settings in an program I have written.
>I want to be able to read in and update these settings.
>
>- Would I be better using DOM or SAX?
>- What would be the best parser for me?
>
>Also, as I'm new to XML in Java (and also fairly new to Java) I'm still
>unsure on what effect exactly implementing XML in my program will have. It's
>a very simple program (the java files are 35kb in total) - it appears to me
>that if I use XML then I'll have to include a comparatively huge XML parser
>with my program when distributing it - I've just downloaded the IBM one and
>it's 2.6MB. Is this true or am I misunderstanding something fundamental
>here?
A lot depends on your requirements.
If using XML, it really depends on several things.
Realize that when using DOM, you are loading the entire document,
which can impact memory consumption (if its a large document), time to
process, etc. Not much of an issue if its a small document. You might
also want to look at JDOM.
SAX is good for large documents, a bit faster.
If the document is simple, then you might want to consider using a
..properties file. Built in functions in java to handle the files,
etc...
--
now with more cowbell
| |
| Steve W. Jackson 2004-04-09, 3:36 pm |
| In article <hmgd701m03s0jdfpi5co9s8jeejkpvjj7b@4ax.com>,
"Bryce (Work)" <spamtrap@berzerker-soft.com> wrote:
>:On Fri, 9 Apr 2004 10:03:36 +0100, "Jo" <jojo@spamfree.com> wrote:
>:
>:>I have a very simple XML document for settings in an program I have written.
>:>I want to be able to read in and update these settings.
>:>
>:>- Would I be better using DOM or SAX?
>:>- What would be the best parser for me?
>:>
>:>Also, as I'm new to XML in Java (and also fairly new to Java) I'm still
>:>unsure on what effect exactly implementing XML in my program will have. It's
>:>a very simple program (the java files are 35kb in total) - it appears to me
>:>that if I use XML then I'll have to include a comparatively huge XML parser
>:>with my program when distributing it - I've just downloaded the IBM one and
>:>it's 2.6MB. Is this true or am I misunderstanding something fundamental
>:>here?
>:
>:A lot depends on your requirements.
>:
>:If using XML, it really depends on several things.
>:
>:Realize that when using DOM, you are loading the entire document,
>:which can impact memory consumption (if its a large document), time to
>:process, etc. Not much of an issue if its a small document. You might
>:also want to look at JDOM.
>:
>:SAX is good for large documents, a bit faster.
>:
>:If the document is simple, then you might want to consider using a
>:.properties file. Built in functions in java to handle the files,
>:etc...
>:
>:--
>:now with more cowbell
Good advice, but it's lacking a fundamental point. If you use a recent
Java version (as of about 1.3, if memory serves), there's no need for
any additional software. Skip JDOM, Xerces, IBM, all the rest. As a
matter of fact, a major part of Xerces is what's now included in Java
(see the javax.xml, org.xml.sax and org.w3c packages in the API). You
can do both DOM and SAX parsing, and manipulate DOM documents all you
like, all without anything that's not already included in 1.3 and later.
= Steve =
--
Steve W. Jackson
Montgomery, Alabama
| |
| Bryce (Work) 2004-04-09, 4:34 pm |
| On Fri, 09 Apr 2004 13:33:19 -0500, "Steve W. Jackson"
<stevewjackson@charter.net> wrote:
>Good advice, but it's lacking a fundamental point. If you use a recent
>Java version (as of about 1.3, if memory serves), there's no need for
>any additional software. Skip JDOM, Xerces, IBM, all the rest. As a
>matter of fact, a major part of Xerces is what's now included in Java
>(see the javax.xml, org.xml.sax and org.w3c packages in the API). You
>can do both DOM and SAX parsing, and manipulate DOM documents all you
>like, all without anything that's not already included in 1.3 and later.
Thats true... But there is a cost to using XML. Sometimes its worth
it. Sometimes, a lightweight mechanism like properties are approriate.
--
now with more cowbell
| |
| Josef Garvi 2004-04-11, 4:34 pm |
| Jo wrote:
> I have a very simple XML document for settings in an program I have written.
> I want to be able to read in and update these settings.
>
> - Would I be better using DOM or SAX?
Use DOM.
> - What would be the best parser for me?
Use the Xerces-version that is built into the JDK.
> Also, as I'm new to XML in Java (and also fairly new to Java) I'm still
> unsure on what effect exactly implementing XML in my program will have. It's
> a very simple program (the java files are 35kb in total) - it appears to me
> that if I use XML then I'll have to include a comparatively huge XML parser
> with my program when distributing it - I've just downloaded the IBM one and
> it's 2.6MB. Is this true or am I misunderstanding something fundamental
> here?
I'm not an expert at this, but I guess that if you use the libraries that
are in the JDK, your program will not grow from it in size.
--
Josef Garvi
"Reversing desertification through drought tolerant trees"
http://www.eden-foundation.org/
new income - better environment - more food - less poverty
| |
| Josef Garvi 2004-04-11, 4:34 pm |
| Bryce (Work) wrote:
>
> Thats true... But there is a cost to using XML. Sometimes its worth
> it. Sometimes, a lightweight mechanism like properties are approriate.
True.
On the other hand, one is likely to need XML in one way or another
nowadays. Getting used to the basics of XML by implementing something
simple as in Jo's case can be a good way of getting acquainted with the
technology.
--
Josef Garvi
"Reversing desertification through drought tolerant trees"
http://www.eden-foundation.org/
new income - better environment - more food - less poverty
| |
| Dale King 2004-04-12, 5:51 pm |
| "Bryce (Work)" <spamtrap@berzerker-soft.com> wrote in message
news:hmgd701m03s0jdfpi5co9s8jeejkpvjj7b@
4ax.com...
> On Fri, 9 Apr 2004 10:03:36 +0100, "Jo" <jojo@spamfree.com> wrote:
>
written.[color=darkred]
It's[color=darkred]
me[color=darkred]
parser[color=darkred]
and[color=darkred]
>
> A lot depends on your requirements.
>
> If using XML, it really depends on several things.
>
> Realize that when using DOM, you are loading the entire document,
> which can impact memory consumption (if its a large document), time to
> process, etc. Not much of an issue if its a small document. You might
> also want to look at JDOM.
I suggest XOM as a replacement for DOM/JDOM. It is Elliotte Rusty Harold's
answer to the shortcomings of both:
http://www.cafeconleche.org/XOM/
I've been using it and like it a lot. It is a very clean design.
--
Dale King
| |
| Juha Laiho 2004-04-25, 6:34 am |
| "Steve W. Jackson" <stevewjackson@charter.net> said:
>Good advice, but it's lacking a fundamental point. If you use a recent
>Java version (as of about 1.3, if memory serves), there's no need for
>any additional software.
As long as your XML data is US-ASCII. It seems that the XML parser
versions distributed with Sun JDK are very bad at handling non-US-ASCII
data (yes, there was a proper character set declaration in the XML data).
Switching to a recent version of Xalan fixed the problem.
--
Wolf a.k.a. Juha Laiho Espoo, Finland
(GC 3.0) GIT d- s+: a C++ ULSH++++$ P++@ L+++ E- W+$@ N++ !K w !O !M V
PS(+) PE Y+ PGP(+) t- 5 !X R !tv b+ !DI D G e+ h---- r+++ y++++
"...cancel my subscription to the resurrection!" (Jim Morrison)
| |
| Josef Garvi 2004-04-27, 4:12 am |
| Icemerth wrote:
>
> bb
What does "bb" mean?
--
Josef Garvi
"Reversing desertification through drought tolerant trees"
http://www.eden-foundation.org/
new income - better environment - more food - less poverty
| |
|
|
| Icemerth 2004-04-28, 12:51 am |
| Josef Garvi <josef@eden-foundation.org> wrote in message news:<c5c6kj$3psk$1@ID-194406.news.uni-berlin.de>...
> Jo wrote:
>
>
> Use DOM.
>
>
> Use the Xerces-version that is built into the JDK.
>
>
>
> I'm not an expert at this, but I guess that if you use the libraries that
> are in the JDK, your program will not grow from it in size.
bb
|
|
|
|
|