This document gives a short introduction to writing recipes in the RecipeBook XML markup language. Several examples are given to illustrate key points.
A basic RecipeBook XML recipe consists of three main parts, a title, a list of ingredients and preparation instructions. Each of these is represented by a set of tags much like HTML. A very simple recipe is shown below.
<recipe> <title>Peanutbutter On A Spoon</title> <ingredientlist> <ingredient>Peanutbutter</ingredient> </ingredientlist> <preparation>Stick a spoon in a jar of peanutbutter, scoop and pull out a big glob of peanutbutter.</preparation> </recipe>
Additional information about the recipe may be included by using the optional <recipeinfo>, <serving> and <notes> tags. Here is an example of the previous recipe being expanded to include more information. New information is shown as highlighted text.
<recipe> <title>Peanutbutter On A Spoon</title> <recipeinfo> <blurb>A crunchy snack that is easy to share with friends.</blurb> <author>Little Johnny</author> <source>Johnny's Mom</source> <yield>1 spoonful</yield> </recipeinfo> <ingredientlist> <ingredient>Peanutbutter</ingredient> </ingredientlist> <preparation>Stick a spoon in a jar of peanutbutter, scoop and pull out a big glob of peanutbutter.</preparation> <serving>Put the peanutbutter coated spoon in your mouth and enjoy.<serving> <notes>Keep a glass of milk handy to avoid getting your tongue stuck to the roof of your mouth.</notes> </recipe>
It is possible to add more detail to a recipe's ingredients by using the optional tags <quantity>, <unit> and <fooditem>. These tags may be used within <ingredient> to specify how ingredients are measured. An example is shown below.
<recipe> <title>Peanutbutter And Celery</title> <recipeinfo> <blurb>A crunchy snack that is easy to share with friends.</blurb> <author>Little Johnny</author> <source>Johnny's Mom</source> <yield>4 sticks</yield> </recipeinfo> <ingredientlist> <ingredient><quantity>4</quantity> <unit>tsp.<unit> of <fooditem>peanutbutter<fooditem></ingredient> <ingredient><quantity>2</quantity> <unit>ribs<unit> of <fooditem>celery<fooditem></ingredient> </ingredientlist> <preparation>Ask Mom to cut the celery ribs in half. Stick a teaspoon in a jar of peanutbutter. Spread the peanut butter in the hollow part of the celery. Repeat until all four are done.</preparation> <serving>Serve with a glass of milk.</serving> </recipe>
While these tags are not required they can be useful for programs that do things like automatically compile shopping lists so it is good to include them in the recipe.
It should also be noted that there is no specific order required for the tags nor is it necessary to include all three. So, for example, an ingredient like <ingredient>Juice from <quantity>1</quantity> <fooditem>lime</fooditem> is perfectly fine. <ingredient><fooditem>Salt</fooditem> to taste.</ingredient> is valid as well.
In addition to marking parts of the ingredient list it is also possible to mark parts of the preparation. Specifically, any equipment required for the preparation can be placed between <equipment> tags.
<recipe>
<title>Peanutbutter And Celery</title>
<recipeinfo>
<blurb>A crunchy snack that is easy to share with friends.</blurb>
<author>Little Johnny</author>
<source>Johnny's Mom</source>
<yield>4 sticks</yield>
</recipeinfo>
<ingredientlist>
<ingredient><quantity>4</quantity> <unit>tsp.<unit> of <fooditem>peanutbutter<fooditem></ingredient>
<ingredient><quantity>2</quantity> <unit>ribs<unit> of <fooditem>celery<fooditem></ingredient>
</ingredientlist>
<preparation>Ask Mom to cut the celery ribs in half. Stick <equipment>a teaspoon</equipment> in a jar of
peanutbutter. Spread the peanut butter in the hollow part of the celery. Repeat until all four are done.</preparation>
<serving>Serve with a glass of milk.</serving>
</recipe>
Just like the ingredient markup, the equipment tags aid programs that automatically create a list of required equipment by examining the preparation instructions.
RecipeBook XML recipes can be checked for proper structure by using a validation service like the one at http://validator.w3.org. For this to work there must be an XML declaration and a document type definition (DTD) declaration at the beginning of the RecipeBook XML document. The example below shows the first few lines of the sample recipe with the declarations added.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE recipe PUBLIC "-//Happy-Monkey//DTD RecipeBook//EN"
"http://www.happy-monkey.net/recipebook/recipebook.dtd">
<recipe>
<title>Peanutbutter And Celery</title>
...
Now that you have learned the basics of RecipeBook XML check out the other documentation on the RecipeBook XML web site.