The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

SQL::Translator::Parser::XML::SQLFairy - parser for SQL::Translator's XML

SYNOPSIS

  use SQL::Translator;
  use SQL::Translator::Parser::XML::SQLFairy;

  my $translator     = SQL::Translator->new(
      from           => 'XML-SQLFairy',
      to             => 'MySQL',
      filename       => 'schema.xml',
      show_warnings  => 1,
      add_drop_table => 1,
  );

  print $obj->translate;

DESCRIPTION

This parser handles the flavor of XML used natively by the SQLFairy project (SQL::Translator). The XML must be in the namespace "http://sqlfairy.sourceforge.net/sqlfairy.xml."

To see an example of the XML translate one of your schema :) e.g.

  $ sqlt -f MySQL -t XML-SQLFairy schema.sql

attrib_values

The parser will happily parse XML produced with the attrib_values arg set. If it sees a value set as an attribute and a tag, the tag value will override that of the attribute.

e.g. For the xml below the table would get the name 'bar'.

  <sqlf:table name="foo">
    <sqlf:name>foo</name>
  </sqlf:table>

default_value

Leave the tag out all together to use the default in Schema::Field. Use empty tags or EMPTY_STRING for a zero lenth string. NULL for an explicit null (currently sets default_value to undef in the Schema::Field obj).

  <sqlf:default_value></sqlf:default_value>             <!-- Empty string -->
  <sqlf:default_value>EMPTY_STRING</sqlf:default_value> <!-- Empty string -->
  <sqlf:default_value>NULL</sqlf:default_value>         <!-- NULL -->

  <sqlf:default_value/> <!-- Empty string BUT DON'T USE! See BUGS -->

ARGS

Doesn't take any extra parser args at the moment.

BUGS

Empty Tags e.g. <sqlf:default_value/> Will be parsed as "" and hence also false. This is a bit counter intuative for some tags as seeing <sqlf:is_nullable /> you might think that it was set when it fact it wouldn't be. So for now it is safest not to use them until their handling by the parser is defined.

TODO

  • Support sqf:options.

  • Test forign keys are parsed ok.

  • Sort out sane handling of empty tags <foo/> vs tags with no content <foo></foo> vs it no tag being there.

  • Control over defaulting of non-existant tags.

AUTHOR

Mark D. Addison <mark.addison@itn.co.uk>.

SEE ALSO

perl(1), SQL::Translator, SQL::Translator::Producer::XML::SQLFairy, SQL::Translator::Schema.