in reply to Moose, the tree structure of XML and object-oriented inheritance hiearchies

Just an update. I have conditional XML rendering working with XML::Generator like so:
augment 'as_xml' => sub { my ($self, $name, $opt)=@_; VendorAddRq( VendorAdd( Name($name), $self->maybeVendorTypeRef($name, $opt) )); }; sub maybeVendorTypeRef { my($self,$name,$opt)=@_; return unless $opt; return unless my $v = $opt->{VendorTypeRef}; VendorTypeRef( $self->hashrender(ListID => $v) , $self->hashrender(FullName => $v) ); } sub hashrender { my($self, $key, $hash)=@_; return '' unless my $v = $hash->{$key} // undef; my $X = XML::Generator->new(pretty => 2); $X->$key($v); }




The mantra of every experienced web application developer is the same: thou shalt separate business logic from display. Ironically, almost all template engines allow violation of this separation principle, which is the very impetus for HTML template engine development.

-- Terence Parr, "Enforcing Strict Model View Separation in Template Engines"

  • Comment on Re: Moose, the tree structure of XML and object-oriented inheritance hiearchies
  • Download Code