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/12 16:58:02 UTC
svn commit: r463265 -
/lenya/trunk/src/modules/opendocument/xslt/common/odt_to_xhtml.xsl
Author: cdupoirieux
Date: Thu Oct 12 07:58:01 2006
New Revision: 463265
URL: http://svn.apache.org/viewvc?view=rev&rev=463265
Log:
RollBack of modifications which should be applied in Forrest...
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=463265&r1=463264&r2=463265
==============================================================================
--- lenya/trunk/src/modules/opendocument/xslt/common/odt_to_xhtml.xsl (original)
+++ lenya/trunk/src/modules/opendocument/xslt/common/odt_to_xhtml.xsl Thu Oct 12 07:58:01 2006
@@ -73,6 +73,8 @@
<xsl:variable name="lineBreak"><xsl:text>
</xsl:text></xsl:variable>
+<xsl:key name="listTypes" match="text:list-style" use="@style:name"/>
+
<xsl:template match="/office:document-content">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
@@ -271,134 +273,17 @@
Yes, paragraphs in ODT really produce a <div> in XHTML,
because an ODT paragraph has no extra line spacing.
-->
-<!-- FIXME : this is not XHTML -->
-<!-- Case of Notes -->
-<xsl:template match="text:p[@text:style-name='Forrest_3a__20_Note']">
- <note>
- <xsl:apply-templates/>
- <xsl:if test="count(node())=0"><br /></xsl:if>
- </note>
-</xsl:template>
-
-<!-- FIXME : this is not XHTML -->
-<!-- Case of Warnings -->
-<xsl:template match="text:p[@text:style-name='Forrest_3a__20_Warning']">
- <warning>
- <xsl:apply-templates/>
- <xsl:if test="count(node())=0"><br /></xsl:if>
- </warning>
-</xsl:template>
-
-<!-- Case of Fixme - still a problem to retrieve the author...-->
-<!-- FIXME : this is not XHTML -->
-<xsl:template match="text:p[@text:style-name='Forrest_3a__20_Fixme']">
- <fixme>
- <xsl:apply-templates/>
- <xsl:if test="count(node())=0"><br /></xsl:if>
- </fixme>
-</xsl:template>
-
-<!-- Case of Sources -->
-<!-- FIXME : this is not XHTML -->
-<xsl:template match="text:p[@text:style-name='Forrest_3a__20_Source']">
- <source>
- <xsl:apply-templates/>
- <xsl:if test="count(node())=0"><br /></xsl:if>
- </source>
-</xsl:template>
-
-<!-- Otherwise -->
-
-<!-- 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>
+ <div class="{translate(@text:style-name,'.','_')}">
<xsl:apply-templates/>
- </p>
+ <xsl:if test="count(node())=0"><br /></xsl:if>
+ </div>
</xsl:template>
<xsl:template match="text: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>
-</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>
+ <span class="{translate(@text:style-name,'.','_')}">
+ <xsl:apply-templates/>
+ </span>
</xsl:template>
<xsl:template match="text:h">
@@ -426,7 +311,7 @@
-->
<xsl:template match="text:list">
<xsl:variable name="level" select="count(ancestor::text:list)+1"/>
-
+
<!-- the list class is the @text:style-name of the outermost
<text:list> element -->
<xsl:variable name="listClass">
@@ -443,7 +328,9 @@
<!-- Now select the <text:list-level-style-foo> element at this
level of nesting for this list -->
- <xsl:variable name="node" select="//office:document-content/office:automatic-styles/text:list-style[@style:name=$listClass]/text:list-level-style-number[@text:level=$level]"/>
+ <xsl:variable name="node" select="key('listTypes',
+ $listClass)/*[@text:level='$level']"/>
+
<!-- emit appropriate list type -->
<xsl:choose>
<xsl:when test="local-name($node)='list-level-style-number'">
@@ -463,21 +350,6 @@
<li><xsl:apply-templates/></li>
</xsl:template>
- <!--+
- | Images
- +-->
-<xsl:template match="draw:image[@xlink:show]">
- <xsl:variable name="href"><xsl:value-of select="@xlink:href"/></xsl:variable>
- <xsl:choose>
- <xsl:when test="starts-with($href, 'http:')">
- <img src="{$href}" alt="{@draw:name}"/>
- </xsl:when>
- <xsl:otherwise>
- <img src="/{$dirname}openDocumentEmbeddedImages/zip-{$filename}.odt/file-{$href}" alt="{../@draw:name}"/>
- </xsl:otherwise>
- </xsl:choose>
-</xsl:template>
-
<xsl:template match="table:table">
<table class="{@table:style-name}">
<colgroup>
@@ -563,7 +435,7 @@
</xsl:template>
<xsl:template match="text:line-break">
-<br />
+ <br />
</xsl:template>
<xsl:variable name="spaces"
@@ -601,19 +473,7 @@
</xsl:template>
<xsl:template match="text:a">
- <a href="{@xlink:href}">
- <xsl:if test="@office:target-frame-name">
- <xsl:attribute name="target">
- <xsl:value-of select="@office:target-frame-name"/>
- </xsl:attribute>
- </xsl:if>
- <xsl:if test="@office:name">
- <xsl:attribute name="title">
- <xsl:value-of select="@office:name"/>
- </xsl:attribute>
- </xsl:if>
- <xsl:apply-templates/>
- </a>
+<a href="{@xlink:href}"><xsl:apply-templates/></a>
</xsl:template>
<!--
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org