MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:mcbrown Date:February 27 2008 3:41pm
Subject:svn commit - mysqldoc@docsrva: r10043 - in trunk/tools: . MySQL/XML
View as plain text  
Author: mcbrown
Date: 2008-02-27 16:41:52 +0100 (Wed, 27 Feb 2008)
New Revision: 10043

Log:
Changing the way we load file data in idremap. This eliminates an issue where reading in the entire file can lead to a request through mmap() for a large chunk of memory (approx 1GB) which causes the entire process to fail if that much memory is not available. 

Adding support to DeepCheck to check figure and imageobject entries have the necessary text for ALT tags (to agree with usability requirements). Also checks that a mediaobject is complete, and that a figure has a title and ID




Modified:
   trunk/tools/MySQL/XML/DeepCheck.pm
   trunk/tools/idremap.pl


Modified: trunk/tools/MySQL/XML/DeepCheck.pm
===================================================================
--- trunk/tools/MySQL/XML/DeepCheck.pm	2008-02-27 15:11:23 UTC (rev 10042)
+++ trunk/tools/MySQL/XML/DeepCheck.pm	2008-02-27 15:41:52 UTC (rev 10043)
Changed blocks: 7, Lines Added: 107, Lines Deleted: 2; 5316 bytes

@@ -13,6 +13,7 @@
 
 use File::Basename;
 use LWP::UserAgent;
+use Data::Dumper;
 
 # Currently addresses:
 # - Checks table column definition/actual columns

@@ -41,11 +42,13 @@
                   'intag' => 0,
                   'tablecount' => 0,
                   'tabledefs' => {},
+                  'figure' => {},
                   'currentbase' => './',
                   'inlink' => 0,
                   'linkref' => '',
                   'linktext' => '',
                   'intable' => 0,
+                  'infigure' => 0,
                   'intodo' => 0,
                   'errorcount' => 0,
                   'checklinelength' => 0,

@@ -141,6 +144,8 @@
 #    }
     }
 
+
+
     if ($element->{Name} eq 'remark' &&
         exists($element->{Attributes}->{role}) &&
         $element->{Attributes}->{role} eq 'todo')

@@ -171,6 +176,63 @@
         }
     }
 
+    if ($element->{Name} eq 'figure')
+    {
+        $self->{infigure} = 1;
+        $self->{figure} = {
+            hasimageobject => 0,
+            hastextobject => 0,
+            hastitle => 0,
+            hasid => 0,
+            id => '',
+            type => 'figure',
+        };
+
+        if (exists($element->{Attributes}->{id}))
+        {
+            $self->{figure}->{hasid} = 1;
+            $self->{figure}->{id} = $element->{Attributes}->{id};
+        }
+    }
+
+    if ($element->{Name} eq 'mediaobject' && $self->{infigure} == 0)
+    {
+        $self->{infigure} = 1;
+        $self->{figure} = {
+            hasimageobject => 0,
+            hastextobject => 0,
+            hastitle => 0,
+            hasid => 0,
+            id => '',
+            type => 'mediaobject',
+            fileref => '',
+        };
+    }        
+    
+    if ($self->{infigure} == 1 &&
+        $element->{Name} eq 'textobject')
+    {
+        $self->{figure}->{hastextobject} = 1;
+    }
+
+    if ($self->{infigure} == 1 &&
+        $element->{Name} eq 'imagedata')
+    {
+        $self->{figure}->{fileref} = $element->{Attributes}->{fileref};
+    }
+
+    if ($self->{infigure} == 1 &&
+        $element->{Name} eq 'imageobject')
+    {
+        $self->{figure}->{hasmediaobject} = 1;
+    }
+
+    if ($self->{infigure} == 1 &&
+        $element->{Name} eq 'title')
+    {
+        $self->{figure}->{hastitle} = 1;
+    }
+
 # Disabled until we can organize a build issue
 #
 #    if ($element->{Name} eq 'xref')

