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

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

From: Mark Lundquist <ml@wrinkledog.com>
Date: Thu, 5 Jul 2007 11:50:17 -0700
Message-Id: <f71d95945dbb4f26f11a7e5621b41831@wrinkledog.com>
Cc: www-xsl-fo@w3.org
To: sol myr <solmyr72@yahoo.com>

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:template match="content">
		<fo:block font-size="13pt">

...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!

Received on Thursday, 5 July 2007 18:50:34 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 20:58:31 UTC