RE: Modularize

Hi, Alexandre

If I were you, first of all I would avoid using of named templates, preserving applying of matched templates (I mean <xsl:template match="section">).. In many cases it improves performance of XSLT, because few templates can be applied to XML nodes at different level at the same time. Of course, certain things can be done only with using named templates. I think, that the best approach of creating stylesheets (especially in case of your document) is creating template for almost every node of source XML.

Furthermore, I would split stylesheet into few ones, each for some concrete purpose. E.g. you can make a separate stylesheet with formatting properties with using xsl:attribute-set.

<xsl:attribute-set name="title.heading"
  use-attribute-sets="normal.para.font">
  <xsl:attribute name="text-transform">capitalize</xsl:attribute>
  <xsl:attribute name="font-weight">bold</xsl:attribute>
  <xsl:attribute name="space-before">9pt</xsl:attribute>
  <xsl:attribute name="space-before.precedence">3</xsl:attribute>
  <xsl:attribute name="space-after">6pt</xsl:attribute>
  <xsl:attribute name="space-after.precedence">3</xsl:attribute>
  <!--<xsl:attribute name="border">0.3px dotted red</xsl:attribute>-->
</xsl:attribute-set>

This is an attribute set for the heading paragraph. As you can see the common paragraph attribute set has been used as the base for it. Thus you can easily change the look of resulting document and preserve document style consistency. It's an analogue for CSS stylesheets, widely used in HTML.

BTW, I think that object oriented or procedure-oriented programming is poorly applicable for XSLT.

I would recommend you to read this book: "Learning XSLT" by Michael Fitzgerald. It's accessible on-line.

Respectfully,
Volodymyr Rodymyuk

> -----Original Message-----
> From: www-xsl-fo-request@w3.org [mailto:www-xsl-fo-request@w3.org] On
> Behalf Of axdmoraes
>      IŽd like do modularize my styles. Like a class in OOP or just a file
> with common styles like table, or a paragraph,...

Received on Wednesday, 5 September 2007 09:57:59 UTC