Downgrade global version - highest version in 9002 on cpan is 1.58 - thus go with...
[dbsrgits/SQL-Translator.git] / lib / SQL / Translator / Producer / XML.pm
index 66b3e88..dc3196a 100644 (file)
@@ -1,10 +1,7 @@
 package SQL::Translator::Producer::XML;
 
 # -------------------------------------------------------------------
-# $Id: XML.pm,v 1.4 2002-11-28 04:21:07 kycl4rk Exp $
-# -------------------------------------------------------------------
-# Copyright (C) 2002 Ken Y. Clark <kclark@cpan.org>,
-#                    darren chamberlain <darren@cpan.org>
+# Copyright (C) 2002-2009 SQLFairy Authors
 #
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License as
@@ -21,118 +18,37 @@ package SQL::Translator::Producer::XML;
 # 02111-1307  USA
 # -------------------------------------------------------------------
 
-=head1 NAME
-
-SQL::Translator::Producer::XML - XML output
+=pod
 
-=head1 SYNOPSIS
+=head1 NAME
 
-  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.
+Previous versions of SQL::Translator included an XML producer, but the 
+namespace has since been further subdivided.  Therefore, this module is 
+now just just an alias to the XML::SQLFairy producer.
 
-=cut
+=head1 SEE ALSO
 
-use strict;
-use vars qw[ $VERSION $XML ];
-$VERSION = sprintf "%d.%02d", q$Revision: 1.4 $ =~ /(\d+)\.(\d+)/;
+SQL::Translator::Producer::XML::SQLFairy.
 
-# -------------------------------------------------------------------
-sub produce {
-    my ( $translator, $data ) = @_;
-    my $indent = 0;
-    aggregate( '<schema>', $indent );
-    
-    $indent++;
-    for my $table ( 
-        map  { $_->[1] }
-        sort { $a->[0] <=> $b->[0] }
-        map  { [ $_->{'order'}, $_ ] }
-        values %$data
-    ) { 
-        aggregate( '<table>', $indent );
-        $indent++;
-
-        aggregate( "<name>$table->{'table_name'}</name>", $indent );
-        aggregate( "<order>$table->{'order'}</order>", $indent );
-
-        #
-        # Fields
-        #
-        aggregate( '<fields>', $indent );
-        for my $field ( 
-            map  { $_->[1] }
-            sort { $a->[0] <=> $b->[0] }
-            map  { [ $_->{'order'}, $_ ] }
-            values %{ $table->{'fields'} }
-        ) {
-            aggregate( '<field>', ++$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</$key>", $indent );
-            }
-
-            $indent--;
-            aggregate( "</field>", $indent-- );
-        }
-        aggregate( "</fields>", $indent );
-
-        #
-        # Indices
-        #
-        aggregate( '<indices>', $indent );
-        for my $index ( @{ $table->{'indices'} } ) {
-            aggregate( '<index>', ++$indent );
-            $indent++;
-
-            for my $key ( keys %$index ) {
-                my $val = defined $index->{ $key } ? $index->{ $key } : '';
-                   $val = ref $val eq 'ARRAY' ? join(',', @$val) : $val;
-                aggregate( "<$key>$val</$key>", $indent );
-            }
-
-            $indent--;
-            aggregate( "</index>", $indent-- );
-        }
-        aggregate( "</indices>", $indent );
-
-        $indent--;
-        aggregate( "</table>", $indent );
-    }
-
-    $indent--;
-    aggregate( '</schema>', $indent );
-
-    return $XML;
-}
+=head1 AUTHOR
 
-# -------------------------------------------------------------------
-sub aggregate {
-    my ( $text, $indent ) = @_;
-    $XML .= ('  ' x $indent) . "$text\n";
-}
+Ken Y. Clark E<lt>kclark@cpan.orgE<gt>.
 
-1;
+=cut
 
 # -------------------------------------------------------------------
-# The eyes of fire, the nostrils of air,
-# The mouth of water, the beard of earth.
-# William Blake
-# -------------------------------------------------------------------
 
-=pod
-
-=head1 AUTHOR
-
-Ken Y. Clark E<lt>kclark@cpan.orgE<gt>
+use strict;
+use vars qw[ $VERSION $DEBUG ];
+$VERSION = '1.59';
+$DEBUG = 1 unless defined $DEBUG;
 
-=head1 SEE ALSO
+use SQL::Translator::Producer::XML::SQLFairy;
 
-XML::Dumper;
+*produce = \&SQL::Translator::Producer::XML::SQLFairy::produce;
 
-=cut
+1;