configuration file parser like Config::General for perl

Discussion in 'Ruby' started by Tammo Tjarks, Sep 4, 2007.

  1. Tammo Tjarks

    Tammo Tjarks Guest

    Hello,
    I have the problem, that in a project I am working in the configuration
    files are in a apache config file like format. This is a mixture of
    XML-Format and normal config format like
    <id>
    name example
    use "for test"
    <id>

    The normal used language is perl, where the format, with some extensions, is
    supported by the Config::General Package.
    Is the something similar existing for Ruby? I have already searched in
    rubyforge, but I could not find something fitting. Somehow xmldigest or
    digestr seems partly to fit, but I am unsure if they support the whole
    range of the config-file. Or are there some settings existing for the
    xml-libraries like rexml to support this uncomliant kind of XML?

    Best regards,
    Tammo
     
    Tammo Tjarks, Sep 4, 2007
    #1
    1. Advertising

  2. Tammo Tjarks

    Trans Guest

    On Sep 4, 11:35 am, Tammo Tjarks <> wrote:
    > Hello,
    > I have the problem, that in a project I am working in the configuration
    > files are in a apache config file like format. This is a mixture of
    > XML-Format and normal config format like
    > <id>
    > name example
    > use "for test"
    > <id>
    >
    > The normal used language is perl, where the format, with some extensions, is
    > supported by the Config::General Package.
    > Is the something similar existing for Ruby? I have already searched in
    > rubyforge, but I could not find something fitting. Somehow xmldigest or
    > digestr seems partly to fit, but I am unsure if they support the whole
    > range of the config-file. Or are there some settings existing for the
    > xml-libraries like rexml to support this uncomliant kind of XML?


    I know nothing of the sort. However, if should be pretty easy to use
    REXML to loop through the XML elements and apply a parser to each
    sections text.

    T.
     
    Trans, Sep 4, 2007
    #2
    1. Advertising

  3. Tammo Tjarks

    Tammo Tjarks Guest

    Trans wrote:

    >
    >
    > On Sep 4, 11:35 am, Tammo Tjarks <> wrote:
    >> Hello,
    >> I have the problem, that in a project I am working in the configuration
    >> files are in a apache config file like format. This is a mixture of
    >> XML-Format and normal config format like
    >> <id>
    >> name example
    >> use "for test"
    >> <id>
    >>
    >> The normal used language is perl, where the format, with some extensions,
    >> is supported by the Config::General Package.
    >> Is the something similar existing for Ruby? I have already searched in
    >> rubyforge, but I could not find something fitting. Somehow xmldigest or
    >> digestr seems partly to fit, but I am unsure if they support the whole
    >> range of the config-file. Or are there some settings existing for the
    >> xml-libraries like rexml to support this uncomliant kind of XML?

    >
    > I know nothing of the sort. However, if should be pretty easy to use
    > REXML to loop through the XML elements and apply a parser to each
    > sections text.
    >
    > T.


    Thanks for your answer. But I am not sure if that works without workaround.
    The Problem is, that the apache config file format allowas also things
    like:
    ---------------------

    version 1.0

    root "not existing"

    <display>
    driver X11
    name test
    </display>

    <modules>
    perl 5.8.2
    ruby 1.8.6
    </modules>

    --------------------

    I should mention that this is a meaningless example. The important point is,
    that you do not have proper xpaths and root-nodes. I have tried it once
    with rexml and it was somehow complaining (I have to look, but it was
    something with a line in rexml with <<)

    What I can try is to surround it by a master-node before read-in but that is
    a hack and I am not sure if it will work. Anyway I will try.

    Regards,
    Tammo
     
    Tammo Tjarks, Sep 4, 2007
    #3
  4. Tammo Tjarks

    Trans Guest

    On Sep 4, 1:21 pm, Tammo Tjarks <> wrote:
    > Trans wrote:
    >
    > > On Sep 4, 11:35 am, Tammo Tjarks <> wrote:
    > >> Hello,
    > >> I have the problem, that in a project I am working in the configuration
    > >> files are in a apache config file like format. This is a mixture of
    > >> XML-Format and normal config format like
    > >> <id>
    > >> name example
    > >> use "for test"
    > >> <id>

    >
    > >> The normal used language is perl, where the format, with some extensions,
    > >> is supported by the Config::General Package.
    > >> Is the something similar existing for Ruby? I have already searched in
    > >> rubyforge, but I could not find something fitting. Somehow xmldigest or
    > >> digestr seems partly to fit, but I am unsure if they support the whole
    > >> range of the config-file. Or are there some settings existing for the
    > >> xml-libraries like rexml to support this uncomliant kind of XML?

    >
    > > I know nothing of the sort. However, if should be pretty easy to use
    > > REXML to loop through the XML elements and apply a parser to each
    > > sections text.

    >
    > > T.

    >
    > Thanks for your answer. But I am not sure if that works without workaround.
    > The Problem is, that the apache config file format allowas also things
    > like:
    > ---------------------
    >
    > version 1.0
    >
    > root "not existing"
    >
    > <display>
    > driver X11
    > name test
    > </display>
    >
    > <modules>
    > perl 5.8.2
    > ruby 1.8.6
    > </modules>
    >
    > --------------------
    >
    > I should mention that this is a meaningless example. The important point is,
    > that you do not have proper xpaths and root-nodes. I have tried it once
    > with rexml and it was somehow complaining (I have to look, but it was
    > something with a line in rexml with <<)
    >
    > What I can try is to surround it by a master-node before read-in but that is
    > a hack and I am not sure if it will work. Anyway I will try.


    If they are only using Xml to do dead simple <x> ... </x> braketing,
    then you could write a parser for that too. As long as there is no
    nesting of identically named nodes, it is very simple parsing and
    Regexp's can be used to do it.

    Just a thought.
    T.
     
    Trans, Sep 5, 2007
    #4
    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. Ivan
    Replies:
    1
    Views:
    3,097
    Natty Gur
    May 21, 2004
  2. Damiano G. Preatoni

    configuration file parser library

    Damiano G. Preatoni, May 5, 2005, in forum: C++
    Replies:
    4
    Views:
    9,006
    __PPS__
    May 5, 2005
  3. CSharpner
    Replies:
    0
    Views:
    1,143
    CSharpner
    Apr 9, 2007
  4. Tech Id
    Replies:
    14
    Views:
    1,375
    Tech Id
    May 23, 2010
  5. Replies:
    1
    Views:
    166
    Gunnar Hjalmarsson
    Jul 31, 2005
Loading...

Share This Page