[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

configuration file parser like Config::General for perl

Tammo Tjarks

9/4/2007 6:53:00 PM

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



3 Answers

Trans

9/4/2007 6:55:00 PM

0



On Sep 4, 11:35 am, Tammo Tjarks <ta...@tammo-tjarks.de> 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.


Tammo Tjarks

9/4/2007 8:21:00 PM

0


Trans wrote:

>
>
> On Sep 4, 11:35 am, Tammo Tjarks <ta...@tammo-tjarks.de> 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



Trans

9/5/2007 10:39:00 AM

0

On Sep 4, 1:21 pm, Tammo Tjarks <ta...@tammo-tjarks.de> wrote:
> Trans wrote:
>
> > On Sep 4, 11:35 am, Tammo Tjarks <ta...@tammo-tjarks.de> 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.