XSLT

<xsl:apply-templates select="/people/person[@state = $ST]"/>

list.xsl

  <xsl:template match="person">
    <tr>
      <xsl:choose>
        <xsl:when test="position() mod 2">
          <xsl:attribute name="class"><xsl:value-of select="'oddrow'"/></xsl:attribute>
        </xsl:when>
        <xsl:otherwise>
          <xsl:attribute name="class"><xsl:value-of select="'evenrow'"/></xsl:attribute>
        </xsl:otherwise>
      </xsl:choose>
      <td>
        <xsl:value-of select="@name"/>
      </td>
      <td>
        <xsl:value-of select="role/@state"/>
      </td>
      <td>
        <xsl:value-of select="role/@district"/>
      </td>
      <td>
        <xsl:value-of select="role/@party"/>
      </td>
    </tr>
  </xsl:template>
  

grid.xsl

  <xsl:template match="person">
      <div class="grid">
        <xsl:apply-templates select="." mode="photo"/>
        <br/>
        <a href="detail-{@id}.html">
          <xsl:value-of select="@name"/>
        </a>
      </div>
  </xsl:template>

 <xsl:template match="person" mode="photo">
    <xsl:param name="size" select="'medium'"/>
    <xsl:variable name="suffix">
      <xsl:choose>
        <xsl:when test="$size = 'small'">
          <xsl:text>-50px</xsl:text>
        </xsl:when>
        <xsl:when test="$size = 'medium'">
          <xsl:text>-100px</xsl:text>
        </xsl:when>
        <xsl:when test="$size = 'large'">
          <xsl:text>-200px</xsl:text>
        </xsl:when>
        <xsl:when test="$size = 'xlarge'">
          <xsl:text></xsl:text>
        </xsl:when>
        <xsl:otherwise>
          <xsl:text>-100px</xsl:text>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:variable>
    <img src="http://morpheus.dce.harvard.edu/govtrack/photos/{@id}{$suffix}.jpeg" alt="Photo of {@name}"/>
  </xsl:template>
      

Copyright © 2002-2009 David P. Heitmeyer

Bookmark and Share