W3C home > Mailing lists > Public > www-xsl-fo@w3.org > May 2006

How to reuse template code

From: omegared (sent by Nabble.com) <lists@nabble.com>
Date: Mon, 15 May 2006 04:39:52 -0700 (PDT)
Message-ID: <4390495.post@talk.nabble.com>
To: www-xsl-fo@w3.org


Hi

I am new to XSL-FO and was hoping somebody would be kind enough to answer
the following questions.  I have read a number of online tutorials but they
do not go above a very basic introduction.  I have been using xml and xslt
files so as to separate my content and format. 

1)Suppose you have two paragraphs which have identical formatting e.g. font
size, colour, style except that one paragraph begins with has different
alignment.  At the moment I am writing two templates e.g.

<xsl:template match="para1">
       <fo:block text-indent="0.5in" 
       		 font-size="12pt" 
                 font-family="sans-serif" 
                 line-height="15pt"
                 space-after.optimum="12pt"
                 text-align="right">
		<xsl:value-of select="."/>
	</fo:block>
</xsl:template>

and 

<xsl:template match="para2">
       <fo:block font-size="12pt" 
                 font-family="sans-serif" 
                 line-height="15pt"
                 space-after.optimum="12pt"
                 text-align="right">
		<xsl:value-of select="."/>
	</fo:block>
</xsl:template>

Is there no way of saying apply all of the template specification in para1
to para2 but change the alignment with repeating the same styling
definitions?    Ddo I have to write separate templates every time
regardless?

2)If I want to apply exactly the same template, do I have to copy the whole
template and change the XPath query?  Is there no way I can reuse the same
template by sating something like:

<apply template select =“para”><value-of=/nodeA></apply template>
<apply template select =“para”><value-of=nodeJ></apply template>

--
View this message in context: http://www.nabble.com/How-to-reuse-template-code-t1620380.html#a4390495
Sent from the w3.org - www-xsl-fo forum at Nabble.com.
Received on Monday, 15 May 2006 11:40:17 GMT

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