List:Commits« Previous MessageNext Message »
From:paul Date:July 15 2006 2:08am
Subject:svn commit - mysqldoc@docsrva: r2740 - in trunk: . make.d refman-4.1 refman-5.0 refman-5.1 tools xsl.d
View as plain text  
Author: paul
Date: 2006-07-15 04:08:48 +0200 (Sat, 15 Jul 2006)
New Revision: 2740

Log:
 r12244@frost:  paul | 2006-07-14 21:06:05 -0500
 Add machinery in preparation for dumping titles.lang.ent:
 - Script to expand title entities in .xml files
 - XSL transform to produce id/title pairs from DocBook document
 - make %.titles target rule that invokes the transform


Added:
   trunk/make.d/xml-titles
   trunk/tools/de-title-entityize.pl
   trunk/xsl.d/extract-titles.xsl
Modified:
   trunk/make.d/vars-docbook
   trunk/refman-4.1/Makefile
   trunk/refman-5.0/Makefile
   trunk/refman-5.1/Makefile

Property changes on: trunk
___________________________________________________________________
Name: svk:merge
   - 4767c598-dc10-0410-bea0-d01b485662eb:/mysqldoc-local/mysqldoc/trunk:11433
b5ec3a16-e900-0410-9ad2-d183a3acac99:/mysqldoc-local/mysqldoc/trunk:12220
bf112a9c-6c03-0410-a055-ad865cd57414:/mysqldoc-local/mysqldoc/trunk:8441
   + 4767c598-dc10-0410-bea0-d01b485662eb:/mysqldoc-local/mysqldoc/trunk:11433
b5ec3a16-e900-0410-9ad2-d183a3acac99:/mysqldoc-local/mysqldoc/trunk:12244
bf112a9c-6c03-0410-a055-ad865cd57414:/mysqldoc-local/mysqldoc/trunk:8441

Property changes on: trunk/tools/de-title-entityize.pl
___________________________________________________________________
Name: svn:executable
   + *


Modified: trunk/make.d/vars-docbook
===================================================================
--- trunk/make.d/vars-docbook	2006-07-14 20:26:49 UTC (rev 2739)
+++ trunk/make.d/vars-docbook	2006-07-15 02:08:48 UTC (rev 2740)
Changed blocks: 1, Lines Added: 7, Lines Deleted: 1; 704 bytes

@@ -245,7 +245,13 @@
 	$(XSL_DIR)/cur-sect-num.xsl \
 	$(XSL_DIR)/map-spchars-remark.xsl
 
-# Driver stylesheet for Docbook -> Texinfo
+# Transform for Docbook -> Texinfo
 
 DBK_TEXI_XSL = $(XSL_DIR)/dbk-texi.xsl
 DBK_TEXI_XSL_DEPS = $(DBK_TEXI_XSL) $(XSL_DIR)/map-spchars-texi.xsl
+
+# Transform that extracts id attribute of each element that has
+# a title and the text of the title
+
+EXTRACT_TITLES_XSL = $(XSL_DIR)/extract-titles.xsl
+EXTRACT_TITLES_XSL_DEPS = $(EXTRACT_TITLES_XSL)


Added: trunk/make.d/xml-titles
===================================================================
--- trunk/make.d/xml-titles	                        (rev 0)
+++ trunk/make.d/xml-titles	2006-07-15 02:08:48 UTC (rev 2740)
Changed blocks: 1, Lines Added: 8, Lines Deleted: 0; 469 bytes

@@ -0,0 +1,8 @@
+# Target rules for transform that extracts id attribute of each
+# element that has a title and the text of the title
+
+%.titles: %.xml $(EXTRACT_TITLES_XSL_DEPS)
+	$(XSLTPROC) --output $@ $(EXTRACT_TITLES_XSL) $<
+
+clean::
+	$(RM) *.titles


