I forgot I'm running it on XSLT 2.0 processor... <xsl:apply-templates select="$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=text%2Fplain&rev=1.3.16.3 > > @text:style-name template needs to be modified and one recursive > template (inherited-classes) needs to be added: > > <xsl:template match="style:style" mode="inherited-classes"> > <xsl:param name="globalData"/> > <xsl:variable name="styleFamily" select="@style:family" /> > <xsl:variable name="parentStyleName" select="@style:parent-style-name" /> > <xsl:variable name="parentStyle" > select="$globalData/office:styles/style:sty...@style:family = > $styleFamily and @style:name = $parentStyleName]"/> > > <xsl:value-of select="translate(@style:name, '.,;: %()[]/\+', > '_____________')"/> > <xsl:text> </xsl:text> > <xsl:apply-templates select="$parentStyle" mode="inherited-classes"> > <xsl:with-param name="globalData" select="$globalData"/> > </xsl:apply-templates> > </xsl:template> > > <xsl:template match="@text:style-name | @draw:style-name | > @draw:text-style-name | @table:style-name"><!-- | > @presentation:style-name--> > <xsl:param name="globalData"/> > <xsl:variable name="style" > select="$globalData/office:automatic-styles/style:sty...@style:name = > current()]"/> > <xsl:variable name="styleFamily" select="$style/@style:family" /> > <xsl:variable name="parentStyleName" > select="$style/@style:parent-style-name" /> > <xsl:variable name="parentStyle" > select="$globalData/office:styles/style:sty...@style:family = > $styleFamily and @style:name = $parentStyleName]"/> > > <xsl:attribute name="class"> > <xsl:value-of select="translate(., '.,;: %()[]/\+', > '_____________')"/> > <xsl:text> </xsl:text> > <xsl:apply-templates select="$parentStyle" > mode="inherited-classes"> > <xsl:with-param name="globalData" select="$globalData"/> > </xsl:apply-templates> > </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="A"> ... <p class="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="A"> ... <p class="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] >> >> > --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
