This Recipe Book is presented by FJD1.com , also as a working example of XML, XSL, & DTD.
Click to visit Trillium University

Trillium University

Culinary School Recipe Book

This page has been depricated!

The code on this page may still be of interest as it presents an example of: XML, XSL, DTD
The new page is a continuation of this project with the added features of allowing users to add recipes to the database, and upload or include a link to their recipe image. These features are written in PHP5 and a source view of this code will soon be made available. Code will remain viewable on this page, and the new code will be posted here at a later date.


Please click here for the new Recipe Book

Scroll down if interested in the code used in this book.

Appetizers

  • Blooming Onion
  • Poppers
  • Stuffed Mushrooms

    Barbecue

    Beverages

    Breads

    Breakfast

    Brunch

    Cakes

    Candy

    Casseroles

    Cookies

    Desserts

    Dinner

    Drinks

    Extras

    Lunch

    Meats

    Pies

    Poultry

    Salads

    Sauces

    Snacks

    Soups

    Supper



    Recipe Writer

    This is the recipe writer (JavaScript) form.
    Enter your recipe information and it will generate the XML code for you to copy and paste to a text file you will name as your_recipe_name.xml and have completed your first XML recipe page. Send us a copy so we may include your recipe on file here.
       Title
       Cook
       Category
       Prep. time
       Yield
    Description

    Ingredients:
    Item 1    
    Item 2    
    Item 3    
    Item 4    
    Item 5    
    Item 6    
    Item 7    
    Item 8    
    Item 9    
    Item 10   
    Item 11   
    Item 12   
    Directions:
    Step 1   
    Step 2   
    Step 3   
    Step 4   
    Step 5   
    Step 6   
       Illustration URL
    Comment:




    After copying the text to your clipboard, open your favorite text editor (Notepad, Wordpad, SynEdit, CodeMax or ?) and PASTE . Now save this file with an extension of xml. (That just means the filename should end in ".xml" instead of ".txt" or ".htm".)

    There are three documents required to make these recipes work.
    The DTD, the XSL style sheet, and the actual XML recipe file

    This is the code for the DTD

    The DTD is responsible for defining the marking up. Note that this file may have been updated since writing the html code needed for their presentation here so some actual features may be missing from the code below. The actual DTD is here but you will need to save it and open it with a text editor to view it instead of simply clicking on the link.

    
     <!ELEMENT recipe 
     (title, cook, category, description, prep_time, illustration,
      ingredients, directions, yield, comment)>
     <!ELEMENT title (#PCDATA)>
     <!ELEMENT cook (#PCDATA)> 
     <!ELEMENT category (#PCDATA)>
     <!ELEMENT prep_time (#PCDATA)> 
     <!ELEMENT description (#PCDATA)>
     <!ELEMENT ingredients (item+)>
     <!ELEMENT item (#PCDATA)>
     <!ELEMENT ingredient (#PCDATA)>
     <!ELEMENT directions (step*)>
     <!ELEMENT step (#PCDATA)>
     <!ELEMENT yield (#PCDATA)>
     <!ELEMENT illustration EMPTY>
     <!ATTLIST illustration href CDATA #REQUIRED>    
     <!ELEMENT comment (#PCDATA)>
    
    

    This is the code for the XSL style sheet

    The style sheet is responsible for marking up the recipes (XML files in general) into what looks like a regular web page. It includes a lot of html and anything which is common to all the recipe pages. Note that these files (here) in general may have been updated since writing the html code needed for their presentation here so some actual features may be missing from the code below. Click here to view the actual style sheet.

    
    
    <?xml version="1.0"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
    
    <xsl:template match="/">
       <xsl:apply-templates />
    </xsl:template>
    
    <xsl:template match="/">
    <html>
     <head>
      <title>Trillium University Culinary School - Recipe </title>
    <style type="text/css">
    body { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12pt; background-color: #ffffb0;}
    a:active { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11pt; color: #FF00FF; text-decoration: none}
    a:hover { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11pt; color: #000033; text-decoration: none}
    a:link { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11pt; color: #0000FF; text-decoration: none}
    a:visited { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11pt; color: #999999; text-decoration: none}
    h3: {font-size: 1.5em}
    </style>
     </head>
       <body >
         <xsl:apply-templates />
       </body>
    </html>
    </xsl:template>
    
    
    
    <xsl:template match="recipe">
    
    <a href="../../index.html"><img src="../../images/tu.gif" border="0" /> INDEX</a>
    
    <table width="100%"><tr><td>
    <b>Category:</b>  <xsl:value-of select="category" />
    </td>
    <td align="right">
    <b>Preperation time:</b>  <xsl:value-of select="prep_time" />
    </td>
    </tr>
    
    <tr>
    <td colspan="2"><center>
    <p style="font-size: 1.25em">
       <span style="font-size: 1.2em">
         <xsl:value-of select="title" /></span>
    </p>
    </center></td></tr>
    
    <tr>
    <td colspan="2"><center>
    <xsl:value-of select="description" />
    </center></td></tr>
    
    
    <tr>
    <td colspan="2"><center>
    <b>Cook:</b>  <xsl:value-of select="cook" />
    </center></td></tr>
    
    </table>
    
    
    <xsl:apply-templates />
    </xsl:template>
    
    
    
    
    
    <xsl:template match="illustration">
    <center>
       <xsl:element name="img">
          <xsl:attribute name="src">
          <xsl:value-of select="@href"/>
          </xsl:attribute>
          <xsl:apply-templates/>
       </xsl:element>
    </center>
    </xsl:template>
    
    
    
    
    
    
    <xsl:template match="ingredients">
    <h3>Ingredients:</h3>
    <p>
            <xsl:for-each select="item">
      		<xsl:value-of/><br/>		
    		</xsl:for-each>
    </p>
    </xsl:template>
    
    
    <xsl:template match="directions">
    <h3>Directions:</h3 >
       <p><ol>
            <xsl:for-each select="step">
      		<li><xsl:value-of/></li>
    		</xsl:for-each>
      </ol>
    </p>
    </xsl:template>
    
    <xsl:template match="yield">
    <p>
      <b>Yield:</b>
       <xsl:value-of/><br/>
    </p>
    </xsl:template>
    
    </xsl:stylesheet>
    
    
    
    

    This is the code for the recipe in XML

    
    
    <?xml version="1.0"?>
    <!DOCTYPE recipe SYSTEM "../../dtd/recipe.dtd">
    <?xml-stylesheet type="text/xsl" href="../../style/recipe.xsl" ?>
    
    <recipe>
     <title>Cake Mix Drop Cookies</title>
     <cook>anonymous Industrial cook</cook>
     <category>Cookies</category>
     <description>Drop cookies made from cake mix package</description>
     <prep_time>1/2 Hour</prep_time>
    <illustration href="../../images/GARLIC.jpg" />
     <ingredients>
      <item>Cake Mix</item>
      <item>1/2 cup Oil</item>
      <item>2 Tablespoons  Water</item>
     </ingredients>
     <directions>
    <step>Preheat oven to 350&#176; F.</step>
    <!-- &#176; is the degree symbol -->
      <step>Mix all ingredients.</step>
    <step>Drop onto ungreased baking sheet and bake 10 min.</step>
     </directions>
     <yield>20 - 30 cookies</yield>
    </recipe>
    
    
    
    
    

    This is a simple, yet functional example of XML.
    To fully understand the relationship between documents, it may be helpful to understand the directory structure being used (any could work, but this is how it is done here, and if you use a different directory structure, you may need to make many subtle changes through the documents to correct the links.)

    All of this is contained in the directory CookBook and the full address of THIS page is http://fjd1.com/CookBook/index.html

    Within this directory is to also be found "favicon.ico", and the directories: "/dtd", "/images", "/recipes", "/script", and "/style".

    In addition, "recipes" also has directories in it for categories of recipes. It is within these directories that the XML recipe files reside. Typical of these would be: http://fjd1.com/CookBook/cookies/cakepackagecookies.xml

    Within "/dtd" is the file: "recipe.dtd"

    Within "/script" is the script on this page "RMLwriter.js" used to write XML recipe documents (above.)

    Within "/style" are: "recipe.css" and "recipe.xsl"

    Images for everything are contained in "/images".
    Note 1: I have cooked for a couple of restaurants including the Govenor House in Olympia, Washington and worked as the Cook aboard the Cherikoff (a purse seiner out of Craig, Alaska.) I am trying to get a few of my friends (some professional cooks, some just good at preparing food or making wine etc.) interested in developing an online school of cooking. This recipe collection is the beginning of this school, and is serving a dual role, perhaps more. These recipe pages (not this page, but the recipe pages linked above in the table of contents) are written in XML (eXtensible Markup Language) and are a working example for those who are interested in seeing examples of this code (as well as the related DTD's and XSL required to make them function.) Note the example above; the recipe is all there. The tags are all understandable to a cook. The webmaster is able to use this RML (Recipe Markup Language?) with the XSL and DTD to turn it into a webpage on the fly. The webmaster just needs to teach the cook how to write in this new RML. Easy eh? (This process is now automated by the form above and all the cook need do now, is fill in the blanks and the entire RML page will be created from them. The webmaster now only needs to teach the client/cook how to paste it as a text file, rename it as an XML-recipe and then upload it to their website's CookBook directory.) Note also that there are other more complete recipe markup languages such as the following one identified as "RecipeML" at http://www.formatdata.com, and that our examples and recipes here are not derived from theirs. (Their DTD file is called recipeml.dtd and ours is named recipe.dtd and our's is intentionally less sophisticated and flexible, being an example rather than having been designed for the real world and industry. If you are looking for an out of the box soution for your food manufactureing needs we suggest you look there.) If you would enjoy helping create an online school of food and drink prep., Send us an email, Trillium University can use your help. -F. Davies Note 2:
    I've gotten a reply from an email I sent to the author of "RecipeML" at http://www.formatdata.com

    After reading the letter below, I beleive I might just hack my current version and with the aid of php, create more than an example, ...an online CookBook which users may contribute recipes to, ...in the near future. I've pretty much gotten the 'go ahead', and considering how much work has gone into his RecipeML and how well done it is, ...I may incorporate some of his ideas. Here is a link to the documentation on RecipeML version .5

    Hi, Frank.
    
    ...
    
    The License Agreement I worked up was my first shot at a legal 
    document.  My main intent with it was that if people claim their 
    software "works with RecipeML" (meaning my schema), there should be 
    some kind of check to ensure that it is truly compatible before they 
    can use the name.  Many people have misunderstood this and it's 
    caused a bit of confusion.  In essence, you can use the DTD if you 
    want to; mainly I like to learn what people are doing with it.  I 
    really need to let the world know that I've revoked the license and 
    open it up for universal use.  (Someday I'll have the time to modify 
    my website!)  I've given up on the business of trying to insure 
    interoperability.
    
    If you're using a schema that you call "Recipe Markup Language" to 
    demonstrate XML, or for any other reason, don't let me or my site 
    stand in your way.  In fact, if you'd like to use my DTD for teaching 
    or illustration, feel free.  It won't be the first time.  I know of a 
    few places that have used it as an example, including a class at 
    Harvard and an organization called Webucator 
    (see http://www.webucator.com/).  
    
    BTW, are there features in your schema that 
    you'd like to see in RecipeML?  Something I've left out?
    
    Thanks for taking the time to write to me.  Good luck with your 
    endeavors.
    
    - Jim Saiya