yet another xml generator



Hello,
there are some modules aimed to make the xml generation easy - XML::Generator,
XML::Writer and XML:Writer::Simple, for example.

For my needs, these are to "verbose" and there is too much code necessary
to express the structure of the resulting xml. So I wrote a piece of code
which uses a bit more declarative approach. If somebody finds it useful,
I'd put it on CPAN - or submit it to an existing module.

Let's look at this code:

$str = element "outer", content {
element "inner" => content {
attribute id => 1;
element "abc", undef;
opt_element "def", $value;
element "ghi", "bb & cc";
}
}

provided that $value contains "dummy", $str contains the following result:

<outer>
<inner id='1'>
<abc/>
<def>dummy</def>
<ghi>bb &amp; cc</ghi>
</inner>
</outer>

provided that $value is undef or "", $str would contain:

<outer>
<inner id='1'>
<abc/>
<ghi>bb &amp; cc</ghi>
</inner>
</outer>

Another example:

$str = opt_element "abc", content {
opt_element "def", $value
}

provided $value is undef or "", as result, $str would contain "".
If $value would be "zzz", $str would contain:

<abc>
<def>zzz</dev>
</abc>

Any comments?

Cheers,
Martin
.