introduction multimedia
[] readme course preface 1 2 3 4 5 6 7 appendix checklist research quotes resources director

talk show tell print

example-recipe.xsl


  <?xml version="1.0"?>
  

recipe

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

For an example look at recipe

recipe


  <xsl:template match="/Recipe">
  <HTML>
  <HEAD>
  <TITLE>
  <xsl:value-of select="Name"/>
  </TITLE>
  </HEAD>
  

body


  <BODY>
  <H3>
  <xsl:value-of select="Name"/>
  </H3>
  <STRONG>
  <xsl:value-of select="Description"/>
  </STRONG>
  <xsl:apply-templates/>
  </BODY>
  </HTML>
  </xsl:template>
  

format ingredients


  
  <!-- Format ingredients -->
  <xsl:template match="Ingredients">
  <H4>Ingredients</H4>
  <TABLE BORDER="1">
  <TR BGCOLOR="#308030"><TH>Qty</TH><TH>Units</TH><TH>Item</TH></TR>
  <xsl:for-each select="Ingredient">
  <TR>
  
  

quantity


  
  <!-- handle empty Qty elements separately -->
  <xsl:if test='Qty[not(.="")]' > 
  <TD><xsl:value-of select="Qty"/></TD>
  </xsl:if>
  
  <xsl:if test='Qty[.=""]' > 
  <TD BGCOLOR="#404040"> </TD>
  </xsl:if>
  
  

units


  
  <TD><xsl:value-of select="Qty/@unit"/></TD>
  <TD><xsl:value-of select="Item"/>
  <xsl:if test='Item/@optional="1"'>
  <SPAN> -- <em><STRONG>optional</STRONG></em></SPAN>
  </xsl:if>
  </TD>
  </TR>
  </xsl:for-each>
  
  </TABLE>
  </xsl:template>
  
  

instructions


  
  <!-- Format instructions -->
  <xsl:template match="Instructions">
  <H4>Instructions</H4>
  <OL>
  <xsl:apply-templates select="Step"/>
  </OL>
  </xsl:template>
  
  <xsl:template match="Step">
  <LI><xsl:value-of select="."/></LI>
  </xsl:template>
  
  

etc


  
  <!-- ignore all not matched -->
  <xsl:template match="*" priority="-1"/>
  
  </xsl:stylesheet>
  


[] readme course preface 1 2 3 4 5 6 7 appendix checklist research quotes resources director
eliens@cs.vu.nl

draft version 0.9 (7/1/2002)