Tecnologías XML / XSL-FO / Ejemplos de aplicación / Subtítulos

 

Subtítulos

Se generan subtítulos con propiedades variadas: tamaño, fuente, alineación y espaciado.

Los subtítulos son bloques específicos. Pueden parecer títulos de capítulo o sección, sin cumplir sus funciones: no identifican claramente contenido y límites y no sirven como encabezados corrientes. El ejemplo muestra cómo la DTD puede predefinir propiedades y variantes tipográficas, cómo las implementa la hoja y cómo gestionar espaciados verticales antes y después.

Extracto de DTD:

<!ELEMENT Abschnitt (Titel, (A | ... | Z-Titel)*)>
<!ELEMENT Z-Titel (#PCDATA | ...)*>
<!ATTLIST Z-Titel Groesse (normal | klein | gross) "normal"
                  Schrift (normal | fett | kursiv) "normal"
                  Aliniierung (links | rechts | mittig) "links">

Hoja de estilo:

<xsl:attribute-set name="Zwischenueberschrift">                          ❶
   <xsl:attribute name="font-family">Arial</xsl:attribute>
   <xsl:attribute name="space-before">15mm</xsl:attribute>
   <xsl:attribute name="space-after">5mm</xsl:attribute>
   <xsl:attribute name="hyphenate">false</xsl:attribute>
   <xsl:attribute name="keep-with-next">always</xsl:attribute>
</xsl:attribute-set>
...
<xsl:template match="Z-Titel">
   <fo:block xsl:use-attribute-sets="Zwischenueberschrift">             ❷
      <xsl:choose>                                                      ❸
         <xsl:when test="@Groesse='gross'">
            <xsl:attribute name="font-size">14pt</xsl:attribute>  
         </xsl:when>
         <xsl:when test="@Groesse='klein'"> 
            <xsl:attribute name="font-size">10pt</xsl:attribute>
         </xsl:when>
         <xsl:otherwise>
            <xsl:attribute name="font-size">12pt</xsl:attribute>
         </xsl:otherwise>
      </xsl:choose>
      <xsl:choose>
         <xsl:when test="@Schrift='fett'">
            <xsl:attribute name="font-weight">bold</xsl:attribute>
         </xsl:when>
         <xsl:when test="@Schrift='kursiv'">
            <xsl:attribute name="font-style">italic</xsl:attribute> 
         </xsl:when>
         <xsl:otherwise>
            <xsl:attribute name="font-weight">normal</xsl:attribute>
         </xsl:otherwise>
      </xsl:choose>
      <xsl:choose>
         <xsl:when test="@Aliniierung='rechts'">
            <xsl:attribute name="text-align">right</xsl:attribute>
         </xsl:when>
         <xsl:when test="@Aliniierung='mittig'"> 
            <xsl:attribute name="text-align">center</xsl:attribute>
         </xsl:when>
         <xsl:otherwise>
            <xsl:attribute name="text-align">left</xsl:attribute>
         </xsl:otherwise>
      </xsl:choose>
      <xsl:apply-templates/>
   </fo:block>
</xsl:template>
 

 

❶ Para mayor claridad, los atributos fijos se agrupan en un <xsl:attribute-set.

❷ El bloque que contiene el subtítulo recibe los atributos fijos de <xsl:attribute-set.

❸ Para las propiedades variables de la DTD, se leen los valores y se convierten en propiedades tipográficas. Véase «Bloques de texto» para más detalles.

 

<< atrás

siguiente >>

volver arriba