Attribute bundles

In this example several attributes are combined in order to assign them together to an element and to repeatedly re-use them.

With the <xsl:attribute-set> element attributes are bundled which are called up later. The use of the element has various advantages. On the one hand they can provide a better overview when set at the beginning of a stylesheet. On the other hand characteristics can be centrally edited.

Source code

<xsl:attribute-set name="Headline-Title1">              ❶
   <xsl:attribute name="font-family">Arial Unicode MS</xsl:attribute>
   <xsl:attribute name="font-size">18pt</xsl:attribute>
   <xsl:attribute name="font-weight">bold</xsl:attribute>
   <xsl:attribute name="space-after">99pt</xsl:attribute>
   <xsl:attribute name="space-before.conditionality">discard</xsl:attribute>
   <xsl:attribute name="keep-with-next">always</xsl:attribute>
</xsl:attribute-set>

❶ The <xsl:attribute-set> element is used in order to assign several attributes together: At first, a name is assigned to the <attribute-set> element with the name attribute followed by the attributes contained in the element and their values. The first attribute set shows an example for a possible formatting of a headline.

<xsl:attribute-set name="table.data">                ❶
   <xsl:attribute name="table-layout">fixed</xsl:attribute>
   <xsl:attribute name="start-indent">2mm</xsl:attribute>
   <xsl:attribute name="end-indent">2mm</xsl:attribute>
   <xsl:attribute name="space-before">10pt</xsl:attribute> 
   <xsl:attribute name="space-after">10pt</xsl:attribute>
   <xsl:attribute name="keep-with-next.within-page">always</xsl:attribute>
</xsl:attribute-set>

❶ The second attribute set demonstrates combined characteristics of a table.

<fo:block xsl:use-attribute-sets="Headline-Title1"            ❶
 axf:outline-level="2" axf:outline-expand="false" keep-with-next="always">
   <fo:table width="110mm">
      <fo:table-column column-number="1" column-width="15mm"/> 

❶ The use-attribute-sets attribute is used in order to access the attributes collected in the <attribute-set> element. The value of this element has to match with the value of the name attribute of one of the <attribute-set> elements.

  next >>

 

 


Copyright © dpunkt.verlag GmbH 2004
Printing of the online version is permitted exclusively for private use. Otherwise this chapter from the book "XSL-FO in der Praxis" ("XSL-FO in practice") is subject to the same provisions as those applicable for the hardcover edition: The work including all its components is protected by copyright. All rights reserved, including reproduction, translation, microfilming as well as storage and processing in electronic systems.

dpunkt.verlag GmbH, Ringstraße 19B, 69115 Heidelberg, fon 06221-14830, fax 06221-148399, hallo@dpunkt.de