Skip to content

Commit

Permalink
temporarily revert to known working XHTML export
Browse files Browse the repository at this point in the history
There is an outstanding PR that isn't finished yet to fix some problems
with the current state of the XHTML export.

#52

Until time is available to finish and integrate this, revert to a
known-working (for ODF) revision 0f01b60
  • Loading branch information
mistmist committed Apr 3, 2024
1 parent 23590f5 commit 7dd6002
Show file tree
Hide file tree
Showing 9 changed files with 82 additions and 497 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
<!-- *************** -->

<!-- ID / NAME of text-box -->
<xsl:template match="@draw:name | @text:id | @xml:id">
<xsl:template match="@draw:name">
<xsl:attribute name="id">
<xsl:choose>
<xsl:when test="number(substring(.,1,1))">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -504,68 +504,16 @@
</xsl:template>


<!-- Context is <style:style> with all style properties elements containing attributes, accessed by */@prop
overwriting the ODF style properties that are being inherited from the 'inheritedStyleProperties' parameter! -->
<xsl:template name="create-inherited-style-properties">
<xsl:param name="inheritedStyleProperties" />

<xsl:element name="style:properties">
<!-- Writing all inherited style properties -->
<xsl:for-each select="$inheritedStyleProperties/@*">
<xsl:sort select="name()" />

<!-- Normalization three ODF attributes to one ODF attribute fo:background color (only temporary not ODF conform but eases mapping to ODF)
There are two different background color:
1) fo:background-color
2) draw:fill-color
mapped to one in CSS.
In addition if there is the attribute @draw:fill="none" the background is 'transparent' -->
<xsl:choose>
<xsl:when test="name() = 'draw:fill-color' or name() = 'fo:background-color' or name() = 'draw:fill'">
<xsl:choose>
<xsl:when test="$inheritedStyleProperties/@draw:fill='none'">
<xsl:attribute name="fo:background-color">transparent</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="name()!='draw:fill'">
<xsl:attribute name="fo:background-color"><xsl:value-of select="."/></xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="fo:background-color">transparent</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="." />
</xsl:otherwise>
</xsl:choose>
<xsl:copy-of select="." />
</xsl:for-each>

<xsl:if test="*/@draw:fill-color or */@fo:background-color or */@draw:fill">
<xsl:choose>
<xsl:when test="*/@draw:fill='none'">
<xsl:attribute name="fo:background-color">transparent</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="*/@draw:fill-color">
<xsl:attribute name="fo:background-color"><xsl:value-of select="*/@draw:fill-color"/></xsl:attribute>
</xsl:when>
<xsl:when test="*/@fo:background-color">
<xsl:attribute name="fo:background-color"><xsl:value-of select="*/@fo:background-color"/></xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="fo:background-color">transparent</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:if>


<!-- split border into border parts for better activation-check on style:joint-border feature -->
<xsl:if test="*/@fo:border">
<xsl:attribute name="fo:border-top"><xsl:value-of select="*/@fo:border"/></xsl:attribute>
Expand All @@ -576,7 +524,7 @@

<!--All current attributes will override already inserted attributes of the same name
XSLT Spec: "Adding an attribute to an element replaces any existing attribute of that element with the same expanded-name." -->
<xsl:for-each select="*/@*[name() != 'style:font-size-rel'][name() != 'fo:border'][name() != 'draw:fill-color']">
<xsl:for-each select="*/@*[name() != 'style:font-size-rel'][name() != 'fo:border']">
<xsl:copy-of select="." />
</xsl:for-each>

Expand Down Expand Up @@ -620,20 +568,21 @@
<xsl:template name="write-collected-styles">
<xsl:param name="globalData" />

<xsl:message>all-doc-styles:start</xsl:message>
<xsl:message>&lt;all-doc-styles&gt;</xsl:message>
<xsl:for-each select="$globalData/all-doc-styles/style">
<xsl:message>***style:start</xsl:message>
<xsl:message>style:family="<xsl:value-of select="current()/@style:family" />"</xsl:message>
<xsl:message>style:name="<xsl:value-of select="current()/@style:name" />"</xsl:message>
<xsl:message> with properties:</xsl:message>
<xsl:message>&lt;style</xsl:message>
<xsl:message>style:family="<xsl:value-of select="current()/@style:family" />"&gt;</xsl:message>
<xsl:message>style:name="<xsl:value-of select="current()/@style:name" />" </xsl:message>
<xsl:message> &lt;*</xsl:message>
<xsl:for-each select="*/@*">
<xsl:message>
<xsl:text></xsl:text>
<xsl:value-of select="name()" />="<xsl:value-of select="." />"</xsl:message>
</xsl:for-each>
<xsl:message>***style:end</xsl:message>
<xsl:message>/&gt;</xsl:message>
<xsl:message>&lt;/style&gt;</xsl:message>
</xsl:for-each>
<xsl:message>all-doc-styles:end</xsl:message>
<xsl:message>&lt;/all-doc-styles&gt;</xsl:message>
</xsl:template>

