changeset 4047:3e706fcccbf3 stable-1.0

Merge of r3996, r3998, r4015, r4023, r4025, r4026, r4027: Changes log build procedure fixes: *) using sed instead of perl *) support <br/> in the middle of input *) fixed "<br>" lookup (eliminates the need in " <br/>" hacks) *) fixed maximum length for unbreakable input *) fixed space lookup (allows a space at column 77 to break a line) *) traling spaces removal in text CHANGES files.
author Igor Sysoev <igor@sysoev.ru>
date Mon, 29 Aug 2011 13:57:43 +0000
parents fd6f821d3fa2
children f872a86a655c
files docs/GNUmakefile docs/xsls/changes.xsls docs/xslt/changes.xslt
diffstat 3 files changed, 67 insertions(+), 32 deletions(-) [+]
line wrap: on
line diff
--- a/docs/GNUmakefile
+++ b/docs/GNUmakefile
@@ -6,20 +6,21 @@ TEMP=	tmp
 CP=	$(HOME)/java
 
 define  XSLScript
-	javavm -cp $(CP)/xsls/saxon.jar:$(CP)/xsls/xsls.jar		\
+	java -cp $(CP)/xsls/saxon.jar:$(CP)/xsls/xsls.jar		\
 		com.pault.StyleSheet					\
 		-x com.pault.XX -y com.pault.XX				\
-	$(1) docs/xsls/dump.xsls					\
-	| awk 'BEGIN{e=0}/^\n*$$/{e=1;next}{if(e){print"";e=0};print}' > $(2)
+		$(1) docs/xsls/dump.xsls				\
+	| sed 's/ *$$//;/^ *$$/N;/\n *$$/D' > $(2)
 
 	if [ ! -s $(2) ]; then rm $(2); fi; test -s $(2)
 endef
 
 define  XSLT
