[Xml-compile] some kind of default schema for a REST XML interface

Mark Overmeer solutions at overmeer.net
Tue Jun 29 21:39:56 GMT 2010


* Mark Blackman (m.blackman at fairfx.com) [100629 21:28]:
> Thanks, I had a feeling you would say something like this. While the message
> could be poorly defined, in fact, I'm pretty sure that <invoices> will always
> be an "array" and <invoice> will always be a complex type with those elements
> of a simple type. I was just irritated at how the type attribute fouled up
> the hash reference nesting (from the Trang-generated schema).

You can easily produce a routine which recursively reduces the
HASH tree. For instance:

   sub cleanup($);
   sub cleanup($)
   {   my $h = shift;
       if(ref $h eq 'HASH')
       {   return cleanup $h->{_}
               if keys %$h==2 && exists $h->{_} && exists $h->{type};
           $h->{$_} = cleanup $h->{$_}
               for keys %$h;
           return $h;
       }
       if(ref $h eq 'ARRAY')
       {   return [ map {cleanup $_} @$h ];
       }
       $h;
   }
       
-- 
Regards,
               MarkOv

------------------------------------------------------------------------
       Mark Overmeer MSc                                MARKOV Solutions
       Mark at Overmeer.net                          solutions at overmeer.net
http://Mark.Overmeer.net                   http://solutions.overmeer.net




More information about the Xml-compile mailing list