Author: cdupoirieux
Date: Fri Oct 13 01:44:59 2006
New Revision: 463592
URL: http://svn.apache.org/viewvc?view=rev&rev=463592
Log:
Move the specific forrest code into odt-to-forrest-xhtml.
(cf. http://svn.apache.org/viewvc?view=rev&revision=463265)
We have to note that some improvements made should be shared with Lenya, such
as the picture management
or the link management which is better in forrest ;)
I need to understand the Lenya project to see if we can improve the
odt-to-xhtml.xsl...
Modified:
forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.input.odt/resources/stylesheets/odt-to-forrest-xhtml.xsl
forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.input.odt/src/documentation/content/xdocs/samples/opendocument-writer.odt
Modified:
forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.input.odt/resources/stylesheets/odt-to-forrest-xhtml.xsl
URL:
http://svn.apache.org/viewvc/forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.input.odt/resources/stylesheets/odt-to-forrest-xhtml.xsl?view=diff&rev=463592&r1=463591&r2=463592
==============================================================================
---
forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.input.odt/resources/stylesheets/odt-to-forrest-xhtml.xsl
(original)
+++
forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.input.odt/resources/stylesheets/odt-to-forrest-xhtml.xsl
Fri Oct 13 01:44:59 2006
@@ -20,7 +20,9 @@
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"
xmlns:xlink="http://www.w3.org/1999/xlink"
- xmlns:dc="http://purl.org/dc/elements/1.1/" >
+ xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"
+ xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"
+ xmlns:dc="http://purl.org/dc/elements/1.1/">
<xsl:import href="lm://transform.odt.xhtml"/>
<xsl:param name="path" select="'odt path name'"/>
@@ -74,4 +76,172 @@
</body>
</html>
</xsl:template>
+
+<!-- FIXME : this is not XHTML -->
+<!-- Case of Notes -->
+<xsl:template match="text:[EMAIL PROTECTED]: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:[EMAIL
PROTECTED]: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:[EMAIL
PROTECTED]: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:[EMAIL
PROTECTED]: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>
+ <xsl:apply-templates/>
+ </p>
+</xsl:template>
+
+<!-- Instead of using styles like in the Lenya file, we try here to recognise
the style to use XHTML specific
+ tags such as <em>, <strong>, <sup> and <sub>... -->
+<xsl:template match="text:span">
+ <xsl:variable name="styleName" select="@text:style-name"/>
+ <xsl:apply-templates
select="//office:document-content/office:automatic-styles/style:[EMAIL
PROTECTED]: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>
+</xsl:template>
+
+ <!--+
+ | Images
+ +-->
+<xsl:template match="draw:[EMAIL PROTECTED]: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="[EMAIL PROTECTED]:name}"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <img
src="/{$dirname}openDocumentEmbeddedImages/zip-{$filename}.odt/file-{$href}"
alt="{../@draw:name}"/>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+ <!--+
+ | Links
+ +-->
+<!-- A little more detailled than in the Lenya file, we add a title and a
target attribute if it is supplied... -->
+<xsl:template match="text:a">
+ <a href="[EMAIL PROTECTED]: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>
+</xsl:template>
+
</xsl:stylesheet>
Modified:
forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.input.odt/src/documentation/content/xdocs/samples/opendocument-writer.odt
URL:
http://svn.apache.org/viewvc/forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.input.odt/src/documentation/content/xdocs/samples/opendocument-writer.odt?view=diff&rev=463592&r1=463591&r2=463592
==============================================================================
Binary files - no diff available.