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.
> 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)>
Chris - 14 Feb 2007 23:19 GMT
>> 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.
[quoted text clipped - 6 lines]
> <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.
sapta - 15 Feb 2007 07:54 GMT
> >> 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.
[quoted text clipped - 19 lines]
>
> 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 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
Daniel Pitts - 14 Feb 2007 22:50 GMT
> >a class like java.util.Properties, except it works with XML.
>
[quoted text clipped - 32 lines]
>
> 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.
Andrew Thompson - 15 Feb 2007 08:15 GMT
..
> 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.
Chris Uppal - 15 Feb 2007 17:22 GMT
> "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
Andy Dingley - 15 Feb 2007 19:09 GMT
On 15 Feb, 17:22, "Chris Uppal" <chris.up...@metagnostic.REMOVE-
THIS.org> wrote:
> What /I/ would like is an "x-archive-only" flag.
So do it! Invent and describe an x-licence header for NNTP
All the infrastructure to express this is already in place
http://creativecommons.org