This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Re: css or xsl for increasing size of first letter in chapter?


If you wanted to use CSS, you could
use Dimitre's stylesheet to add a span 
element around to the first letters, 
then use a class attribute on the span 
class to control the appearance of
its contents.

The advantage of this approach is that
it keeps the presentational stuff in CSS
thus minimising the need to touch the 
XSL stylesheet if your appearance requirements
change.

Regards
Michael

> -----Original Message-----
> From: owner-xsl-list@lists.mulberrytech.com
> [mailto:owner-xsl-list@lists.mulberrytech.com]On Behalf Of Dimitre
> Novatchev
> Sent: Sunday, 4 August 2002 4:45 PM
> To: xsl-list@lists.mulberrytech.com
> Subject: [xsl] Re: css or xsl for increasing size of first letter in
> chapter?
> 
> 
> 
> --- Phillip Rhodes <spamsucks at rhoderunner dot com> wrote:
> 
> > Hi everyone.
> > I am trying to increase the size of the very first letter for each
> > chapter in an xhtml document. I have used the css pseudo class
> > "first-letter" to do it, but it selects all the p elements in a
> > chapter, not just the first.
> > 
> > p:first-letter {
> > font-size: 16pt;
> > }
> > 
> > I could use xsl to make the first child p of the chapter a special
> > class of p like <p class="firstsentence">
> > 
> > Sort of like
> > p.firstsentence:first-letter
> > 
> > But not sure if this is the way to go...., any handy XSL tricks for
> > this?
> > Thanks!
> > 
> > <html>
> > <body>
> > <chapter>
> > <p>This is chapter 1</p>
> > <p>another sentence</p>
> > </chapter>
> > <chapter>
> > <p>This is chapter 2</p>
> > </chapter>
> > </body>
> > </html>
> 
> Hi Philip,
> 
> The following transformation does it:
> 
> <xsl:stylesheet version="1.0" 
>  xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
>   
>   <xsl:template match="@*|node()">
>     <xsl:copy>
>       <xsl:apply-templates select="@*|node()"/>
>     </xsl:copy>
>   </xsl:template>
>   
>   <xsl:template match="chapter/p[1]//text()[1]">
>     <font size="+2">
>       <xsl:value-of select="substring(., 1, 1)"/>
>     </font>
>     <xsl:value-of select="substring(., 2)"/>
>   </xsl:template>
> </xsl:stylesheet>
> 
> It is a customisation of the identity rule, adding a specific rule for
> the first text node within the first "p" in a "chapter". 
> 
> The text is split into two -- the first character is wrapped within an
> appropriate html element ("font" in this case), and the rest of the
> text is simply copied.
> 
> With your source xml:
> 
> <html>
>   <body>
>     <chapter>
>       <p>This is chapter 1</p>
>       <p>another sentence</p>
>     </chapter>
>     <chapter>
>       <p>This is chapter 2</p>
>     </chapter>
>   </body>
> </html>
> 
> the result of applying this transformation is:
> 
> <html>
>    <body>
>       <chapter>
>          <p><font size="+2">T</font>his is chapter 1
>          </p>
>          <p>another sentence</p>
>       </chapter>
>       <chapter>
>          <p><font size="+2">T</font>his is chapter 2
>          </p>
>       </chapter>
>    </body>
> </html>
> 
> 
> and this is displayed by a browser with the first characters of any
> chapter visibly bigger.
> 
> Hope this helped.
> 
> 
> 
> =====
> Cheers,
> 
> Dimitre Novatchev.
> http://fxsl.sourceforge.net/ -- the home of FXSL
> 
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Health - Feel better, live better
> http://health.yahoo.com
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 
> 


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]