Modified: trunk/refman-4.1/Makefile
===================================================================
--- trunk/refman-4.1/Makefile	2006-07-14 20:26:49 UTC (rev 2739)
+++ trunk/refman-4.1/Makefile	2006-07-15 02:08:48 UTC (rev 2740)
Changed blocks: 1, Lines Added: 1, Lines Deleted: 0; 440 bytes

@@ -227,6 +227,7 @@
 include $(MAKE_DIR)/xml-man
 include $(MAKE_DIR)/xml-help
 include $(MAKE_DIR)/xml-remark
+include $(MAKE_DIR)/xml-titles
 include $(MAKE_DIR)/xml-depend
 
 CHAPTERFMT = $(TOOLS_DIR)/chapterfmt.pl


Modified: trunk/refman-5.0/Makefile
===================================================================
--- trunk/refman-5.0/Makefile	2006-07-14 20:26:49 UTC (rev 2739)
+++ trunk/refman-5.0/Makefile	2006-07-15 02:08:48 UTC (rev 2740)
Changed blocks: 1, Lines Added: 1, Lines Deleted: 0; 440 bytes

@@ -227,6 +227,7 @@
 include $(MAKE_DIR)/xml-man
 include $(MAKE_DIR)/xml-help
 include $(MAKE_DIR)/xml-remark
+include $(MAKE_DIR)/xml-titles
 include $(MAKE_DIR)/xml-depend
 
 CHAPTERFMT = $(TOOLS_DIR)/chapterfmt.pl


Modified: trunk/refman-5.1/Makefile
===================================================================
--- trunk/refman-5.1/Makefile	2006-07-14 20:26:49 UTC (rev 2739)
+++ trunk/refman-5.1/Makefile	2006-07-15 02:08:48 UTC (rev 2740)
Changed blocks: 1, Lines Added: 1, Lines Deleted: 0; 440 bytes

@@ -227,6 +227,7 @@
 include $(MAKE_DIR)/xml-man
 include $(MAKE_DIR)/xml-help
 include $(MAKE_DIR)/xml-remark
+include $(MAKE_DIR)/xml-titles
 include $(MAKE_DIR)/xml-depend
 
 CHAPTERFMT = $(TOOLS_DIR)/chapterfmt.pl


Added: trunk/tools/de-title-entityize.pl
===================================================================
--- trunk/tools/de-title-entityize.pl	                        (rev 0)
+++ trunk/tools/de-title-entityize.pl	2006-07-15 02:08:48 UTC (rev 2740)
Changed blocks: 1, Lines Added: 86, Lines Deleted: 0; 3143 bytes