@@ -184,7 +246,7 @@
 #                  'text' => "<xref> to $self->{linkref} within $self->{currsection} links to an item without a title\n"});
 #        }            
 #    }
-    
+
     if ($element->{Name} eq 'emphasis')
     {
         $self->{inemphasis} = 1;

@@ -271,6 +333,49 @@
 {
     my ($self, $element) = @_;
 
+    if (($element->{Name} eq 'figure' && $self->{figure}->{type} eq 'figure') ||
+        ($element->{Name} eq 'mediaobject' && $self->{figure}->{type} eq 'mediaobject'))
+    {
+        my $figure = $self->{figure}->{id} || $self->{figure}->{fileref} || ' [no ID] ';
+
+        if ($self->{figure}->{hastextobject} == 0)
+        {
+            push @{$self->{issuelist}},{'parentid' => $self->{currsection},
+                                        'class' => 'todo',
+                                        'type' => 'figure',
+                                        'text' => "Figure $figure has no alternative text description\n",};
+        }
+
+        if ($self->{figure}->{hasmediaobject} == 0)
+        {
+            push @{$self->{issuelist}},{'parentid' => $self->{currsection},
+                                        'class' => 'todo',
+                                        'type' => 'figure',
+                                        'text' => "Figure $figure has no graphics object\n",};
+        }
+
+        if ($self->{figure}->{type} eq 'figure' &&
+            $self->{figure}->{hastitle} == 0)
+        {
+            push @{$self->{issuelist}},{'parentid' => $self->{currsection},
+                                        'class' => 'todo',
+                                        'type' => 'figure',
+                                        'text' => "Figure $figure has no title\n",};
+        }
+
+        if ($self->{figure}->{type} eq 'figure' &&
+            $self->{figure}->{hasid} == 0)
+        {
+            push @{$self->{issuelist}},{'parentid' => $self->{currsection},
+                                        'class' => 'todo',
+                                        'type' => 'figure',
+                                        'text' => "Figure $figure has no ID\n",};
+        }
+
+        $self->{figure} = undef;
+        $self->{infigure} = 0;
+    }
+
     if ($element->{Name} eq 'entrytbl')
     {
         $self->{tabledefs}->{$self->{tablecount}}->{inentrytbl} = 0;

@@ -425,7 +530,7 @@
                                  "\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}))


Modified: trunk/tools/idremap.pl
===================================================================
--- trunk/tools/idremap.pl	2008-02-27 15:11:23 UTC (rev 10042)
+++ trunk/tools/idremap.pl	2008-02-27 15:41:52 UTC (rev 10043)
Changed blocks: 2, Lines Added: 15, Lines Deleted: 6; 999 bytes

@@ -38,7 +38,21 @@
 
 my $my_handler = MySQL::IDMap::RemapParser->new();
 
-XML::Parser::PerlSAX->new->parse(Source => { SystemId => $file}, 
+my $source = IO::File->new($file,'r');
+binmode($source,':utf8');
+my @filesrc;
+my $block;
+while (my $bytesread = sysread($source,$block,65536))
+{
+    push @filesrc,$block;
+}
+
+my $filesrc = join('',@filesrc);
+$source->close();
+@filesrc = ();
+$block = undef;
+
+XML::Parser::PerlSAX->new->parse(Source => { String => $filesrc}, 
                                  Handler => $my_handler);
 
 my $missing = {};

@@ -51,11 +65,6 @@
 my $url = '';
 my $err_count = 0;
 
-my $source = IO::File->new($file,'r');
-binmode($source,':utf8');
-binmode(STDOUT,':utf8');
-my $filesrc = join('',<$source>);
-$source->close();
 
 if ($filesrc =~ m{<(xref|link) linkend})
 {


Thread
svn commit - mysqldoc@docsrva: r10043 - in trunk/tools: . MySQL/XMLmcbrown27 Feb