/[papo]/papo/xot/zot2xot
ViewVC logotype

Diff of /papo/xot/zot2xot

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by jlenton, Thu Jul 3 23:53:47 2003 UTC revision 1.4 by jlenton, Thu Jul 31 18:55:07 2003 UTC
# Line 1  Line 1 
1  #!/usr/bin/perl -w  #!/usr/bin/perl -w
2    # -*- cperl -*-
3  use strict;  use strict;
4  use lib "$ENV{HOME}/public_perl/";  use lib "$ENV{HOME}/public_perl/";
5  use Zot;  use Zot;
# Line 19  print <<EOF; Line 20  print <<EOF;
20  EOF  EOF
21  foreach my $table ($zot->tables)  foreach my $table ($zot->tables)
22  {  {
23      printf "    <table name=\"%s\"", $table->name;      my $name = $table->name;
24        print  "    <table name=\"$name\"";
25      printf " inherits=\"%s\"", $table->parent      printf " inherits=\"%s\"", $table->parent
26          if $table->parent;          if $table->parent;
27      printf ">\n";      printf ">\n";
# Line 27  foreach my $table ($zot->tables) Line 29  foreach my $table ($zot->tables)
29      foreach ($table->attrs)      foreach ($table->attrs)
30      {      {
31          my $attr = $_;          my $attr = $_;
32          $attr =~ s/^_/$table->name . '_'/e;          my $type = $table->attr($attr);
33          printf "        <field name=\"%s\" type=\"%s\"/>\n", $attr, $table->attr($_);          $attr =~ s/^_/${name}_/;
34            $type =~ s/serial$/int" auto_increment="true/;
35            $type .= '" null="false'
36                if $attr eq 'id';
37            printf "        <field name=\"%s\" type=\"%s\"/>\n", $attr, $type;
38      }      }
39      foreach ($table->rels)      foreach ($table->rels)
40      {      {
41          my $rel = $_;          my $rel = $_;
42          $rel =~ s/^_/$table->name . '_'/e;          $rel =~ s/^_/${name}_/;
43          printf "        <field name=\"%s\" references=\"%s\"/>\n", $rel, $table->rel($_);          printf "        <field name=\"%s\" references=\"%s\"/>\n", $rel, $table->rel($_);
44      }      }
45      print("      </fields>\n",      print("      </fields>\n",
46            "      <indexes>\n",            "      <indexes>\n",
47            "        <index type=\"primary_key\">\n",            "        <index type=\"primary_key\">\n",
48            "          <index_field name=\"id\"/>\n",            "          <index_field name=\"id\"/>\n",
49            "        </index>\n",            "        </index>\n");
50            "      </indexes>\n");  
51        print("        <index name=\"${name}_${_}_idx\">\n",
52              "          <index_field name=\"$_\"/>\n",
53              "        </index>\n")
54            foreach ($table->rels);
55        print("      </indexes>\n");
56      if ($table->styles)      if ($table->styles)
57      {      {
58          printf "      <classes>\n";          printf "      <hooks>\n";
59          printf "        <class name=\"%s\"/>\n", $_          printf "        <hook name=\"%s\"/>\n", $_
60              foreach ($table->styles);              foreach ($table->styles);
61          printf "      </classes>\n";          printf "      </hooks>\n";
62      }      }
63      print "    </table>\n";      print "    </table>\n";
64  }  }
65  print "  </tables>\n";  print "  </tables>\n";
66  if ($zot->styles)  if ($zot->styles)
67  {  {
68      print "  <class_defs>\n";      print "  <hook_defs>\n";
69      foreach ($zot->styles)      foreach ($zot->styles)
70      {      {
71          print "    <class_def name=\"$_\">\n";          print "    <hook_def name=\"$_\">\n";
72          printf("      <class_impl target=\"dot\"><![CDATA[%s]]></class_impl>\n",          printf("      <hook_impl target=\"dot\"><![CDATA[%s]]></hook_impl>\n",
73                 $zot->style($_));                 $zot->style($_));
74          printf("      <class_impl target=\"xml\"><![CDATA[%s]]></class_impl>\n",          printf("      <hook_impl target=\"xml\"><![CDATA[%s]]></hook_impl>\n",
75                 sql_style($_));                 sql_style($_));
76          print "    </class_def>\n";          print "    </hook_def>\n";
77      }      }
78      print "  </class_defs>\n";      print "  </hook_defs>\n";
79  }  }
80  print "</database>\n";  print "</database>\n";
81    

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26