Thread: if test=????
View Single Post
  #2 (permalink)  
Old August 24th, 2006, 08:27 AM
joefawcett's Avatar
joefawcett joefawcett is offline
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

You need to use the starts-with function:
Code:
<?xml version="1.0" encoding="utf-8"?>

<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:param name="artistSearch" select="'Bo'"/>
  <xsl:template match="/">
    <html>
      <head>
        <title>CD Collection</title>
      </head>
      <body>
        <table>
          <caption>
            Artists starting with#xa0;<xsl:value-of select="$artistSearch"/>
          </caption>
          <thead>
            <tr>
              <th>Title</th>
              <th>Artist</th>
              <th>Country</th>
              <th>Company</th>
              <th>Price</th>
              <th>Year</th>
            </tr>
          </thead>
          <tbody>
            <xsl:apply-templates select="catalog/cd[starts-with(artist, $artistSearch)]" />
          </tbody>
        </table>
      </body>
    </html>
  </xsl:template>
  <xsl:template match="cd">
    <tr>
      <td>
        <xsl:value-of select="title"/>
      </td>
      <td>
        <xsl:value-of select="artist"/>
      </td>
      <td>
        <xsl:value-of select="country"/>
      </td>
      <td>
        <xsl:value-of select="company"/>
      </td>
      <td>
        <xsl:value-of select="price"/>
      </td>
      <td>
        <xsl:value-of select="year"/>
      </td>
    </tr>
  </xsl:template>
</xsl:stylesheet>
--

Joe (Microsoft MVP - XML)
Reply With Quote