<xsl:template name="map-odf-style-properties">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,11 @@
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" exclude-result-prefixes="chart config dc dom dr3d draw fo form math meta number office ooo oooc ooow script style svg table text xforms xlink xsd xsi">


<!-- *** Background color handling *** -->
<xsl:template match="@fo:background-color | @draw:fill-color | @draw:fill">
<xsl:choose>
<xsl:when test="@draw:fill='none'">
<xsl:text>background-color:transparent; </xsl:text>
</xsl:when>
<xsl:when test="name()!='draw:fill'">
<xsl:text>background-color:</xsl:text>
<xsl:value-of select="."/>
<xsl:text>; </xsl:text>
</xsl:when>
</xsl:choose>
<!-- *** Properties with a 'fo:' prefix *** -->
<xsl:template match="@fo:background-color">
<xsl:text>background-color:</xsl:text>
<xsl:value-of select="."/>
<xsl:text>; </xsl:text>
</xsl:template>

<xsl:template match="@fo:border | @fo:border-top | @fo:border-bottom | @fo:border-left | @fo:border-right">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,7 @@
<xsl:param name="node-position" />

<xsl:attribute name="class">
<xsl:call-template name="create-unique-style-id">
<xsl:with-param name="styleName" select="@table:style-name"/>
<xsl:with-param name="styleFamily" select="'table-row'"/>
</xsl:call-template>
<xsl:value-of select="translate(@table:style-name, '. %()/\+', '')" />
</xsl:attribute>
</xsl:template>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,7 @@
</xsl:attribute>
</xsl:if>
<xsl:attribute name="class">
<xsl:call-template name="create-unique-style-id">
<xsl:with-param name="styleName" select="parent::*/@text:style-name"/>
<xsl:with-param name="styleFamily" select="'table'"/>
</xsl:call-template>
<xsl:value-of select="translate(parent::*/@text:style-name, '.,;: %()[]/\+', '_____________')"/>
</xsl:attribute>
</xsl:if>

Expand Down Expand Up @@ -320,10 +317,7 @@ Scenarios unmatched:
<xsl:element namespace="{$namespace}" name="p">
<xsl:if test="$position = 1">
<xsl:attribute name="class">
<xsl:call-template name="create-unique-style-id">
<xsl:with-param name="styleName" select="@text:style-name"/>
<xsl:with-param name="styleFamily" select="'paragraph'"/>
</xsl:call-template>
<xsl:value-of select="translate(@text:style-name, '.,;: %()[]/\+', '_____________')"/>
</xsl:attribute>
</xsl:if>
<xsl:apply-templates mode="content-table">
Expand All @@ -347,10 +341,7 @@ Scenarios unmatched:
<xsl:element namespace="{$namespace}" name="p">
<xsl:if test="$position = 1">
<xsl:attribute name="class">
<xsl:call-template name="create-unique-style-id">
<xsl:with-param name="styleName" select="@text:style-name"/>
<xsl:with-param name="styleFamily" select="'paragraph'"/>
</xsl:call-template>
<xsl:value-of select="translate(@text:style-name, '.,;: %()[]/\+', '_____________')"/>
</xsl:attribute>
</xsl:if>
<xsl:call-template name="grab-cell-content-before-tab-stop">
Expand All @@ -367,10 +358,7 @@ Scenarios unmatched:
<xsl:element namespace="{$namespace}" name="p">
<xsl:if test="$position = 1">
<xsl:attribute name="class">
<xsl:call-template name="create-unique-style-id">
<xsl:with-param name="styleName" select="@text:style-name"/>
<xsl:with-param name="styleFamily" select="'paragraph'"/>
</xsl:call-template>
<xsl:value-of select="translate(@text:style-name, '.,;: %()[]/\+', '_____________')"/>
</xsl:attribute>
</xsl:if>
<xsl:call-template name="grab-cell-content-before-tab-stop">
Expand All @@ -394,10 +382,7 @@ Scenarios unmatched:
<xsl:element namespace="{$namespace}" name="p">
<xsl:if test="$position = 1">
<xsl:attribute name="class">
<xsl:call-template name="create-unique-style-id">
<xsl:with-param name="styleName" select="@text:style-name"/>
<xsl:with-param name="styleFamily" select="'paragraph'"/>
</xsl:call-template>
<xsl:value-of select="translate(@text:style-name, '.,;: %()[]/\+', '_____________')"/>
</xsl:attribute>
</xsl:if>
<xsl:element namespace="{$namespace}" name="td">
Expand Down
Loading

0 comments on commit 7dd6002

Please sign in to comment.