home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / XML Utilities / Professional Programmer XSL IDE / Xselerator25.msi / Data.Cab / F18042_DrinkParams.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2001-10-04  |  2.7 KB  |  78 lines

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <!-- ===========================================================
  3.   Styelsheet:     DrinkParams.xsl
  4.   Category:       FilteringSorting
  5.   Sub-category:   Filtering: Selecting records based on parameters
  6.   Author:         David Silverlight
  7.                   HeadGeek@xmlpitstop.com
  8.   Created:        2001-05-16
  9.   Description:-
  10.     This stylesheet demonstrates filtering records based on a
  11.     value passed in as a parameter.  In this example, we are
  12.     extracting only the records that match the parameter passed
  13.     in.
  14. ================================================================ -->
  15. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  16.   <xsl:output method="html" encoding="ISO-8859-1" doctype-public="-//W3C//DTD HTML 4.0 Transitional//EN" />
  17.   <!-- Display of drink listing (note the default value) -->
  18.   <xsl:param name="drinktype" select="'house'" />
  19.  
  20.   <xsl:template match="/">
  21.     <html>
  22.       <head>
  23.         <title>FilteringSorting - Filtering: Selecting records based on parameters</title>
  24.         <style type="text/css">
  25.           H1 {COLOR: red; FONT-FAMILY: Arial; FONT-SIZE: 14pt;}
  26.           H2 {COLOR: darkblue; FONT-FAMILY: Arial; FONT-SIZE: 12pt;}
  27.           .head {COLOR: darkblue; FONT-FAMILY: Arial; FONT-SIZE: 14pt;}
  28.           .subhead {COLOR: darkblue; FONT-FAMILY: Arial; FONT-SIZE: 12pt;}
  29.           .text {COLOR: black; FONT-FAMILY: Arial; FONT-SIZE: 12pt;}
  30.           TH {COLOR: white; FONT-FAMILY: Arial; background-color: darkblue;}
  31.           TD {COLOR: darkblue; FONT-FAMILY: Arial}
  32.           TR { background-color: beige; }
  33.           BODY { background-color: beige; }
  34.         </style>
  35.       </head>
  36.       <body>
  37.         <xsl:apply-templates select="drinks/drink[drinktype=$drinktype]" />
  38.       </body>
  39.     </html>
  40.   </xsl:template>
  41.  
  42.   <xsl:template match="drink">
  43.       <xsl:if test="position() > 1">
  44.           <hr/>
  45.       </xsl:if>
  46.     <xsl:apply-templates select="name" />
  47.     <xsl:apply-templates select="directions" />
  48.     <xsl:apply-templates select="ingredients" />
  49.   </xsl:template>
  50.  
  51.   <xsl:template match="name">
  52.     <font color="darkred" face="arial" size="5">
  53.       <xsl:value-of select="." />
  54.       <BR />
  55.       <BR />
  56.     </font>
  57.   </xsl:template>
  58.  
  59.   <xsl:template match="directions">
  60.     <font face="arial black" size="3">Directions:</font>
  61.     <br/>
  62.     <xsl:value-of select="." />
  63.     <br/>
  64.     <br/>
  65.   </xsl:template>
  66.  
  67.   <xsl:template match="ingredients">
  68.     <font face="arial black" size="3">Ingredients:</font>
  69.     <xsl:apply-templates />
  70.   </xsl:template>
  71.  
  72.   <xsl:template match="ingredient">
  73.     <ul>
  74.       <xsl:value-of select="." />
  75.     </ul>
  76.   </xsl:template>
  77. </xsl:stylesheet>
  78.