Improve trigger 'scope' attribute support (RT#119997)
[dbsrgits/SQL-Translator.git] / lib / SQL / Translator / Producer / XML / SQLFairy.pm
index 553e044..ce9e151 100644 (file)
@@ -1,23 +1,5 @@
 package SQL::Translator::Producer::XML::SQLFairy;
 
-# -------------------------------------------------------------------
-# Copyright (C) 2003-9 SQLFair Authors.
-#
-# 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
@@ -144,7 +126,7 @@ Default is 2, set to 0 to turn off indenting.
 
 =head1 LEGACY FORMAT
 
-The previous version of the SQLFairy XML allowed the attributes of the the
+The previous version of the SQLFairy XML allowed the attributes of the
 schema objects to be written as either xml attributes or as data elements, in
 any combination. The old producer could produce attribute only or data element
 only versions. While this allowed for lots of flexibility in writing the XML
@@ -159,14 +141,14 @@ To convert your old format files simply pass them through the translator :)
 =cut
 
 use strict;
-use vars qw[ $VERSION @EXPORT_OK ];
-$VERSION = '1.59';
+use warnings;
+our @EXPORT_OK;
+our $VERSION = '1.59';
 
 use Exporter;
 use base qw(Exporter);
 @EXPORT_OK = qw(produce);
 
-use IO::Scalar;
 use SQL::Translator::Utils qw(header_comment debug);
 BEGIN {
     # Will someone fix XML::Writer already?
@@ -193,14 +175,14 @@ sub produce {
     $PArgs          = $translator->producer_args;
     my $newlines    = defined $PArgs->{newlines} ? $PArgs->{newlines} : 1;
     my $indent      = defined $PArgs->{indent}   ? $PArgs->{indent}   : 2;
-    my $io          = IO::Scalar->new;
 
     # Setup the XML::Writer and set the namespace
+    my $io;
     my $prefix = "";
     $prefix    = $Name            if $PArgs->{add_prefix};
     $prefix    = $PArgs->{prefix} if $PArgs->{prefix};
     my $xml         = XML::Writer->new(
-        OUTPUT      => $io,
+        OUTPUT      => \$io,
         NAMESPACES  => 1,
         PREFIX_MAP  => { $Namespace => $prefix },
         DATA_MODE   => $newlines,
@@ -289,7 +271,7 @@ sub produce {
     xml_obj_children( $xml, $schema,
         tag    => 'trigger',
         methods => [qw/name database_events action on_table perform_action_when
-            fields order extra/],
+            fields order extra scope/],
     );
 
     #
@@ -348,7 +330,7 @@ sub xml_obj_children {
 
 #
 # Takes an XML::Writer, Schema::* object and list of method names
-# and writes the obect out as XML. All methods values are written as attributes
+# and writes the object out as XML. All methods values are written as attributes
 # except for the methods listed in @MAP_AS_ELEMENTS which get written as child
 # data elements.
 #
@@ -368,7 +350,7 @@ sub xml_obj {
     my @meths              = @{ $args{'methods'} };
     my $empty_tag          = 0;
 
-    # Use array to ensure consistant (ie not hash) ordering of attribs
+    # Use array to ensure consistent (ie not hash) ordering of attribs
     # The order comes from the meths list passed in.
     my @tags;
     my @attr;
@@ -414,7 +396,7 @@ Mark Addison E<lt>mark.addison@itn.co.ukE<gt>.
 
 =head1 SEE ALSO
 
-L<perl(1)>, L<SQL::Translator>, L<SQL::Translator::Parser::XML::SQLFairy>,
+C<perl(1)>, L<SQL::Translator>, L<SQL::Translator::Parser::XML::SQLFairy>,
 L<SQL::Translator::Schema>, L<XML::Writer>.
 
 =cut