X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FSQL%2FTranslator%2FProducer%2FXML.pm;h=584690f4d2df5646f382a5d686ad248007be3e3b;hb=4384692aca82fb49ad4a49c08d7ddbde85bc4ecb;hp=e71b281f72f196674f720038eb6708b7b3da1284;hpb=abfa405acf15e963e5b5760fa74464d91ca25f7e;p=dbsrgits%2FSQL-Translator.git diff --git a/lib/SQL/Translator/Producer/XML.pm b/lib/SQL/Translator/Producer/XML.pm index e71b281..584690f 100644 --- a/lib/SQL/Translator/Producer/XML.pm +++ b/lib/SQL/Translator/Producer/XML.pm @@ -1,139 +1,35 @@ package SQL::Translator::Producer::XML; -# ------------------------------------------------------------------- -# $Id: XML.pm,v 1.5 2003-01-27 17:04:48 dlc Exp $ -# ------------------------------------------------------------------- -# Copyright (C) 2003 Ken Y. Clark , -# darren chamberlain , -# Chris Mungall -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; version 2. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA -# 02111-1307 USA -# ------------------------------------------------------------------- +=pod =head1 NAME -SQL::Translator::Producer::XML - XML output - -=head1 SYNOPSIS - - use SQL::Translator::Producer::XML; +SQL::Translator::Producer::XML - Alias to XML::SQLFairy producer =head1 DESCRIPTION -Meant to create some sort of usable XML output. - -=cut - -use strict; -use vars qw[ $VERSION $XML ]; -$VERSION = sprintf "%d.%02d", q$Revision: 1.5 $ =~ /(\d+)\.(\d+)/; +Previous versions of SQL::Translator included an XML producer, but the +namespace has since been further subdivided. Therefore, this module is +now just an alias to the XML::SQLFairy producer. -# ------------------------------------------------------------------- -sub produce { - my ( $translator, $data ) = @_; - my $indent = 0; - aggregate( '', $indent ); - - $indent++; - for my $table ( - map { $_->[1] } - sort { $a->[0] <=> $b->[0] } - map { [ $_->{'order'}, $_ ] } - values %$data - ) { - aggregate( '', $indent ); - $indent++; - - aggregate( "$table->{'table_name'}", $indent ); - aggregate( "$table->{'order'}", $indent ); - - # - # Fields - # - aggregate( '', $indent ); - for my $field ( - map { $_->[1] } - sort { $a->[0] <=> $b->[0] } - map { [ $_->{'order'}, $_ ] } - values %{ $table->{'fields'} } - ) { - aggregate( '', ++$indent ); - $indent++; - - for my $key ( keys %$field ) { - my $val = defined $field->{ $key } ? $field->{ $key } : ''; - $val = ref $val eq 'ARRAY' ? join(',', @$val) : $val; - aggregate( "<$key>$val", $indent ); - } - - $indent--; - aggregate( "", $indent-- ); - } - aggregate( "", $indent ); +=head1 SEE ALSO - # - # Indices - # - aggregate( '', $indent ); - for my $index ( @{ $table->{'indices'} } ) { - aggregate( '', ++$indent ); - $indent++; +SQL::Translator::Producer::XML::SQLFairy. - for my $key ( keys %$index ) { - my $val = defined $index->{ $key } ? $index->{ $key } : ''; - $val = ref $val eq 'ARRAY' ? join(',', @$val) : $val; - aggregate( "<$key>$val", $indent ); - } +=head1 AUTHOR - $indent--; - aggregate( "", $indent-- ); - } - aggregate( "", $indent ); +Ken Youens-Clark Ekclark@cpan.orgE. - $indent--; - aggregate( "
", $indent ); - } +=cut - $indent--; - aggregate( '
', $indent ); +use strict; +use warnings; +our $DEBUG; +our $VERSION = '1.59'; +$DEBUG = 1 unless defined $DEBUG; - return $XML; -} +use SQL::Translator::Producer::XML::SQLFairy; -# ------------------------------------------------------------------- -sub aggregate { - my ( $text, $indent ) = @_; - $XML .= (' ' x $indent) . "$text\n"; -} +*produce = \&SQL::Translator::Producer::XML::SQLFairy::produce; 1; - -# ------------------------------------------------------------------- -# The eyes of fire, the nostrils of air, -# The mouth of water, the beard of earth. -# William Blake -# ------------------------------------------------------------------- - -=pod - -=head1 AUTHOR - -Ken Y. Clark Ekclark@cpan.orgE - -=head1 SEE ALSO - -XML::Dumper; - -=cut