On Thu, 2007-11-08 at 09:49 +0100, EMMEL Thomas wrote: > Hi rangers... > > I wonder whether someone can give me some help on applying a patch to > forrest (html-to-document.xsl) to allow for something like > > <ul class='myul'> > ... > </ul> > > or > > <ul id='myul'> > ... > </ul> > > together with some css applied to that element. > > The CSS is no problem, I am now much more familiar with that (after > reading Andy Budd's) very good book about CSS-mastery... > > My problem is XSL, since I have not yet the time to dive into XSL. > > I changed the file html-to-document.xsl for the ul-element to allow for > the class (see below), the id is not tested but maybe of interest in the > future. > > My questions are: > 1. How can I avoid to make changes always in the installation of forrest? > Can I use a project-specific local html-to-document.xsl-file instead? >
Yes, you can. http://forrest.apache.org/docs_0_80/locationmap.html In your project locationmap you need to implement the match <match pattern="transform.html.document"> and point to your custom implementation. > 2. Is the way I have done it the preferable way? > Normally if writing code (python for me) I would prefere to write a > function since the core choose-function is repeated twice here. I have to admit that the 2 choose functions seem to do exactly the same. > 3. In addition, since this problem will reappear for a lot of elements > again and again a more general solution could be better! Any hints? > Not sure what you mean. > 4. As I have several of these changes and some improvements done here it > would be nice if I could provide these to the main trunk. > How should I proceed? > http://forrest.apache.org/contrib.html HTH salu2 > > Actually we are using forrest 0.8 but I can easily add 0.9dev to my path. > > Here is the change: > Adding an extra 'choose' let me allow for the class in ul... > --------------------- > <xsl:template match="ul"> > <xsl:choose> > <xsl:when test="name(..)='p'"> > <xsl:text disable-output-escaping="yes"><![CDATA[</p>]]></xsl:text> > <xsl:choose> > <xsl:when test="@class"> > <ul> > <xsl:attribute name="class"><xsl:value-of > select="@class"/></xsl:attribute> > <xsl:apply-templates/> > </ul> > </xsl:when> > <xsl:otherwise> > <ul> > <xsl:apply-templates/> > </ul> > </xsl:otherwise> > </xsl:choose> > <xsl:text disable-output-escaping="yes"><![CDATA[<p>]]></xsl:text> > </xsl:when> > <xsl:otherwise> > <xsl:choose> > <xsl:when test="@class"> > <ul> > <xsl:attribute name="class"><xsl:value-of > select="@class"/></xsl:attribute> > <xsl:apply-templates/> > </ul> > </xsl:when> > <xsl:otherwise> > <ul> > <xsl:apply-templates/> > </ul> > </xsl:otherwise> > </xsl:choose> > </xsl:otherwise> > </xsl:choose> > </xsl:template> > > > Many Thanks > > Thomas -- Thorsten Scherler thorsten.at.apache.org Open Source Java consulting, training and solutions
