yet another xml generator
  Home FAQ Contact Sign in
comp.lang.perl.modules only
 
Advanced search
POPULAR GROUPS

more...

comp.lang.perl.modules Profile…
 Up
yet another xml generator         


Author: Martin Busik
Date: Mar 17, 2008 18:38

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:
Show full article (1.22Kb)
5 Comments
Re: yet another xml generator         


Author: Darin McBride
Date: Mar 18, 2008 12:54

Martin Busik wrote:
> 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.

This looks really interesting. What would hold me back, personally, is
integrating it into other methods. For example, I usually have a stock, or
template, XML file, and then use XML::Twig to read that, add/remove/modify
what I need to, and write it out (to a file, to stdout for apache to send,
whatever). If I could do something like:

$twig->insert_decl('after',
twig_element "out", content {
#...
});
Show full article (1.97Kb)
no comments
Re: yet another xml generator         


Author: Martin Busik
Date: Mar 19, 2008 15:37

Hi Darin,
> This looks really interesting. What would hold me back, personally, is
> integrating it into other methods. For example, I usually have a stock,
> or
> template, XML file, and then use XML::Twig to read that,
> add/remove/modify
> what I need to, and write it out (to a file, to stdout for apache to
> send,
> whatever). If I could do something like:
> $twig->insert_decl('after',
> twig_element "out", content {
> #...
> });

I'm haven't used XML::Twig before, what is the meaning of
insert_decl('after',xxx) ?
May be, you can give me an another example?
Show full article (2.36Kb)
no comments
Re: yet another xml generator         


Author: John Bokma
Date: Mar 19, 2008 16:16

"Martin Busik" wrote:
> if all of the above variables contain either undef or "", no output is
> generated
> at all. IMO this makes it more readable.

I recommend to make this a setting for each, i.e.

undef -> generate empty element, or no-op, or exception
"" -> generate empty element, or no-op, or exception

no comments
Re: yet another xml generator         


Author: Darin McBride
Date: Mar 19, 2008 20:01

Martin Busik wrote:
> Hi Darin,
>
>> This looks really interesting. What would hold me back, personally, is
>> integrating it into other methods. For example, I usually have a stock,
>> or
>> template, XML file, and then use XML::Twig to read that,
>> add/remove/modify
>> what I need to, and write it out (to a file, to stdout for apache to
>> send,
>> whatever). If I could do something like:
>> $twig->insert_decl('after',
>> twig_element "out", content {
>> #...
>> });
>
> I'm haven't used XML::Twig before, what is the meaning of
> insert_decl('after',xxx) ?
> May be, you can give me an another example?
Show full article (4.64Kb)
no comments
Re: yet another xml generator         


Author: mirod
Date: Mar 20, 2008 03:40

On Mar 18, 2:38 am, "Martin Busik" wrote:
> 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...
Show full article (2.21Kb)
no comments