List:Commits« Previous MessageNext Message »
From:mcbrown Date:October 6 2007 3:29am
Subject:svn commit - mysqldoc@docsrva: r7976 - in trunk: make.d tools tools/MySQL tools/MySQL/DynXML tools/MySQL/XML
View as plain text  
Author: mcbrown
Date: 2007-10-06 05:29:42 +0200 (Sat, 06 Oct 2007)
New Revision: 7976

Log:
Updating to IDMap v3 functionality
Restructing directories
Updating all related scripts



Added:
   trunk/tools/MySQL/XML/SpellCheck.pm
   trunk/tools/MySQL/XML/WordCount.pm
Removed:
   trunk/tools/IDMap.pm
   trunk/tools/MySQLDeepCheck.pm
   trunk/tools/MySQLDynXML.pm
   trunk/tools/MySQLXMLWriter.pm
   trunk/tools/dyndocs-opsfuncs-generate.pl
   trunk/tools/dyndocs-optvars-generate.pl
   trunk/tools/genarbelements.pl
Renamed/Moved:
   trunk/tools/MySQL/DynXML (from rev 7975, trunk/tools/MySQLDynXML)
   trunk/tools/MySQL/DynXML.pm (from rev 7975, trunk/tools/MySQLDynXML.pm)
   trunk/tools/MySQL/IDMap.pm (from rev 7975, trunk/tools/IDMap.pm)
   trunk/tools/MySQL/XML/DeepCheck.pm (from rev 7975, trunk/tools/MySQLDeepCheck.pm)
   trunk/tools/MySQL/XML/Writer.pm (from rev 7975, trunk/tools/MySQLXMLWriter.pm)
   trunk/tools/arbitrary-parser.pl (from rev 7975, trunk/tools/genarbelements.pl)
Modified:
   trunk/make.d/vars-docbook
   trunk/tools/MySQL/DynXML/Changelog.pm
   trunk/tools/MySQL/DynXML/ChangelogParser.pm
   trunk/tools/MySQL/DynXML/ChangelogVersionParser.pm
   trunk/tools/MySQL/DynXML/Opfuncs.pm
   trunk/tools/MySQL/DynXML/OpfuncsParser.pm
   trunk/tools/MySQL/DynXML/Optvar.pm
   trunk/tools/MySQL/DynXML/OptvarParser.pm
   trunk/tools/MySQL/DynXML/ReservedWords.pm
   trunk/tools/check-renamed-nodes.pl
   trunk/tools/convert-newsfile-tochangelog.pl
   trunk/tools/deep-check.pl
   trunk/tools/divide-docbook-file.pl
   trunk/tools/dynxml-parser.pl
   trunk/tools/fixup-multibyte.pl
   trunk/tools/idfind.pl
   trunk/tools/idmap.pl
   trunk/tools/idremap.pl
   trunk/tools/idtree.pl
   trunk/tools/idvalidate.pl
   trunk/tools/query-changelog.pl
   trunk/tools/remap-note-para.pl
   trunk/tools/spell-check.pl
   trunk/tools/update-dictionaries.pl
   trunk/tools/xml-word-count.pl
   trunk/tools/xmldepend.pl


Modified: trunk/make.d/vars-docbook
===================================================================
--- trunk/make.d/vars-docbook	2007-10-05 19:15:49 UTC (rev 7975)
+++ trunk/make.d/vars-docbook	2007-10-06 03:29:42 UTC (rev 7976)
Changed blocks: 2, Lines Added: 2, Lines Deleted: 2; 715 bytes

@@ -136,7 +136,7 @@
 
 # GENARBITRARY takes an aspec file and template and generates and arbitrary doc
 
-GENARBITRARY = $(TOOLS_DIR)/genarbelements.pl
+GENARBITRARY = $(TOOLS_DIR)/arbitrary-parser.pl
 
 # XMLWORDCOUNT counts the words in an XML file, by tag
 

@@ -144,7 +144,7 @@
 
 # IDMAP builds a map of the IDs in an XML document
 
-IDMAP = $(TOOLS_DIR)/idmap2.pl
+IDMAP = $(TOOLS_DIR)/idmap.pl
 
 # IDVALIDATE checks the output from XMLLINT and checks if a valid ID
 # exists elsewhere in the doc


Modified: trunk/tools/MySQL/DynXML/Changelog.pm
===================================================================
--- trunk/tools/MySQLDynXML/Changelog.pm	2007-10-05 19:15:49 UTC (rev 7975)
+++ trunk/tools/MySQL/DynXML/Changelog.pm	2007-10-06 03:29:42 UTC (rev 7976)
Changed blocks: 3, Lines Added: 29, Lines Deleted: 22; 2883 bytes

@@ -1,10 +1,22 @@
-package MySQLDynXML::Changelog;
+package MySQL::DynXML::Changelog;
 
-use MySQLDynXML::ChangelogParser;
-use MySQLDynXML::ChangelogVersionParser;
+# Load the standard MySQL Libraries
 
+use MySQL;
+
+# Ensure we have enabled error checking
+
+use strict;
+use warnings;
+
+# Load MySQL modules
+
+use MySQL::DynXML::ChangelogParser;
+use MySQL::DynXML::ChangelogVersionParser;
+
+# Load local modules
+
 use Data::Dumper;
-
 use IO::String;
 use Carp;
 

@@ -41,18 +53,10 @@
     my ($version,$product,$filter) = ($item =~ m/role="(.*?):(.*?):(.*?)"/);
 
     $options->{product} = $product;
-
-    my ($logentries,$entriesbyversion,$bugsbyversion,$versions,$customheaders) = 
+    
+    $self->{tdcache}->{$options->{product}} = 
         $self->load_changelog_xml($options->{product},$options);
 
-    $self->{tdcache}->{$options->{product}} = {
-        logentries => $logentries,
-        entriesbyversion => $entriesbyversion,
-        bugsbyversion => $bugsbyversion,
-        versions => $versions,
-        custom => $customheaders,
-    };
-
     my $string;
 
     if ($tabletype eq 'entrylist')

@@ -209,27 +213,30 @@
         $self->{sources}->{$filename} = 1;
         $self->{sources}->{$verfilename} = 1;
 
-        my $my_handler = MySQLDynXML::ChangelogParser->new();
+        my $my_handler = MySQL::DynXML::ChangelogParser->new();
 
         XML::Parser::PerlSAX->new->parse(Source => { SystemId => $filename}, 
                                          Handler => $my_handler,
                                          );
 
-        my $ver_handler = MySQLDynXML::ChangelogVersionParser->new();
+        my $ver_handler = MySQL::DynXML::ChangelogVersionParser->new();
 
         XML::Parser::PerlSAX->new->parse(Source => { SystemId => $verfilename}, 
                                          Handler => $ver_handler);
 
-        return($my_handler->{logentries},
-               $my_handler->{entriesbyversion},
-               $my_handler->{bugsbyversion},
-               $ver_handler->{versions},
-               $my_handler->{custom});
+        my $returnval = {logentries => $my_handler->{logentries},
+                         entriesbyversion => $my_handler->{entriesbyversion},
+                         bugsbyversion => $my_handler->{bugsbyversion},
+                         version => $ver_handler->{versions},
+                         custom => $my_handler->{custom},
+                         bugtoentry => $my_handler->{bugtoentry},
+                     };
+        return $returnval;
     }
     else
     {
         print STDERR "WARNING: Couldn't load $filename for parsing ($!)";
-        return(undef,undef);
+        return(undef);
     }
 
 }


Modified: trunk/tools/MySQL/DynXML/ChangelogParser.pm
===================================================================
--- trunk/tools/MySQLDynXML/ChangelogParser.pm	2007-10-05 19:15:49 UTC (rev 7975)
+++ trunk/tools/MySQL/DynXML/ChangelogParser.pm	2007-10-06 03:29:42 UTC (rev 7976)
Changed blocks: 1, Lines Added: 13, Lines Deleted: 1; 575 bytes

@@ -1,4 +1,16 @@
-package MySQLDynXML::ChangelogParser;
+package MySQL::DynXML::ChangelogParser;
+
+# Load the standard MySQL Libraries
+
+use MySQL;
+
+# Ensure we have enabled error checking
+
+use strict;
+use warnings;
+
+# Load local modules
+
 use Digest::MD5 qw(md5_hex);
 use Encode qw(encode_utf8);
 


Modified: trunk/tools/MySQL/DynXML/ChangelogVersionParser.pm
===================================================================
--- trunk/tools/MySQLDynXML/ChangelogVersionParser.pm	2007-10-05 19:15:49 UTC (rev 7975)
+++ trunk/tools/MySQL/DynXML/ChangelogVersionParser.pm	2007-10-06 03:29:42 UTC (rev 7976)
Changed blocks: 1, Lines Added: 10, Lines Deleted: 1; 562 bytes

@@ -1,5 +1,14 @@
-package MySQLDynXML::ChangelogVersionParser;
+package MySQL::DynXML::ChangelogVersionParser;
 
