W3C home > Mailing lists > Public > www-xsl-fo@w3.org > July 2007

Re: Antwort: Re: [xsl-fo] : Does FO support reusable style definition, similar to CSS?

From: Sharon Adler <sca@us.ibm.com>
Date: Tue, 10 Jul 2007 10:15:50 -0400
To: Olaf Wentzien <olaf.wentzien@ppi.de>
Cc: www-xsl-fo@w3.org
Message-ID: <OF59C92696.B32AE906-ON85257314.004D70AE-85257314.004E5AF3@us.ibm.com>
However, attribute sets were invented to create a "container" for a 
collection of style attributes that can be managed/modified together.  It 
is important to remember that XSLT provides the front-end computational 
capability to manage the information that contributes to the layout 
funcitionality.

Sharon

Sharon C. Adler
 Senior Manager, Extensible Technologies
 IBM Research
 PO Box 704, Yorktown Heights, NY  10598
 tel:  914-784-6411 t/l 863
 fax: 914-784-6324




Olaf Wentzien <olaf.wentzien@ppi.de> 
Sent by: www-xsl-fo-request@w3.org
07/06/2007 03:45 AM

To
www-xsl-fo@w3.org
cc

Subject
Antwort: Re: [xsl-fo] : Does FO support reusable style definition, similar 
 to CSS?






Hi Sol & -ml-,

that's truly the right way  to do it. If you want some more code savings 
and ease of maintenance
you additionally may define and use some variables as for instance:

 
             <xsl:variable name="bigfont">20pt</xsl:variable>
             <xsl:variable name="smallfont">13pt</xsl:variable>


                 <xsl:template match="heading">
                                 <fo:block font-size="{$bigfont}">
                                                 <xsl:apply-templates/>
                                 </fo:block>
                 </xsl:template>

                 <xsl:template match="content">
                                 <fo:block font-size="{$smallfont}">
                                                 <xsl:apply-templates/>
                                 </fo:block>
                 </xsl:template>

If you like, put all the variables you need in an extra xsl-document, 
which you than can import in
a lot of other stylesheets.

Regards / Olaf

www-xsl-fo-request@w3.org schrieb am 05.07.2007 20:50:42:

> 
> 
> Hi Sol,
> 
> On Jul 4, 2007, at 12:45 PM, sol myr wrote:
> 
> > Newbie question, please:
> > Does FO support 'reusable formatting' definitions, similar to CSS 
> > "Class" ?
> > For example, suppose I have a document with 2 types of text:
> > - Heading, using font size 20pt
> > - Content, using font size 13pt
> >
> > So , a naiive approach produces this page:
> > <fo:block font-size="20pt"> Some Heading  </fo:block>
> > <fo:block font-size="13pt"> Some content...  </fo:block>
> > <fo:block font-size="20pt"> More Heading  </fo:block>
> > <fo:block font-size="13pt"> More content...  </fo:block>
> >
> >
> > But this is difficult to maintain (e.g if I change  my mind and 
> > want all headings to be 25pt).
> > Is there a better way ? Does FO support something like the 'Class' 
> > notion of CSS , so that you declare that 'MyHeading' means 'font size 
> > of 20', and from now on use it, something like:
> >  <fo:block class='MyHeading'>
> 
> You need to shift your thinking :-)
> 
> HTML is a document language.  XSL-FO is not.  It's a layout language, 
> which is something completely different.  You're not meant to write 
> documents in XSL-FO.  The idea with XSL is that you are supposed to use 
> XSLT and XSL-FO together.  So instead of necessarily using a predefined 
> document language like HTML, you write your document in whatever XML 
> vocabulary suits your task, and then use XSLT transforms to translate 
> that into XSL-FO, which is an XML layout language.  In XSL-FO there is 
> no "formatting properties language" like CSS (with hooks in the 
> document language to trigger the properties... like "class" and "id" 
> attributes), because there's no need for one in the way XSLT-FO is 
> meant to be used.
> 
> So to take up your example, the source document might contain markup 
> like this:
> 
>    <heading>blah blah blah... </heading>
>    <content>blah blah blah... </content>
> 
>    <heading>blah blah blah... </heading>
>    <content>blah blah blah... </content>
> 
> ...which is very easy to maintain.  Your XSLT stylesheet might contain:
> 
>    <xsl:template match="heading">
>       <fo:block font-size="20pt">
>          <xsl:apply-templates/>
>       </fo:block>
>    </xsl:template>
> 
>    <xsl:template match="content">
>       <fo:block font-size="13pt">
>          <xsl:apply-templates/>
>       </fo:block>
>    </xsl:template>
> 
> ...which is also very easy to maintain.
> 
> Running the source document through the XSLT stylesheet produces the 
> XSL-FO source like in your example, which you quite rightly do not have 
> to maintain by hand!
> 
> cheers,
> ?ml?
> 
> 
Received on Tuesday, 10 July 2007 14:16:02 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 3 October 2007 16:06:14 GMT