Added copy to project source of modified version of Jeni's
authorMichael Smith <xmldoc@users.sourceforge.net>
Sat, 30 Jun 2007 04:17:51 +0000 (04:17 +0000)
committerMichael Smith <xmldoc@users.sourceforge.net>
Sat, 30 Jun 2007 04:17:51 +0000 (04:17 +0000)
markup.xsl stylesheet; source is in the contrib module but
annoying/stupid to require others to have to build it from there.

releasetools/Variables.mk
releasetools/modified-markup.xsl [new file with mode: 0644]
releasetools/svnlog2docbook.xsl

index 586a56941b8224558a8cf73004e22015c6114b20..9a6ce59dd43c43ec20d24a68344b6aa7526358d6 100644 (file)
@@ -54,7 +54,7 @@ DOC_LINK_STYLE=$(DOCBUILD_STYLESHEETS)/doc-link-docbook.xsl
 DBX_STYLE=$(DOCBUILD_STYLESHEETS)/dblatex-release-notes.xsl
 
 # MARKUP_XSL is a modified version of Jeni Tennison's "Markup Utility"
-MARKUP_XSL=$(DOCBOOK_SVN)/contrib/tools/tennison/modified-markup.xsl
+MARKUP_XSL=$(DOCBOOK_SVN)/releasetools/modified-markup.xsl
 
 # stylesheet used in taking XML output from "svn log" and using it
 # to generate NEWS file(s) and releases notes