+# Load the standard MySQL Libraries
+
+use MySQL;
+
+# Ensure we have enabled error checking
+
+use strict;
+use warnings;
+
 sub new
 {
     my $self = shift;


Modified: trunk/tools/MySQL/DynXML/Opfuncs.pm
===================================================================
--- trunk/tools/MySQLDynXML/Opfuncs.pm	2007-10-05 19:15:49 UTC (rev 7975)
+++ trunk/tools/MySQL/DynXML/Opfuncs.pm	2007-10-06 03:29:42 UTC (rev 7976)
Changed blocks: 4, Lines Added: 21, Lines Deleted: 6; 1624 bytes

@@ -1,8 +1,23 @@
-package MySQLDynXML::Opfuncs;
+package MySQL::DynXML::Opfuncs;
 
-use MySQLDynXML::OpfuncsParser;
+# Load the standard MySQL Libraries
+
+use MySQL;
+
+# Ensure we have enabled error checking
+
+use strict;
+use warnings;
+
+# Load MySQL modules
+
+use MySQL::IDMap;
+use MySQL::XML::Writer;
+use MySQL::DynXML::OpfuncsParser;
+
+# Load local modules
+
 use Data::Dumper;
-use MySQLXMLWriter;
 
 sub new
 {

@@ -19,7 +34,7 @@
         dependencyreq => 0,
     };
 
-    my $my_handler = MySQLDynXML::OpfuncsParser->new($object->{dynxmlcore});
+    my $my_handler = MySQL::DynXML::OpfuncsParser->new($object->{dynxmlcore});
 
     my $srcfile = sprintf('%s/opsfunctions/opfunctions.xml',
                           $object->{options}->{srcdir});

@@ -117,7 +132,7 @@
 {
     my ($self,$idlist) = @_;
 
-    my $idmap = IDMap->new({sources => [sprintf('../refman-%s',$self->{options}->{version})]});
+    my $idmap = MySQL::IDMap->new({sources => [sprintf('../refman-%s',$self->{options}->{version})]});
 
     my $iodest = IO::String->new();
 

@@ -158,7 +173,7 @@
 #        else
 #        {
 
-        if (exists($idmap->{$self->{td}->{$id}->{xrefto}}))
+        if (exists($idmap->{byid}->{$self->{td}->{$id}->{xrefto}}))
         {
             print $iodest xml_row(xml_entry(sprintf('<link linkend="%s">%s</link>%s',
                                                     $self->{td}->{$id}->{xrefto},


Modified: trunk/tools/MySQL/DynXML/OpfuncsParser.pm
===================================================================
--- trunk/tools/MySQLDynXML/OpfuncsParser.pm	2007-10-05 19:15:49 UTC (rev 7975)
+++ trunk/tools/MySQL/DynXML/OpfuncsParser.pm	2007-10-06 03:29:42 UTC (rev 7976)
Changed blocks: 1, Lines Added: 10, Lines Deleted: 1; 517 bytes

@@ -1,5 +1,14 @@
-package MySQLDynXML::OpfuncsParser;
+package MySQL::DynXML::OpfuncsParser;
 
+# Load the standard MySQL Libraries
+
+use MySQL;
+
+# Ensure we have enabled error checking
+
+use strict;
+use warnings;
+
 sub new
 {
     my $self = shift;


Modified: trunk/tools/MySQL/DynXML/Optvar.pm
===================================================================
--- trunk/tools/MySQLDynXML/Optvar.pm	2007-10-05 19:15:49 UTC (rev 7975)
+++ trunk/tools/MySQL/DynXML/Optvar.pm	2007-10-06 03:29:42 UTC (rev 7976)
Changed blocks: 15, Lines Added: 63, Lines Deleted: 23; 6875 bytes

@@ -1,8 +1,23 @@
-package MySQLDynXML::Optvar;
+package MySQL::DynXML::Optvar;
 
-use MySQLDynXML::OptvarParser;
+# Load the standard MySQL Libraries
+
+use MySQL;
+
+# Ensure we have enabled error checking
+
+use strict;
+use warnings;
+
+# Load MySQL Modules
+
+use MySQL::IDMap;
+use MySQL::XML::Writer;
+use MySQL::DynXML::OptvarParser;
+
+# Load local modules
+
 use Data::Dumper;
-use MySQLXMLWriter;
 use File::Basename;
 use IO::String;
 

@@ -30,7 +45,7 @@
 
     if (-f $filename)
     {
-        $my_handler = MySQLDynXML::OptvarParser->new($self->{dynxmlcore});
+        my $my_handler = MySQL::DynXML::OptvarParser->new($self->{dynxmlcore});
         XML::Parser::PerlSAX->new->parse(Source => { SystemId => $filename}, 
                                          Handler => $my_handler);
         return($my_handler->{tabledata},$filename);

@@ -176,7 +191,8 @@
     foreach my $id (sort { $td->{$a}->{'_sortbase'} cmp 
                                $td->{$b}->{'_sortbase'} } keys %{$td})
     {
-        if ($options->{tabletype} eq 'versionsummary' ||
+        if ((exists($options->{tabletype}) && 
+             $options->{tabletype} eq 'versionsummary') ||
             (exists($options->{selectall}) && 
              $options->{selectall} eq 'yes'))
         {

@@ -238,10 +254,9 @@
     my ($td,$idlist,$options) = @_;
 
     # Load the ID maps for the different manual versions
+    my $idmap = MySQL::IDMap->new();
 
-    my $idmap41 = IDMap->new({sources => ['../refman-4.1']});
-    my $idmap50 = IDMap->new({sources => ['../refman-5.0']});
-    my $idmap51 = IDMap->new({sources => ['../refman-5.1']});
+    # Initialize the structure to hold the output
 
     my $outfile = IO::String->new();
 

@@ -346,19 +361,19 @@
                 {
                     my $linkloc = undef;
                     if (($ver eq '4.1') &&
-                        exists($idmap41->{$td->{$id}->{xrefto}}))
+                        exists($idmap->{byprefixid}->{'refman-4.1'}->{$td->{$id}->{xrefto}}))
                     {
-                        $linkloc = generate_html_xref($idmap41,$td->{$id}->{xrefto});
+                        $linkloc = generate_html_xref($idmap,$td->{$id}->{xrefto});
                     }
                     if (($ver eq '5.0') &&
-                        exists($idmap50->{$td->{$id}->{xrefto}}))
+                        exists($idmap->{byprefixid}->{'refman-5.0'}->{$td->{$id}->{xrefto}}))
                     {
-                        $linkloc = generate_html_xref($idmap50,$td->{$id}->{xrefto});
+                        $linkloc = generate_html_xref($idmap,$td->{$id}->{xrefto});
                     }
                     if (($ver eq '5.1') &&
-                        exists($idmap51->{$td->{$id}->{xrefto}}))
+                        exists($idmap->{byprefixid}->{'refman-5.1'}->{$td->{$id}->{xrefto}}))
                     {
-                        $linkloc = generate_html_xref($idmap51,$td->{$id}->{xrefto});
+                        $linkloc = generate_html_xref($idmap,$td->{$id}->{xrefto});
                     }
 
                     if (defined($linkloc))

@@ -636,7 +651,7 @@
 </thead>
 <tbody>
 EOF
-    my $idmap = IDMap->new({sources => [sprintf('../refman-%s',$options->{version})]});
+    my $idmap = MySQL::IDMap->new({sources => [sprintf('../refman-%s',$options->{version})]});
 
 foreach my $id (@{$idlist})
 {

@@ -648,7 +663,7 @@
                               $id);
 
     if (exists($td->{$id}->{xrefto}) && 
-        exists($idmap->{$td->{$id}->{xrefto}}))
+        exists($idmap->{byid}->{$td->{$id}->{xrefto}}))
     {
         $id_text=sprintf('<link linkend="%s">%s</link>',$td->{$id}->{xrefto},$id_text);
     }

@@ -738,7 +753,7 @@
 </thead>
 <tbody>
 EOF
-    my $idmap = IDMap->new({sources => [sprintf('../refman-%s',$options->{version})]});
+    my $idmap = MySQL::IDMap->new({sources => [sprintf('../refman-%s',$options->{version})]});
 
 foreach my $id (@{$idlist})
 {

@@ -747,7 +762,7 @@
                               $td->{$id}->{type}->{systemvar}->{format} || 
                               $id);
     if (exists($td->{$id}->{xrefto}) && 
-        exists($idmap->{$td->{$id}->{xrefto}}))
+        exists($idmap->{byid}->{$td->{$id}->{xrefto}}))
     {
         $id_text=sprintf('<link linkend="%s">%s</link>',$td->{$id}->{xrefto},$id_text);
     }

@@ -842,7 +857,7 @@
 
     my $count = 0;
 
-    my $idmap = IDMap->new({sources => [sprintf('../refman-%s',$options->{version})]});
+    my $idmap = MySQL::IDMap->new({sources => [sprintf('../refman-%s',$options->{version})]});
 
     foreach my $id (@{$idlist})
     {

@@ -895,7 +910,7 @@
             $opts = {rowsep => {0 => 0}};
 
             if (exists($td->{$id}->{xrefto}) && 
-                exists($idmap->{$td->{$id}->{xrefto}}))
+                exists($idmap->{byid}->{$td->{$id}->{xrefto}}))
             {
                 $opts->{xref} = $td->{$id}->{xrefto};
             }

@@ -919,7 +934,7 @@
             
             $opts = {rowsep => {0 => 0}};
 
-            if (exists($idmap->{$td->{$id}->{xrefto}}))
+            if (exists($idmap->{byid}->{$td->{$id}->{xrefto}}))
             {
                 $opts->{xref} = $td->{$id}->{xrefto};
             }

@@ -936,7 +951,7 @@
         {
             $opts = {};
             if (exists($td->{$id}->{xrefto}) && 
-                exists($idmap->{$td->{$id}->{xrefto}}))
+                exists($idmap->{byid}->{$td->{$id}->{xrefto}}))
             {
                 $opts->{xref} = $td->{$id}->{xrefto};
             }

@@ -976,7 +991,7 @@
     {
         my $attr = {};
 
-        if (($counter == 0) && exists($options->{xref}) && defined($options->{xref}) && exists($idmap->{$options->{xref}}) )
+        if (($counter == 0) && exists($options->{xref}) && defined($options->{xref}) && exists($idmap->{byid}->{$options->{xref}}) )
         {
             $attr->{_xref} = $options->{xref};
             die "Have a undefined ID, which should be impossible " . Dumper($row) unless (defined($options->{xref}));

@@ -1142,4 +1157,29 @@
     return (keys %{$words});
 }
 
+sub generate_html_xref
+{
+    my ($idmap,$idref) = @_;
+
+    my $urlcore = 'http://dev.mysql.com/doc/';
+    my $url;
+
+    if ($idmap->{byid}->{$idref}->{type} =~ m/^(appendix|article|book|part|chapter|example|glossary|preface|refentry|refsection|section)$/i)
+    {
+        $url = sprintf('%s%s/%s.html',
+                       $urlcore,
+                       $idmap->{byid}->{$idref}->{urlbase},
+                       $idref);
+    }
+    else
+    {
+        $url = sprintf('%s%s/%s.html#%s',
+                       $urlcore,
+                       $idmap->{byid}->{$idref}->{urlbase},
+                       $idmap->{byid}->{$idref}->{parent},
+                       $idref);
+    }
+    return($url);
+}
+
 1;


Modified: trunk/tools/MySQL/DynXML/OptvarParser.pm
===================================================================
--- trunk/tools/MySQLDynXML/OptvarParser.pm	2007-10-05 19:15:49 UTC (rev 7975)
+++ trunk/tools/MySQL/DynXML/OptvarParser.pm	2007-10-06 03:29:42 UTC (rev 7976)
Changed blocks: 1, Lines Added: 10, Lines Deleted: 1; 512 bytes

@@ -1,5 +1,14 @@
-package MySQLDynXML::OptvarParser;
+package MySQL::DynXML::OptvarParser;
 
+# Load the standard MySQL Libraries
+
+use MySQL;
+
+# Ensure we have enabled error checking
+
+use strict;
+use warnings;
+
 sub new
 {
     my $self = shift;


Modified: trunk/tools/MySQL/DynXML/ReservedWords.pm
===================================================================
--- trunk/tools/MySQL/XML/DeepCheck.pm	                        (rev 0)
+++ trunk/tools/MySQL/XML/DeepCheck.pm	2007-10-06 03:29:42 UTC (rev 7976)
Changed blocks: 4, Lines Added: 1370, Lines Deleted: 5; 40615 bytes

@@ -1,7 +1,21 @@
-package MySQLDynXML::ReservedWords;
+package MySQL::DynXML::ReservedWords;
 
+# Load the standard MySQL Libraries
+
+use MySQL;
+
+# Ensure we have enabled error checking
+
+use strict;
+use warnings;
+
+# Load MySQL Modules
+
+use MySQL::XML::Writer;
+
+# Load local modules
+
 use Data::Dumper;
-use MySQLXMLWriter;
 
 sub new
 {

Copied: trunk/tools/MySQL/DynXML.pm (from rev 7975, trunk/tools/MySQLDynXML.pm)
===================================================================
--- trunk/tools/MySQL/DynXML.pm	                        (rev 0)
+++ trunk/tools/MySQL/DynXML.pm	2007-10-06 03:29:42 UTC (rev 7976)

@@ -0,0 +1,142 @@
+package MySQL::DynXML;
+
+# Load the standard MySQL Libraries
+
+use MySQL;
+
+# Ensure we have enabled error checking
+
+use strict;
+use warnings;
+
+sub new
+{
+    my $self = shift;
+    my $class = ref($self) || $self;
+
+    return bless {
+        tdcache => {},
+        sources => {},
+    }, $class;
+}
+
+sub compress_versions
+{
+    my ($self,$baseversions,$versionlist) = @_;
+
+    my (@basesorted,@versorted) = ((),());
+
+    if (ref($baseversions) eq 'ARRAY')
+    {
+        @basesorted = sort { $self->vertodec($a) <=> $self->vertodec($b) } @{$baseversions};
+    }
+    elsif (ref($baseversions) eq 'HASH')
+    {
+        @basesorted = sort { $self->vertodec($a) <=> $self->vertodec($b) } keys %{$baseversions};
+    }
+
+    if (ref($versionlist) eq 'ARRAY')
+    {
+        @versorted = sort { $self->vertodec($a) <=> $self->vertodec($b) } @{$versionlist};
+    }
+    elsif (ref($versionlist) eq 'HASH')
+    {
+        @versorted = sort { $self->vertodec($a) <=> $self->vertodec($b) } keys %{$versionlist};
+    }
+
+    my $offset = 0;
+    my $first = $basesorted[0];
+    my $counter = 1;
+    my @compressed;
+    my $i;
+
+    for($i=0;$i<scalar @versorted;$i++)
+    {
+        if ($versorted[$i] eq $basesorted[$i+$offset])
+        {
+            $counter++;
+            next;
+        }
+        else
+        {
+            # We're not in the sequence so create a compressed entry
+            if ($counter == 1)
+            {
+                push @compressed,$versorted[$i-1];
+            }
+            else
+            {
+                push @compressed,sprintf('%s-%s',$first,$versorted[$i-1]);
+            }
+            $first = $versorted[$i];
+            $counter = 1;
+            for (my $j = $i; $j < scalar(@basesorted);$j++)
+            {
+                if ($basesorted[$j] eq $versorted[$i])
+                {
+                    $offset = $j-$i;
+                    last;
+                }
+            }
+        }
+    }
+    if ($counter == 1)
+    {
+        push @compressed,$versorted[$i-1];
+    }
+    else
+    {
+        push @compressed,sprintf('%s-%s',$first,$versorted[$i-1]);
+    }
+
+    return @compressed;
+}
+
+
+sub vertodec
+{
+    my ($self,$ver) = @_;
+
+    my ($escs) = ($ver =~ m/(ES|CS)$/);
+    $ver =~ s/(ES|CS)$//;
+
+    if ($ver =~ m/(\d+[\. -]\d+[\. -]\d+)-[a-z]+-(\d+[\. -]\d+[\. -]\d+)/)
+    {
+        my ($major,$minor) = (vertodecraw($1),vertodecraw($2));
+        return(sprintf('%d.%d',$major,$minor));
+    }
+    else
+    {
+        return(vertodecraw($ver));
+    }
+}
+
+sub vertodecraw
+{
+    my ($version) = @_;
+
+    my ($a,$b,$c,$ext) = split(/[\. -]/,$version);
+
+    $a = 0 unless defined($a);
+    $b = 0 unless defined($b);
+    $c = 0 unless defined($c);
+    
+    my $d = 0;
+
+    if ($c =~ m/([0-9]+)([a-z])/)
+    {
+        $c = $1;
+        if ($d =~ m/sp(\d+)/)
+        {
+            $d = $1;
+        }
+        else
+        {
+            $d = ord($d);
+        }
+    }
+
+    return(($a*1000000)+($b*10000)+($c*100)+$d);
+}
+
+1;

Copied: trunk/tools/MySQL/IDMap.pm (from rev 7975, trunk/tools/IDMap.pm)
===================================================================
--- trunk/tools/MySQL/IDMap.pm	                        (rev 0)
+++ trunk/tools/MySQL/IDMap.pm	2007-10-06 03:29:42 UTC (rev 7976)

@@ -0,0 +1,703 @@
+package MySQL::IDMap;
+
+# IDMap.pm
+#
+# Loads the ID map detail (in metadata/*.idmap) for use 
+# by various utilities
+
+# Martin MC Brown
+# mc@stripped
+# 2007-10-03
+
+# Load the standard MySQL Libraries
+
+use MySQL;
+
+# Ensure we have enabled error checking
+
+use strict;
+use warnings;
+
+# Module specific modules
+
+use Carp;
+use Data::Dumper;
+use File::Basename;
+
+sub new
+{
+    my $self = shift;
+    my $class = ref($self) || $self;
+    my $opts = shift;
+    my $object = {};
+
+    my $maptypes = [qw/root idmap ridmap image xmlimport dynimport entityfile indexterm command option function/];
+
+    my ($forward,$reverse) = ({},{});
+
+    for (my $i=0; $i < scalar @{$maptypes};$i++)
+    {
+        $object->{_types}->{forward}->{$i} = $maptypes->[$i];
+        $object->{_types}->{reverse}->{$maptypes->[$i]} = $i;
+    }
+
+    bless $object, $class;
+
+    return $object if (exists($opts->{skiploading}) && ($opts->{skiploading} == 1));
+
+    my $sources = undef;
+
+    if (exists($opts->{sources}))
+    {
+        if (ref($opts->{sources}) eq 'ARRAY')
+        {
+            $sources = $opts->{sources};
+        }
+        else
+        {
+            if (!defined($sources) || ($sources eq ''))
+            {
+                $sources = builddefaultsources();
+            }
+            else
+            {
+                $sources = parsesrcpathoptions($opts->{sources});
+            }
+        }
+    }
+    else
+    {
+        $sources = builddefaultsources();
+    }
+
+    $object->loadentities($sources);
+
+    $object->loadmaps($sources);
+
+    if (exists($opts->{altmaptypes}))
+    {
+        $object->loadrmaps($opts->{sources}) if (exists($opts->{reverse}) &&
+                                                 $opts->{reverse} == 1);
+    }
+
+    return $object;
+}
+
+sub parsesrcpathoptions
+{
+    my ($srcpathopt) = @_;
+
+    my @srcpaths;
+    
+    if (defined($srcpathopt) && $srcpathopt ne '')
+    {
+        my @newsrcpaths = split(/ /,$srcpathopt);
+        my (@hasadd,@hasnew) = ((),());
+        
+        foreach my $path (@newsrcpaths)
+        {
+            if ($path =~ m/^\+/)
+        {
+            my $realpath = $path;
+            $realpath =~ s/^\+//;
+            push @hasadd,$realpath;
+        }
+            else
+            {
+                push @hasnew,$path;
+            }
+        }
+        if (scalar(@hasnew) > 0)
+        {
+            @srcpaths = @hasnew;
+        }
+        push @srcpaths,@hasadd;
+    }
+    return(\@srcpaths);
+}
+
+sub maptypebyname
+{
+    my ($self,$name) = @_;
+    return $self->{_types}->{reverse}->{$name};
+}
+
+sub maptypebynumber
+{
+    my ($self,$number) = @_;
+    return $self->{_types}->{forward}->{$number};
+}
+
+sub loadmaps
+{
+    my ($self,$srcs) = @_;
+
+    foreach my $prefix (@{$srcs})
+    {
+        my @maps = glob($prefix . '/' . 'metadata/*.idmap');
+
+        $prefix = $self->resolvefilename('',$prefix);
+
+        foreach my $file (@maps)
+        {
+            $self->loadmap($file,$prefix);
+        }
+    }
+}
+
+sub builddefaultsources
+{
+    my @basepaths = ('.','..','../..');
+    my @basedirs = qw/
+        refman-4.1 
+        refman-5.0 
+        refman-5.1 
+        refman-5.2
+        refman-common 
+        gui-common 
+        internals 
+        query-browser 
+        administrator 
+        migration-toolkit 
+        workbench 
+        falcon 
+        ndbapi
+        mysqldoc-guide
+        guibook
+        /;
+
+    my @srcpaths = (); 
+
+    foreach my $basedir (@basepaths)
+    {
+        foreach my $dir (@basedirs)
+        {
+            my $fdir = sprintf('%s/%s',$basedir,$dir);
+            push(@srcpaths, $fdir) if (-d $fdir);
+        }
+    }
+    return \@srcpaths;
+}
+
+sub builddepth
+{
+    my ($self) = @_;
+
+    # Now calculate the depth of each item
+
+    foreach my $id (keys %{$self->{byid}})
+    {
+        next if ($id =~ m/__.*?__/);
+        next unless ($self->{byid}->{$id}->{idmapversion} >= 2);
+        $self->walktree($id);
+    }
+}
+
+sub walktree
+{
+    my ($self,$id) = @_;
+
+    if (exists($self->{byid}->{$id}->{parent}) &&
+        defined($self->{byid}->{$id}->{parent}))
+    {
+        if ($self->{byid}->{$id}->{parent} eq $id)
+        {
+            $self->{byid}->{$id}->{depth} = 1;
+        }
+        elsif (exists($self->{$self->{byid}->{$id}->{parent}}->{depth}))
+        {
+            $self->{byid}->{$id}->{depth} = $self->{$self->{byid}->{$id}->{parent}}->{depth} + 1;
+        }
+        else
+        {
+            $self->{byid}->{$id}->{depth} = $self->walktree($self->{byid}->{$id}->{parent}) or 0 + 1;
+        }
+    }
+    return($self->{byid}->{$id}->{depth});
+}
+
+sub buildtree
+{
+    my ($self,$prefix) = @_;
+
+    my $idtree = {};
+
+    foreach my $id (keys %{$self->{byid}})
+    {
+        $idtree->{$id} = {} unless(exists($idtree->{$id}));
+        if (exists($self->{mapfilesbyid}->{$id}))
+        {
+# it's a root file, so we make sure we identify any XML imports in this file
+            foreach my $file (keys %{$self->{xmlimportbyparent}->{$id}})
+            {
+                my $realfile = $self->resolvefilename($self->{byid}->{$id}->{prefix},$file);
+                if (exists($self->{mapfilesbyfullpath}->{$realfile}->{rootid}) &&
+                    defined($self->{mapfilesbyfullpath}->{$realfile}->{rootid}))
+                {
+                    $idtree->{$id}->{$self->{mapfilesbyfullpath}->{$realfile}->{rootid}} = 1;
+                }
+            }
+        }
+        if (exists($self->{byid}->{$id}->{parent}) &&
+            defined($self->{byid}->{$id}->{parent}))
+        {
+            if (defined($prefix))
+            {
+                next unless (exists($self->{byprefixid }->{$prefix}->{$id}->{prefix}));
+            }
+            next if ($self->{byid}->{$id}->{parent} eq $id);
+            $idtree->{$self->{byid}->{$id}->{parent}}->{$id} = 1;
+        }
+    }
+    
+    return($idtree);
+}
+
+sub loadrmaps
+{
+    my ($self,$srcs) = @_;
+
+    foreach my $prefix (@{$srcs})
+    {
+        my @maps = glob($prefix . '/' . 'metadata/*.ridmap');
+
+        foreach my $file (@maps)
+        {
+            $self->loadrmap($file,$prefix);
+        }
+    }
+}
+
+sub loadrmap
+{
+    my ($self,$file,$prefix) = @_;
+
+    open(IDMAP,$file) or croak "Could not load ID map file $file: $!\n";
+
+    my @lines = <IDMAP>;
+
+    close(IDMAP);
+
+    if (scalar @lines == 0)
+    {
+        return;
+    }
+
+    my $version = 0;
+
+    if (defined($lines[0]) && 
+        $lines[0] =~ m/^!!!mapversion:([0-9]+)!!!$/)
+    {
+        $version = $1;
+        shift @lines;
+    }
+
+    my ($srcfile,$repository,$docbase,
+        $docversion,$doclang,$urlbase,
+        ) =
+            (undef,undef,undef,
+             undef,undef,undef,
+             );
+
+    if ($version == 1)
+    {
+        if ($lines[0] =~ m/^!!!INFO!!!(.*?)$/)
+        {
+            my ($infoline) = ($1);
+            ($srcfile,$docbase,
+             $docversion,$doclang,$urlbase) 
+                = split(/:/,$infoline,5);
+            shift @lines;
+        }
+        else
+        {
+            croak "You have a version $version ID Map but without a valid header; regenerate the ID map for $file and try again!\n";
+        }
+    }
+    
+    foreach my $line (@lines)
+    {
+        chomp $line;
+        my ($parent,$id) = split(/:/,$line);
+        $self->{$id}->{reverse}->{$prefix}->{$parent} = 1;
+    }
+}
+
+sub loadmap
+{
+    my ($self,$file,$prefix) = @_;
+
+    open(IDMAP,$file) or croak "Could not load ID map file $file: $!\n";
+
+    my @lines = <IDMAP>;
+
+    close(IDMAP);
+
+    if (scalar @lines == 0)
+    {
+        return;
+    }
+
+    my $version = 0;
+
+    if (defined($lines[0]) && 
+        $lines[0] =~ m/^!!!mapversion:([0-9]+)!!!$/)
+    {
+        $version = $1;
+        shift @lines;
+    }
+
+    my ($srcfile,$repository,$docbase,
+        $docversion,$doclang,$urlbase,
+        $roottype,$rootid
+        ) =
+            (undef,undef,undef,
+             undef,undef,undef,
+             undef,undef
+             );
+
+    if ($version == 1 || 
+        $version == 2)
+    {
+        if ($lines[0] =~ m/^!!!INFO!!!(.*?)$/)
+        {
+            my ($infoline) = ($1);
+            ($srcfile,$docbase,
+             $docversion,$doclang,$urlbase) 
+                = split(/:/,$infoline,5);
+            shift @lines;
+        }
+        else
+        {
+            croak "You have a version $version ID Map but without a valid header; regenerate the ID map for $file and try again!\n";
+        }
+    }
+    elsif ($version == 3)
+    {
+        if ($lines[0] =~ m/^!!!INFO!!!(.*?)$/)
+        {
+            my ($infoline) = ($1);
+            ($srcfile,$docbase,
+             $docversion,$doclang,$urlbase,$roottype,$rootid) 
+                = split(/:/,$infoline,7);
+            shift @lines;
+
+            $self->{fileinfo} = {
+                srcfile => $srcfile,
+                docbase => $docbase,
+                docversion => $docversion,
+                doclang => $doclang,
+                urlbase => $urlbase,
+                roottype => $roottype,
+                rootid => $rootid,
+                prefix => $prefix,
+                idmapversion => $version,
+            };
+            $self->{mapfilesbyfile}->{$srcfile} = $self->{fileinfo};
+            my $fullpath = sprintf('%s/%s',$prefix,$srcfile);
+            $self->{mapfilesbyfullpath}->{$fullpath} = $self->{fileinfo};
+            if (defined($rootid))
+            {
+                $self->{mapfilesbyid}->{$rootid} = $self->{fileinfo};
+            }
+        }
+        else
+        {
+            croak "You have a version $version ID Map but without a valid header; regenerate the ID map for $file and try again!\n";
+        }
+    }
+    else
+    {
+        croak "Unknown ID map version $version; regenerate the ID map for $file and try again!\n";
+    }
+
+    $self->{'__idmap_version__'} = $version;
+    
+    foreach my $line (@lines)
+    {
+        chomp $line;
+
+        my ($id,$type,$parent,
+            $title) = 
+                (undef,undef,undef,
+                 undef);
+        
+        if ($version == 0)
+        {
+            ($id,$type,$parent,$srcfile,$urlbase,$title) = split(/:/,$line,6);
+
+            $title = $self->parsentities($prefix,$title);
+        
+            if (exists($self->{$id}))
+            {
+                push @{$self->{$id}->{adds}},$prefix;
+            }
+            else
+            {
+                $self->{$id} = {id => $id,
+                                type => $type,
+                                parent => $parent,
+                                file => $srcfile,
+                                prefix => $prefix,
+                                urlbase => $urlbase,
+                                title => $title,
+                                idmapversion => $version,
+                            };
+            }
+        }
+        elsif ($version == 1 || 
+               $version == 2)
+        {
+            ($id,$type,$parent,
+             $title) = 
+                 split(/:/,$line,4);
+
+            $title = $self->parsentities($prefix,$title);
+
+            my $record = {id => $id,
+                          type => $type,
+                          parent => $parent,
+                          file => $srcfile,
+                          prefix => $prefix,
+                          docbase => $docbase,
+                          docversion => $docversion,
+                          doclang => $doclang,
+                          urlbase => $urlbase,
+                          title => $title,
+                          idmapversion => $version,
+                      };
+        
+            if (exists($self->{$id}))
+            {
+                push @{$self->{$id}->{adds}},$prefix;
+                $self->{$id}->{alts}->{$prefix} = $record;
+            }
+            else
+            {
+                $self->{$id} = $record;
+            }
+        }
+        elsif ($version == 3)
+        {
+            my ($idtype,$restofline) = split(/:/,$line,2);
+
+            $self->parseline_idmap($prefix,$restofline)
+                if ($self->{_types}->{forward}->{$idtype} eq 'idmap');
+            $self->parseline_ridmap($prefix,$restofline) 
+                if ($self->{_types}->{forward}->{$idtype} eq 'ridmap');
+            $self->parseline_xmlimport($prefix,$restofline) 
+                if ($self->{_types}->{forward}->{$idtype} eq 'xmlimport');
+            $self->parseline_image($prefix,$restofline) 
+                if ($self->{_types}->{forward}->{$idtype} eq 'image');
+            $self->parseline_entityfile($prefix,$restofline) 
+                if ($self->{_types}->{forward}->{$idtype} eq 'entityfile');
+            $self->parseline_indexterm($prefix,$restofline) 
+                if ($self->{_types}->{forward}->{$idtype} eq 'indexterm');
+        }
+    }
+
+    $self->{filelist}->{$file} = $self->{fileinfo};
+
+}
+
+sub parseline_idmap
+{
+    my ($self,$prefix,$line) = @_;
+
+    my ($id,$type,$parent,$title) = split(/:/,$line,4);
+
+    $title = $self->parsentities($prefix,$title);
+
+    my $record = {id => $id,
+                  type => $type,
+                  parent => $parent,
+                  file => $self->{fileinfo}->{srcfile},
+                  prefix => $prefix,
+                  docbase => $self->{fileinfo}->{docbase},
+                  docversion => $self->{fileinfo}->{docversion},
+                  doclang => $self->{fileinfo}->{doclang},
+                  urlbase => $self->{fileinfo}->{urlbase},
+                  title => $title,
+                  idmapversion => $self->{fileinfo}->{idmapversion},
+                  adds => [$prefix],
+    };
+    
+    if (exists($self->{byid}->{$id}))
+    {
+        push @{$self->{byid}->{$id}->{adds}},$prefix;
+        $self->{byid}->{$id}->{alts}->{$prefix} = $record;
+    }
+    else
+    {
+        $self->{byid}->{$id} = $record;
+    }
+    $self->{byprefixid}->{$prefix}->{$id} = $record;
+}
+
+sub parseline_ridmap
+{
+    my ($self,$prefix,$line) = @_;
+
+    my ($parent,$id) = split(/:/,$line);
+    $self->{reversebyid}->{$id}->{$prefix}->{$parent} = 1;
+}
+
+sub parseline_image
+{
+    my ($self,$prefix,$line) = @_;
+
+    my ($parent,$file) = split(/:/,$line);
+    $self->{imageimportbyfile}->{$file}->{$parent} = 1;
+    $self->{imageimportbyparent}->{$parent}->{$file} = 1;
+}
+
+sub parseline_xmlimport
+{
+    my ($self,$prefix,$line) = @_;
+
+    my ($parent,$xmlimport) = split(/:/,$line);
+    $self->{xmlimportbyfile}->{$xmlimport}->{$parent} = 1;
+    $self->{xmlimportbyparent}->{$parent}->{$xmlimport} = 1;
+}
+
+sub parseline_dynimport
+{
+    my ($self,$line) = @_;
+
+}
+
+sub parseline_entityfile
+{
+    my ($self,$prefix,$line) = @_;
+
+    $self->{entitybyfile}->{$self->{fileinfo}->{srcfile}}->{$line} = 1;
+    my $fullpath = sprintf('%s/%s',
+                           $prefix,
+                           $self->{fileinfo}->{srcfile});
+    $self->{entitybyfullpath}->{$fullpath}->{$line} = 1;
+    $self->{entitybyentityfile}->{$line}->{$self->{fileinfo}->{srcfile}} = 1;
+    $self->{entitybyentityfile}->{$line}->{$fullpath} = 1;
+}
+
+sub parseline_indexterm
+{
+    my ($self,$prefix,$line) = @_;
+    
+    my ($parent,$primary,$secondary,$tertiary,$see,$seealso) = split(/:/,$line);
+
+    my $indexrecord = {parent => $parent,
+                       primary => $primary,
+                       secondary => $secondary,
+                       tertiary => $tertiary,
+                       see => $see,
+                       seealso => $seealso,};
+
+    push @{$self->{indexbyparent}->{$parent}},$indexrecord;
+}
+
+sub parsentities
+{
+    my ($self,$prefix,$string) = @_;
+
+    return $string unless(defined($string));
+
+    if ($string =~ m{&(.*?);})
+    {
+        my @ents = ($string =~ m/&(.*?);/);
+        
+        foreach my $entity (@ents)
+        {
+            my $repl = $self->{entities}->{$entity}->{$prefix} || 
+                $self->{entities}->{$entity}->{'_value'};
+            $string =~ s/&$entity;/$repl/ if (defined($entity) && defined($repl));
+        }
+    }
+    return($string);
+}
+
+sub loadentities
+{
+    my ($self,$srcs) = @_;
+
+    unshift(@{$srcs},'../common');
+
+    my $entities = {};
+
+    foreach my $prefix (@{$srcs})
+    {
+        my @maps = glob($prefix . '/' . '*.ent');
+        
+        foreach my $file (@maps)
+        {
+            load_entity_file($entities,$file,$prefix);        
+        }
+    }
+    $self->{entities} = $entities;
+}
+
+sub load_entity_file
+{
+    my ($entities,$file,$prefix) = @_;
+    my $fh;
+
+    $fh = IO::File->new ($file, "r")
+        or die "FATAL: Can't open entity file $file\n";
+
+    while(my $line = <$fh>)
+    {
+        chomp($line);
+        
+        if ($line =~ m/<!ENTITY/)
+        {
+            # check for nested entity file definition, recurse if so
+            if ($line =~ /<!ENTITY\s+\%\s*\S+\s+SYSTEM\s+['"](.*)['"]\s*>/)
+            {
+                my $entfile = $1;         # new file to read
+                my $dir = dirname($file); # dir of current file
+                # compute new file path relative to current file's dir
+                # unless we're already in current dir or path is absolute
+                $entfile = $dir . "/" . $entfile
+                    unless $dir eq "." || $entfile =~ m|^/|;
+                # prefix now become prefix of new file
+                $prefix = dirname($entfile);
+                load_entity_file($entities, $entfile, $prefix);
+                next;
+            }
+
+            my ($entity,$value) = ($line =~ m/<!ENTITY\s+(\S+?)\s+['"](.*)['"]>/);
+            if (exists($entities->{$entity}))
+            {
+                $entities->{$entity}->{_value} = $value;
+                $entities->{$entity}->{$prefix} = $value;
+            }
+            else
+            {
+                $entities->{$entity} = {'_value' => $value,
+                                        $prefix => $value};
+            }
+        }
+    }
+    $fh->close ();
+}
+
+sub resolvefilename
+{
+    my ($self,$prefix,$name) = @_;
+
+    if ($name =~ m{^../})
+    {
+        $name =~ s|^../||;
+        return($name);
+    }
+    
+    if ($name =~ m{^./})
+    {
+        $name =~ s|^./||;
+        return $name;
+    }
+
+    return $prefix . '/' . $name;
+
+}
+
+1;

Copied: trunk/tools/MySQL/XML/DeepCheck.pm (from rev 7975, trunk/tools/MySQLDeepCheck.pm)
===================================================================
--- trunk/tools/MySQL/XML/DeepCheck.pm	                        (rev 0)
+++ trunk/tools/MySQL/XML/DeepCheck.pm	2007-10-06 03:29:42 UTC (rev 7976)

@@ -0,0 +1,506 @@
+package MySQL::XML::DeepCheck;
+
+# Load the standard MySQL Libraries
+
+use MySQL;
+
+# Ensure we have enabled error checking
+
+use strict;
+use warnings;
+
+# Load local specific modules
+
+use File::Basename;
+use LWP::UserAgent;
+
+# Currently addresses:
+# - Checks table column definition/actual columns
+# - Checks width of columns equal 100%
+# - Checks images (defined and local filesystem)
+#   Only reports filesystem images with --checkimages
+# - Checks section IDs (duplicates)
+# - Checks line length of <programlisting> elements 
+#   Now enabled with --checkwidth
+#   Set max line length with --linelength (default: 72)
+# - Checks for empty <link> references
+# - Checks for <Table> and <informaltable> definitions
+# - Checks external (ulinks) if you ask with checkulink
+
+sub new
+{
+    my $self = shift;
+    my $class = ref($self) || $self;
+    my $options = shift;
+
+    return bless {'options' => $options,
+                  'sectionids' => {},
+                  'triedulinks' => {},
+                  'currsection' => '',
+                  'sectionmap' => [],
+                  'intag' => 0,
+                  'tablecount' => 0,
+                  'tabledefs' => {},
+                  'currentbase' => './',
+                  'inlink' => 0,
+                  'linkref' => '',
+                  'linktext' => '',
+                  'intable' => 0,
+                  'intodo' => 0,
+                  'errorcount' => 0,
+                  'checklinelength' => 0,
+                  'savedtext' => '',
+                  'inemphasis' => 0,
+                  'issuelist' => [],
+                  'issueclearlist' => [],
+                  'loc' => [],
+              }, $class;
+}
+
+sub print_error
+{
+    my ($self,@params) = @_;
+
+    print "\n" if ($self->{errorcount} == 0);
+    $self->{errorcount}++;
+
+    print STDERR (@params);
+}
+
+sub printf_error
+{
+    my ($self,$format,@params) = @_;
+
+    $self->print_error(sprintf($format,@params));
+}
+
+sub start_element
+{
+    my ($self, $element) = @_;
+
+    if ($self->{options}->{checkulink})
+    {
+        if  ($element->{Name} eq 'ulink')
+        {
+            if (!exists($self->{triedulinks}->{$element->{Attributes}->{'url'}}))
+            {
+                $self->{triedulinks}->{$element->{Attributes}->{'url'}} = 1;
+                my $ua = LWP::UserAgent->new;
+                
+                my $response = $ua->head($element->{Attributes}->{url});
+                
+                if ($response->is_error())
+                {
+                    push(@{$self->{issuelist}},
+                         {'parentid' => $self->{currsection},
+                          'type' => 'badulink',
+                          'class' => 'todo',
+                          'text' => join('',"Error URL link to ",
+                                         $element->{Attributes}->{url} || 'Not specified',
+                                         " fails with ", 
+                                         $response->status_line,
+                                         "\n")});
+                }
+            }
+        }
+    }
+
+    if ($element->{Name} =~ m/^(chapter|section|appendix)$/)
+    {
+        if (exists($element->{Attributes}->{'xml:base'}))
+        {
+            $self->{currentbase} = dirname($element->{Attributes}->{'xml:base'}) . '/' || './';
+        }
+#        else
+#        {
+#            $self->{currentbase} = './';
+#        }
+    }
+
+    if ($element->{Name} eq 'imagedata')
+    {
+        if (exists($self->{known_imgs}->{$element->{Attributes}->{fileref}}))
+        {
+            $self->{known_imgs}->{$element->{Attributes}->{fileref}} = 2;
+        }
+        my $realref = sprintf('%s%s',
+                              $self->{currentbase},
+                              $element->{Attributes}->{fileref});
+# Currently disabled because the image references do not take source file locations
+# into account
+
+#        if (!-e $realref)
+#        {
+#            push(@{$self->{issuelist}},
+#                 {'parentid' => $self->{currsection},
+#                  'type' => 'image-missing',
+#                  'class' => 'todo',
+#                  'text' => "Error image: $realref does not exist\n"});
+#        }
+#    }
+
+    if ($element->{Name} eq 'remark' &&
+        exists($element->{Attributes}->{role}) &&
+        $element->{Attributes}->{role} eq 'todo')
+    {
+        $self->{intodo} = 1;
+    }
+
+    if ($element->{Name} eq 'programlisting')
+    {
+        $self->{checklinelength} = 1;
+    }
+
+    if ($element->{Name} eq 'link' ||
+        $element->{Name} eq 'xref')
+    {
+        $self->{inlink} = 1;
+        if (exists($element->{Attributes}->{linkend}))
+        {
+            $self->{linkref} = $element->{Attributes}->{linkend};
+        }
+        else 
+        {
+            push(@{$self->{issuelist}},
+                 {'parentid' => $self->{currsection},
+                  'type' => 'linkend-missing',
+                  'class' => 'todo',
+                  'text' => "Cannot have a <$element->{Name}> without linkend attribute\n"});
+        }
+    }
+
+    if ($element->{Name} eq 'emphasis')
+    {
+        $self->{inemphasis} = 1;
+    }        
+
+    if ($element->{Name} =~ m/^(appendix|article|book|part|chapter|example|preface|refentry|refsection|section)$/i)
+    {
+        if (exists($element->{Attributes}->{id}))
+        {
+            push(@{$self->{sectionmap}},$element->{Attributes}->{id});
+            $self->{currsection} = $element->{Attributes}->{id};
+            if (exists($self->{sectionids}->{$element->{Attributes}->{id}}))
+            {
+                push(@{$self->{issuelist}},
+                     {'parentid' => $self->{currsection},
+                      'type' => 'idmissing',
+                          'class' => 'todo',
+                      'text' => "Found a duplicate reference ID ($element->{Attributes}->{id})\n"});
+            }
+            else
+            {
+                $self->{sectionids}->{$element->{Attributes}->{id}} = 0;
+            }
+            $self->{sectionids}->{$element->{Attributes}->{id}}++;
+        }
+        else
+        {
+            push(@{$self->{issuelist}},
+                 {'parentid' => $self->{currsection},
+                  'type' => 'idmissing',
+                  'class' => 'todo',
+                  'text' => "Found a $element->{Name} without an ID!\n"});
+        }
+    }
+
+    if ($self->{intable} >= 1)
+    {
+        if ($element->{Name} eq 'entrytbl')
+        {
+            $self->{tabledefs}->{$self->{tablecount}}->{inentrytbl} = 1;
+        }
+        
+        if ($element->{Name} eq 'tgroup')
+        {
+            $self->{tabledefs}->{$self->{tablecount}}->{defcolumns} = $element->{Attributes}->{cols};
+            $self->{tabledefs}->{$self->{tablecount}}->{speccolumns} = 0;
+            $self->{tabledefs}->{$self->{tablecount}}->{foundcolumns} = 0;
+            $self->{tabledefs}->{$self->{tablecount}}->{maxcolumns} = 0;
+            $self->{tabledefs}->{$self->{tablecount}}->{section} = $self->{currsection};
+        }
+        if ($element->{Name} eq 'row')
+        {
+            $self->{tabledefs}->{$self->{tablecount}}->{foundcolumns} = 0;
+        }
+        if ($element->{Name} eq 'entry')
+        {
+            $self->{tabledefs}->{$self->{tablecount}}->{foundcolumns}++ 
+                unless (exists($self->{tabledefs}->{$self->{tablecount}}->{inentrytbl}) &&
+                        $self->{tabledefs}->{$self->{tablecount}}->{inentrytbl} == 1);
+        }
+        if ($element->{Name} eq 'colspec')
+        {
+            if (defined($element->{Attributes}->{colwidth}))
+            {
+                my ($width) = ($element->{Attributes}->{colwidth} =~ m/(\d+)/);
+                $self->{tabledefs}->{$self->{tablecount}}->{speccolumns}++;
+                $self->{tabledefs}->{$self->{tablecount}}->{colwidth} += $width;
+            }
+        }
+    }
+    else
+    {
+        if ($element->{Name} eq 'informaltable' or
+            $element->{Name} eq 'table')
+        {
+            $self->{intable} = 1;
+            $self->{tablecount}++;
+            $self->{tabledefs}->{$self->{tablecount}} = {};
+        }
+    }
+}
+
+sub end_element
+{
+    my ($self, $element) = @_;
+
+    if ($element->{Name} eq 'entrytbl')
+    {
+        $self->{tabledefs}->{$self->{tablecount}}->{inentrytbl} = 0;
+    }
+
+    if ($element->{Name} eq 'section')
+    {
+        if (exists($element->{Attributes}->{id}))
+        {
+            my $cursection = pop(@{$self->{sectionmap}});
+            $self->{currsection} = $self->{sectionmap}->[-1];
+        }
+    }
+
+    if ($element->{Name} eq 'remark' && 
+        $self->{intodo} == 1)
+    {
+        $self->{todotext} =~ s/^\s+//msg;
+        $self->{todotext} =~ s/\s+$//msg;
+
+        push @{$self->{issuelist}},{'parentid' => $self->{currsection},
+                                    'class' => 'todo',
+                                    'type' => 'remark',
+                                    'text' => "$self->{todotext}\n"};
+        $self->{intodo} = 0;
+        $self->{todotext} = '';
+    }
+
+    if ($element->{Name} eq 'programlisting')
+    {
+        $self->{checklinelength} = 0;
+    }
+
+    if ($element->{Name} eq 'link' ||
+        $element->{Name} eq 'xref')
+    {
+        if (((length($self->{linktext}) == 0) ||
+            ($self->{linktext} =~ m/^\s+$/)) && 
+            $element->{Name} eq 'link')
+        {
+            push(@{$self->{issuelist}},
+                 {'parentid' => $self->{currsection},
+                  'type' => 'link',
+                  'class' => 'todo',
+                  'text' => join('',"You cannot use <link> to'",
+                                 $self->{linkref} || 'NOLINK',
+                                 "' without linking text\n")});
+        }
+        if (((length($self->{linktext}) > 0) ||
+            ($self->{linktext} =~ m/^\s+$/)) && 
+            $element->{Name} eq 'xref')
+        {
+            push(@{$self->{issuelist}},
+                 {'parentid' => $self->{currsection},
+                  'type' => 'xref',
+                  'class' => 'todo',
+                  'text' => join('',"You cannot use <xref> to '",
+                                 $self->{linkref} || 'NOLINK',
+                                 "' with linking text\n")});
+        }
+        $self->{linkref} = '';
+        $self->{linktext} = '';
+        $self->{inlink} = 0;
+    }
+
+    if ($element->{Name} eq 'row')
+    {
+        if ($self->{tabledefs}->{$self->{tablecount}}->{foundcolumns} > 
+            $self->{tabledefs}->{$self->{tablecount}}->{maxcolumns})
+        {
+            $self->{tabledefs}->{$self->{tablecount}}->{maxcolumns} =             
+                $self->{tabledefs}->{$self->{tablecount}}->{foundcolumns};
+        }
+    }
+
+    if ($element->{Name} eq 'emphasis')
+    {
+        if ($self->{savedtext} =~ m/^(note|caution|warning|important)(:)?$/i)
+        {
+            my $word = lc($1);
+            push(@{$self->{issuelist}},
+                 {'parentid' => $self->{currsection},
+                  'type' => 'admonition',
+                  'class' => 'todo',
+                  'text' => join('',"Use of <emphasis>\u$word</emphasis> within section ",
+                                 $self->{currsection} || 'UNKNOWN',
+                                 " is deprecated. Use <$word><para></para></$word> instead\n")});
+        }
+        $self->{savedtext} = '';
+        $self->{inemphasis} = 0;
+    }
+
+    if ($element->{Name} eq 'informaltable' ||
+        $element->{Name} eq 'table')
+    {
+        # Check the number of columns defined, and specified, match
+
+        my $errorcounter = 0;
+
+        if (!defined($self->{tabledefs}->{$self->{tablecount}}->{speccolumns}))
+        {
+            $errorcounter++;
+            push(@{$self->{issuelist}},
+                 {'parentid' => $self->{tabledefs}->{$self->{tablecount}}->{section},
+                  'type' => 'tablefault',
+                  'class' => 'todo',
+                  'priority' => 1,
+                  'text' => join('',"Error in Table within section ",
+                                 $self->{tabledefs}->{$self->{tablecount}}->{section} || 'UNKNOWN',
+                                 ": No columns specified in table!\n")});
+        }
+        elsif (!defined($self->{tabledefs}->{$self->{tablecount}}->{defcolumns}))
+        {
+            $errorcounter++;
+            push(@{$self->{issuelist}},
+                 {'parentid' => $self->{tabledefs}->{$self->{tablecount}}->{section},
+                  'type' => 'tablefault',
+                  'class' => 'todo',
+                  'priority' => 1,
+                  'text' => join('',"Error in Table within section ",
+                                 $self->{tabledefs}->{$self->{tablecount}}->{section} || 'UNKNOWN',
+                                 ": No columns in table!\n")});
+        }
+        elsif ($self->{tabledefs}->{$self->{tablecount}}->{speccolumns} != 
+               $self->{tabledefs}->{$self->{tablecount}}->{defcolumns})
+        {
+            $errorcounter++;
+            push(@{$self->{issuelist}},
+                 {'parentid' => $self->{tabledefs}->{$self->{tablecount}}->{section},
+                  'type' => 'tablefault',
+                  'class' => 'todo',
+                  'priority' => 10,
+                  'text' => join('',"Error in Table within section $self->{tabledefs}->{$self->{tablecount}}->{section}\n",
+                                 "\tWarning!: Column definition mismatch!!\n",
+                                 "\tGroup defined columns (tgroup) $self->{tabledefs}->{$self->{tablecount}}->{defcolumns}\n",
+                                 "\tSpecified columns (colspec) $self->{tabledefs}->{$self->{tablecount}}->{speccolumns}\n")});
+        }
+        elsif (($self->{tabledefs}->{$self->{tablecount}}->{speccolumns} != 
+               $self->{tabledefs}->{$self->{tablecount}}->{maxcolumns}) ||
+               ($self->{tabledefs}->{$self->{tablecount}}->{speccolumns} != 
+               $self->{tabledefs}->{$self->{tablecount}}->{maxcolumns}))
+        {
+            $errorcounter++;
+            push(@{$self->{issuelist}},
+                 {'parentid' => $self->{tabledefs}->{$self->{tablecount}}->{section},
+                  'type' => 'tablefault',
+                  'class' => 'todo',
+                  'priority' => 10,
+                  'text' => join('',"Error in Table within section $self->{tabledefs}->{$self->{tablecount}}->{section}\n",
+                                 "\tWarning!: Column definition/column number mismatch!!\n",
+                                 "\tGroup defined columns (tgroup) $self->{tabledefs}->{$self->{tablecount}}->{defcolumns}\n",
+                                 "\tSpecified columns (colspec) $self->{tabledefs}->{$self->{tablecount}}->{speccolumns}\n",
+                                 "\tActual columns (entry) $self->{tabledefs}->{$self->{tablecount}}->{maxcolumns}\n")});
+        }
+
+        # Check the column width count and ensure that the total figures equal 100
+
+        if (!defined($self->{tabledefs}->{$self->{tablecount}}->{colwidth}))
+        {
+            $errorcounter++;
+            push(@{$self->{issuelist}},
+                 {'parentid' => $self->{tabledefs}->{$self->{tablecount}}->{section},
+                  'type' => 'tablefault',
+                  'class' => 'alert',
+                  'text' => join('',"Error in Table within section ",
+                                 $self->{tabledefs}->{$self->{tablecount}}->{section} || 'UNKNOWN',
+                                 ": No column width specified\n")});
+        }
+        elsif ($self->{tabledefs}->{$self->{tablecount}}->{colwidth} == 0)
+        {
+            $errorcounter++;
+            push(@{$self->{issuelist}},
+                 {'parentid' => $self->{tabledefs}->{$self->{tablecount}}->{section},
+                  'type' => 'tablefault',
+                  'class' => 'alert',
+                  'text' => join('',"Error in Table within section ",
+                                 $self->{tabledefs}->{$self->{tablecount}}->{section} || 'UNKNOWN',
+                                 ": Total column width is 0\n")});
+        }
+        elsif ($self->{tabledefs}->{$self->{tablecount}}->{colwidth} == 0)
+        {
+            $errorcounter++;
+            push(@{$self->{issuelist}},
+                 {'parentid' => $self->{tabledefs}->{$self->{tablecount}}->{section},
+                  'type' => 'tablefault',
+                  'class' => 'alert',
+                  'text' => join('',"Error in Table within section ",
+                                 $self->{tabledefs}->{$self->{tablecount}}->{section} || 'UNKNOWN',
+                                 ": Total column width is less than 100%\n")});
+        }
+        elsif ($self->{tabledefs}->{$self->{tablecount}}->{colwidth} > 100)
+        {
+            $errorcounter++;
+            push(@{$self->{issuelist}},
+                 {'parentid' => $self->{tabledefs}->{$self->{tablecount}}->{section},
+                  'type' => 'tablefault',
+                  'class' => 'alert',
+                  'text' => join('',"Error in Table within section ",
+                                 $self->{tabledefs}->{$self->{tablecount}}->{section} || 'UNKNOWN',
+                                 ": Total column width is more than 100%\n")});
+        }
+
+        if ($errorcounter == 0)
+        {
+            push @{$self->{issueclearlist}},
+                 {'parentid' => $self->{tabledefs}->{$self->{tablecount}}->{section},
+                  'type' => 'tablefault',
+                  'class' => 'alert',
+              };
+        }            
+
+        $self->{intable} = 0;
+    }
+}    
+
+sub characters
+{
+    my ($self, $element) = @_;
+
+    if ($self->{intodo} == 1)
+    {
+        $self->{todotext} .= $element->{Data};
+    }
+
+    if ($self->{inemphasis} == 1)
+    {
+        $self->{savedtext} .= $element->{Data};
+    }
+
+    if ($self->{inlink} == 1)
+    {
+        $self->{linktext} .= $element->{Data};
+    }
+
+    if ($self->{options}->{checkwidth} && 
+        $self->{checklinelength})
+    {
+        my @lines = split /[\r\n]+/,$element->{Data};
+        foreach my $line (@lines)
+        {
+            $self->printf_error("Following line is more than $self->{options}->{linelength} characters long\n%s\n\n",$line) 
+                if (length($line) > $self->{options}->{linelength});
+        }
+    }
+
+    $self->{text} .= $element->{Data} if ($self->{intag} == 1);
+}
+
+1;


Added: trunk/tools/MySQL/XML/SpellCheck.pm
===================================================================
--- trunk/tools/MySQL/XML/SpellCheck.pm	                        (rev 0)
+++ trunk/tools/MySQL/XML/SpellCheck.pm	2007-10-06 03:29:42 UTC (rev 7976)
Changed blocks: 1, Lines Added: 83, Lines Deleted: 0; 1846 bytes

@@ -0,0 +1,83 @@
+package MySQL::XML::SpellCheck;
+
+# Load the standard MySQL Libraries
+
+use MySQL;
+
+# Ensure we have enabled error checking
+
+use strict;
+use warnings;
+
+# Load local specific modules
+
+use File::Basename;
+
+sub new
+{
+    my $self = shift;
+    my $class = ref($self) || $self;
+    my $options = shift;
+
+
+    return bless {'wordlist' => {},
+                  'parsewords' => 0,
+                  'wordbuffer' => '',
+              }, $class;
+}
+
+sub start_element
+{
+    my ($self, $element) = @_;
+
+    if ($element->{Name} =~ m/^(literal|programlisting|option|userinput|replaceable|remark)$/)
+    {
+        push @{$self->{state}},$self->{parsewords};
+        $self->{parsewords} = 0;
+    }
+    else
+    {
+        $self->{parsewords} = 1;
+    }
+}
+
+sub end_element
+{
+    my ($self, $element) = @_;
+
+    if ($element->{Name} =~ m/^(literal|programlisting|option|userinput|replaceable|remark)$/)
+    {
+        $self->{parsewords} = pop @{$self->{state}};
+    }
+
+    if (length($self->{wordbuffer}) > 0)
+    {
+        my @words = split /[\s(),\.;\?:"\/]+/,$self->{wordbuffer};
+        foreach my $word (@words)
+        {
+            next unless ($word =~ m/[a-z]/i);
+            if (exists($self->{wordlist}->{$word}))
+            {
+                $self->{wordlist}->{$word}++;
+            }
+            else
+            {
+                $self->{wordlist}->{$word} = 1;
+            }
+        }
+$self->{wordbuffer} = '';
+    }
+    
+}    
+
+sub characters
+{
+    my ($self, $element) = @_;
+
+    if ($self->{parsewords} != 0)
+    {
+        $self->{wordbuffer} .= $element->{Data};
+    }
+}
+
+1;


Added: trunk/tools/MySQL/XML/WordCount.pm
===================================================================
--- trunk/tools/MySQL/XML/Writer.pm	                        (rev 0)
+++ trunk/tools/MySQL/XML/Writer.pm	2007-10-06 03:29:42 UTC (rev 7976)
Changed blocks: 2, Lines Added: 182, Lines Deleted: 1; 4136 bytes

@@ -0,0 +1,115 @@
+package MySQL::XML::WordCount;
+
+# Load the standard MySQL Libraries
+
+use MySQL;
+
+# Ensure we have enabled error checking
+
+use strict;
+use warnings;
+
+sub new
+{
+    my $self = shift;
+    my $class = ref($self) || $self;
+    my $map = shift;
+
+    return bless {
+                  'tagmap' => $map,
+                  'tagcount' => {},
+                  'tagwordcount' => {},
+                  'currtag' => '',
+                  'captext' => 1,
+                  'currtext' => '',
+                  'totalwc' => 0,
+                  'ignorewc' => 0,
+                  'idmap' => [],
+                  'idwc' => {},
+                  'idcurr' => '',
+                  'currtextmap' => [],
+              }, $class;
+}
+
+sub start_element
+{
+    my ($self, $element) = @_;
+
+    if (exists($element->{Attributes}->{id}) &&
+        ($element->{Name} =~ m/^(section|chapter)$/i))
+    {
+        if (scalar @{$self->{idmap}} == 0)
+        {
+            push @{$self->{idmap}},$element->{Attributes}->{id};
+        $self->{idcurr} = $element->{Attributes}->{id};
+        }
+        else
+        {
+            push @{$self->{idmap}},$self->{idcurr};
+        }
+    }
+
+
+    $self->{currtext} .= ' ';
+    push @{$self->{currtextmap}},$self->{currtext};
+    $self->{currtext} = '';
+    $self->{tagcount}->{$element->{Name}}++;
+    $self->{currtag} = $element->{Name};
+}
+
+sub end_element
+{
+    my ($self, $element) = @_;
+    
+    my $wc = count_words($self->{currtext});
+    $self->{tagwordcount}->{$element->{Name}} += $wc;
+    if (exists($self->{tagmap}->{$element->{Name}}))
+    {
+        $self->{ignorewc} += $wc;
+    }
+    else
+    {
+        $self->{totalwc} += $wc;
+        $self->{idwc}->{$self->{idcurr}} += $wc;
+    }
+    $self->{currtext} = pop @{$self->{currtextmap}};
+
+    if ($element->{Name} =~ m/^(section|chapter)$/i)
+    {
+        my $old = $self->{idcurr};
+        $self->{idcurr} = pop @{$self->{idmap}} || $self->{idcurr};
+        if ($old ne $self->{idcurr})
+        {
+            $self->{idwc}->{$self->{idcurr}} += $self->{idwc}->{$old};
+        }
+    }
+
+}    
+
+sub characters
+{
+    my ($self, $element) = @_;
+    $element->{Data} =~ s/[\r\n]+/ /g;
+    while ($element->{Data} =~ s/[ ][ ]+/ /g) {}
+    $self->{currtext} .= $element->{Data} if ($self->{captext});
+}
+
+sub count_words
+{
+    my ($text) = @_;
+
+    my $words = 0;
+
+    for my $word (split(/[^\w]+/, $text))
+{
+    $words++ unless ($word =~ m/^\s+?$/);
+}
+return $words;
+}
+
+sub entity_reference
+{
+    my ($self, $element) = @_;
+}
+
+1;

Copied: trunk/tools/MySQL/XML/Writer.pm (from rev 7975, trunk/tools/MySQLXMLWriter.pm)
===================================================================
--- trunk/tools/MySQL/XML/Writer.pm	                        (rev 0)
+++ trunk/tools/MySQL/XML/Writer.pm	2007-10-06 03:29:42 UTC (rev 7976)

@@ -0,0 +1,66 @@
+package MySQL::XML::Writer;
+
+# Load the standard MySQL Libraries
+
+use MySQL;
+
+# Ensure we have enabled error checking
+
+use strict;
+use warnings;
+
+# Export the XML functions directly
+
+use vars qw(@ISA @EXPORT);
+require Exporter;
+@ISA = qw(Exporter);
+
+@EXPORT = qw(xml_row 
+             xml_entry
+             xml_bold
+             xml_literal
+             xml_entrytbl
+             xml_escape
+             );
+
+sub xml_row
+{
+    return sprintf('<row>%s</row>',join('',@_)) . "\n";
+}
+
+sub xml_entry
+{
+    if ((scalar @_ == 0) || 
+        (!defined($_[0])))
+    {
+        return '<entry/>';
+    }
+    return sprintf('<entry>%s</entry>',join('',@_));
+}
+
+sub xml_entrytbl
+{
+    return sprintf('<entrytbl cols="2"><tbody>%s</tbody></entrytbl>',join('',@_));
+}
+
+sub xml_bold
+{
+    return sprintf('<emphasis role="bold">%s</emphasis>',join('',@_));
+}
+
+sub xml_literal
+{
+    return sprintf('<literal>%s</literal>',join('',@_));
+}
+
+sub xml_escape
+{
+    my ($string) = @_;
+
+    $string =~ s/&/&amp;/g;
+    $string =~ s/</&lt;/g;
+    $string =~ s/>/&gt;/g;
+    return($string);
+}
+
+1;


Modified: trunk/tools/check-renamed-nodes.pl
===================================================================
--- trunk/tools/check-renamed-nodes.pl	2007-10-05 19:15:49 UTC (rev 7975)
+++ trunk/tools/check-renamed-nodes.pl	2007-10-06 03:29:42 UTC (rev 7976)
Changed blocks: 1, Lines Added: 12, Lines Deleted: 32; 1932 bytes

@@ -1,49 +1,29 @@
 #! /usr/bin/perl -w
 # vim:set ts=2 sw=2 expandtab:
 
-# check-renamed-nodes.pl - checks the current renamed-nodes file and
-# ensures the target ID exists somewhere
+# check-renamed-nodes.pl
+#
+# Checks the current renamed-nodes file and ensures the target ID exists somewhere
 
 # Martin MC Brown
 # mc@stripped
 # 2007-08-29
 
 use strict;
+use warnings;
+
+# Load the MySQL specific modules
+
 use lib qw(./tools/ ../tools ../../tools ../../../trunk/tools);
-use IDMap;
+use MySQL::IDMap;
+
+# Load the local modules
+
 use Getopt::Long;
 use Data::Dumper;
 
-my ($srcpathopt,$debug,$showreverse,$showlevel,$showtype,$optformat) = ('',0,0,0,'','');
-my @srcpaths = ('.',
-                '../refman-5.1',
-                '../refman-5.0',
-                '../refman-4.1',
-                '../refman-common',
-                '../gui-common',
-                '../internals',
-                '../query-browser',
-                '../administrator',
-                '../migration-toolkit',
-                '../workbench',
-                '../falcon',
-                '../ndbapi',
-                './refman-5.1',
-                './refman-5.0',
-                './refman-4.1',
-                './refman-common',
-                './gui-common',
-                './internals',
-                './query-browser',
-                './administrator',
-                './migration-toolkit',
-                './workbench',
-                './falcon',
-                './ndbapi',
-                );
+my $idmap = MySQL::IDMap->new();
 
-my $idmap = IDMap->new({sources => \@srcpaths});
-
 open(NODES,"renamed-nodes.txt") or die "Couldn't find a renamed-nodes file I liked\n";
 
 while(my $line = <NODES>)


Modified: trunk/tools/convert-newsfile-tochangelog.pl
===================================================================
--- trunk/tools/convert-newsfile-tochangelog.pl	2007-10-05 19:15:49 UTC (rev 7975)
+++ trunk/tools/convert-newsfile-tochangelog.pl	2007-10-06 03:29:42 UTC (rev 7976)
Changed blocks: 3, Lines Added: 18, Lines Deleted: 12; 1304 bytes

@@ -1,16 +1,6 @@
 #!/usr/bin/perl -w
 
-use lib './tools','../tools','../../tools';
-use XML::DOM;
-use Data::Dumper;
-use Digest::MD5 qw/md5_hex/;
-use Encode qw(encode_utf8);
-use IO::File;
-use Getopt::Long;
-use MySQLDynXML;
-use strict;
-
-# parsenewsfile.pl
+# convert-newsfile-tochangelog.pl
 # 
 # Parses an existing DocBook formatted news file and extract and translate
 # changelog entries into the new changelog entry format

@@ -19,6 +9,22 @@
 # mc@stripped
 # 2007-08-15
 
+use strict;
+use warnings;
+
+# Load the MySQL specific modules
+
+use lib qw(./tools/ ../tools ../../tools ../../../trunk/tools);
+use MySQL::DynXML;
+
+# Load the local modules
+
+use Data::Dumper;
+use Digest::MD5 qw/md5_hex/;
+use Encode qw(encode_utf8);
+use IO::File;
+use Getopt::Long;
+
 my ($opt_debug,$opt_product,$opt_outfile,$opt_outver) = (0,undef,undef,undef);
 
 GetOptions("debug" => \$opt_debug,

@@ -37,7 +43,7 @@
 exit(1);
 }
 
-my $dynxml = MySQLDynXML->new();
+my $dynxml = MySQL::DynXML->new();
 my $logentries = {};
 my $bybugid = {};
 my $versionentries = {};


Modified: trunk/tools/deep-check.pl
===================================================================
--- trunk/tools/deep-check.pl	2007-10-05 19:15:49 UTC (rev 7975)
+++ trunk/tools/deep-check.pl	2007-10-06 03:29:42 UTC (rev 7976)
Changed blocks: 3, Lines Added: 18, Lines Deleted: 26; 2353 bytes

@@ -1,33 +1,28 @@
 #! /usr/bin/perl -w
 # vim:set ts=2 sw=2 expandtab:
 
-# deep-check.pl - perform a deep check of the DocBook source
-#
-# Currently addresses:
-# - Checks table column definition/actual columns
-# - Checks width of columns equal 100%
-# - Checks images (defined and local filesystem)
-#   Only reports filesystem images with --checkimages
-# - Checks section IDs (duplicates)
-# - Checks line length of <programlisting> elements 
-#   Now enabled with --checkwidth
-#   Set max line length with --linelength (default: 72)
-# - Checks for empty <link> references
-# - Checks for <Table> and <informaltable> definitions
-# - Checks external (ulinks) if you ask with checkulink
+# deep-check.pl
+# 
+# Perform a deep check of the DocBook source
+# 
+# This is an interface to the MySQL::XML::DeepCheck module
 
 # Martin MC Brown
 # mc@stripped
 # 2006-06-29
 
 use strict;
-use lib './tools', '../tools', '../../tools';
-use Getopt::Long;
-use MySQLDeepCheck;
-use MySQLDynXML;
+use warnings;
 
-my $dynxml = new MySQLDynXML;
+# Load the MySQL specific modules
 
+use lib qw(./tools/ ../tools ../../tools ../../../trunk/tools);
+use MySQL::XML::DeepCheck;
+
+# Load the local modules
+
+use Getopt::Long;
+
 my ($checkwidth,
     $linelength,
     $checkimages,

@@ -61,9 +56,6 @@
     exit 0;
 }
 
-eval "require XML::Parser::PerlSAX;";
-$dynxml->show_requirements() if ($@);
-
 if ($checkulink)
 {
     print STDERR "\nWarning: Checking for external links may take some time. Please be patient\n";

@@ -94,10 +86,10 @@
     $known_imgs->{$img} = 1;
 }
 
-my $my_handler = MySQLDeepCheck->new({checkwidth => $checkwidth,
-                                      linelength => $linelength,
-                                      checkulink => $checkulink,
-                                  });
+my $my_handler = MySQL::XML::DeepCheck->new({checkwidth => $checkwidth,
+                                           linelength => $linelength,
+                                           checkulink => $checkulink,
+                                       });
 
 XML::Parser::PerlSAX->new->parse(Source => { SystemId => $file}, 
                                  Handler => $my_handler);


Modified: trunk/tools/divide-docbook-file.pl
===================================================================
--- trunk/tools/divide-docbook-file.pl	2007-10-05 19:15:49 UTC (rev 7975)
+++ trunk/tools/divide-docbook-file.pl	2007-10-06 03:29:42 UTC (rev 7976)
Changed blocks: 1, Lines Added: 5, Lines Deleted: 1; 462 bytes

@@ -8,11 +8,15 @@
 # mc@stripped
 # 2007-08-31
 
+use strict;
+use warnings;
+
+# Load the local modules
+
 use XML::DOM;
 use Data::Dumper;
 use IO::File;
 use Getopt::Long;
-use strict;
 
 my ($opt_idlist) = (undef);
 


Modified: trunk/tools/dynxml-parser.pl
===================================================================
--- trunk/tools/dynxml-parser.pl	2007-10-05 19:15:49 UTC (rev 7975)
+++ trunk/tools/dynxml-parser.pl	2007-10-06 03:29:42 UTC (rev 7976)
Changed blocks: 3, Lines Added: 21, Lines Deleted: 24; 2271 bytes

@@ -9,21 +9,27 @@
 # 2007-08-25
 
 use strict;
-use lib './tools', '../tools', '../../tools';
-use Getopt::Long;
-use IO::File;
-use IDMap;
-use MySQLDynXML;
+use warnings;
 
+# Load the MySQL specific modules
+
+use lib qw(./tools/ ../tools ../../tools ../../../trunk/tools);
+use MySQL::DynXML;
+
 # Dynamic doc types to parse
 
-use MySQLDynXML::Optvar;
-use MySQLDynXML::Opfuncs;
-use MySQLDynXML::ReservedWords;
-use MySQLDynXML::Changelog;
+use MySQL::DynXML::Optvar;
+use MySQL::DynXML::Opfuncs;
+use MySQL::DynXML::ReservedWords;
+use MySQL::DynXML::Changelog;
 
-my $dynxml = new MySQLDynXML();
+# Load the local modules
 
+use Getopt::Long;
+use IO::File;
+
+my $dynxml = new MySQL::DynXML();
+
 my ($opt_infile,$opt_outfile,$opt_srcdir) = (undef,undef,undef);
 
 GetOptions("infile=s" => \$opt_infile,

@@ -37,24 +43,15 @@
     show_help("You must specify the infile, outfile and srcdir");
 }
 
-# Module testing
-
-eval "require XML::Parser::PerlSAX;";
-$dynxml->show_requirements() if ($@);
-eval "require IO::File;";
-$dynxml->show_requirements() if ($@);
-eval "require IO::String;";
-$dynxml->show_requirements() if ($@);
-
 my $options = {infile => $opt_infile,
                outfile => $opt_outfile,
                srcdir => $opt_srcdir,
            };
 
-my $OptVars = new MySQLDynXML::Optvar($dynxml,$options);
-my $OpFuncs = new MySQLDynXML::Opfuncs($dynxml,$options);
-my $ReservedWords = new MySQLDynXML::ReservedWords($dynxml,$options);
-my $ChangeLog = new MySQLDynXML::Changelog($dynxml,$options);
+my $OptVars = new MySQL::DynXML::Optvar($dynxml,$options);
+my $OpFuncs = new MySQL::DynXML::Opfuncs($dynxml,$options);
+my $ReservedWords = new MySQL::DynXML::ReservedWords($dynxml,$options);
+my $ChangeLog = new MySQL::DynXML::Changelog($dynxml,$options);
 
 inplace_parse($options);
 

@@ -125,7 +122,7 @@
         }
         else
         {
-            print STDERR "Warning: Dynamic datatype $inserttype not recognized\n";
+            print STDERR "$0: WARNING: Dynamic datatype $inserttype not recognized\n";
         }
         
         $inplacefile =~ s/$item/$string/g;


Modified: trunk/tools/fixup-multibyte.pl
===================================================================
--- trunk/tools/fixup-multibyte.pl	2007-10-05 19:15:49 UTC (rev 7975)
+++ trunk/tools/fixup-multibyte.pl	2007-10-06 03:29:42 UTC (rev 7976)
Changed blocks: 3, Lines Added: 6, Lines Deleted: 3; 710 bytes

@@ -1,8 +1,9 @@
 #! /usr/bin/perl -w
 # vim:set ts=2 sw=2 expandtab:
 
-# fixup-multibyte.pl - post-process FO to incorporate special font
-# for unknown characters
+# fixup-multibyte.pl 
+# 
+# Ppost-process FO to incorporate special font for unknown characters
 
 # Martin MC Brown
 # mc@stripped

@@ -10,7 +11,7 @@
 
 use strict;
 
-open(DATA,$ARGV[0]);
+open(DATA,$ARGV[0]) or die "Cannot open $ARGV[0] ($!)\n";
 
 while(<DATA>)
 {

@@ -46,3 +47,5 @@
     }
     print;
 }
+
+close(DATA);


Modified: trunk/tools/idfind.pl
===================================================================
--- trunk/tools/idfind.pl	2007-10-05 19:15:49 UTC (rev 7975)
+++ trunk/tools/idfind.pl	2007-10-06 03:29:42 UTC (rev 7976)
Changed blocks: 6, Lines Added: 37, Lines Deleted: 83; 6731 bytes

@@ -1,46 +1,30 @@
 #! /usr/bin/perl -w
 # vim:set ts=2 sw=2 expandtab:
 
-# idfind.pl - finds an ID from the current ID maps and displays
-#             the corresponding file
+# idfind.pl
+#
+# Find and ID within all the ID maps and display information about the
+# ID that was found
 
 # Martin MC Brown
 # mc@stripped
 # 2006-09-06
 
 use strict;
+use warnings;
+
+# Load the MySQL specific modules
+
 use lib qw(./tools/ ../tools ../../tools ../../../trunk/tools);
-use IDMap;
+use MySQL::IDMap;
+
+# Load the local modules
+
 use Getopt::Long;
 use Data::Dumper;
 
 my ($srcpathopt,$debug,$showreverse,$showlevel,$showtype,$optformat) = ('',0,0,0,'','');
-my @srcpaths = ('.',
-                '../refman-5.1',
-                '../refman-5.0',
-                '../refman-4.1',
-                '../refman-common',
-                '../gui-common',
-                '../internals',
-                '../query-browser',
-                '../administrator',
-                '../migration-toolkit',
-                '../workbench',
-                '../falcon',
-                '../ndbapi',
-                './refman-5.1',
-                './refman-5.0',
-                './refman-4.1',
-                './refman-common',
-                './gui-common',
-                './internals',
-                './query-browser',
-                './administrator',
-                './migration-toolkit',
-                './workbench',
-                './falcon',
-                './ndbapi',
-                );
+my @srcpaths = ();
 
 GetOptions("srcpaths=s" => \$srcpathopt,
            "debug" => \$debug,

@@ -49,31 +33,6 @@
            "level=s" => \$showlevel,
            "format=s" => \$optformat);
 
-if (defined($srcpathopt) && $srcpathopt ne '')
-{
-    my @newsrcpaths = split(/ /,$srcpathopt);
-    my (@hasadd,@hasnew) = ((),());
-    
-    foreach my $path (@newsrcpaths)
-    {
-        if ($path =~ m/^\+/)
-        {
-            my $realpath = $path;
-            $realpath =~ s/^\+//;
-            push @hasadd,$realpath;
-        }
-        else
-        {
-            push @hasnew,$path;
-        }
-    }
-    if (scalar(@hasnew) > 0)
-    {
-        @srcpaths = @hasnew;
-    }
-    push @srcpaths,@hasadd;
-}
-
 if ((scalar @ARGV == 0) && ($showlevel == 0) && ($showtype eq ''))
 {
         print <<EOF;

@@ -97,17 +56,17 @@
 exit;
 }
 
-my $idmap = IDMap->new({sources => \@srcpaths});
+my $idmap = MySQLIDMap->new({sources => $srcpathopt});
 
 my ($id);
 
 if ($showlevel > 0)
 {
-    foreach $id (keys %{$idmap})
+    foreach $id (keys %{$idmap->{byid}})
     {
-        if ($idmap->{$id}->{depth} <= $showlevel) 
+        if ($idmap->{byid}->{$id}->{depth} <= $showlevel) 
         {
-            print "$id => $idmap->{$id}->{title}\n";
+            print "$id => $idmap->{byid}->{$id}->{title}\n";
         }
     }
 }

@@ -115,27 +74,27 @@
 {
     my @types = split /,/,$showtype;
 
-    foreach $id (keys %{$idmap})
+    foreach $id (keys %{$idmap->{byid}})
     {
         next if ($id =~ m/__.*?__/);
         foreach my $type (@types)
         {
-            if (defined($idmap->{$id}->{type}) &&
-                ($idmap->{$id}->{type} eq $type))
+            if (defined($idmap->{byid}->{$id}->{type}) &&
+                ($idmap->{byid}->{$id}->{type} eq $type))
             {
                 if ($optformat eq 'xml')
                 {
                     printf('<sowitem docbase="%s" file="%s" id="%s"><title>%s</title></sowitem>',
-                           $idmap->{$id}->{docbase},
-                           $idmap->{$id}->{file},
+                           $idmap->{byid}->{$id}->{docbase},
+                           $idmap->{byid}->{$id}->{file},
                            $id,
-                           $idmap->{$id}->{title},
+                           $idmap->{byid}->{$id}->{title},
                            );
                     print "\n";
                 }
                 else
                 {
-                    print "$id ($idmap->{$id}->{title}) in $idmap->{$id}->{docbase}, $idmap->{$id}->{file}\n";
+                    print "$id ($idmap->{byid}->{$id}->{title}) in $idmap->{byid}->{$id}->{docbase}, $idmap->{byid}->{$id}->{file}\n";
                 }
            }
         }

@@ -145,7 +104,9 @@
 {
     foreach $id (@ARGV)
     {
-        my @matches = grep /$id/,keys %{$idmap};
+        print "Looking for $id\n";
+
+        my @matches = grep /$id/,keys %{$idmap->{byid}};
         
         if (scalar @matches == 0)
         {

@@ -156,31 +117,24 @@
         {
             next if ($match =~ m/__.*?__/);
             
-            if (exists($idmap->{$match}->{file}))
+            if (exists($idmap->{byid}->{$match}->{alts}))
             {
-                if (exists($idmap->{$match}->{alts}))
-                {
-                    print "$match is located within $idmap->{$match}->{prefix}/$idmap->{$match}->{file}\n";
-                    print Dumper($idmap->{$match}),"\n" if ($debug);
-                    print "  -> also located within ",join(', ',@{$idmap->{$match}->{adds}}),"\n";
-                }
-                else
-                {
-                    print "$match is located within $idmap->{$match}->{prefix}/$idmap->{$match}->{file}\n";
-                    print Dumper($idmap->{$match}),"\n" if ($debug);
-                }
+                print "$match is located within $idmap->{byid}->{$match}->{prefix}/$idmap->{byid}->{$match}->{file}\n";
+                print Dumper($idmap->{byid}->{$match}),"\n" if ($debug);
+                print "  -> also located within ",join(', ',@{$idmap->{byid}->{$match}->{adds}}),"\n";
             }
             else
             {
-                print "Can't find $id in current maps (from @srcpaths)\n"; 
+                print "$match is located within $idmap->{byid}->{$match}->{prefix}/$idmap->{byid}->{$match}->{file}\n";
+                print Dumper($idmap->{byid}->{$match}),"\n" if ($debug);
             }
             if ($showreverse && 
-                exists($idmap->{$match}->{reverse}))
+                exists($idmap->{reversebyid}->{$match}))
             {
-                foreach my $ver (keys %{$idmap->{$match}->{reverse}})
+                foreach my $prefix (keys %{$idmap->{reversebyid}->{$match}})
                 {
-                    print("  -> and is referenced within these sections ($ver) ",
-                          join(', ',keys %{$idmap->{$match}->{reverse}->{$ver}}),"\n");
+                    print("  -> and is referenced within these sections ($prefix) ",
+                          join(', ',keys %{$idmap->{reversebyid}->{$match}->{$prefix}}),"\n");
                 }
             }
         }


Modified: trunk/tools/idmap.pl
===================================================================
--- trunk/tools/idmap.pl	2007-10-05 19:15:49 UTC (rev 7975)
+++ trunk/tools/idmap.pl	2007-10-06 03:29:42 UTC (rev 7976)
Changed blocks: 6, Lines Added: 190, Lines Deleted: 199; 13872 bytes

@@ -1,65 +1,48 @@
 #! /usr/bin/perl -w
 # vim:set ts=2 sw=2 expandtab:
 
-# idmap.pl - build a map of section, para and other IDs to map references
+# idmap.pl 
+#
+# Parse one or more  DocBook XML documents and build an IDMap of
+# the sections, figures, indexterms and other elements within the file
+# for use when validating, remapping and extending the documentation
 
 # Martin MC Brown
 # mc@stripped
 # 2006-08-03
 
 use strict;
+use warnings;
+
+# Load the MySQL specific modules
+
+use lib qw(./tools/ ../tools ../../tools ../../../trunk/tools);
+use MySQL::IDMap;
+use MySQL::IDMap::XMLParser;
+use MySQL::IDMap::DTDParser;
+
+# Load the local modules
+
 use File::Basename;
 use File::Path;
 use Getopt::Long;
 use IO::File;
+use Data::Dumper;
 
-my $idmapversion = 2;
+# The version of the ID MApping system that this script expects or implements
 
+my $idmapversion = 3;
+
 my $opt_reconcile = 0;
-my $opt_debug = 1;
+my $opt_debug = 0;
 
 GetOptions("reconcile" => \$opt_reconcile,
            "debug" => \$opt_debug);
 
-eval "require XML::Parser::PerlSAX;";
-
-if ($@) 
-{
-    die <<EOF;
-ERROR: Cannot load the PerlSAX parser.
-
-You need to install the expat library and the XML::Parser::PerlSAX module for perl. 
-Either do it by hand:
- - libexpat is available from http://expat.sourceforge.net
- - PerlSAX is available from http://search.cpan.org/~kmacleod/libxml-perl-0.08/lib/XML/Parser/PerlSAX.pm
-
-Using CPAN: 
- - Install libexpat
- - Run: 
-
-\$ perl -MCPAN -e 'install XML::Parser::PerlSAX'
-
-Using apt-get:
-
-\$ apt-get install libexpat-dev
-\$ perl -MCPAN -e 'install XML::Parser::PerlSAX'
-
-Using YaST: 
-
-\$ yast -i expat
-\$ perl -MCPAN -e 'install XML::Parser::PerlSAX'
-
-Using emerge (Gentoo):
-
-\$ emerge -uD libxml-perl
-
-Please install and try again.
-
-EOF
-}
-
 my $urlbase = shift;
 
+print STDERR "$0: DEBUG: URL Base is $urlbase\n" if ($opt_debug);
+
 my ($docbase,$docversion,$doclang) = ('','','');
 my @elems = split(m{/},$urlbase);
 if (scalar @elems == 3)

@@ -92,7 +75,7 @@
 {
     foreach my $file (keys %{$filemap})
     {
-        print STDERR "idmap.pl: Parsing $file\n" if ($opt_debug);
+        print STDERR "$0: DEBUG: Parsing $file\n" if ($opt_debug);
         gen_idmap($file,$filemap);
     }
 }

@@ -105,6 +88,7 @@
     my ($mapfile) = sprintf('%s/%s/%s%s',$path,'metadata',$name,'idmap');
     my ($maptempfile) = sprintf('%s-tmp',$mapfile);
     my ($mapdir) = sprintf('%s/%s',$path,'metadata');
+    my $idmap = new MySQL::IDMap({skiploading => 1,});
 
     # no update if $mapfile is not out of date (exists and was
     # modified more recently than $file)

@@ -116,11 +100,16 @@
 
     mkpath($mapdir);
 
-    my $my_handler = MySQLDocBook->new();
-    my $my_dtdhandler = MyDTDHandler->new();
+    my $my_handler = MySQL::IDMap::XMLParser->new();
+    my $my_dtdhandler = MySQL::IDMap::DTDParser->new();
 
     XML::Parser::PerlSAX->new->parse(Source => { SystemId => $file}, 
-                                     Handler => $my_handler);
+                                     Handler => $my_handler,
+                                     DTDHandler => $my_dtdhandler);
+    
+    # Write out the ID map
+    # for v3 we output everything in one file with a line prefix for each
+    # information
 
     lockfile ($maptempfile);
     my $dest = IO::File->new($maptempfile,'w');

@@ -130,28 +119,177 @@
     binmode($dest,':utf8');
 
     print $dest "!!!mapversion:$idmapversion!!!\n";
-    printf $dest "!!!INFO!!!%s\n",join(':',$file,$docbase,$docversion,$doclang,$urlbase);
+    printf $dest "!!!INFO!!!%s\n",join(':',
+                                       $file,
+                                       $docbase,
+                                       $docversion,
+                                       $doclang,
+                                       $urlbase,
+                                       $my_handler->{roottype} || '',
+                                       $my_handler->{rootid} || '');
 
     foreach my $id (sort { $a cmp $b } keys %{$my_handler->{ids}})
     {
         if (!defined($id) || $id eq '')
         {
-            printf STDERR ("WARNING: Can't make a valid ID$dest on %s when the ID for '%s' is not specified\n",
+            printf STDERR ("WARNING: Can't make a valid ID $dest on %s when the ID for '%s' is not specified\n",
                            $file, 
                            $my_handler->{ids}->{$id}->{title});
         }
         else
         {
             print $dest (join(':',
-                            $id,
-                            $my_handler->{ids}->{$id}->{type} || '',
-                            $my_handler->{ids}->{$id}->{sectionparent} || '',
-                            $my_handler->{ids}->{$id}->{title} || $id),
-                       "\n");
+                              $idmap->{_types}->{reverse}->{idmap},
+                              $id,
+                              $my_handler->{ids}->{$id}->{type} || '',
+                              $my_handler->{ids}->{$id}->{sectionparent} || $my_handler->{rootid} || '',
+                              $my_handler->{ids}->{$id}->{title} || $id),
+                         "\n");
         }
     }
-    close($dest);
 
+    if (scalar @{$my_handler->{revlink}})
+    {
+        foreach my $revlink (@{$my_handler->{revlink}})
+        {
+            print $dest (join(':',
+                              $idmap->{_types}->{reverse}->{ridmap},
+                              $revlink->{parent} || $my_handler->{rootid} || '',
+                              $revlink->{linkend}),
+                         "\n");
+        }
+    }
+
+    if (scalar @{$my_handler->{images}})
+    {
+        # Write out the image map
+
+        foreach my $images (@{$my_handler->{images}})
+        {
+            print $dest (join(':',
+                              $idmap->{_types}->{reverse}->{image},
+                              $images->{parent} || $my_handler->{rootid} || '',
+                              $images->{fileref}),
+                         "\n");
+        }
+    }
+
+    if (scalar @{$my_handler->{xmlimports}})
+    {
+        # Write out the xmlimports
+
+        foreach my $xmlimport (@{$my_handler->{xmlimports}})
+        {
+            print $dest (join(':',
+                              $idmap->{_types}->{reverse}->{xmlimport},
+                              $xmlimport->{parent} || $my_handler->{rootid} || '',
+                              $xmlimport->{href}),
+                         "\n");
+        }
+    }
+
+    if (scalar @{$my_handler->{dynimports}})
+    {
+        # Write out the dynimports
+
+        foreach my $dynimport (@{$my_handler->{dynimports}})
+        {
+            print $dest (join(':',
+                              $idmap->{_types}->{reverse}->{dynimport},
+                              $dynimport->{parent} || $my_handler->{rootid} || '',
+                              $dynimport->{href}),
+                         "\n");
+        }
+    }
+
+    if (scalar keys %{$my_dtdhandler->{entityfiles}})
+    {
+        # Write out the entity imports
+
+        foreach my $entityimport (keys %{$my_dtdhandler->{entityfiles}})
+        {
+            print $dest (join(':',
+                              $idmap->{_types}->{reverse}->{entityfile},
+                              $entityimport),
+                         "\n");
+        }
+    }
+
+    if (scalar @{$my_handler->{indexterms}})
+    {
+        # Write out the entity imports
+
+        foreach my $indexterm (@{$my_handler->{indexterms}})
+        {
+            print $dest (join(':',
+                              $idmap->{_types}->{reverse}->{indexterm},
+                              $indexterm->{parent} || '',
+                              $indexterm->{primary} || '',
+                              $indexterm->{secondary} || '',
+                              $indexterm->{tertiary} || '',
+                              $indexterm->{see} || '',
+                              $indexterm->{seealso} || '',
+                         ),
+                         "\n");
+        }
+    }
+
+    if (scalar keys %{$my_handler->{commands}})
+    {
+        # Write out the entity imports
+
+        foreach my $command (keys %{$my_handler->{commands}})
+        {
+            foreach my $parent (keys %{$my_handler->{commands}->{$command}})
+            {
+                print $dest (join(':',
+                                  $idmap->{_types}->{reverse}->{command},
+                                  $command || '',
+                                  $parent || '',
+                             ),
+                             "\n");
+            }
+        }
+    }
+
+    if (scalar keys %{$my_handler->{options}})
+    {
+        # Write out the entity imports
+
+        foreach my $option (keys %{$my_handler->{options}})
+        {
+            foreach my $parent (keys %{$my_handler->{options}->{$option}})
+            {
+                print $dest (join(':',
+                                  $idmap->{_types}->{reverse}->{option},
+                                  $option || '',
+                                  $parent || '',
+                             ),
+                             "\n");
+            }
+        }
+    }
+
+    if (scalar keys %{$my_handler->{functions}})
+    {
+        # Write out the entity imports
+
+        foreach my $function (keys %{$my_handler->{functions}})
+        {
+            foreach my $parent (keys %{$my_handler->{functions}->{$function}})
+            {
+                print $dest (join(':',
+                                  $idmap->{_types}->{reverse}->{function},
+                                  $function || '',
+                                  $parent || '',
+                             ),
+                             "\n");
+            }
+        }
+    }
+
+    close($dest);
+    
     unlink($mapfile);
     rename($maptempfile,$mapfile);
     unlockfile ($maptempfile);

@@ -235,150 +373,3 @@
   flock (LOCK, LOCK_UN);
 }
 
-# This is not used, but retained here for reference
-
-package MyDTDHandler;
-use Data::Dumper;
-
-sub new
-{
-    my $self = shift;
-    my $class = ref($self) || $self;
-
-    return bless {entities => {},}, $class;
-}
-
-sub entity_decl
-{
-    my ($self,$element) = @_;
-
-    if (defined($element->{Value}))
-    {
-        $self->{entities}->{$element->{Name}} = $element->{Value};
-    }
-    else
-    {
-        if (open(ENTITYFILE,$element->{SystemId}))
-        {
-            while(my $line = <ENTITYFILE>)
-            {
-                chomp($line);
-                
-                if ($line =~ m/<!ENTITY/)
-                {
-                    my ($entity,$value) = ($line =~ m/<!ENTITY\s+(\S+?)\s+"(.*?)"/);
-#                    $main::entities->{$entity} = $value;
-                }
-            }
-            close(ENTITYFILE);
-        }
-        else
-        {
-            print STDERR ("Couldn't open entity file ",$element->{SystemId} || 'undefined',"\n");
-            return;
-        }
-    }
-}
-
-1;
-
-package MySQLDocBook;
-
-sub new
-{
-    my $self = shift;
-    my $class = ref($self) || $self;
-    my $tag = shift;
-
-    return bless {'tag' => $tag,
-                  'sectionids' => {},
-                  'currid' => '',
-                  'currsection' => '',
-                  'sectionmap' => [],
-                  'ids' => {},
-                  'captext' => 0,
-                  'currtext' => '',
-              }, $class;
-}
-
-sub start_element
-{
-    my ($self, $element) = @_;
-
-    if (exists($element->{Attributes}->{id}))
-    {
-        return unless ($element->{Name} =~ m/^(appendix|article|book|part|chapter|example|glossary|glossentry|para|preface|programlisting|refentry|refsection|section|figure)$/i);
-
-        $self->{ids}->{$element->{Attributes}->{id}} = {'type' => $element->{Name},
-                                                        'sectionparent' => $self->{currsection} || $element->{Attributes}->{id} || '--TOP--',
-                                                        'title' => undef,
-                                                    };
-        if ($element->{Name} eq 'section' ||
-            $element->{Name} eq 'refsection')
-        {
-            push(@{$self->{sectionmap}},$element->{Attributes}->{id});
-            $self->{currsection} = $element->{Attributes}->{id};
-            if (exists($self->{sectionids}->{$element->{Attributes}->{id}}))
-            {
-                print STDERR "Error: Found a duplicate section ID ($element->{Attributes}->{id})\n";
-            }
-            else
-            {
-                $self->{sectionids}->{$element->{Attributes}->{id}} = 0;
-            }
-            $self->{sectionids}->{$element->{Attributes}->{id}}++;
-        }
-        $self->{currid} = $element->{Attributes}->{id};
-    }
-    if ($self->{captext})
-    {
-        $self->{currtext} .= sprintf('<%s>',$element->{Name});
-    }
-    if ($element->{Name} eq 'title')
-    {
-        $self->{captext} = 1;
-        $self->{currtext} = '';
-    }
-}
-
-sub end_element
-{
-    my ($self, $element) = @_;
-
-    if ($element->{Name} eq 'section' ||
-        $element->{Name} eq 'refsection')
-    {
-        my $cursection = pop(@{$self->{sectionmap}});
-        $self->{currsection} = $self->{sectionmap}->[-1];
-    }
-    if ($element->{Name} eq 'title' && (!defined($self->{ids}->{$self->{currid}}->{title})))
-    {
-        $self->{ids}->{$self->{currid}}->{title} = $self->{currtext};
-        $self->{captext} = 0;
-    }
-    if ($self->{captext})
-    {
-        $self->{currtext} .= sprintf('</%s>',$element->{Name});
-    }
-}    
-
-sub characters
-{
-    my ($self, $element) = @_;
-    $element->{Data} =~ s/[\r\n]+/ /g;
-    while ($element->{Data} =~ s/[ ][ ]+/ /g) {}
-    $self->{currtext} .= $element->{Data} if ($self->{captext});
-}
-
-sub entity_reference
-{
-    my ($self, $element) = @_;
-    
-    if ($self->{captext})
-    {
-        $self->{currtext} .= sprintf('&%s;',$element->{Name});
-    }
-}
-
-
-1;


Modified: trunk/tools/idremap.pl
===================================================================
--- trunk/tools/idremap.pl	2007-10-05 19:15:49 UTC (rev 7975)
+++ trunk/tools/idremap.pl	2007-10-06 03:29:42 UTC (rev 7976)
Changed blocks: 3, Lines Added: 90, Lines Deleted: 69; 8377 bytes

@@ -1,69 +1,37 @@
 #! /usr/bin/perl -w
 # vim:set ts=2 sw=2 expandtab:
 
-# idremap.pl - remaps <xref linkend> entries to external URLs
+# idremap.pl
+#
+# Remaps <xref linkend> and <link linkend> entries to public URLs
+# using the information from the IDMap data
 
 # Martin MC Brown
 # mc@stripped
 # 2006-08-17
 
 use strict;
+use warnings;
+
+# Load the MySQL specific modules
+
 use lib qw(./tools/ ../tools ../../tools ../../../trunk/tools);
-use IDMap;
+use MySQL::IDMap;
+
+# Load the local modules
+
 use Data::Dumper;
 use Getopt::Long;
 use IO::File;
 
-eval "require XML::Parser::PerlSAX;";
-
-if ($@) 
-{
-    die <<EOF;
-ERROR: Cannot load the PerlSAX parser.
-
-You need to install the expat library and the XML::Parser::PerlSAX module for perl. 
-Either do it by hand:
- - libexpat is available from http://expat.sourceforge.net
- - PerlSAX is available from http://search.cpan.org/~kmacleod/libxml-perl-0.08/lib/XML/Parser/PerlSAX.pm
-
-Using CPAN: 
- - Install libexpat
- - Run: 
-
-\$ perl -MCPAN -e 'install XML::Parser::PerlSAX'
-
-Using apt-get:
-
-\$ apt-get install libexpat-dev
-\$ perl -MCPAN -e 'install XML::Parser::PerlSAX'
-
-Using YaST: 
-
-\$ yast -i expat
-\$ perl -MCPAN -e 'install XML::Parser::PerlSAX'
-
-Using emerge (Gentoo):
-
-\$ emerge -uD libxml-perl
-
-Please install and try again.
-
-EOF
-}
-
 my ($srcpathopt,$warnings) = ('',0);
-my @srcpaths = ('.','../refman-common');
 
 GetOptions("srcpaths=s" => \$srcpathopt,
            "warnings" => \$warnings);
 
-if ($srcpathopt)
-{
-    @srcpaths = split(/ /,$srcpathopt);
-}
+my $idmap = MySQL::IDMap->new({sources => $srcpathopt});
+$idmap->builddepth();
 
-my $idmap = IDMap->new({sources => \@srcpaths});
-
 my $file = shift;
 
 my $my_handler = MySQLDocBook->new();

@@ -96,63 +64,115 @@
 
     foreach my $match (@matches)
     {
-        my ($idref,$type,$srcrepl,$content);
+        my ($idref,$origidref,$type,$srcrepl,$content);
 
         if ($match =~ m{(<xref linkend="(.*?)"/>)})
         {
             $srcrepl = $1;
-            $idref = $2;
+            $origidref = $idref = $2;
             $type = 'xref';
         }
         elsif ($match =~ m{(<link linkend="(.*?)">(.*?)</link>)}ms)
         {
             $srcrepl = $1;
-            $idref = $2;
+            $origidref = $idref = $2;
             $type = 'link';
             $content = $3;
         }
+
+        my $prefix = undef;
+
+        if ($idref =~ m{(.*):(.*)})
+        {
+            $prefix = $1;
+            $idref = $2;
+        }
+
         my $title = '';
         if ($idref =~ m/^qandaitem/)
         {
-            print STDERR "The ID \"$idref\" is automatically generated, and assumed correct\n"
+            print STDERR "$0: WARNING: The ID \"$idref\" is automatically generated, and assumed correct\n"
                 if ($warnings);
             next;
         }
 
-        if (exists($missing->{$idref}))
+        if (exists($missing->{$origidref}))
         {
-            if (!exists($idmap->{$idref}->{file}))
+            if (defined($prefix))
             {
-                print STDERR "Error: Cannot find reference for id=\"$idref\"\n";
-                next;
+                if (!exists($idmap->{byprefixid}->{$prefix}->{$idref}->{file}))
+                {
+                    print STDERR "$0: ERROR: Cannot find reference for id [$idref] within prefix [$prefix]\n";
+                    next;
+                }
             }
-            if (length($idmap->{$idref}->{title}) == 0)
+            else
             {
-                print STDERR "Warning: Link text would be blank (???) because title text for $idref is not defined\n";
+                if (!exists($idmap->{byid}->{$idref}->{file}))
+                {
+                    print STDERR "$0: ERROR: Cannot find reference for id=[$idref]\n";
+                    next;
+                }
             }
+            if (length($idmap->{byid}->{$idref}->{title}) == 0)
+            {
+                print STDERR "$0: WARNING: Link text would be blank (???) because title text for $idref is not defined\n";
+            }
 
-            if (($idmap->{$idref}->{type} =~ m/^book$/i) &&
-                ($idmap->{$idref}->{parent} eq $idref))
+            if (($idmap->{byid}->{$idref}->{type} =~ m/^book$/i) &&
+                ($idmap->{byid}->{$idref}->{parent} eq $idref))
             {
-                print STDERR "Replacing $idref with $urlcore/$idmap->{$idref}->{urlbase}/$idref.html [$idmap->{$idref}->{title}](direct)\n"
+                if (defined($prefix))
+                {
+                    $url = sprintf('%s%s/index.html',$urlcore,$idmap->{byprefixid}->{$prefix}->{$idref}->{urlbase});
+                }
+                else
+                {
+                    $url = sprintf('%s%s/index.html',$urlcore,$idmap->{byid}->{$idref}->{urlbase});
+                }
+                $title = $idmap->{byid}->{$idref}->{title} || $idref;
+                print STDERR "$0: INFO: Replacing (toplevel) $idref with $url [$title]\n"
                     if ($warnings);
-                $url = sprintf('%s%s/index.html',$urlcore,$idmap->{$idref}->{urlbase});
-                $title = $idmap->{$idref}->{title} || $idref;
             }
-            elsif (($idmap->{$idref}->{type} =~ m/^(appendix|article|part|chapter|example|glossary|glossentry|preface|refentry|refsection|section)$/i) &&
-                (exists($idmap->{$idref}->{depth}) && ($idmap->{$idref}->{depth} <= 3)))
+            elsif (($idmap->{byid}->{$idref}->{type} =~ 
+                    m/^(appendix|article|part|chapter|example|glossary|glossentry|preface|refentry|refsection|section)$/i) &&
+                (exists($idmap->{byid}->{$idref}->{depth}) && 
+                 ($idmap->{byid}->{$idref}->{depth} <= 3)))
             {
-                print STDERR "Replacing $idref with $urlcore/$idmap->{$idref}->{urlbase}/$idref.html [$idmap->{$idref}->{title}](direct)\n"
+                if (defined($prefix))
+                {
+                    $url = sprintf('%s%s/%s.html',$urlcore,$idmap->{byprefixid}->{$prefix}->{$idref}->{urlbase},$idref);
+                }
+                else
+                {
+                    $url = sprintf('%s%s/%s.html',$urlcore,$idmap->{byid}->{$idref}->{urlbase},$idref);
+                }
+                $title = $idmap->{byid}->{$idref}->{title} || $idref;
+
+                print STDERR "$0: INFO: Replacing (section) $idref with $url [$title]\n"
                     if ($warnings);
-                $url = sprintf('%s%s/%s.html',$urlcore,$idmap->{$idref}->{urlbase},$idref);
-                $title = $idmap->{$idref}->{title} || $idref;
             }
             else
             {
-                print STDERR "Replacing $idref with $urlcore/$idmap->{$idref->{parent}}->{urlbase}/$idmap->{$idref}->{parent}.html (parent)\n"
+                if (defined($prefix))
+                {
+                    $url = sprintf('%s%s/%s.html#%s',
+                                   $urlcore,
+                                   $idmap->{byprefixid}->{$prefix}->{$idref}->{urlbase},
+                                   $idmap->{byprefixid}->{$prefix}->{$idref}->{parent},
+                                   $idref);
+                }
+                else
+                {
+                    $url = sprintf('%s%s/%s.html#%s',
+                                   $urlcore,
+                                   $idmap->{byid}->{$idref}->{urlbase},
+                                   $idmap->{byid}->{$idref}->{parent},
+                                   $idref);
+                }
+                $title = $idmap->{byid}->{$idmap->{byid}->{$idref}->{parent}}->{title} || $idref;
+                print STDERR "$0: INFO: Replacing (para within page) $idref with $url [$title]\n"
                     if ($warnings);
-                $url = sprintf('%s%s/%s.html#%s',$urlcore,$idmap->{$idref}->{urlbase},$idmap->{$idref}->{parent},$idref);
-                $title = $idmap->{$idmap->{$idref}->{parent}}->{title} || $idref;
             }
             my $destrepl = '';
             if ($type eq 'xref')

@@ -165,6 +185,7 @@
             }
             my $sourcematch = quotemeta($match);
             $filesrc =~ s/$sourcematch/$destrepl/msg;
+            print STDERR "$0: INFO: Replacing $sourcematch with $destrepl\n" if ($warnings);
         }
     }
 }


Modified: trunk/tools/idtree.pl
===================================================================
--- trunk/tools/idtree.pl	2007-10-05 19:15:49 UTC (rev 7975)
+++ trunk/tools/idtree.pl	2007-10-06 03:29:42 UTC (rev 7976)
Changed blocks: 2, Lines Added: 29, Lines Deleted: 73; 3804 bytes

@@ -1,98 +1,55 @@
 #! /usr/bin/perl -w
 # vim:set ts=2 sw=2 expandtab:
 
-# idfind.pl - finds an ID from the current ID maps and displays
-#             the corresponding file
+# idtree.pl 
+#
+# Displays an (unordered) tree structure using the information 
+# from the IDMap and resolving all the child elements to build
+# the tree structure
 
 # Martin MC Brown
 # mc@stripped
 # 2006-09-06
 
 use strict;
+use warnings;
+
+# Load the MySQL specific modules
+
 use lib qw(./tools/ ../tools ../../tools ../../../trunk/tools);
-use IDMap;
+use MySQLIDMap;
+
+# Load the local modules
+
 use Getopt::Long;
 use Data::Dumper;
 
-my ($srcpathopt,$opt_showallchildren,$opt_version) = ('',0,'refman-5.1');
-my @srcpaths = ('.',
-                '../refman-5.1',
-                '../refman-5.0',
-                '../refman-4.1',
-                '../refman-common',
-                '../gui-common',
-                '../internals',
-                '../query-browser',
-                '../administrator',
-                '../migration-toolkit',
-                '../workbench',
-                '../falcon',
-                '../ndbapi',
-                './refman-5.1',
-                './refman-5.0',
-                './refman-4.1',
-                './refman-common',
-                './gui-common',
-                './internals',
-                './query-browser',
-                './administrator',
-                './migration-toolkit',
-                './workbench',
-                './falcon',
-                './ndbapi',
-                );
+my ($srcpathopt,$opt_showallchildren,$opt_version) = ('',0,undef);
+my @srcpaths = ();
 
 GetOptions("srcpaths=s" => \$srcpathopt,
            "showallchildren" => \$opt_showallchildren,
            "prefix=s" => \$opt_version);
 
-if (defined($srcpathopt) && $srcpathopt ne '')
+
+my $toprootid = $ARGV[0];
+
+if (!defined($toprootid))
 {
-    my @newsrcpaths = split(/ /,$srcpathopt);
-    my (@hasadd,@hasnew) = ((),());
-    
-    foreach my $path (@newsrcpaths)
-    {
-        if ($path =~ m/^\+/)
-        {
-            my $realpath = $path;
-            $realpath =~ s/^\+//;
-            push @hasadd,$realpath;
-        }
-        else
-        {
-            push @hasnew,$path;
-        }
-    }
-    if (scalar(@hasnew) > 0)
-    {
-        @srcpaths = @hasnew;
-    }
-    push @srcpaths,@hasadd;
+    print STDERR "You must specify a root ID\n";
+    exit(1);
 }
 
-my $idmap = IDMap->new({sources => \@srcpaths});
+my $idmap = MySQLIDMap->new({sources => $srcpathopt});
 
-my $idtree = {};
-
-foreach my $id (keys %{$idmap})
+if (!exists($idmap->{byid}->{$toprootid}))
 {
-    $idtree->{$id} = {} unless(exists($idtree->{$id}));
-    next if ($id =~ m/^__.*__$/);
-#    next unless (exists($idmap->{$id}->{file}));
-    if (exists($idmap->{$id}->{parent}))
-    {
-        next unless (($idmap->{$id}->{prefix} =~ m/$opt_version/) ||
-                     (exists($idmap->{$id}->{adds}) &&
-                      (grep /$opt_version/,@{$idmap->{$id}->{adds}})
-                      )
-                     );
-        next if ($idmap->{$id}->{parent} eq $id);
-        $idtree->{$idmap->{$id}->{parent}}->{$id} = 1;
-    }
-
+    print STDERR "Can't find $toprootid in current maps. Is the directory list complete?\n";
+    exit(1);
 }
 
+my $idtree = $idmap->buildtree($prefix);
+
 sub walktree
 {
     my ($id,$rootlist,$depth) = @_;

@@ -108,12 +65,11 @@
     }
 }
 
-
 my $allroot = {};
 
-walktree($ARGV[0],$allroot,0);
+walktree($toprootid,$allroot,0);
 
 if ($opt_showallchildren)
 {
-    print("All children of $ARGV[0]:\n",join("\n",keys %{$allroot}),"\n");
+    print("All children of $toprootid:\n",join("\n",keys %{$allroot}),"\n");
 }


Modified: trunk/tools/idvalidate.pl
===================================================================
--- trunk/tools/idvalidate.pl	2007-10-05 19:15:49 UTC (rev 7975)
+++ trunk/tools/idvalidate.pl	2007-10-06 03:29:42 UTC (rev 7976)
Changed blocks: 3, Lines Added: 41, Lines Deleted: 7; 2196 bytes

@@ -8,8 +8,15 @@
 # 2006-08-17
 
 use strict;
+use warnings;
+
+# Load the MySQL specific modules
+
 use lib qw(./tools/ ../tools ../../tools ../../../trunk/tools);
-use IDMap;
+use MySQL::IDMap;
+
+# Load the local modules
+
 use Getopt::Long;
 
 my ($srcpathopt,$warnings) = ('',0);

@@ -23,7 +30,7 @@
     @srcpaths = split(/ /,$srcpathopt);
 }
 
-my $idmap = IDMap->new({sources => \@srcpaths});
+my $idmap = MySQL::IDMap->new({sources => \@srcpaths});
 
 my $retval = 0;
 my $linkerrs = 0;

@@ -51,15 +58,42 @@
 
 foreach my $idref (keys %{$missingids})
 {
-    if (exists($idmap->{$idref}->{file}))
+    my $prefix = undef;
+
+    if ($idref =~ m{(.*?):(.*)})
     {
-        print STDERR "Warning: xref/link ID $idref found in external file $idmap->{$idref}->{prefix}/$idmap->{$idref}->{file}\n" 
-            if ($warnings);
+        $prefix = $1;
+        $idref = $2;
     }
+
+    if (defined($prefix))
+    {
+        if (exists($idmap->{byprefixid}->{$prefix}->{$idref}))
+        {
+            printf STDERR ("$0: WARNING: xref/link ID %s found in external file %s/%s\n",
+                           $idref,
+                           $idmap->{byprefixid}->{$prefix}->{$idref}->{prefix},
+                           $idmap->{byprefixid}->{$prefix}->{$idref}->{file})
+                if ($warnings);
+        }
+        else
+        {
+            print STDERR "$0: ERROR: xref ID \"$prefix:$idref\" not found within current ID references\n";
+            $retval = 1;
+        }
+    }
     else
     {
-        print STDERR "Error: xref ID \"$idref\" not found internally or externally\n";
-        $retval = 1;
+        if (exists($idmap->{byid}->{$idref}))
+        {
+            print STDERR "$0: WARNING: xref/link ID $idref found in external file $idmap->{$idref}->{prefix}/$idmap->{$idref}->{file}\n" 
+                if ($warnings);
+        }
+        else
+        {
+            print STDERR "Error: xref ID \"$idref\" not found within current ID references\n";
+            $retval = 1;
+        }
     }
 }
 


Modified: trunk/tools/query-changelog.pl
===================================================================
--- trunk/tools/query-changelog.pl	2007-10-05 19:15:49 UTC (rev 7975)
+++ trunk/tools/query-changelog.pl	2007-10-06 03:29:42 UTC (rev 7976)
Changed blocks: 2, Lines Added: 18, Lines Deleted: 16; 1657 bytes

@@ -1,31 +1,33 @@
 #! /usr/bin/perl -w
 # vim:set ts=2 sw=2 expandtab:
 
-# query-changelog.pl - query changelog for information
+# query-changelog.pl
+# 
+# Query the dynamic changelog for information
+# 
+# This is a front-end to the information built using the 
+# MySQL::DynXML::Changelog module
 
 # Martin MC Brown
 # mc@stripped
 # 2006-09-04
 
 use strict;
-use lib './tools', '../tools', '../../tools';
+use warnings;
+
+# Load the MySQL specific modules
+
+use lib qw(./tools/ ../tools ../../tools ../../../trunk/tools);
+use MySQL::DynXML;
+use MySQL::DynXML::Changelog;
+
+# Load the local modules
+
 use Getopt::Long;
 use Data::Dumper;
-use IDMap;
-use MySQLDynXML;
-use MySQLDynXML::Changelog;
 
-my $dynxml = new MySQLDynXML();
+my $dynxml = new MySQL::DynXML();
 
-# Module testing
-
-eval "require XML::Parser::PerlSAX;";
-$dynxml->show_requirements() if ($@);
-eval "require IO::File;";
-$dynxml->show_requirements() if ($@);
-eval "require IO::String;";
-$dynxml->show_requirements() if ($@);
-
 my ($opt_versionfrom,$opt_versionto,$opt_buglist,$opt_bugsonly,$opt_product,$opt_srcdir,$opt_help) =
     (undef,undef,undef,0,'mysqld',undef,0);
 

@@ -71,7 +73,7 @@
     srcdir => $chosen_dir,
 };
 
-my $changelog = new MySQLDynXML::Changelog($dynxml,$options);
+my $changelog = new MySQL::DynXML::Changelog($dynxml,$options);
 
 my ($logentries,$entriesbyversion,$bugsbyversion,$versions) = $changelog->force_load_xml($options->{product},$options);
 


Modified: trunk/tools/remap-note-para.pl
===================================================================
--- trunk/tools/remap-note-para.pl	2007-10-05 19:15:49 UTC (rev 7975)
+++ trunk/tools/remap-note-para.pl	2007-10-06 03:29:42 UTC (rev 7976)
Changed blocks: 1, Lines Added: 3, Lines Deleted: 1; 564 bytes

@@ -1,7 +1,9 @@
 #!/usr/bin/perl -w
 # vim:set ts=2 sw=2 expandtab:
 
-# remap-note-para.pl - remaps <para><emphasis>Note|Caution|Important|Warning</emphasis>...</para>
+# remap-note-para.pl
+# 
+# Remaps <para><emphasis>Note|Caution|Important|Warning</emphasis>...</para>
 # to <note><para>...</para></note>
 
 # Martin MC Brown


Modified: trunk/tools/spell-check.pl
===================================================================
--- trunk/tools/spell-check.pl	2007-10-05 19:15:49 UTC (rev 7975)
+++ trunk/tools/spell-check.pl	2007-10-06 03:29:42 UTC (rev 7976)
Changed blocks: 3, Lines Added: 16, Lines Deleted: 110; 3321 bytes

@@ -1,14 +1,28 @@
 #! /usr/bin/perl -w
 # vim:set ts=2 sw=2 expandtab:
 
-# spell-check.pl - perform a deep check of the DocBook source
+# spell-check.pl
+# 
+# Spell checks an XML document be extracting the text within elements
+# and then comparing this against to the dictionaries
 #
+# The words to be checked are extracted using the MySQL::XML::SpellCheck
+# module
 
 # Martin MC Brown
 # mc@stripped
 # 2006-11-23
 
 use strict;
+use warnings;
+
+# Load the MySQL specific modules
+
+use MySQL;
+use MySQL::XML::SpellCheck;
+
+# Load the local modules
+
 use Getopt::Long;
 use Data::Dumper;
 

@@ -32,46 +46,9 @@
     exit 0;
 }
 
-eval "require XML::Parser::PerlSAX;";
-
-if ($@) 
-{
-    die <<EOF;
-ERROR: Cannot load the PerlSAX parser.
-
-You need to install the expat library and the XML::Parser::PerlSAX module for perl. 
-Either do it by hand:
- - libexpat is available from http://expat.sourceforge.net
- - PerlSAX is available from http://search.cpan.org/~kmacleod/libxml-perl-0.08/lib/XML/Parser/PerlSAX.pm
-
-Using CPAN: 
- - Install libexpat
- - Run: 
-
-\$ perl -MCPAN -e 'install XML::Parser::PerlSAX'
-
-Using apt-get:
-
-\$ apt-get install libexpat-dev
-\$ perl -MCPAN -e 'install XML::Parser::PerlSAX'
-
-Using YaST: 
-
-\$ yast -i expat
-\$ perl -MCPAN -e 'install XML::Parser::PerlSAX'
-
-Using emerge (Gentoo):
-
-\$ emerge -uD libxml-perl
-
-Please install and try again.
-
-EOF
-}
-
 my $file = shift or die "You must supply the name of the file to process";
 
-my $my_handler = MySQLDocBook->new();
+my $my_handler = MySQL::XML::SpellCheck->new();
 
 XML::Parser::PerlSAX->new->parse(Source => { SystemId => $file}, 
                                  Handler => $my_handler);

@@ -134,74 +111,3 @@
     close(WORDS);
 }
 
-package MySQLDocBook;
-use File::Basename;
-
-sub new
-{
-    my $self = shift;
-    my $class = ref($self) || $self;
-    my $options = shift;
-
-
-    return bless {'wordlist' => {},
-                  'parsewords' => 0,
-                  'wordbuffer' => '',
-              }, $class;
-}
-
-sub start_element
-{
-    my ($self, $element) = @_;
-
-    if ($element->{Name} =~ m/^(literal|programlisting|option|userinput|replaceable|remark)$/)
-    {
-        push @{$self->{state}},$self->{parsewords};
-        $self->{parsewords} = 0;
-    }
-    else
-    {
-        $self->{parsewords} = 1;
-    }
-}
-
-sub end_element
-{
-    my ($self, $element) = @_;
-
-    if ($element->{Name} =~ m/^(literal|programlisting|option|userinput|replaceable|remark)$/)
-    {
-        $self->{parsewords} = pop @{$self->{state}};
-    }
-
-    if (length($self->{wordbuffer}) > 0)
-    {
-        my @words = split /[\s(),\.;\?:"\/]+/,$self->{wordbuffer};
-        foreach my $word (@words)
-        {
-            next unless ($word =~ m/[a-z]/i);
-            if (exists($self->{wordlist}->{$word}))
-            {
-                $self->{wordlist}->{$word}++;
-            }
-            else
-            {
-                $self->{wordlist}->{$word} = 1;
-            }
-        }
-$self->{wordbuffer} = '';
-    }
-    
-}    
-
-sub characters
-{
-    my ($self, $element) = @_;
-
-    if ($self->{parsewords} != 0)
-    {
-        $self->{wordbuffer} .= $element->{Data};
-    }
-}
-
-1;


Modified: trunk/tools/update-dictionaries.pl
===================================================================
--- trunk/tools/update-dictionaries.pl	2007-10-05 19:15:49 UTC (rev 7975)
+++ trunk/tools/update-dictionaries.pl	2007-10-06 03:29:42 UTC (rev 7976)
Changed blocks: 3, Lines Added: 11, Lines Deleted: 14; 1349 bytes

@@ -9,14 +9,20 @@
 # 2007-08-25
 
 use strict;
-use lib './tools','../tools', '../../tools';
-use Getopt::Long;
-use IO::File;
-use IDMap;
+use warnings;
+
+# Load the MySQL specific modules
+
+use lib qw(./tools/ ../tools ../../tools ../../../trunk/tools);
 use MySQLDynXML;
 use MySQLDynXML::Optvar();
 use MySQLDynXML::Opfuncs();
 
+# Load the local modules
+
+use Getopt::Long;
+use IO::File;
+
 my $dynxml = new MySQLDynXML();
 
 my ($opt_outfile,$opt_srcdir) = (undef,undef,undef);

@@ -30,15 +36,6 @@
     show_help("You must specify the outfile and srcdir");
 }
 
-# Module testing
-
-eval "require XML::Parser::PerlSAX;";
-show_requirements() if ($@);
-eval "require IO::File;";
-show_requirements() if ($@);
-eval "require IO::String;";
-show_requirements() if ($@);
-
 my $options = {outfile => $opt_outfile,
                srcdir => $opt_srcdir,
            };

@@ -60,7 +57,7 @@
 genoptionstable.pl --infile=FILENAME --outfile=FILENAME
 
  --infile    Specify the input DocBook XML file
- --outfile   Specify the output DocBook XML file";
+ --outfile   Specify the output DocBook XML file\n";
 
     if (defined($message))
     {


Modified: trunk/tools/xml-word-count.pl
===================================================================
--- trunk/tools/xml-word-count.pl	2007-10-05 19:15:49 UTC (rev 7975)
+++ trunk/tools/xml-word-count.pl	2007-10-06 03:29:42 UTC (rev 7976)
Changed blocks: 4, Lines Added: 18, Lines Deleted: 145; 4385 bytes

@@ -1,13 +1,28 @@
 #! /usr/bin/perl -w
 # vim:set ts=2 sw=2 expandtab:
 
-# dbstats.pl - Report statistics on DocBook files
+# xml-word-count.pl
+# 
+# Count words within an XML file, resolving the information by 
+# tags, sections and allowing individual tags to be ignored 
+#
+# This is a front-end interface to the MySQL::XML::WordCount 
+# module.
 
 # Martin MC Brown
 # mc@stripped
 # 2007-03-02
 
 use strict;
+use warnings
+
+# Load the MySQL specific modules
+
+use lib qw(./tools/ ../tools ../../tools ../../../trunk/tools);
+use MySQL::XML::WordCount;
+
+# Load the local modules
+
 use Getopt::Long;
 use Data::Dumper;
 

@@ -66,6 +81,8 @@
         Words should be separated by single comma only..
     --detailed
         Shows tag by tag counts and word counts
+    --sectiondetail
+        Shows section-by-section counts (per ID)
 
     By default, the script only outputs a summary word count for each file
 

@@ -75,43 +92,6 @@
 
 }
 
-eval "require XML::Parser::PerlSAX;";
-
-if ($@) 
-{
-    die <<EOF;
-ERROR: Cannot load the PerlSAX parser.
-
-You need to install the expat library and the XML::Parser::PerlSAX module for perl. 
-Either do it by hand:
- - libexpat is available from http://expat.sourceforge.net
- - PerlSAX is available from http://search.cpan.org/~kmacleod/libxml-perl-0.08/lib/XML/Parser/PerlSAX.pm
-
-Using CPAN: 
- - Install libexpat
- - Run: 
-
-\$ perl -MCPAN -e 'install XML::Parser::PerlSAX'
-
-Using apt-get:
-
-\$ apt-get install libexpat-dev
-\$ perl -MCPAN -e 'install XML::Parser::PerlSAX'
-
-Using YaST: 
-
-\$ yast -i expat
-\$ perl -MCPAN -e 'install XML::Parser::PerlSAX'
-
-Using emerge (Gentoo):
-
-\$ emerge -uD libxml-perl
-
-Please install and try again.
-
-EOF
-}
-
 my $filemap = {};
 
 # Build the tag map

@@ -192,110 +172,3 @@
     return ($my_handler->{totalwc},$my_handler->{ignorewc});
 }
 
-
-package MySQLDocBookStats;
-
-sub new
-{
-    my $self = shift;
-    my $class = ref($self) || $self;
-    my $map = shift;
-
-    return bless {
-                  'tagmap' => $map,
-                  'tagcount' => {},
-                  'tagwordcount' => {},
-                  'currtag' => '',
-                  'captext' => 1,
-                  'currtext' => '',
-                  'totalwc' => 0,
-                  'ignorewc' => 0,
-                  'idmap' => [],
-                  'idwc' => {},
-                  'idcurr' => '',
-                  'currtextmap' => [],
-              }, $class;
-}
-
-sub start_element
-{
-    my ($self, $element) = @_;
-
-    if (exists($element->{Attributes}->{id}) &&
-        ($element->{Name} =~ m/^(section|chapter)$/i))
-    {
-        if (scalar @{$self->{idmap}} == 0)
-        {
-            push @{$self->{idmap}},$element->{Attributes}->{id};
-        $self->{idcurr} = $element->{Attributes}->{id};
-        }
-        else
-        {
-            push @{$self->{idmap}},$self->{idcurr};
-        }
-    }
-
-
-    $self->{currtext} .= ' ';
-    push @{$self->{currtextmap}},$self->{currtext};
-    $self->{currtext} = '';
-    $self->{tagcount}->{$element->{Name}}++;
-    $self->{currtag} = $element->{Name};
-}
-
-sub end_element
-{
-    my ($self, $element) = @_;
-    
-    my $wc = count_words($self->{currtext});
-    $self->{tagwordcount}->{$element->{Name}} += $wc;
-    if (exists($self->{tagmap}->{$element->{Name}}))
-    {
-        $self->{ignorewc} += $wc;
-    }
-    else
-    {
-        $self->{totalwc} += $wc;
-        $self->{idwc}->{$self->{idcurr}} += $wc;
-    }
-    $self->{currtext} = pop @{$self->{currtextmap}};
-
-    if ($element->{Name} =~ m/^(section|chapter)$/i)
-    {
-        my $old = $self->{idcurr};
-        $self->{idcurr} = pop @{$self->{idmap}} || $self->{idcurr};
-        if ($old ne $self->{idcurr})
-        {
-            $self->{idwc}->{$self->{idcurr}} += $self->{idwc}->{$old};
-        }
-    }
-
-}    
-
-sub characters
-{
-    my ($self, $element) = @_;
-    $element->{Data} =~ s/[\r\n]+/ /g;
-    while ($element->{Data} =~ s/[ ][ ]+/ /g) {}
-    $self->{currtext} .= $element->{Data} if ($self->{captext});
-}
-
-sub count_words
-{
-    my ($text) = @_;
-
-    my $words = 0;
-
-    for my $word (split(/[^\w]+/, $text))
-{
-    $words++ unless ($word =~ m/^\s+?$/);
-}
-return $words;
-}
-
-sub entity_reference
-{
-    my ($self, $element) = @_;
-}
-
-1;


Modified: trunk/tools/xmldepend.pl
===================================================================
--- trunk/tools/xmldepend.pl	2007-10-05 19:15:49 UTC (rev 7975)
+++ trunk/tools/xmldepend.pl	2007-10-06 03:29:42 UTC (rev 7976)
Changed blocks: 1, Lines Added: 2, Lines Deleted: 1; 440 bytes

@@ -57,7 +57,8 @@
 
 use strict;
 use warnings;
-use XML::Parser::PerlSAX;
+use lib qw(./tools/ ../tools ../../tools ../../../trunk/tools);
+use MySQLXML;
 
 my $XMLDEPEND_VERSION = "1.00";
 my $prog_name = "xmldepend.pl";


Thread
svn commit - mysqldoc@docsrva: r7976 - in trunk: make.d tools tools/MySQL tools/MySQL/DynXML tools/MySQL/XMLmcbrown6 Oct