You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by cd...@apache.org on 2006/10/02 15:08:28 UTC
svn commit: r452024 -
/lenya/trunk/src/modules/opendocument/xslt/common/odt_to_xhtml.xsl
Author: cdupoirieux
Date: Mon Oct 2 06:08:27 2006
New Revision: 452024
URL: http://svn.apache.org/viewvc?view=rev&rev=452024
Log:
It was a little more complicated than I thought.
Ok, now the styles management is Ok (em, sub, sup and strong at least...)
I am going to work on the boxes (Warnings, Notes...)
Modified:
lenya/trunk/src/modules/opendocument/xslt/common/odt_to_xhtml.xsl
Modified: lenya/trunk/src/modules/opendocument/xslt/common/odt_to_xhtml.xsl
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/opendocument/xslt/common/odt_to_xhtml.xsl?view=diff&rev=452024&r1=452023&r2=452024
==============================================================================
--- lenya/trunk/src/modules/opendocument/xslt/common/odt_to_xhtml.xsl (original)
+++ lenya/trunk/src/modules/opendocument/xslt/common/odt_to_xhtml.xsl Mon Oct 2 06:08:27 2006
@@ -310,52 +310,100 @@
</xsl:template>
-->
<!-- Otherwise -->
-<xsl:template match="text:p">
- <div class="{translate(@text:style-name,'.','_')}">
- <xsl:apply-templates/>
- <xsl:if test="count(node())=0"><br /></xsl:if>
- </div>
-</xsl:template>
-
-<!-- Case of the Code style -->
-<xsl:template match="text:span[@text:style-name='Forrest_3a__20_Code']">
- <code>
- <xsl:apply-templates/>
- </code>
-</xsl:template>
-
-<!-- Case of the below style -->
-<xsl:template match="text:span[@text:style-name='Forrest_3a__20_Below']">
- <sub>
- <xsl:apply-templates/>
- </sub>
-</xsl:template>
-<!-- Case of the above style -->
-<xsl:template match="text:span[@text:style-name='Forrest_3a__20_Above']">
- <sup>
- <xsl:apply-templates/>
- </sup>
-</xsl:template>
-
-<!-- Case of the strong style -->
-<xsl:template match="text:span[@text:style-name='Strong_20_Emphasis']">
- <strong>
- <xsl:apply-templates/>
- </strong>
-</xsl:template>
-
-<!-- Case of the emphasys style - generally rendered with Italic -->
-<xsl:template match="text:span[@text:style-name='Emphasis']">
- <em>
+<!-- FIXME : An idea should be to add a class attribute to <p> in order to be able to keep the original
+ layout. Maybe depending on a properties keepLayout=True. -->
+<xsl:template match="text:p">
+ <p>
<xsl:apply-templates/>
- </em>
+ </p>
</xsl:template>
<xsl:template match="text:span">
- <span class="{translate(@text:style-name,'.','_')}">
- <xsl:apply-templates/>
- </span>
+ <xsl:variable name="styleName" select="@text:style-name"/>
+ <xsl:apply-templates select="//office:document-content/office:automatic-styles/style:style[@style:name=$styleName]/style:text-properties/@*[last()]">
+ <xsl:with-param name="text" select="./text()"/>
+ </xsl:apply-templates>
+ <!--span class="{translate(@text:style-name,'.','_')}">
+ <xsl:apply-templates/>
+ </span-->
+</xsl:template>
+
+<xsl:template match="style:text-properties/@*">
+ <xsl:param name="text"/>
+ <xsl:param name="indStyle" select="count(../@*)"/>
+ <xsl:choose>
+ <!-- Case of the emphasys style - generally rendered with Italic -->
+ <xsl:when test="name()='fo:font-style' and .='italic'">
+ <xsl:call-template name="layout-span">
+ <xsl:with-param name="text" select="$text"/>
+ <xsl:with-param name="indStyle" select="$indStyle"/>
+ <xsl:with-param name="tag" select="'em'"/>
+ </xsl:call-template>
+ </xsl:when>
+ <!-- Case of the strong style -->
+ <xsl:when test="name()='fo:font-weight' and .='bold'">
+ <xsl:call-template name="layout-span">
+ <xsl:with-param name="text" select="$text"/>
+ <xsl:with-param name="indStyle" select="$indStyle"/>
+ <xsl:with-param name="tag" select="'strong'"/>
+ </xsl:call-template>
+ </xsl:when>
+ <!-- Case of the exponent style -->
+ <xsl:when test="name()='style:text-position' and starts-with(.,'super')">
+ <xsl:call-template name="layout-span">
+ <xsl:with-param name="text" select="$text"/>
+ <xsl:with-param name="indStyle" select="$indStyle"/>
+ <xsl:with-param name="tag" select="'sup'"/>
+ </xsl:call-template>
+ </xsl:when>
+ <!-- Case of the subscript style -->
+ <xsl:when test="name()='style:text-position' and starts-with(.,'sub')">
+ <xsl:call-template name="layout-span">
+ <xsl:with-param name="text" select="$text"/>
+ <xsl:with-param name="indStyle" select="$indStyle"/>
+ <xsl:with-param name="tag" select="'sub'"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:call-template name="text-span">
+ <xsl:with-param name="text" select="$text"/>
+ <xsl:with-param name="indStyle" select="$indStyle"/>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template name="layout-span">
+ <xsl:param name="text"/>
+ <xsl:param name="indStyle"/>
+ <xsl:param name="tag" select="NONE"/>
+ <!-- Add a layout tag for a span -->
+ <xsl:if test="not($tag='NONE')">
+ <xsl:element name="{$tag}">
+ <xsl:call-template name="text-span">
+ <xsl:with-param name="text" select="$text"/>
+ <xsl:with-param name="indStyle" select="$indStyle"/>
+ </xsl:call-template>
+ </xsl:element>
+ </xsl:if>
+</xsl:template>
+
+<xsl:template name="text-span">
+ <xsl:param name="text"/>
+ <xsl:param name="indStyle" select="last()"/>
+ <!-- Add the text of a span or continue to browse the styles -->
+ <xsl:choose>
+ <xsl:when test="$indStyle=1">
+ <xsl:apply-templates select="$text"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates select="../@*[number($indStyle)-1]">
+ <xsl:with-param name="text" select="$text"/>
+ <xsl:with-param name="indStyle" select="number($indStyle)-1"/>
+ </xsl:apply-templates>
+ </xsl:otherwise>
+ </xsl:choose>
</xsl:template>
<xsl:template match="text:h">
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org