-	xsltproc $(shell echo $4					\
+	xmllint --noout --valid $2;					\
+	xsltproc -o $3							\
+		$(shell echo $4						\\
 		| sed -e "s/\([^= ]*\)=\([^= ]*\)/--param \1 \"'\2'\"/g") \
-		$3 $1							\
-	> $(HTML)/$(strip $(2))
+		$1 $2
 endef
 
 
--- a/docs/xsls/changes.xsls
+++ b/docs/xsls/changes.xsls
@@ -64,10 +64,16 @@ X:template para(prefix) = "para" {
 X:template wrap(text, prefix) {
     X:if "$text" {
         X:var offset = {
-            X:if "starts-with($text, concat($br, ' '))" {
-                !{string-length($br) + 2}
-            } else {
-                1
+            X:choose {
+                X:when "starts-with($text, concat($br, ' '))" {
+                    !{string-length($br) + 2}
+                }
+                X:when "starts-with($text, $br)" {
+                    !{string-length($br) + 1}
+                }
+                X:otherwise {
+                    1
+                }
             }
         }
 
@@ -79,7 +85,8 @@ X:template wrap(text, prefix) {
 
         !{$prefix}
 
-        !{translate(substring($text, $offset, $length), '&#xA0;', ' ')}
+        !{normalize-space(translate(substring($text, $offset, $length),
+                                    '&#xA0;', ' '))}
 
         X:text {&#10;}
 
@@ -89,20 +96,23 @@ X:template wrap(text, prefix) {
 
 
 X:template length(text, prefix, length) {
-    X:var break = "substring-before(substring($text, 1, $length - $prefix),
+    X:var break = "substring-before(substring($text, 1,
+                                    $length - $prefix + string-length($br)),
                                     $br)"
 
     X:choose {
         X:when "$break" { !{string-length($break)} }
 
-        X:when "$length = 0" { !{$max} }
+        X:when "$length = 0" { !{$max - $prefix} }
 
-        X:when "string-length($text) + $prefix &lt;= $length
-                or substring($text, $length - $prefix, 1) = ' '"
-        {
+        X:when "string-length($text) + $prefix &lt;= $length" {
             !{$length - $prefix}
         }
 
+        X:when "substring($text, $length - $prefix + 1, 1) = ' '" {
+            !{$length - $prefix + 1}
+        }
+
         X:otherwise {
             !length(text = "$text", prefix = "$prefix", length = "$length - 1")
         }
--- a/docs/xslt/changes.xslt
+++ b/docs/xslt/changes.xslt
@@ -4,23 +4,29 @@
    <xsl:output encoding="koi8-r" method="text"/>
 
    <xsl:param select="'en'" name="lang"/>
+
    <xsl:param select="'../xml/change_log_conf.xml'" name="configuration"/>
 
    <xsl:variable select="document($configuration)/configuration" name="conf"/>
+
    <xsl:variable select="$conf/start" name="start"/>
+
    <xsl:variable select="$conf/indent" name="indent"/>
+
    <xsl:variable select="$conf/length" name="max"/>
+
    <xsl:variable name="br">&lt;br&gt;</xsl:variable>
-   
+
    <xsl:template match="/">
       <xsl:apply-templates select="change_log"/>
    </xsl:template>
-   
+
    <xsl:template match="change_log">
       <xsl:apply-templates select="changes"/>
    </xsl:template>
-   
+
    <xsl:template match="changes">
+
       <xsl:text>
 </xsl:text>
 
@@ -31,10 +37,14 @@
       </xsl:if>
 
       <xsl:if test="$lang='en'">
+
          <xsl:value-of select="substring(@date, 1, 2)"/>
+
          <xsl:value-of select="$conf/changes[@lang=$lang]/month[number(substring(current()/@date,                                                             4, 2))]"/>
+
          <xsl:value-of select="substring(@date, 7, 4)"/>
       </xsl:if>
+
       <xsl:text>
 </xsl:text>
 
@@ -44,8 +54,8 @@
 </xsl:text>
    </xsl:template>
 
-   
    <xsl:template match="change">
+
       <xsl:variable select="$conf/changes[@lang=$lang]/*[local-name(.)=current()/@type]" name="prefix"/>
 
       <xsl:variable name="postfix">
@@ -59,9 +69,9 @@
       </xsl:apply-templates>
    </xsl:template>
 
-   
    <xsl:template match="para" name="para">
       <xsl:param name="prefix"/>
+
       <xsl:variable name="text">
          <xsl:apply-templates/>
       </xsl:variable>
@@ -73,6 +83,7 @@
          <xsl:with-param select="normalize-space($text)" name="text"/>
          <xsl:with-param name="prefix">
             <xsl:choose>
+
                <xsl:when test="position() = 1">
                   <xsl:value-of select="$prefix"/>
                </xsl:when>
@@ -84,31 +95,38 @@
       </xsl:call-template>
    </xsl:template>
 
-   
    <xsl:template name="wrap">
       <xsl:param name="text"/>
       <xsl:param name="prefix"/>
+
       <xsl:if test="$text">
+
          <xsl:variable name="offset">
+
             <xsl:choose>
                <xsl:when test="starts-with($text, concat($br, ' '))">
                   <xsl:value-of select="string-length($br) + 2"/>
                </xsl:when>
+               <xsl:when test="starts-with($text, $br)">
+                  <xsl:value-of select="string-length($br) + 1"/>
+               </xsl:when>
                <xsl:otherwise>
-                1</xsl:otherwise>
+                    1</xsl:otherwise>
             </xsl:choose>
          </xsl:variable>
 
          <xsl:variable name="length">
+
             <xsl:call-template name="length">
                <xsl:with-param select="substring($text, $offset)" name="text"/>
                <xsl:with-param select="string-length($prefix)" name="prefix"/>
                <xsl:with-param select="$max" name="length"/>
             </xsl:call-template>
          </xsl:variable>
+
          <xsl:value-of select="$prefix"/>
 
-         <xsl:value-of select="translate(substring($text, $offset, $length), ' ', ' ')"/>
+         <xsl:value-of select="normalize-space(translate(substring($text, $offset, $length),                                     ' ', ' '))"/>
 
          <xsl:text>
 </xsl:text>
@@ -119,23 +137,29 @@
          </xsl:call-template>
       </xsl:if>
    </xsl:template>
-   
+
    <xsl:template name="length">
       <xsl:param name="text"/>
       <xsl:param name="prefix"/>
       <xsl:param name="length"/>
-      <xsl:variable select="substring-before(substring($text, 1, $length - $prefix),                                     $br)" name="break"/>
+
+      <xsl:variable select="substring-before(substring($text, 1,                                     $length - $prefix + string-length($br)),                                     $br)" name="break"/>
+
       <xsl:choose>
          <xsl:when test="$break">
             <xsl:value-of select="string-length($break)"/>
          </xsl:when>
          <xsl:when test="$length = 0">
-            <xsl:value-of select="$max"/>
+            <xsl:value-of select="$max - $prefix"/>
          </xsl:when>
-         <xsl:when test="string-length($text) + $prefix &lt;= $length                 or substring($text, $length - $prefix, 1) = ' '">
+         <xsl:when test="string-length($text) + $prefix &lt;= $length">
             <xsl:value-of select="$length - $prefix"/>
          </xsl:when>
+         <xsl:when test="substring($text, $length - $prefix + 1, 1) = ' '">
+            <xsl:value-of select="$length - $prefix + 1"/>
+         </xsl:when>
          <xsl:otherwise>
+
             <xsl:call-template name="length">
                <xsl:with-param select="$text" name="text"/>
                <xsl:with-param select="$prefix" name="prefix"/>
@@ -145,14 +169,14 @@
       </xsl:choose>
    </xsl:template>
 
-   
    <xsl:template match="at">@</xsl:template>
-   
+
    <xsl:template match="br">
       <xsl:value-of select="$br"/>
    </xsl:template>
-   
+
    <xsl:template match="nobr">
       <xsl:value-of select="translate(., ' ', ' ')"/>
    </xsl:template>
-</xsl:stylesheet>
\ No newline at end of file
+
+</xsl:stylesheet>