Re: odf2xhtml

Martynas Jusevicius <[email protected]> Sun, 21 Mar 2010 16:56:00 +0100
Newsgroups gmane.comp.openoffice.devel.xml
Message-ID <[email protected]>
I forgot I'm running it on XSLT 2.0 processor...
<xsl:apply-templates select=3D"$parentStyle"> will probably not work in
XSLT 1.0, but you get the general idea.

On Sun, Mar 21, 2010 at 4:29 PM, Martynas Jusevicius
<[email protected]> wrote:
> Here's a partial fix for this issue, I don't know if I should try
> submitting it somewhere.
>
> It requires modification of /export/xhtml/body.xhtml stylesheet:
> http://framework.openoffice.org/source/browse/*checkout*/framework/filter=
/source/xslt/odf2xhtml/export/xhtml/body.xsl?content-type=3Dtext%2Fplain&re=
v=3D1.3.16.3
>
> @text:style-name template needs to be modified and one recursive
> template (inherited-classes) needs to be added:
>
> <xsl:template match=3D"style:style" mode=3D"inherited-classes">
> =A0 =A0<xsl:param name=3D"globalData"/>
> =A0 =A0<xsl:variable name=3D"styleFamily" select=3D"@style:family" />
> =A0 =A0<xsl:variable name=3D"parentStyleName" select=3D"@style:parent-sty=
le-name" />
> =A0 =A0<xsl:variable name=3D"parentStyle"
> select=3D"$globalData/office:styles/style:style[@style:family =3D
> $styleFamily and @style:name =3D $parentStyleName]"/>
>
> =A0 =A0<xsl:value-of select=3D"translate(@style:name, '.,;: %()[]/\+',
> '_____________')"/>
> =A0 =A0<xsl:text> </xsl:text>
> =A0 =A0<xsl:apply-templates select=3D"$parentStyle" mode=3D"inherited-cla=
sses">
> =A0 =A0 =A0 =A0<xsl:with-param name=3D"globalData" select=3D"$globalData"=
/>
> =A0 =A0</xsl:apply-templates>
> </xsl:template>
>
> <xsl:template match=3D"@text:style-name | @draw:style-name |
> @draw:text-style-name | @table:style-name"><!-- |
> @presentation:style-name-->
> =A0 =A0 =A0 =A0<xsl:param name=3D"globalData"/>
> =A0 =A0 =A0 =A0<xsl:variable name=3D"style"
> select=3D"$globalData/office:automatic-styles/style:style[@style:name =3D
> current()]"/>
> =A0 =A0 =A0 =A0<xsl:variable name=3D"styleFamily" select=3D"$style/@style=
:family" />
> =A0 =A0 =A0 =A0<xsl:variable name=3D"parentStyleName"
> select=3D"$style/@style:parent-style-name" />
> =A0 =A0 =A0 =A0<xsl:variable name=3D"parentStyle"
> select=3D"$globalData/office:styles/style:style[@style:family =3D
> $styleFamily and @style:name =3D $parentStyleName]"/>
>
> =A0 =A0 =A0 =A0<xsl:attribute name=3D"class">
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0<xsl:value-of select=3D"translate(., '.,;:=
 %()[]/\+',
> '_____________')"/>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0<xsl:text> </xsl:text>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0<xsl:apply-templates select=3D"$parentStyl=
e"
> mode=3D"inherited-classes">
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0<xsl:with-param name=3D"globalData=
" select=3D"$globalData"/>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0</xsl:apply-templates>
> =A0 =A0 =A0 =A0</xsl:attribute>
> </xsl:template>
>
> There is also at least one other place in body.xsl (in the text:h
> template) where @text:style-name template needs to be called (with the
> $globalData param) for the fix to have effect instead of simply
> outputting style name to the @class attribute.
>
> The full fix would be to prevent excessive (overlapping in parent and
> children) CSS properties from bein generated.
>
> Martynas
> odt2epub.com
>
> On Fri, Mar 19, 2010 at 5:55 PM, Vyacheslav Sedov
> <[email protected]> wrote:
>> good idea - i can help with XSLT 2.0 - our project have some odf2xhtml
>> code - our code is XSLT 2.0 - not XSLT 1.0 from OpenOffice
>>
>> with best wishes,
>> Slav
>>
>> 2010/3/19 Martynas Jusevicius <[email protected]>:
>>> Hey list,
>>>
>>> I've been working with odf2xhtml XSLT filter a lot lately, in relation
>>> to ePub e-books. It does its job but it's really showing its age. I
>>> wonder if there are plans for a new version? It could really benefit
>>> from many of XSLT 2 features.
>>>
>>> One of the most annoying things is the generated CSS. If style A
>>> defines bold text and style B is inherited from A and additionally
>>> defines right alignment, odf2xhtml generates such code:
>>>
>>> .A { font-weight: bold; }
>>> .B { font-weight: bold; text-align: right; }
>>>
>>> <p class=3D"A"> ... <p class=3D"B">
>>>
>>> That shows up OK in the browser, but removes the relationship between
>>> A and B in the XHTML/CSS output. For example, if I need to select all
>>> elements with style inherited from A, I cannot do that without looking
>>> into the original ODT and examining the styles.
>>>
>>> I think much better output could be achieved using multiple classes in =
XHTML:
>>>
>>> .A { font-weight: bold; }
>>> .B { text-align: right; }
>>>
>>> <p class=3D"A"> ... <p class=3D"A B">
>>>
>>> What do you think?
>>>
>>> Martynas
>>> odt2epub.com
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [email protected]
>>> For additional commands, e-mail: [email protected]
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>>
>>
>