Easy XML config files?

C

Chris

We have XML config files in our app. To get data out of the files, I
find myself writing SAX content handlers over and over.

Is there a quick and easy way for me to avoid this? It would be nice to
have a class like java.util.Properties, except it works with XML.
 
D

Daniel Pitts

We have XML config files in our app. To get data out of the files, I
find myself writing SAX content handlers over and over.

Is there a quick and easy way for me to avoid this? It would be nice to
have a class like java.util.Properties, except it works with XML.

java.util.Properties DOES work with XML.
Look at the loadFromXML method
<URL:http://java.sun.com/j2se/1.5.0/docs/api/java/util/
Properties.html#loadFromXML(java.io.InputStream)>
 
S

Stefan Ram

Chris said:
a class like java.util.Properties, except it works with XML.

I have a library to implement something like this.
The source language, however, is not exactly XML, but Unotal.
Unotal is a - in my opinion - simplified and improved XML.

Say, the file »source.uno« contained:

< x =< a = 2 b = 3 > y = 4 A B C >

Then,

public class Main
{ public static void main( final java.lang.String[] args )
{ final de.dclj.ram.notation.unotal.RoomSource source =
de.dclj.ram.notation.unotal.RoomFromModule.roomFrom
( new java.io.File( "source.uno" ));
java.lang.System.out.println( source );
java.lang.System.out.println( source.get( 2 ));
java.lang.System.out.println( source.get( "x" ) );
java.lang.System.out.println( source.getRoom( "x" ).get( "a" )); }}

prints

< x =< a =2 b =3 >y =4 A B C >
C
< a =2 b =3 >
2

The experimental library ram.jar is alpha-released under the GPL:

http://www.purl.org/stefan_ram/pub/ram-jar

Unotal is being described:

http://www.purl.org/stefan_ram/pub/unotal_en
 
D

Daniel Pitts

Chris said:
a class like java.util.Properties, except it works with XML.

I have a library to implement something like this.
The source language, however, is not exactly XML, but Unotal.
Unotal is a - in my opinion - simplified and improved XML.

Say, the file »source.uno« contained:

< x =< a = 2 b = 3 > y = 4 A B C >

Then,

public class Main
{ public static void main( final java.lang.String[] args )
{ final de.dclj.ram.notation.unotal.RoomSource source =
de.dclj.ram.notation.unotal.RoomFromModule.roomFrom
( new java.io.File( "source.uno" ));
java.lang.System.out.println( source );
java.lang.System.out.println( source.get( 2 ));
java.lang.System.out.println( source.get( "x" ) );
java.lang.System.out.println( source.getRoom( "x" ).get( "a" )); }}

prints

< x =< a =2 b =3 >y =4 A B C >
C
< a =2 b =3 >
2

The experimental library ram.jar is alpha-released under the GPL:

http://www.purl.org/stefan_ram/pub/ram-jar

Unotal is being described:

http://www.purl.org/stefan_ram/pub/unotal_en

That is neither simplified nor improved over XML.
It may be a better communication protocol for specific circumstances,
but if you understood the goal of XML, then you would realize your
unotal falls far short.
 
C

Chris

Daniel said:
java.util.Properties DOES work with XML.
Look at the loadFromXML method
<URL:http://java.sun.com/j2se/1.5.0/docs/api/java/util/
Properties.html#loadFromXML(java.io.InputStream)>

Thanks, didn't know that. Properties, though, only handle name/value
pairs, and it's not possible to have multiple values for one name:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
<properties>
<comment>yo</comment>
<entry key="name">value</entry>
<entry key="name">a second value</entry> NOT ALLOWED
</properties>

That's one reason we use XML instead of .properties files.
 
S

sapta

Thanks, didn't know that. Properties, though, only handle name/value
pairs, and it's not possible to have multiple values for one name:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
<properties>
<comment>yo</comment>
<entry key="name">value</entry>
<entry key="name">a second value</entry> NOT ALLOWED
</properties>

That's one reason we use XML instead of .properties files.

Why don't u use castor framework?
<a>http://www.castor.org/</a>
 
A

Andrew Thompson

On Feb 15, 9:40 am, (e-mail address removed)-berlin.de (Stefan Ram) wrote:
...
I have a library to implement something like this. ...
(snip tech. details)

"Note: The author of this message requested that
it not be archived. This message will be removed
from Groups in 6 days (Feb 22, 9:40 am)."

I had been wonderring, why do you flag your
messages for 'no archive'?

(As an aside, they always seem like very
technical answers - worth being available
in later searches..)

Andrew T.
 
C

Chris Uppal

Andrew said:
"Note: The author of this message requested that
it not be archived. This message will be removed
from Groups in 6 days (Feb 22, 9:40 am)."

I had been wonderring, why do you flag your
messages for 'no archive'?

Still further off-topic. What /I/ would like is an "x-archive-only" flag. I
have no objection to Google (or anyone) archiving my posts; I don't like having
them exploited by organisations like (but not limited to) Google to lure and
deceive users into dependence on their ad-ridden websites....

(Not that I'd bother using that flag if it did exist -- at least, not unless
quite a few other people did too.)

-- chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,527
Members
44,999
Latest member
MakersCBDGummiesReview

Latest Threads

Top