Easy XML config files?

Discussion in 'Java' started by Chris, Feb 14, 2007.

  1. Chris

    Chris Guest

    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.
     
    Chris, Feb 14, 2007
    #1
    1. Advertising

  2. Chris

    Daniel Pitts Guest

    On Feb 14, 2:10 pm, Chris <> wrote:
    > 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)>
     
    Daniel Pitts, Feb 14, 2007
    #2
    1. Advertising

  3. Chris

    Stefan Ram Guest

    Chris <> writes:
    >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
     
    Stefan Ram, Feb 14, 2007
    #3
  4. Chris

    Daniel Pitts Guest

    On Feb 14, 2:40 pm, -berlin.de (Stefan Ram) wrote:
    > Chris <> writes:
    > >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.
     
    Daniel Pitts, Feb 14, 2007
    #4
  5. Chris

    Chris Guest

    Daniel Pitts wrote:
    > On Feb 14, 2:10 pm, Chris <> wrote:
    >> 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)>
    >


    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.
     
    Chris, Feb 14, 2007
    #5
  6. Chris

    sapta Guest

    On Feb 15, 4:19 am, Chris <> wrote:
    > Daniel Pitts wrote:
    > > On Feb 14, 2:10 pm, Chris <> wrote:
    > >> 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)>

    >
    > 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>
     
    sapta, Feb 15, 2007
    #6
  7. OT: Why 'no archive' on your posts?

    On Feb 15, 9:40 am, -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.
     
    Andrew Thompson, Feb 15, 2007
    #7
  8. Chris

    Chris Uppal Guest

    Re: Why 'no archive' on your posts?

    Andrew Thompson wrote:

    > "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
     
    Chris Uppal, Feb 15, 2007
    #8
  9. Chris

    Andy Dingley Guest

    Re: Why 'no archive' on your posts?

    On 15 Feb, 17:22, "Chris Uppal" <-
    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
     
    Andy Dingley, Feb 15, 2007
    #9
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Hazzard
    Replies:
    2
    Views:
    676
    Hazzard
    Apr 6, 2004
  2. CSharpner
    Replies:
    0
    Views:
    1,129
    CSharpner
    Apr 9, 2007
  3. Bruno Desthuilliers
    Replies:
    5
    Views:
    411
    Bruno Desthuilliers
    Aug 29, 2007
  4. Ollie Riches
    Replies:
    1
    Views:
    1,687
    Gregory A. Beamer
    Dec 4, 2008
  5. Nick Johnson

    Windows Application App.config Files vs. web.config

    Nick Johnson, Mar 12, 2007, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    707
    Nick Johnson
    Mar 12, 2007
Loading...

Share This Page