Author: mcbrown
Date: 2006-08-24 10:00:31 +0200 (Thu, 24 Aug 2006)
New Revision: 3096
Log:
Introducing the ID mapping, checking and remapping functionality into the source tree.
Added:
trunk/tools/IDMap.pm
trunk/tools/idmap.pl
trunk/tools/idremap.pl
trunk/tools/idvalidate.pl
Modified:
trunk/administrator/Makefile
trunk/gui-common/Makefile
trunk/internals/Makefile
trunk/make.d/vars-docbook
trunk/make.d/xml-prep
trunk/make.d/xml-valid
trunk/migration-toolkit/Makefile
trunk/mysqltest/Makefile
trunk/ndbapi/Makefile
trunk/proto-doc/Makefile
trunk/query-browser/Makefile
trunk/refman-4.1/Makefile
trunk/refman-5.0/Makefile
trunk/refman-5.1/Makefile
trunk/refman-common/Makefile
trunk/userguide/Makefile
trunk/workbench/Makefile
Property changes on: trunk/tools/idmap.pl
___________________________________________________________________
Name: svn:executable
+ *
Property changes on: trunk/tools/idremap.pl
___________________________________________________________________
Name: svn:executable
+ *
Property changes on: trunk/tools/idvalidate.pl
___________________________________________________________________
Name: svn:executable
+ *
Modified: trunk/administrator/Makefile
===================================================================
--- trunk/administrator/Makefile 2006-08-24 02:34:02 UTC (rev 3095)
+++ trunk/administrator/Makefile 2006-08-24 08:00:31 UTC (rev 3096)
Changed blocks: 1, Lines Added: 9, Lines Deleted: 0; 546 bytes
@@ -10,6 +10,15 @@
DOC_LANG = en
+# Set IDMAP and remap variables
+
+IDMAP_LANG = $(DOC_LANG)
+IDMAP_MAIN = administrator
+
+IDMAP_URLBASE = $(IDMAP_MAIN)/$(IDMAP_LANG)
+IDMAP_REFS = . ../refman-common ../refman-5.1
+IDMAP_SRCS = $(ADMINISTRATOR_SRCS)
+
# Import standard variables
include $(MAKE_DIR)/vars-layout
Modified: trunk/gui-common/Makefile
===================================================================
--- trunk/gui-common/Makefile 2006-08-24 02:34:02 UTC (rev 3095)
+++ trunk/gui-common/Makefile 2006-08-24 08:00:31 UTC (rev 3096)
Changed blocks: 1, Lines Added: 9, Lines Deleted: 0; 518 bytes
@@ -10,6 +10,15 @@
DOC_LANG = en
+# Set IDMAP and remap variables
+
+IDMAP_LANG = $(DOC_LANG)
+IDMAP_MAIN = gui-common
+
+IDMAP_URLBASE = $(IDMAP_MAIN)/$(IDMAP_LANG)
+IDMAP_REFS = . ../refman-5.1 ../refman-common
+IDMAP_SRCS = *.xml
+
# Import standard variables
include $(MAKE_DIR)/vars-layout
Modified: trunk/internals/Makefile
===================================================================
--- trunk/internals/Makefile 2006-08-24 02:34:02 UTC (rev 3095)
+++ trunk/internals/Makefile 2006-08-24 08:00:31 UTC (rev 3096)
Changed blocks: 1, Lines Added: 9, Lines Deleted: 0; 526 bytes
@@ -10,6 +10,15 @@
DOC_LANG = en
+# Set IDMAP and remap variables
+
+IDMAP_LANG = $(DOC_LANG)
+IDMAP_MAIN = internals
+
+IDMAP_URLBASE = $(IDMAP_MAIN)/$(IDMAP_LANG)
+IDMAP_REFS = . ../refman-common ../refman-5.1
+IDMAP_SRCS = $(INTERNALS_SRCS)
+
# Import standard variables
include $(MAKE_DIR)/vars-layout
Modified: trunk/make.d/vars-docbook
===================================================================
--- trunk/make.d/vars-docbook 2006-08-24 02:34:02 UTC (rev 3095)
+++ trunk/make.d/vars-docbook 2006-08-24 08:00:31 UTC (rev 3096)
Changed blocks: 1, Lines Added: 14, Lines Deleted: 0; 740 bytes
@@ -83,6 +83,20 @@
DEEP_CHECK = $(TOOLS_DIR)/deep-check.pl
+# IDMAP builds a map of the IDs in an XML document
+
+IDMAP = $(TOOLS_DIR)/idmap.pl
+
+# IDVALIDATE checks the output from XMLLINT and checks if a valid ID
+# exists elsewhere in the doc
+
+IDVALIDATE = $(TOOLS_DIR)/idvalidate.pl
+
+# IDREMAP finds missing IDs in a document and remaps missing IDs to
+# the URL of the right ID as a URL
+
+IDREMAP = $(TOOLS_DIR)/idremap.pl
+
# FIXUP_MANPAGES post-processes the manpages generated from the Reference
# manual.
Modified: trunk/make.d/xml-prep
===================================================================
--- trunk/make.d/xml-prep 2006-08-24 02:34:02 UTC (rev 3095)
+++ trunk/make.d/xml-prep 2006-08-24 08:00:31 UTC (rev 3096)
Changed blocks: 1, Lines Added: 3, Lines Deleted: 1; 896 bytes
@@ -10,11 +10,13 @@
# BUG_PREP fixes up "Bug #xxxx" bug references into <ulink> elements
# that point to htto://bugs.mysql.com bug reports.
-%-prepped.xml: %.xml $(DBK_PREP_XSL_DEPS) $(GET_SVN_REVISION) $(BUG_PREP)
+%-prepped.xml: %.xml $(DBK_PREP_XSL_DEPS) $(GET_SVN_REVISION) $(BUG_PREP) idmap.refs
$(XSLTPROC) \
--stringparam repository.revision "`$(GET_SVN_REVISION)`" \
--param map.remark.to.para $(MAP_REMARK_TO_PARA) \
$(DBK_PREP_XSL) $< | $(BUG_PREP) > $@
+ $(IDREMAP) --srcpath="$(IDMAP_REFS)" $@ >$@.xprep
+ mv $@.xprep $@
# For <remark> preprocessing, prepping is the same as %-prepped.xml,
# except that we must ignore the remark-mapping parameter (which causes
Modified: trunk/make.d/xml-valid
===================================================================
--- trunk/make.d/xml-valid 2006-08-24 02:34:02 UTC (rev 3095)
+++ trunk/make.d/xml-valid 2006-08-24 08:00:31 UTC (rev 3096)
Changed blocks: 1, Lines Added: 18, Lines Deleted: 2; 1069 bytes
@@ -1,11 +1,27 @@
# Validate an XML document
-%.valid: %.xml
- $(XMLLINT) --xinclude --postvalid --noout --nonet $<
+%.valid: %.xml idmap.refs
+ $(XMLLINT) --xinclude --postvalid --noout --nonet $< 2>&1 |$(IDVALIDATE) --srcpath="$(IDMAP_REFS)"
+%.validwarn: %.xml idmap.refs
+ $(XMLLINT) --xinclude --postvalid --noout --nonet $< 2>&1 |$(IDVALIDATE) --srcpath="$(IDMAP_REFS)" --warnings
+
+%.validpure: %.xml
+ $(XMLLINT) --xinclude --postvalid --noout --nonet $< 2>&1
+
%.deepcheck: %-prepped.xml
$(DEEP_CHECK) $<
+idmap.refs:
+ @ for dir in $(IDMAP_REFS); do\
+ $(shell echo $(dir) ) \
+ $(MAKE) -C $$dir idmap; \
+ done
+
+idmap:
+ @ echo Rebuilding maps for $(IDMAP_URLBASE)
+ @ $(IDMAP) $(IDMAP_URLBASE) $(IDMAP_SRCS)
+
help::
@echo "make file.valid - validate file.xml"
@echo "make file.deepcheck - perform deep check of file.xml"
Modified: trunk/migration-toolkit/Makefile
===================================================================
--- trunk/migration-toolkit/Makefile 2006-08-24 02:34:02 UTC (rev 3095)
+++ trunk/migration-toolkit/Makefile 2006-08-24 08:00:31 UTC (rev 3096)
Changed blocks: 1, Lines Added: 9, Lines Deleted: 0; 566 bytes
@@ -10,6 +10,15 @@
DOC_LANG = en
+# Set IDMAP and remap variables
+
+IDMAP_LANG = $(DOC_LANG)
+IDMAP_MAIN = migration-toolkit
+
+IDMAP_URLBASE = $(IDMAP_MAIN)/$(IDMAP_LANG)
+IDMAP_REFS = . ../refman-5.1 ../refman-common
+IDMAP_SRCS = $(MIGRATION_TOOLKIT_SRCS)
+
# Import standard variables
include $(MAKE_DIR)/vars-layout
Modified: trunk/mysqltest/Makefile
===================================================================
--- trunk/mysqltest/Makefile 2006-08-24 02:34:02 UTC (rev 3095)
+++ trunk/mysqltest/Makefile 2006-08-24 08:00:31 UTC (rev 3096)
Changed blocks: 1, Lines Added: 9, Lines Deleted: 0; 526 bytes
@@ -10,6 +10,15 @@
DOC_LANG = en
+# Set IDMAP and remap variables
+
+IDMAP_LANG = $(DOC_LANG)
+IDMAP_MAIN = mysqltest
+
+IDMAP_URLBASE = $(IDMAP_MAIN)/$(IDMAP_LANG)
+IDMAP_REFS = . ../refman-5.1 ../refman-common
+IDMAP_SRCS = $(MYSQLTEST_SRCS)
+
# Import standard variables
include $(MAKE_DIR)/vars-layout
Modified: trunk/ndbapi/Makefile
===================================================================
--- trunk/ndbapi/Makefile 2006-08-24 02:34:02 UTC (rev 3095)
+++ trunk/ndbapi/Makefile 2006-08-24 08:00:31 UTC (rev 3096)
Changed blocks: 1, Lines Added: 9, Lines Deleted: 0; 511 bytes
@@ -10,6 +10,15 @@
DOC_LANG = en
+# Set IDMAP and remap variables
+
+IDMAP_LANG = $(DOC_LANG)
+IDMAP_MAIN = ndbapi
+
+IDMAP_URLBASE = $(IDMAP_MAIN)/$(IDMAP_LANG)
+IDMAP_REFS = . ../refman-5.1 ../refman-common
+IDMAP_SRCS = $(NDBAPI_SRCS)
+
# Import standard variables
include $(MAKE_DIR)/vars-layout
Modified: trunk/proto-doc/Makefile
===================================================================
--- trunk/proto-doc/Makefile 2006-08-24 02:34:02 UTC (rev 3095)
+++ trunk/proto-doc/Makefile 2006-08-24 08:00:31 UTC (rev 3096)
Changed blocks: 1, Lines Added: 10, Lines Deleted: 0; 510 bytes
@@ -10,6 +10,16 @@
DOC_LANG = en
+# Set IDMAP and remap variables
+
+IDMAP_LANG = $(DOC_LANG)
+IDMAP_MAIN = refman
+IDMAP_VER = 5.1
+
+IDMAP_URLBASE = $(IDMAP_MAIN)/$(IDMAP_VER)/$(IDMAP_LANG)
+IDMAP_REFS = .
+IDMAP_SRCS = *.xml
+
# Import standard variables
include $(MAKE_DIR)/vars-layout
Modified: trunk/query-browser/Makefile
===================================================================
--- trunk/query-browser/Makefile 2006-08-24 02:34:02 UTC (rev 3095)
+++ trunk/query-browser/Makefile 2006-08-24 08:00:31 UTC (rev 3096)
Changed blocks: 1, Lines Added: 9, Lines Deleted: 0; 546 bytes
@@ -10,6 +10,15 @@
DOC_LANG = en
+# Set IDMAP and remap variables
+
+IDMAP_LANG = $(DOC_LANG)
+IDMAP_MAIN = query-browser
+
+IDMAP_URLBASE = $(IDMAP_MAIN)/$(IDMAP_LANG)
+IDMAP_REFS = . ../refman-5.1 ../refman-common
+IDMAP_SRCS = $(QUERY_BROWSER_SRCS)
+
# Import standard variables
include $(MAKE_DIR)/vars-layout
Modified: trunk/refman-4.1/Makefile
===================================================================
--- trunk/refman-4.1/Makefile 2006-08-24 02:34:02 UTC (rev 3095)
+++ trunk/refman-4.1/Makefile 2006-08-24 08:00:31 UTC (rev 3096)
Changed blocks: 1, Lines Added: 10, Lines Deleted: 0; 551 bytes
@@ -10,6 +10,16 @@
DOC_LANG = en
+# Set IDMAP and remap variables
+
+IDMAP_LANG = $(DOC_LANG)
+IDMAP_MAIN = refman
+IDMAP_VER = 4.1
+
+IDMAP_URLBASE = $(IDMAP_MAIN)/$(IDMAP_VER)/$(IDMAP_LANG)
+IDMAP_REFS = . ../refman-common ../internals
+IDMAP_SRCS = $(MANUAL_SRCS)
+
# Import standard variables
include $(MAKE_DIR)/vars-layout
Modified: trunk/refman-5.0/Makefile
===================================================================
--- trunk/refman-5.0/Makefile 2006-08-24 02:34:02 UTC (rev 3095)
+++ trunk/refman-5.0/Makefile 2006-08-24 08:00:31 UTC (rev 3096)
Changed blocks: 1, Lines Added: 10, Lines Deleted: 0; 551 bytes
@@ -10,6 +10,16 @@
DOC_LANG = en
+# Set IDMAP and remap variables
+
+IDMAP_LANG = $(DOC_LANG)
+IDMAP_MAIN = refman
+IDMAP_VER = 4.1
+
+IDMAP_URLBASE = $(IDMAP_MAIN)/$(IDMAP_VER)/$(IDMAP_LANG)
+IDMAP_REFS = . ../refman-common ../internals
+IDMAP_SRCS = $(MANUAL_SRCS)
+
# Import standard variables
include $(MAKE_DIR)/vars-layout
Modified: trunk/refman-5.1/Makefile
===================================================================
--- trunk/refman-5.1/Makefile 2006-08-24 02:34:02 UTC (rev 3095)
+++ trunk/refman-5.1/Makefile 2006-08-24 08:00:31 UTC (rev 3096)
Changed blocks: 1, Lines Added: 10, Lines Deleted: 0; 551 bytes
@@ -10,6 +10,16 @@
DOC_LANG = en
+# Set IDMAP and remap variables
+
+IDMAP_LANG = $(DOC_LANG)
+IDMAP_MAIN = refman
+IDMAP_VER = 5.1
+
+IDMAP_URLBASE = $(IDMAP_MAIN)/$(IDMAP_VER)/$(IDMAP_LANG)
+IDMAP_REFS = . ../refman-common ../internals
+IDMAP_SRCS = $(MANUAL_SRCS)
+
# Import standard variables
include $(MAKE_DIR)/vars-layout
Modified: trunk/refman-common/Makefile
===================================================================
--- trunk/refman-common/Makefile 2006-08-24 02:34:02 UTC (rev 3095)
+++ trunk/refman-common/Makefile 2006-08-24 08:00:31 UTC (rev 3096)
Changed blocks: 1, Lines Added: 10, Lines Deleted: 0; 522 bytes
@@ -10,6 +10,16 @@
DOC_LANG = en
+# Set IDMAP and remap variables
+
+IDMAP_LANG = $(DOC_LANG)
+IDMAP_MAIN = refman
+IDMAP_VER = 5.1
+
+IDMAP_URLBASE = $(IDMAP_MAIN)/$(IDMAP_VER)/$(IDMAP_LANG)
+IDMAP_REFS = .
+IDMAP_SRCS = *.xml
+
# Import standard variables
include $(MAKE_DIR)/vars-layout
Added: trunk/tools/IDMap.pm
===================================================================
--- trunk/tools/IDMap.pm (rev 0)
+++ trunk/tools/IDMap.pm 2006-08-24 08:00:31 UTC (rev 3096)
Changed blocks: 1, Lines Added: 55, Lines Deleted: 0; 1323 bytes
@@ -0,0 +1,55 @@
+package IDMap;
+
+use Carp;
+use Data::Dumper;
+
+sub new
+{
+ my $self = shift;
+ my $class = ref($self) || $self;
+ my $opts = shift;
+ my $object = {};
+ bless $object, $class;
+
+ $object->loadmaps($opts->{sources});
+
+ return $object;
+}
+
+sub loadmaps
+{
+ my ($self,$srcs) = @_;
+
+ foreach my $prefix (@{$srcs})
+ {
+ my @maps = glob($prefix . '/' . 'metadata/*.idmap');
+
+ foreach my $file (@maps)
+ {
+ $self->loadmap($file,$prefix);
+ }
+ }
+}
+
+sub loadmap
+{
+ my ($self,$file,$prefix) = @_;
+
+ open(IDMAP,$file) or croak "Could not load ID map file $file: $!\n";
+
+ while(my $line = <IDMAP>)
+ {
+ chomp $line;
+ my ($id,$type,$parent,$srcfile,$urlbase,$title) = split /:/,$line,6;
+ $self->{$id} = {id => $id,
+ type => $type,
+ parent => $parent,
+ file => $srcfile,
+ prefix => $prefix,
+ urlbase => $urlbase,
+ title => $title,
+ };
+ }
+}
+
+1;
Added: trunk/tools/idmap.pl
===================================================================
--- trunk/tools/idmap.pl (rev 0)
+++ trunk/tools/idmap.pl 2006-08-24 08:00:31 UTC (rev 3096)
Changed blocks: 1, Lines Added: 188, Lines Deleted: 0; 5222 bytes
@@ -0,0 +1,188 @@
+#! /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
+
+# Martin MC Brown
+# mc@stripped
+# 2006-08-03
+
+use strict;
+use File::Basename;
+use File::Path;
+use Getopt::Long;
+
+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'
+
+Please install and try again.
+
+EOF
+}
+
+my $urlbase = shift;
+
+for my $file (@ARGV)
+{
+# We skup anything not an XML file
+ next unless ($file =~ m/\.xml$/);
+# We skip anything not in the current directory
+ next if ($file =~ m{/});
+ gen_idmap($file);
+}
+
+sub gen_idmap
+{
+ my ($file) = @_;
+
+ my $my_handler = MySQLDocBook->new();
+
+ XML::Parser::PerlSAX->new->parse(Source => { SystemId => $file},
+ Handler => $my_handler);
+
+ my ($name,$path,$suffix) = fileparse($file,qw/xml/);
+
+ my ($mapfile) = sprintf('%s/%s/%s%s',$path,'metadata',$name,'idmap');
+
+ my ($mapdir) = sprintf('%s/%s',$path,'metadata');
+
+ mkpath($mapdir);
+
+ my ($mapfilemtime) = 0;
+
+ ($mapfilemtime) = (stat($mapfile))[9] if -e $mapfile;
+ my ($filemtime) = (stat($file))[9];
+
+ return if ($mapfilemtime >= $filemtime);
+
+# print STDERR "Generating idmap for $file -> $mapfile\n";
+
+ open(MAP,">$mapfile") or die "Couldn't open map destination file ($mapfile): $!";
+
+ foreach my $id (sort { $a cmp $b } keys %{$my_handler->{ids}})
+ {
+ print MAP (join(':',
+ $id,
+ $my_handler->{ids}->{$id}->{type},
+ $my_handler->{ids}->{$id}->{sectionparent},
+ $file,
+ $urlbase,
+ $my_handler->{ids}->{$id}->{title} || $id),
+ "\n");
+ }
+ close(MAP);
+}
+
+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}))
+ {
+ $self->{ids}->{$element->{Attributes}->{id}} = {'type' => $element->{Name},
+ 'sectionparent' => $self->{currsection} || '--TOP--',
+ 'title' => undef,
+ };
+ if ($element->{Name} eq 'section')
+ {
+ 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')
+ {
+ if (exists($element->{Attributes}->{id}))
+ {
+ 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});
+}
+
+1;
Property changes on: trunk/tools/idmap.pl
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/tools/idremap.pl
===================================================================
--- trunk/tools/idremap.pl (rev 0)
+++ trunk/tools/idremap.pl 2006-08-24 08:00:31 UTC (rev 3096)
Changed blocks: 1, Lines Added: 160, Lines Deleted: 0; 4111 bytes
@@ -0,0 +1,160 @@
+#! /usr/bin/perl -w
+# vim:set ts=2 sw=2 expandtab:
+
+# idvalidate.pl - parses the output of the XMLLINT and validates wider IDs
+
+# Martin MC Brown
+# mc@stripped
+# 2006-08-17
+
+use strict;
+use lib '../tools';
+use IDMap;
+use Data::Dumper;
+use Getopt::Long;
+use strict;
+
+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'
+
+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 = IDMap->new({sources => \@srcpaths});
+
+my $file = shift;
+
+my $my_handler = MySQLDocBook->new();
+
+XML::Parser::PerlSAX->new->parse(Source => { SystemId => $file},
+ Handler => $my_handler);
+
+my $missing = {};
+
+foreach my $id (keys %{$my_handler->{links}})
+{
+ $missing->{$id} = 1 if (!exists($my_handler->{ids}->{$id}));
+}
+
+my $url = '';
+my $urlcore = 'http://dev.mysql.com/doc/';
+
+open(DATA,$file);
+
+while(<DATA>)
+{
+ my (@matches) = ($_ =~ m{(<xref linkend=".*?"/>)}g);
+
+ foreach my $match (@matches)
+ {
+ $match =~ m{(<xref linkend="(.*?)"/>)};
+ my $idref = $2;
+ my $srcrepl = $1;
+ my $title = '';
+ if (exists($missing->{$idref}))
+ {
+# print STDERR Dumper($idmap->{$idref}),"\n";
+
+ if ($idmap->{$idref}->{type} eq 'section' ||
+ $idmap->{$idref}->{type} eq 'appendix' ||
+ $idmap->{$idref}->{type} eq 'refentry' ||
+ $idmap->{$idref}->{type} eq 'refsection' ||
+ $idmap->{$idref}->{type} eq 'chapter')
+ {
+ print STDERR "Replacing $idref with URL/$idref.html [$idmap->{$idref}->{title}](direct)\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 URL/$idmap->{$idref}->{parent}.html (parent)\n"
+ if ($warnings);
+ $url = sprintf('%s%s/%s.html#%s',$urlcore,$idmap->{$idref}->{parent},$idmap->{$idref}->{urlbase},$idref);
+ $title = $idmap->{$idmap->{$idref}->{parent}}->{title} || $idref;
+ }
+ my $destrepl = sprintf('<ulink url="%s">%s</ulink>',$url,$title);
+ $_ =~ s/$srcrepl/$destrepl/;
+ }
+ }
+ print;
+}
+
+package MySQLDocBook;
+
+sub new
+{
+ my $self = shift;
+ my $class = ref($self) || $self;
+ my $tag = shift;
+
+ return bless {'links' => {},
+ 'ids' => {},
+ }, $class;
+}
+
+sub start_element
+{
+ my ($self, $element) = @_;
+
+ if (exists($element->{Attributes}->{id}))
+ {
+ $self->{ids}->{$element->{Attributes}->{id}} = 1;
+ }
+
+ if (exists($element->{Attributes}->{linkend}))
+ {
+ $self->{links}->{$element->{Attributes}->{linkend}} = 1;
+ }
+}
+
+sub end_element
+{
+ my ($self, $element) = @_;
+
+}
+
+sub characters
+{
+ my ($self, $element) = @_;
+}
+
+1;
Property changes on: trunk/tools/idremap.pl
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/tools/idvalidate.pl
===================================================================
--- trunk/tools/idvalidate.pl (rev 0)
+++ trunk/tools/idvalidate.pl 2006-08-24 08:00:31 UTC (rev 3096)
Changed blocks: 1, Lines Added: 72, Lines Deleted: 0; 1687 bytes
@@ -0,0 +1,72 @@
+#! /usr/bin/perl -w
+# vim:set ts=2 sw=2 expandtab:
+
+# idvalidate.pl - parses the output of the XMLLINT and validates wider IDs
+
+# Martin MC Brown
+# mc@stripped
+# 2006-08-17
+
+use strict;
+use lib '../tools';
+use IDMap;
+use Getopt::Long;
+
+my ($srcpathopt,$warnings) = ('',0);
+my @srcpaths = ('.','../refman-common');
+
+GetOptions("srcpaths=s" => \$srcpathopt,
+ "warnings" => \$warnings);
+
+if ($srcpathopt)
+{
+ @srcpaths = split(/ /,$srcpathopt);
+}
+
+my $idmap = IDMap->new({sources => \@srcpaths});
+
+my $retval = 0;
+my $linkerrs = 0;
+my $notvalid = 0;
+my @errlines;
+
+my $missingids = {};
+
+while(<STDIN>)
+{
+ if (m/xref: validity error.*?ID "(.*?)"/)
+ {
+ my $idref = $1;
+ $missingids->{$idref} = 1;
+ }
+ elsif (m/does not validate/)
+ {
+ $notvalid = $_;
+ }
+ else
+ {
+ push @errlines,$_;
+ }
+}
+
+foreach my $idref (keys %{$missingids})
+{
+ if (exists($idmap->{$idref}))
+ {
+ print STDERR "Warning: xref ID $idref found in external file $idmap->{$idref}->{prefix}/$idmap->{$idref}->{file}\n"
+ if ($warnings);
+ }
+ else
+ {
+ print STDERR "Error: xref ID \"$idref\" not found internally or externally\n";
+ }
+}
+
+if (scalar @errlines)
+{
+ print STDERR @errlines;
+ print STDERR $notvalid;
+ exit(1);
+}
+
+exit(0);
Property changes on: trunk/tools/idvalidate.pl
___________________________________________________________________
Name: svn:executable
+ *
Modified: trunk/userguide/Makefile
===================================================================
--- trunk/userguide/Makefile 2006-08-24 02:34:02 UTC (rev 3095)
+++ trunk/userguide/Makefile 2006-08-24 08:00:31 UTC (rev 3096)
Changed blocks: 1, Lines Added: 9, Lines Deleted: 0; 526 bytes
@@ -10,6 +10,15 @@
DOC_LANG = en
+# Set IDMAP and remap variables
+
+IDMAP_LANG = $(DOC_LANG)
+IDMAP_MAIN = userguide
+
+IDMAP_URLBASE = $(IDMAP_MAIN)/$(IDMAP_LANG)
+IDMAP_REFS = . ../refman-5.1 ../refman-common
+IDMAP_SRCS = $(USERGUIDE_SRCS)
+
# Import standard variables
include $(MAKE_DIR)/vars-layout
Modified: trunk/workbench/Makefile
===================================================================
--- trunk/workbench/Makefile 2006-08-24 02:34:02 UTC (rev 3095)
+++ trunk/workbench/Makefile 2006-08-24 08:00:31 UTC (rev 3096)
Changed blocks: 1, Lines Added: 9, Lines Deleted: 0; 526 bytes
@@ -10,6 +10,15 @@
DOC_LANG = en
+# Set IDMAP and remap variables
+
+IDMAP_LANG = $(DOC_LANG)
+IDMAP_MAIN = workbench
+
+IDMAP_URLBASE = $(IDMAP_MAIN)/$(IDMAP_LANG)
+IDMAP_REFS = . ../refman-5.1 ../refman-common
+IDMAP_SRCS = $(WORKBENCH_SRCS)
+
# Import standard variables
include $(MAKE_DIR)/vars-layout
| Thread |
|---|
| • svn commit - mysqldoc@docsrva: r3096 - in trunk: administrator gui-common internals make.d migration-toolkit mysqltest ndbapi proto-doc query-browser ... | mcbrown | 24 Aug |