From: Ken Youens-Clark Date: Wed, 20 Aug 2003 17:13:58 +0000 (+0000) Subject: All cosmetic changes while I was looking to find "uninitialized values," X-Git-Tag: v0.04~283 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=bc05db0745407bbb0e7e6ab6506b3be6f25509dc;p=dbsrgits%2FSQL-Translator.git All cosmetic changes while I was looking to find "uninitialized values," but these errors seem to be w/in the guts of XML::Writer and have nothing to do with how it's being called. --- diff --git a/lib/SQL/Translator/Producer/SqlfXML.pm b/lib/SQL/Translator/Producer/SqlfXML.pm index d9b631c..32fcd9a 100644 --- a/lib/SQL/Translator/Producer/SqlfXML.pm +++ b/lib/SQL/Translator/Producer/SqlfXML.pm @@ -1,11 +1,12 @@ package SQL::Translator::Producer::SqlfXML; # ------------------------------------------------------------------- -# $Id: SqlfXML.pm,v 1.4 2003-08-14 12:03:00 grommit Exp $ +# $Id: SqlfXML.pm,v 1.5 2003-08-20 17:13:58 kycl4rk Exp $ # ------------------------------------------------------------------- # Copyright (C) 2003 Ken Y. Clark , # darren chamberlain , -# Chris Mungall +# Chris Mungall , +# Mark Addison . # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as @@ -25,7 +26,7 @@ package SQL::Translator::Producer::SqlfXML; use strict; use warnings; use vars qw[ $VERSION ]; -$VERSION = sprintf "%d.%02d", q$Revision: 1.4 $ =~ /(\d+)\.(\d+)/; +$VERSION = sprintf "%d.%02d", q$Revision: 1.5 $ =~ /(\d+)\.(\d+)/; use Exporter; use base qw(Exporter); @@ -36,7 +37,7 @@ use SQL::Translator::Utils qw(header_comment); use XML::Writer; my $namespace = 'http://sqlfairy.sourceforge.net/sqlfairy.xml'; -my $name = 'sqlt'; +my $name = 'sqlt'; { our ($translator,$PArgs,$schema); @@ -44,11 +45,10 @@ our ($translator,$PArgs,$schema); sub debug { $translator->debug(@_,"\n"); } # Shortcut. sub produce { - $translator = shift; - $PArgs = $translator->producer_args; - $schema = $translator->schema; - - my $io = IO::Scalar->new; + $translator = shift; + $PArgs = $translator->producer_args; + $schema = $translator->schema; + my $io = IO::Scalar->new; my $xml = XML::Writer->new( OUTPUT => $io, NAMESPACES => 1, @@ -127,11 +127,12 @@ sub produce { sub xml_obj { my ($xml, $obj, %args) = @_; - my $tag = $args{tag}; - my @meths = @{$args{methods}}; - my $attrib_values = $PArgs->{attrib_values}; - my $empty_tag = 0; - my $end_tag = $args{end_tag}; + my $tag = $args{'tag'} || ''; + my $end_tag = $args{'end_tag'} || ''; + my $attrib_values = $PArgs->{'attrib_values'} || ''; + my @meths = @{ $args{'methods'} }; + my $empty_tag = 0; + if ( $attrib_values and $end_tag ) { $empty_tag = 1; $end_tag = 0; @@ -140,31 +141,32 @@ sub xml_obj { if ( $attrib_values ) { my %attr = map { my $val = $obj->$_; - ($_ => ref($val) eq 'ARRAY' ? join(", ",@$val) : $val); + ($_ => ref($val) eq 'ARRAY' ? join(', ', @$val) : $val); } @meths; - foreach (keys %attr) { delete $attr{$_} unless defined $attr{$_}; } + foreach ( keys %attr ) { delete $attr{$_} unless defined $attr{$_}; } $empty_tag ? $xml->emptyTag( [ $namespace => $tag ], %attr ) : $xml->startTag( [ $namespace => $tag ], %attr ); } else { $xml->startTag( [ $namespace => $tag ] ); - xml_objAttr($xml,$obj, @meths); + xml_objAttr( $xml, $obj, @meths ); } - $xml->endTag( [ $namespace => $tag ] ) if $end_tag; + $xml->endTag( [ $namespace => $tag ] ) if $end_tag; } # Takes an xml writer, a Schema::* object and a list of methods and adds the # XML for those methods. sub xml_objAttr { my ($xml, $obj, @methods) = @_; - my $emit_empty = $PArgs->{emit_empty_tags}; - for my $method (@methods) { + my $emit_empty = $PArgs->{'emit_empty_tags'}; + + for my $method ( @methods ) { my $val = $obj->$method; debug " ".ref($obj)."->$method=", (defined $val ? "'$val'" : ""); next unless $emit_empty || defined $val; - $val = "" if not defined $val; + $val = '' if not defined $val; $val = ref $val eq 'ARRAY' ? join(',', @$val) : $val; debug " Adding Attr:".$method."='",$val,"'"; $xml->dataElement( [ $namespace => $method ], $val ); @@ -231,8 +233,8 @@ Creates XML output of a schema. =head1 AUTHOR Ken Y. Clark Ekclark@cpan.orgE, -darren chamberlain Edarren@cpan.orgE, -mark addison Emark.addison@itn.co.ukE, +Darren Chamberlain Edarren@cpan.orgE, +Mark Addison Emark.addison@itn.co.ukE. =head1 SEE ALSO