forrest-svn mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject svn commit: r170274 - /forrest/trunk/plugins/org.apache.forrest.plugin.output.Text/resources/stylesheets/txt/document2txt.xsl
Date Sun, 15 May 2005 22:50:07 GMT
Author: rick
Date: Sun May 15 15:50:06 2005
New Revision: 170274

URL: http://svn.apache.org/viewcvs?rev=170274&view=rev
Log:
Fixes FOR-494.

In addition to fixing the various link elements (a, link, fork, jump)
also handles the icon, img and acronym elements in lists and tables with
proper spacing.


Modified:
    forrest/trunk/plugins/org.apache.forrest.plugin.output.Text/resources/stylesheets/txt/document2txt.xsl

Modified: forrest/trunk/plugins/org.apache.forrest.plugin.output.Text/resources/stylesheets/txt/document2txt.xsl
URL: http://svn.apache.org/viewcvs/forrest/trunk/plugins/org.apache.forrest.plugin.output.Text/resources/stylesheets/txt/document2txt.xsl?rev=170274&r1=170273&r2=170274&view=diff
==============================================================================
--- forrest/trunk/plugins/org.apache.forrest.plugin.output.Text/resources/stylesheets/txt/document2txt.xsl
(original)
+++ forrest/trunk/plugins/org.apache.forrest.plugin.output.Text/resources/stylesheets/txt/document2txt.xsl
Sun May 15 15:50:06 2005
@@ -775,38 +775,186 @@
       <xsl:with-param name="level" select="$level"/>
     </xsl:apply-templates>
 
-    <xsl:text>[Link to: </xsl:text>
-    <xsl:value-of select="@href"/>
-    <xsl:text>]</xsl:text>
+    <xsl:text> </xsl:text>
+    <xsl:call-template name="wrap-text">
+      <xsl:with-param name="text" select="concat('[Link: ', @href, ']')"/>
+      <xsl:with-param name="indent" select="$level * $indent-per-level"/>
+      <xsl:with-param name="width"
+          select="$document-width - ($level * $indent-per-level)"/>
+    </xsl:call-template>
+      
+    <xsl:choose>
+      <xsl:when test="starts-with(following-sibling::text(),' ')">
+        <xsl:text> </xsl:text>
+      </xsl:when>
+      <xsl:when test="starts-with(following-sibling::text(),'&#xa;')">
+        <xsl:text> </xsl:text>
+      </xsl:when>
+      <xsl:otherwise/>
+    </xsl:choose>
   </xsl:template>
 
-  <xsl:template match="icon">
+  <xsl:template match="link|jump|fork|a" mode="in-list">
     <xsl:param name="level" select="'1'"/>
-    <xsl:text> </xsl:text>
-    <xsl:apply-templates>
+    <xsl:apply-templates mode="in-list">
       <xsl:with-param name="level" select="$level"/>
     </xsl:apply-templates>
 
-    <xsl:value-of select="concat('[Icon: ', @alt, '] ')"/>
+    <xsl:text> </xsl:text>
+    <xsl:call-template name="wrap-text">
+      <xsl:with-param name="text" select="concat('[Link: ', @href, ']')"/>
+      <xsl:with-param name="indent" select="$level * $indent-per-level"/>
+      <xsl:with-param name="width"
+          select="$document-width - ($level * $indent-per-level)"/>
+    </xsl:call-template>
+      
+    <xsl:choose>
+      <xsl:when test="starts-with(following-sibling::text(),' ')">
+        <xsl:text> </xsl:text>
+      </xsl:when>
+      <xsl:when test="starts-with(following-sibling::text(),'&#xa;')">
+        <xsl:text> </xsl:text>
+      </xsl:when>
+      <xsl:otherwise/>
+    </xsl:choose>
   </xsl:template>
 
-  <xsl:template match="img">
+  <xsl:template match="icon|img">
     <xsl:param name="level" select="'1'"/>
+
+    <xsl:variable name="type">
+      <xsl:choose>
+        <xsl:when test="local-name()='icon'">Icon: </xsl:when>
+        <xsl:when test="local-name()='img'">Image: </xsl:when>
+        <xsl:otherwise>Unknown: </xsl:otherwise>
+      </xsl:choose>
+    </xsl:variable>
+
+    <xsl:variable name="value">
+      <xsl:choose>
+        <xsl:when test="local-name()='icon'">
+          <xsl:value-of select="@alt"/>
+        </xsl:when>
+        <xsl:when test="local-name()='img'">
+          <xsl:value-of select="@alt"/>
+        </xsl:when>
+        <xsl:otherwise>
+          <xsl:value-of select="local-name()"/>
+        </xsl:otherwise>
+      </xsl:choose>
+    </xsl:variable>
+
     <xsl:text> </xsl:text>
