SQL::Translator::Parser::XML::SQLFairy - parser for SQL::Translator's XML
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;
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
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>
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 -->
Doesn't take any extra parser args at the moment.
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.
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.
Mark D. Addison <mark.addison@itn.co.uk>.
perl(1), SQL::Translator, SQL::Translator::Producer::XML::SQLFairy, SQL::Translator::Schema.
To install SQL::Translator, copy and paste the appropriate command in to your terminal.
cpanm
cpanm SQL::Translator
CPAN shell
perl -MCPAN -e shell install SQL::Translator
For more information on module installation, please visit the detailed CPAN module installation guide.