configuration file parser like Config::General for perl

T

Tammo Tjarks

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
 
T

Trans

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.
 
T

Tammo Tjarks

Trans said:
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
 
T

Trans

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.
 

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

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top