+    <xsl:call-template name="wrap-text">
+      <xsl:with-param name="text" select="concat('[', $type, $value, ']')"/>
+      <xsl:with-param name="indent" select="$level * $indent-per-level"/>
+      <xsl:with-param name="width"
+          select="$document-width - ($level * $indent-per-level)"/>
+    </xsl:call-template>
+      
+    <xsl:choose>
+      <xsl:when test="starts-with(following-sibling::text(),' ')">
+        <xsl:text> </xsl:text>
+      </xsl:when>
+      <xsl:when test="starts-with(following-sibling::text(),'&#xa;')">
+        <xsl:text> </xsl:text>
+      </xsl:when>
+      <xsl:otherwise/>
+    </xsl:choose>
+
+  </xsl:template>
+
+  <xsl:template match="icon|img" mode="in-list">
+    <xsl:param name="level" select="'1'"/>
+
+    <xsl:variable name="type">
+      <xsl:choose>
+        <xsl:when test="local-name()='icon'">Icon: </xsl:when>
+        <xsl:when test="local-name()='img'">Image: </xsl:when>
+        <xsl:otherwise>Unknown: </xsl:otherwise>
+      </xsl:choose>
+    </xsl:variable>
+
+    <xsl:variable name="value">
+      <xsl:choose>
+        <xsl:when test="local-name()='icon'">
+          <xsl:value-of select="@alt"/>
+        </xsl:when>
+        <xsl:when test="local-name()='img'">
+          <xsl:value-of select="@alt"/>
+        </xsl:when>
+        <xsl:otherwise>
+          <xsl:value-of select="local-name()"/>
+        </xsl:otherwise>
+      </xsl:choose>
+    </xsl:variable>
+
+    <xsl:text> </xsl:text>
+    <xsl:call-template name="wrap-text">
+      <xsl:with-param name="text" select="concat('[', $type, $value, ']')"/>
+      <xsl:with-param name="indent" select="$level * $indent-per-level"/>
+      <xsl:with-param name="width"
+          select="$document-width - ($level * $indent-per-level)"/>
+    </xsl:call-template>
+      
+    <xsl:choose>
+      <xsl:when test="starts-with(following-sibling::text(),' ')">
+        <xsl:text> </xsl:text>
+      </xsl:when>
+      <xsl:when test="starts-with(following-sibling::text(),'&#xa;')">
+        <xsl:text> </xsl:text>
+      </xsl:when>
+      <xsl:otherwise/>
+    </xsl:choose>
+
+  </xsl:template>
+
+  <xsl:template match="acronym">
+    <xsl:param name="level" select="'1'"/>
     <xsl:apply-templates>
       <xsl:with-param name="level" select="$level"/>
     </xsl:apply-templates>
 
-    <xsl:text>[Image: </xsl:text>
-    <xsl:value-of select="@alt"/>
-    <xsl:text>]</xsl:text>
+    <xsl:call-template name="wrap-text">
+      <xsl:with-param name="text" select="concat(' (',@title,')')"/>
+      <xsl:with-param name="indent" select="$level * $indent-per-level"/>
+      <xsl:with-param name="width"
+          select="$document-width - ($level * $indent-per-level)"/>
+    </xsl:call-template>
+      
+    <xsl:choose>
+      <xsl:when test="starts-with(following-sibling::text(),' ')">
+        <xsl:text> </xsl:text>
+      </xsl:when>
+      <xsl:when test="starts-with(following-sibling::text(),'&#xa;')">
+        <xsl:text> </xsl:text>
+      </xsl:when>
+      <xsl:otherwise/>
+    </xsl:choose>
   </xsl:template>
 
-  <xsl:template match="acronym/@title">
+  <xsl:template match="acronym" mode="in-list">
     <xsl:param name="level" select="'1'"/>
-    <xsl:attribute name="title">
-      <xsl:value-of select="normalize-space(.)"/>
-    </xsl:attribute>
+    <xsl:apply-templates>
+      <xsl:with-param name="level" select="$level"/>
+    </xsl:apply-templates>
+
+    <xsl:call-template name="wrap-text">
+      <xsl:with-param name="text" select="concat(' (',@title,')')"/>
+      <xsl:with-param name="indent" select="$level * $indent-per-level"/>
+      <xsl:with-param name="width"
+          select="$document-width - ($level * $indent-per-level)"/>
+    </xsl:call-template>
+      
+    <xsl:choose>
+      <xsl:when test="starts-with(following-sibling::text(),' ')">
+        <xsl:text> </xsl:text>
+      </xsl:when>
+      <xsl:when test="starts-with(following-sibling::text(),'&#xa;')">
+        <xsl:text> </xsl:text>
+      </xsl:when>
+      <xsl:otherwise/>
+    </xsl:choose>
   </xsl:template>
 
   <xsl:template match="version">



Mime
View raw message