diff --git a/releasetools/modified-markup.xsl b/releasetools/modified-markup.xsl
new file mode 100644 (file)
index 0000000..fd4354c
--- /dev/null
@@ -0,0 +1,235 @@
+<?xml version="1.0"?>
+<!-- * -->
+<!-- * This is a MODIFIED version of markup.xsl; original is at: -->
+<!-- * -->
+<!-- *   http://www.jenitennison.com/xslt/utilities/markup.xsl-->
+<!-- * -->
+<!-- * This modified version of markup.xsl is used as part of -->
+<!-- * the internal build of the DocBook Project XSL Stylesheets -->
+<!-- * -->
+<!-- *   http://docbook.sourceforge.net/release/xsl/current/ -->
+<!-- * -->
+<!-- * Copyright 2007 The DocBook Project <docbook-developers@sf.net> -->
+<!-- * -->
+<!-- * This modified version may be redistributed and modified -->
+<!-- * under the same terms as the original (see detals below) -->
+<!--
+    markup.xsl - an XSLT stylesheet to markup words and phrases in text
+    Copyright (C) 2000  Dr Jeni Tennison
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+    
+    Dr Jeni Tennison - http://www.jenitennison.com - mail@jenitennison.com
+-->
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+
+
+<xsl:variable name="punctuation">,:;!? 
+
+  "'()[]&lt;&gt;{}/=*</xsl:variable>
+<xsl:variable name="lowercase" select="'abcdefghijklmnopqrstuvwxyz'"/>
+<xsl:variable name="uppercase" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>
+
+<xsl:template name="markup">
+  <xsl:param name="text"/>
+  <xsl:param name="phrases"/>
+  <xsl:param name="words-only" select="true()"/>
+  <xsl:param name="first-only" select="false()"/>
+  <xsl:param name="match-case" select="false()"/>
+  <xsl:variable name="lcase-text" select="translate($text, $uppercase, $lowercase)"/>
+  <xsl:variable name="included-phrases" select="$phrases[($match-case and contains($text, .)) or                                  (not($match-case) and contains($lcase-text,                                                                 translate(., $uppercase, $lowercase)))]"/>
+  <xsl:choose>
+       <xsl:when test="$included-phrases">
+                 <xsl:for-each select="$included-phrases">
+                       <xsl:sort select="string-length(.)" data-type="number" order="descending"/>
+                       <xsl:if test="position() = 1">
+                                 <xsl:variable name="phrase" select="."/>
+                                 <xsl:variable name="word" select="string($phrase)"/>
+                                 <xsl:variable name="remaining" select="$included-phrases[. != $word]"/>
+                                 <xsl:variable name="match">
+                                       <xsl:choose>
+                                               <xsl:when test="$words-only">
+                                                       <xsl:call-template name="get-first-word">
+                                                               <xsl:with-param name="text" select="$text"/>
+                                                               <xsl:with-param name="word" select="$word"/>
+                                                               <xsl:with-param name="match-case" select="$match-case"/>
+                                                       </xsl:call-template>
+                                                 </xsl:when>
+                                                 <xsl:otherwise><xsl:value-of select="$word"/></xsl:otherwise>
+                                               </xsl:choose>
+                                 </xsl:variable>
+                                 <xsl:choose>
+                                       <xsl:when test="string($match)">
+                                               <xsl:variable name="first">
+                                                       <xsl:if test="contains($punctuation, substring($match, 1, 1))"><xsl:value-of select="substring($match, 1, 1)"/></xsl:if>
+                                               </xsl:variable>
+                                               <xsl:variable name="last">
+                                                       <xsl:if test="contains($punctuation, substring($match, string-length($match)))"><xsl:value-of select="substring($match, string-length($match))"/></xsl:if>                                                      
+                                               </xsl:variable>
+                                               <xsl:variable name="replace" select="substring($match, string-length($first) + 1,                                                                string-length($match) - (string-length($first) + string-length($last)))"/>
+                                                 <xsl:choose>
+                                                   <xsl:when test="$remaining">
+                                               <xsl:call-template name="markup">
+                                                 <xsl:with-param name="text" select="concat(substring-before($text, $match), $first)"/>
+                                                 <xsl:with-param name="phrases" select="$remaining"/>
+                                                                         <xsl:with-param name="words-only" select="$words-only"/>
+                                                                         <xsl:with-param name="first-only" select="$first-only"/>
+                                                                         <xsl:with-param name="match-case" select="$match-case"/>
+                                               </xsl:call-template>
+                                               <xsl:apply-templates select="$phrase" mode="markup">
+                                                       <xsl:with-param name="word" select="$replace"/>
+                                               </xsl:apply-templates>
+                                                     <xsl:choose>
+                                                       <xsl:when test="$first-only">
+                                                               <xsl:call-template name="markup">
+                                                                 <xsl:with-param name="text" select="concat($last, substring-after($text, $match))"/>
+                                                                 <xsl:with-param name="phrases" select="$remaining"/>
+                                                                                         <xsl:with-param name="words-only" select="$words-only"/>
+                                                                                         <xsl:with-param name="first-only" select="$first-only"/>
+                                                                                         <xsl:with-param name="match-case" select="$match-case"/>
+                                                               </xsl:call-template>
+                                                             </xsl:when>
+                                                             <xsl:otherwise>
+                                                               <xsl:call-template name="markup">
+                                                                 <xsl:with-param name="text" select="concat($last, substring-after($text, $match))"/>
+                                                                 <xsl:with-param name="phrases" select="$included-phrases"/>
+                                                                                         <xsl:with-param name="words-only" select="$words-only"/>
+                                                                                         <xsl:with-param name="first-only" select="$first-only"/>
+                                                                                         <xsl:with-param name="match-case" select="$match-case"/>
+                                                               </xsl:call-template>
+                                                             </xsl:otherwise>
+                                                           </xsl:choose>
+                                                   </xsl:when>
+                                                   <xsl:otherwise>
+                                                     <xsl:value-of select="concat(substring-before($text, $match), $first)"/>
+                                               <xsl:apply-templates select="$phrase" mode="markup">
+                                                       <xsl:with-param name="word" select="$replace"/>
+                                               </xsl:apply-templates>
+                                                     <xsl:value-of select="concat($last, substring-after($text, $match))"/>
+                                                   </xsl:otherwise>
+                                                 </xsl:choose>
+                                               </xsl:when>
+                                               <xsl:otherwise>
+                                                       <xsl:choose>
+                                                               <xsl:when test="$remaining">
+                                                                       <xsl:call-template name="markup">
+                                                                               <xsl:with-param name="text" select="$text"/>
+                                                                               <xsl:with-param name="phrases" select="$remaining"/>
+                                                                         <xsl:with-param name="words-only" select="$words-only"/>
+                                                                         <xsl:with-param name="first-only" select="$first-only"/>
+                                                                         <xsl:with-param name="match-case" select="$match-case"/>
+                                                                       </xsl:call-template>
+                                                               </xsl:when>
+                                                               <xsl:otherwise><xsl:value-of select="$text"/></xsl:otherwise>
+                                                       </xsl:choose>
+                                               </xsl:otherwise>
+                                       </xsl:choose>
+                               </xsl:if>
+                       </xsl:for-each>
+               </xsl:when>
+       <xsl:otherwise><xsl:value-of select="$text"/></xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template name="get-first-word">
+       <xsl:param name="text"/>
+       <xsl:param name="word"/>
+       <xsl:param name="match-case" select="false()"/>
+       <xsl:choose>
+               <xsl:when test="$match-case">
+                       <xsl:call-template name="get-first-word-matching-case">
+                               <xsl:with-param name="text" select="$text"/>
+                               <xsl:with-param name="word" select="$word"/>
+                       </xsl:call-template>
+               </xsl:when>
+               <xsl:otherwise>
+                       <xsl:call-template name="get-first-word-non-matching-case">
+                               <xsl:with-param name="text" select="$text"/>
+                               <xsl:with-param name="word" select="$word"/>
+                       </xsl:call-template>
+               </xsl:otherwise>
+       </xsl:choose>
+</xsl:template>
+
+<xsl:template name="get-first-word-matching-case">
+       <xsl:param name="text"/>
+       <xsl:param name="word"/>
+       <xsl:variable name="before" select="substring-before($text, $word)"/>
+       <xsl:variable name="after" select="substring-after($text, $word)"/>
+       <xsl:variable name="punc-before" select="contains($punctuation, substring($before, string-length($before), 1))"/>
+       <xsl:variable name="punc-after" select="contains($punctuation, substring($after, 1, 1))"/>
+       <xsl:choose>
+               <xsl:when test="not(contains($text, $word))"/>
+               <xsl:when test="$punc-before and $punc-after">
+                       <xsl:value-of select="substring($text, string-length($before), string-length($word) + 2)"/>
+               </xsl:when>
+               <xsl:when test="$text = $word">
+                       <xsl:value-of select="$word"/>
+               </xsl:when>
+               <xsl:when test="$punc-after and starts-with($text, $word)">
+                       <xsl:value-of select="substring($text, 1, string-length($word) + 1)"/>
+               </xsl:when>
+               <xsl:when test="$punc-before and not(substring-after($text, $word))">
+                       <xsl:value-of select="substring($text, string-length($text) - string-length($word))"/>
+               </xsl:when>
+               <xsl:when test="contains($after, $word)">
+                       <xsl:call-template name="get-first-word-matching-case">
+                               <xsl:with-param name="text" select="$after"/>
+                               <xsl:with-param name="word" select="$word"/>
+                       </xsl:call-template>
+               </xsl:when>
+       </xsl:choose>   
+</xsl:template>
+
+<xsl:template name="get-first-word-non-matching-case">
+       <xsl:param name="text"/>
+       <xsl:param name="word"/>
+       <xsl:variable name="lcase-text" select="translate($text, $uppercase, $lowercase)"/>
+       <xsl:variable name="lcase-word" select="translate($word, $uppercase, $lowercase)"/>
+       <xsl:variable name="before" select="substring($text, 1, string-length(substring-before($lcase-text, $lcase-word)))"/>
+       <xsl:variable name="after" select="substring($text, string-length($before) + string-length($word) + 1)"/>
+       <xsl:variable name="punc-before" select="contains($punctuation, substring($before, string-length($before), 1))"/>
+       <xsl:variable name="punc-after" select="contains($punctuation, substring($after, 1, 1))"/>
+       <xsl:choose>
+               <xsl:when test="not(contains($lcase-text, $lcase-word))"/>
+               <xsl:when test="$punc-before and $punc-after">
+                       <xsl:value-of select="substring($text, string-length($before), string-length($word) + 2)"/>
+               </xsl:when>
+               <xsl:when test="$lcase-text = $lcase-word">
+                       <xsl:value-of select="$text"/>
+               </xsl:when>
+               <xsl:when test="$punc-after and starts-with($lcase-text, $lcase-word)">
+                       <xsl:value-of select="substring($text, 1, string-length($word) + 1)"/>
+               </xsl:when>
+               <xsl:when test="$punc-before and not(substring-after($lcase-text, $lcase-word))">
+                       <xsl:value-of select="substring($text, string-length($text) - string-length($word))"/>
+               </xsl:when>
+               <xsl:when test="contains(translate($after, $uppercase, $lowercase), $lcase-word)">
+                       <xsl:call-template name="get-first-word-non-matching-case">
+                               <xsl:with-param name="text" select="$after"/>
+                               <xsl:with-param name="word" select="$word"/>
+                       </xsl:call-template>
+               </xsl:when>
+       </xsl:choose>
+</xsl:template>
+
+<xsl:template match="*" mode="markup">
+       <xsl:param name="word"/>
+       <a href="{@id}.html">
+               <xsl:value-of select="$word"/>
+       </a>
+</xsl:template>
+
+</xsl:stylesheet>
index a7bc872f85f5919caa6c5b8e40ed083816437517..1ba25bc51e70476b2934787cdf758a4b3ba0b26a 100644 (file)
@@ -19,7 +19,7 @@
   <!-- * -->
   <!-- *   http://www.jenitennison.com/xslt/utilities/markup.html -->
   <!-- * -->
-  <xsl:import href="../contrib/tools/tennison/modified-markup.xsl" />
+  <xsl:import href="./modified-markup.xsl" />
   <xsl:include href="../xsl/lib/lib.xsl" />
 
   <!-- * RepositoryRoot is the same as what "svn info" shows -->