Witten
Bainbridge
Nichols
HOME HELP PREFERENCES SEARCHFIGURESTABLES

XSL style sheet illustrating context-sensitive formatting

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:fo="http://www.w3.org/1999/XSL/Format"
        version="1.0">
<xsl:import href="un_basic.xsl"/>
<xsl:template match="Agency/Photo[@desc]">
     Available: <xsl:value-of select="@desc"/>
</xsl:template>
<xsl:template match="Agency/Photo[@desc='A photo']">
</xsl:template>
<xsl:template match="Agency">
  <fo:block space-before="8pt" space-after="3pt" font-size="20pt" 
            font-family="Helvetica"
            margin-left="0.2in" margin-right="5mm">
     <xsl:apply-templates select="." mode="Extra Color"/>
  </fo:block>
</xsl:template>
<xsl:template match="Agency[position()>1]" mode="Extra Color">
   <xsl:attribute name="background-color">#ffa080</xsl:attribute>
   <xsl:attribute name="color">red</xsl:attribute>
   <xsl:apply-templates/>
</xsl:template>
<xsl:template match="Name[@hq='Rome, Italy']">
  <fo:inline color="rgb(255,160,80)">
     <xsl:apply-templates/>
  </fo:inline>
</xsl:template>
</xsl:stylesheet>

Figure 4.16: XSL style sheet illustrating context-sensitive formatting;