1SQL::Translator::ProducUesre:r:XCMoLn:t:rSiQbLuFtSaeQidLr:yP:(eT3rr)lanDsolcautmoern:t:aPtrioodnucer::XML::SQLFairy(3)
2
3
4
6 SQL::Translator::Producer::XML::SQLFairy - SQLFairy's default XML
7 format
8
10 use SQL::Translator;
11
12 my $t = SQL::Translator->new(
13 from => 'MySQL',
14 to => 'XML-SQLFairy',
15 filename => 'schema.sql',
16 show_warnings => 1,
17 );
18
19 print $t->translate;
20
22 Creates XML output of a schema, in the flavor of XML used natively by
23 the SQLFairy project (SQL::Translator). This format is detailed here.
24
25 The XML lives in the "http://sqlfairy.sourceforge.net/sqlfairy.xml"
26 namespace. With a root element of <schema>.
27
28 Objects in the schema are mapped to tags of the same name as the
29 objects class (all lowercase).
30
31 The attributes of the objects (e.g. $field->name) are mapped to
32 attributes of the tag, except for sql, comments and action, which get
33 mapped to child data elements.
34
35 List valued attributes (such as the list of fields in an index) get
36 mapped to comma separated lists of values in the attribute.
37
38 Child objects, such as a tables fields, get mapped to child tags
39 wrapped in a set of container tags using the plural of their contained
40 classes name.
41
42 An objects' extra attribute (a hash of arbitrary data) is mapped to a
43 tag called extra, with the hash of data as attributes, sorted into
44 alphabetical order.
45
46 e.g.
47
48 <schema name="" database=""
49 xmlns="http://sqlfairy.sourceforge.net/sqlfairy.xml">
50
51 <tables>
52 <table name="Story" order="1">
53 <fields>
54 <field name="id" data_type="BIGINT" size="20"
55 is_nullable="0" is_auto_increment="1" is_primary_key="1"
56 is_foreign_key="0" order="3">
57 <extra ZEROFILL="1" />
58 <comments></comments>
59 </field>
60 <field name="created" data_type="datetime" size="0"
61 is_nullable="1" is_auto_increment="0" is_primary_key="0"
62 is_foreign_key="0" order="1">
63 <extra />
64 <comments></comments>
65 </field>
66 ...
67 </fields>
68 <indices>
69 <index name="foobar" type="NORMAL" fields="foo,bar" options="" />
70 </indices>
71 </table>
72 </tables>
73
74 <views>
75 <view name="email_list" fields="email" order="1">
76 <sql>SELECT email FROM Basic WHERE email IS NOT NULL</sql>
77 </view>
78 </views>
79
80 </schema>
81
82 To see a complete example of the XML translate one of your schema :)
83
84 $ sqlt -f MySQL -t XML-SQLFairy schema.sql
85
87 add_prefix
88 Set to true to use the default namespace prefix of 'sqlf', instead
89 of using the default namespace for
90 "http://sqlfairy.sourceforge.net/sqlfairy.xml namespace"
91
92 e.g.
93
94 <!-- add_prefix=0 -->
95 <field name="foo" />
96
97 <!-- add_prefix=1 -->
98 <sqlf:field name="foo" />
99
100 prefix
101 Set to the namespace prefix you want to use for the
102 "http://sqlfairy.sourceforge.net/sqlfairy.xml namespace"
103
104 e.g.
105
106 <!-- prefix='foo' -->
107 <foo:field name="foo" />
108
109 newlines
110 If true (the default) inserts newlines around the XML, otherwise
111 the schema is written on one line.
112
113 indent
114 When using newlines the number of whitespace characters to use as
115 the indent. Default is 2, set to 0 to turn off indenting.
116
118 The previous version of the SQLFairy XML allowed the attributes of the
119 schema objects to be written as either xml attributes or as data
120 elements, in any combination. The old producer could produce attribute
121 only or data element only versions. While this allowed for lots of
122 flexibility in writing the XML the result is a great many possible XML
123 formats, not so good for DTD writing, XPathing etc! So we have moved to
124 a fixed version described above.
125
126 This version of the producer will now only produce the new style XML.
127 To convert your old format files simply pass them through the
128 translator :)
129
130 $ sqlt -f XML-SQLFairy -t XML-SQLFairy schema-old.xml > schema-new.xml
131
133 Ken Youens-Clark <kclark@cpan.org>, Darren Chamberlain
134 <darren@cpan.org>, Mark Addison <mark.addison@itn.co.uk>.
135
137 perl(1), SQL::Translator, SQL::Translator::Parser::XML::SQLFairy,
138 SQL::Translator::Schema, XML::Writer.
139
140
141
142perl v5.30.1 20S2Q0L-:0:1T-r3a0nslator::Producer::XML::SQLFairy(3)