@@ -0,0 +1,86 @@
+#!/usr/bin/perl -w
+# de-title-entityize.pl - helper script for expanding title entities
+# in refman files to the text that the entities stand for.
+
+# ASSUMPTION: Entity definitions are quoted with " and not with '.
+
+# How to use:
+
+# Run this script with a titles.<lang>.ent script as the first argument
+# and the .xml files that you want to modify as the remaining arguments.
+# The script reads the title entities from the first file, and modifies
+# the remaining files by expanding any title entity references to their
+# definitions.  Result: the .xml files will no longer use the title entities.
+
+# Example:
+
+# cd mysqldoc
+# de-title-entityize.pl refman-common/titles.en.ent refman*/*.xml
+
+# Note that in a translation repository, the preceding command is too
+# broad. You must convert each of the refman* directories using the
+# proper titles title (appropriate for the language).  The following
+# example (for the mysqldoc-de repository) converts the German files
+# using the German titles, then everything else with the English titles:
+
+# cd mysqldoc-de
+# de-title-entityize.pl refman-common/titles.de.ent refman*-de/*.xml
+# de-title-entityize.pl refman-common/titles.de.ent refman-common/*-de.xml
+# de-title-entityize.pl refman-common/titles.en.ent refman*/*.xml
+
+# After converting the title entity references, remove the lines
+# from DOCTYPE declarations that refer to the title entities file.
+
+# Who-to-blame:
+# Paul DuBois
+# paul@stripped
+# 2006-07-14
+
+use strict;
+
+die "Usage: $0 title-entity-file xml-file ...\n" unless @ARGV >= 2;
+
+open (IN, $ARGV[0]) or die "$0: Cannot open $ARGV[0] for reading: $!\n";
+{
+  local $/ = undef;
+  $_ = <IN>;            # slurp title entities file as single string
+}
+close (IN);
+shift (@ARGV);
+
+# Extract the entity name/definition pairs and store them in a
+# hash keyed by name.
+
+my %ent = ();
+
+$ent{$1} = $2 while m/<!ENTITY\s+(\S+)\s*["]([^"]+)["]\s*>/g;
+
+# Read each remaining argument, open it, read its contents, expand each
+# title entity reference to its definition, and write the result back
+# out.  In other words, this destructively rewrites each file.
+
+foreach my $file (@ARGV)
+{
+  my $doc;
+  warn "-- ", $file, " --\n";
+  open (IN, $file) or die "$0: Cannot open $file for reading: $!\n";
+  {
+    local $/ = undef;
+    $doc = <IN>;            # slurp input document as single string
+  }
+  close (IN);
+
+  # For each entity:
+  # - yank it out of the title entities file
+  # - generate a command to invoke the replace utility to replace it
+  #   in all .xml files in the current directory
+
+  foreach my $name (keys (%ent))
+  {
+    $doc =~ s/&$name;/$ent{$name}/g;
+  }
+
+  open (OUT, ">$file") or die "$0: Cannot open $file for writing: $!\n";
+  print OUT $doc;
+  close (OUT);
+}


Property changes on: trunk/tools/de-title-entityize.pl
___________________________________________________________________
Name: svn:executable
   + *


Added: trunk/xsl.d/extract-titles.xsl
===================================================================
--- trunk/xsl.d/extract-titles.xsl	                        (rev 0)
+++ trunk/xsl.d/extract-titles.xsl	2006-07-15 02:08:48 UTC (rev 2740)
Changed blocks: 1, Lines Added: 57, Lines Deleted: 0; 1805 bytes

@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+  extract-titles.xsl - Transform that extracts id attribute of each
+  element with a title and the text of the title
+
+  This also includes elements that have a refmiscinfo[@class='refman']
+  element, which we use for the title of manpage sections.
+
+  Produces two-column output: id and title, with a tab between
+-->
+
+<xsl:stylesheet
+  version="1.0"
+  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+<!-- We do not want any XML header -->
+
+<xsl:output method="text" omit-xml-declaration="yes"/>
+
+<!-- variables that contain newline, tab characters -->
+<xsl:variable name="newline" select="'&#xA;'"/>
+<xsl:variable name="tab" select="'&#x9;'"/>
+
+<!--
+  Look for:
+  - <title> elements with a parent that has an id attribute
+  - <refmiscinfo> elements with a class attribute of 'refman' and a
+    grandparent that has an id attribute
+  Write:
+  - id attribute value
+  - normalized content of title
+-->
+
+<xsl:template match="title">
+  <xsl:if test="../@id">
+    <xsl:value-of select="../@id"/>
+    <xsl:value-of select="$tab"/>
+    <xsl:value-of select="normalize-space(.)"/>
+    <xsl:value-of select="$newline"/>
+  </xsl:if>
+</xsl:template>
+
+<xsl:template match="refmiscinfo[@class='refman']">
+  <xsl:if test="../../@id">
+    <xsl:value-of select="../../@id"/>
+    <xsl:value-of select="$tab"/>
+    <xsl:value-of select="normalize-space(.)"/>
+    <xsl:value-of select="$newline"/>
+  </xsl:if>
+</xsl:template>
+
+<xsl:template match="*">
+  <xsl:apply-templates select="*"/>
+</xsl:template>
+
+</xsl:stylesheet>


Thread
svn commit - mysqldoc@docsrva: r2740 - in trunk: . make.d refman-4.1 refman-5.0 refman-5.1 tools xsl.dpaul15 Jul