You are viewing a plain text version of this content. The canonical link for it is here.
Posted to svn@forrest.apache.org by rg...@apache.org on 2005/09/14 23:18:08 UTC
svn commit: r280941 -
/forrest/trunk/plugins/org.apache.forrest.plugin.input.OpenOffice.org/resources/stylesheets/openoffice-writer2forrest.xsl
Author: rgardler
Date: Wed Sep 14 14:18:00 2005
New Revision: 280941
URL: http://svn.apache.org/viewcvs?rev=280941&view=rev
Log:
better handle indentation in source sections (thanks to Eduardo Milln)
Modified:
forrest/trunk/plugins/org.apache.forrest.plugin.input.OpenOffice.org/resources/stylesheets/openoffice-writer2forrest.xsl
Modified: forrest/trunk/plugins/org.apache.forrest.plugin.input.OpenOffice.org/resources/stylesheets/openoffice-writer2forrest.xsl
URL: http://svn.apache.org/viewcvs/forrest/trunk/plugins/org.apache.forrest.plugin.input.OpenOffice.org/resources/stylesheets/openoffice-writer2forrest.xsl?rev=280941&r1=280940&r2=280941&view=diff
==============================================================================
--- forrest/trunk/plugins/org.apache.forrest.plugin.input.OpenOffice.org/resources/stylesheets/openoffice-writer2forrest.xsl (original)
+++ forrest/trunk/plugins/org.apache.forrest.plugin.input.OpenOffice.org/resources/stylesheets/openoffice-writer2forrest.xsl Wed Sep 14 14:18:00 2005
@@ -72,31 +72,62 @@
</sub>
</xsl:template>
- <!--+
- | Source
- +-->
- <xsl:template match="text:p[@text:style-name='Forrest: Source']">
+<!--+
+ | Source
+ +-->
+ <xsl:template match="text:p[@text:style-name='Forrest: Source' and (preceding-sibling::node()[1]/@text:style-name='Forrest: Source')]">
+ <!-- Two subsequnt paragraphs should be considered a single source section -->
+ </xsl:template>
+
+
+
+ <xsl:template name="forrest-source" match="text:p[@text:style-name='Forrest: Source' and not (preceding-sibling::node()[1]/@text:style-name='Forrest: Source')]">
<source>
-<xsl:text>
-</xsl:text>
- <xsl:apply-templates/>
-<xsl:text>
-</xsl:text>
-
+ <xsl:text>
+ </xsl:text>
+ <xsl:apply-templates />
+ <xsl:for-each select="following-sibling::*[1][@text:style-name='Forrest: Source']">
+ <xsl:call-template name="forrest-source-output" />
+ </xsl:for-each>
+ <xsl:text>
+ </xsl:text>
</source>
- </xsl:template>
+ </xsl:template>
+
<xsl:template match="text:p[@text:style-name='Forrest: Source']/text:line-break">
<br/>
</xsl:template>
-
- <!--+
- | Warning
- +-->
- <xsl:template match="text:p[@text:style-name='Forrest: Warning']">
- <warning>
- <xsl:apply-templates/>
- </warning>
+
+ <!-- When the indentation is formed by spaces -->
+ <xsl:template match="text:p[@text:style-name='Forrest: Source']/text:s">
+ <xsl:call-template name="forrest-source-indent">
+ <xsl:with-param name="len"><xsl:value-of select="@text:c" /></xsl:with-param>
+ </xsl:call-template>
+ </xsl:template>
+
+ <!-- When the indentation is formed by tab-stops -->
+ <xsl:template match="text:p[@text:style-name='Forrest: Source']/text:tab-stop">
+ <xsl:call-template name="forrest-source-indent">
+ <xsl:with-param name="len">4</xsl:with-param>
+ </xsl:call-template>
</xsl:template>
+
+ <xsl:template name="forrest-source-indent">
+ <xsl:param name="len"></xsl:param>
+ <!-- Limited to 100 indents, but it works!-->
+ <xsl:variable name="padding">                                                                                                    </xsl:variable>
+ <xsl:value-of select="substring($padding,1,$len)" />
+ </xsl:template>
+
+
+ <xsl:template name="forrest-source-output">
+ <xsl:text>
+ </xsl:text>
+ <xsl:apply-templates />
+ <xsl:for-each select="following-sibling::*[1][@text:style-name='Forrest: Source']">
+ <xsl:call-template name="forrest-source-output" />
+ </xsl:for-each>
+ </xsl:template>
<!--+
| Fixme