- From: Olaf Wentzien <olaf.wentzien@ppi.de>
- Date: Fri, 6 Jul 2007 09:45:41 +0200
- To: www-xsl-fo@w3.org
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 Friday, 6 July 2007 07:46:00 UTC