Dave Jarvis' Repositories

git clone https://repo.autonoma.ca/repo/recipe-books.git

More comments, renamed footer variable to clarify usage intent.

AuthorDave Jarvis <email>
Date2013-03-02 14:55:14 GMT-0800
Commita8f868d983238af313898195dc29743147dc6916
Parent8a42160
xsl/latex.xsl
<xsl:param name="ebook" select="true()" />
-<!-- If true, a footer (with page number) appears on full page photo pages. -->
-<xsl:param name="footer" select="false()" />
-
-<!--
- | Citation style format; valid values:
- | endcitations (default)
- | footercitations
- | inlinecitations
- +-->
-<xsl:param name="citation-style" select="''" />
-
-<!-- These will come from the XML...
-<xsl:param name="book-back-cover" select="true()" />
--->
-
-<!-- Keys -->
-<xsl:key name="ingredient-id" match="/recipe-book/ingredients/ingredient" use="@id" />
-<xsl:key name="recipe-by-category" match="recipe" use="tags/tag[1]" />
-
-<xsl:template match="/recipe-book">
- <xsl:text>\documentclass</xsl:text>
- <xsl:text>[</xsl:text>
- <xsl:if test="not($ebook)">
- <xsl:text>print,</xsl:text>
- </xsl:if>
- <xsl:if test="$footer">
- <xsl:text>fullpagefooter,</xsl:text>
- </xsl:if>
- <xsl:value-of select="$citation-style"/>
- <xsl:text>]</xsl:text>
- <xsl:text>{recipe-book}&#xa;</xsl:text>
- <xsl:text>\usepackage{hyperref}&#xa;</xsl:text>
- <xsl:value-of select="$preamble" />
- <xsl:text>\makeindex[flatingred]&#xa;</xsl:text>
- <xsl:text>\makeindex[catingred]&#xa;</xsl:text>
- <xsl:apply-templates select='book' />
- <xsl:text>\begin{document}&#xa;</xsl:text>
- <xsl:text>\frontmatter&#xa;</xsl:text>
- <xsl:if test="$book-front-cover">
- <xsl:text>\makecover</xsl:text>
- <xsl:if test="$book-copyright">
- <xsl:text>[copyrightpage]</xsl:text>
- </xsl:if>
- <xsl:text>&#xa;</xsl:text>
- </xsl:if>
- <xsl:apply-templates select="book/overview" mode="book-overview" />
- <xsl:if test="$recipe-toc">
- <xsl:text>\cleartoverso\tableofcontents*&#xa;</xsl:text>
- </xsl:if>
- <xsl:text>\mainmatter&#xa;</xsl:text>
-
- <!--
- | "Muenchian Method" as described in
- | XSLT Cookbook, by Sal Mangano, O'Reilly, pg195
- | for sorting tagged recipes into "chapters"
- +-->
- <xsl:for-each select="recipe[count(. | key('recipe-by-category',tags/tag[1])[1]) = 1]">
- <xsl:variable name="current-grouping-key" select="tags/tag[1]"/>
- <xsl:if test="$current-grouping-key != ''">
- <xsl:text>&#xa;\recipecategory{</xsl:text>
- <xsl:apply-templates select="$current-grouping-key" mode="escape-capitalize"/>
- <xsl:text>}&#xa;&#xa;</xsl:text>
- <xsl:variable name="current-group"
- select="key('recipe-by-category', $current-grouping-key)" />
- <xsl:for-each select="$current-group">
- <xsl:apply-templates select="." />
- </xsl:for-each>
- </xsl:if>
- </xsl:for-each>
-
- <!--
- | All untagged recipes to go into a "Recipes" chapter.
- +-->
- <xsl:if test="recipe[tags/tag = '' or not(tags/tag)]">
- <xsl:text>&#xa;\recipecategory{Recipes}&#xa;&#xa;</xsl:text>
- <xsl:apply-templates select="recipe[tags/tag = '' or not(tags/tag)]" />
- </xsl:if>
-
- <xsl:text>\backmatter&#xa;</xsl:text>
- <xsl:text>\renewcommand{\clearforchapter}{\newpage}&#xa;</xsl:text>
- <xsl:if test="$ingredient-index">
- <xsl:text>\renewcommand{\indexname}{Ingredients in Alphabetic Order}&#xa;</xsl:text>
- <xsl:text>\printindex[flatingred]&#xa;</xsl:text>
- <xsl:text>\renewcommand{\indexname}{Ingredients by Categories}&#xa;</xsl:text>
- <xsl:text>\reduceindexindent&#xa;</xsl:text>
- <xsl:text>\printindex[catingred]&#xa;</xsl:text>
- </xsl:if>
- <xsl:text>\end{document}&#xa;</xsl:text>
-</xsl:template>
-
-<!--
- | Meta information about the book.
- +-->
-<xsl:template match="book">
- <xsl:text>\title{</xsl:text>
- <xsl:apply-templates select="title" mode="escape-capitalize" />
- <xsl:text>}&#xa;</xsl:text>
- <xsl:text>\date{</xsl:text>
- <xsl:apply-templates select="created" mode="escape-capitalize" />
- <xsl:text>}&#xa;</xsl:text>
- <xsl:text>\author{</xsl:text>
- <xsl:apply-templates select="author" mode="escape-capitalize" />
- <xsl:text>}&#xa;</xsl:text>
- <xsl:apply-templates select="photo" mode="book" />
-</xsl:template>
-
-<xsl:template match="overview" mode="book-overview">
- <xsl:text>&#xa;\begin{overview}{</xsl:text>
- <xsl:apply-templates select="@label" mode="escape-capitalize" />
- <xsl:text>}&#xa;</xsl:text>
- <xsl:if test="../photo[@use='overview']">
- <xsl:apply-templates select="../photo[@use='overview']/uri" mode="book-overview"/>
- </xsl:if>
- <xsl:apply-templates select="p" />
- <xsl:text>\end{overview}&#xa;&#xa;</xsl:text>
-</xsl:template>
-
-<xsl:template match="p">
- <xsl:apply-templates modes="escape" />
- <xsl:text>&#xa;&#xa;</xsl:text>
-</xsl:template>
-
-<!--
- | Transforms a recipe from XML into LaTeX.
- +-->
-<xsl:template match="recipe">
- <!--
- | If a facing full-page photo is used, check whether a filler photo
- | (e.g., advertsement) is required to make up the page number.
- +-->
- <xsl:if test="description/photo[@use='one-page' or @use='two-page']">
- <xsl:text>\checkfiller&#xa;</xsl:text>
- </xsl:if>
- <xsl:text>\begin{recipe}{</xsl:text>
- <xsl:apply-templates select="description/title" />
- <xsl:text>}&#xa;</xsl:text>
- <xsl:apply-templates select="description/photo[@use='recipe-inset']" mode="recipe" />
- <xsl:apply-templates />
- <xsl:apply-templates select="description/photo[@use='one-page' or @use='two-page']" mode="recipe" />
- <xsl:text>\end{recipe}&#xa;&#xa;</xsl:text>
-</xsl:template>
-
-<xsl:template match="photo[@use='front-cover']" mode="book">
- <xsl:apply-templates select="citation[descendant::*]" />
- <xsl:apply-templates select="uri" mode="book" />
-</xsl:template>
-
-<xsl:template match="photo[@use='overview']" mode="book" />
-
-<xsl:template match="photo[@use='recipe-inset']" mode="recipe">
- <xsl:apply-templates select="citation[descendant::*]" />
- <xsl:apply-templates select="uri" mode="recipe-inset" />
-</xsl:template>
-
-<xsl:template match="photo[@use='one-page']" mode="recipe">
- <xsl:apply-templates select="citation[descendant::*]" />
- <xsl:apply-templates select="uri" mode="one-page" />
-</xsl:template>
-
-<xsl:template match="photo[@use='two-page']" mode="recipe">
- <xsl:apply-templates select="citation[descendant::*]" />
- <xsl:apply-templates select="uri" mode="two-page" />
-</xsl:template>
-
-<xsl:template match="uri" mode="book-overview">
- <xsl:text>\begin{wrapfigure}{l}{.45\textwidth}&#xa;</xsl:text>
- <xsl:text>\insetphoto[\linewidth]{</xsl:text>
- <xsl:apply-templates />
- <xsl:text>}&#xa;</xsl:text>
- <xsl:text>\end{wrapfigure}&#xa;&#xa;</xsl:text>
-</xsl:template>
-
-<xsl:template match="uri" mode="book">
- <xsl:if test="$book-front-cover">
- <xsl:text>\frontcoverphoto{</xsl:text>
- <xsl:apply-templates />
- <xsl:text>}&#xa;</xsl:text>
- </xsl:if>
-</xsl:template>
-
-<xsl:template match="uri" mode="recipe-inset">
- <xsl:text>\insetphoto{</xsl:text>
- <xsl:apply-templates />
- <xsl:text>}&#xa;</xsl:text>
-</xsl:template>
-
-<xsl:template match="uri" mode="one-page">
- <xsl:text>\fullpagephoto{</xsl:text>
- <xsl:apply-templates />
- <xsl:text>}&#xa;</xsl:text>
-</xsl:template>
-
-<xsl:template match="uri" mode="two-page">
- <xsl:text>\twopagespreadphoto{</xsl:text>
- <xsl:apply-templates />
- <xsl:text>}&#xa;</xsl:text>
-</xsl:template>
-
-<xsl:template match="photo/citation[descendant::*]">
- <xsl:if test="author">
- <xsl:text>\photocredit</xsl:text>
- <xsl:if test="author/@url">
- <xsl:text>[</xsl:text>
- <xsl:apply-templates select="author/@url" mode="escape" />
- <xsl:text>]</xsl:text>
- </xsl:if>
- <xsl:text>{</xsl:text>
- <xsl:apply-templates select="author" mode="escape" />
- <xsl:text>}&#xa;</xsl:text>
- </xsl:if>
-
- <xsl:if test="license">
- <xsl:text>\photolicense</xsl:text>
- <xsl:if test="license/@url">
- <xsl:text>[</xsl:text>
- <xsl:apply-templates select="license/@url" mode="escape" />
- <xsl:text>]</xsl:text>
- </xsl:if>
- <xsl:text>{</xsl:text>
- <xsl:apply-templates select="license" mode="escape" />
- <xsl:text>}&#xa;</xsl:text>
- </xsl:if>
-</xsl:template>
-
-<xsl:template match="description/title">
- <xsl:apply-templates mode="escape-capitalize" />
-</xsl:template>
-
-<!-- Pre-heated oven temperature, not to be confused with ingredient prep. -->
-<xsl:template match="preparation">
- <xsl:apply-templates />
-</xsl:template>
-
-<xsl:template match="oven">
- <xsl:text>\oven{</xsl:text>
- <xsl:value-of select="@temperature" />
- <xsl:text>\,</xsl:text>
- <xsl:choose>
- <xsl:when test="@unit='C' or @unit='F'">
- <xsl:text>\textdegree </xsl:text>
- </xsl:when>
- </xsl:choose>
- <xsl:value-of select="@unit" />
- <xsl:text>}&#xa;&#xa;</xsl:text>
-</xsl:template>
-
-<xsl:template match="equipment[descendant::text()]">
- <xsl:text>\begin{equipment}&#xa;</xsl:text>
- <!-- Select non-empty child nodes. -->
- <xsl:for-each select="*[child::*]">
- <xsl:text> \item[</xsl:text>
- <xsl:call-template name="escape-capitalize">
- <xsl:with-param name="ec" select="name()" />
- </xsl:call-template>
- <xsl:text>] </xsl:text>
- <xsl:call-template name="escape-capitalize">
- <xsl:with-param name="ec" select="." />
- </xsl:call-template>
- <xsl:text>&#xa;</xsl:text>
- </xsl:for-each>
- <xsl:text>\end{equipment}&#xa;&#xa;</xsl:text>
-</xsl:template>
-
-<!--
- | Puts the value of all labels (ingredients and directions) in brackets.
- +-->
-<xsl:template match="@label">
- <xsl:text>[</xsl:text>
- <xsl:call-template name="escape-capitalize">
- <xsl:with-param name="ec" select="." />
- </xsl:call-template>
- <xsl:text>]</xsl:text>
- <xsl:text>&#xa;</xsl:text>
-</xsl:template>
-
-<xsl:template match="ingredients[parent::recipe]">
- <xsl:text>\begin{ingredients}&#xa;</xsl:text>
- <xsl:apply-templates select="@label" />
- <xsl:apply-templates select="ingredient" />
- <xsl:text>\end{ingredients}&#xa;&#xa;</xsl:text>
-
- <!--
- | If non-empty conditions exist, insert a preparation section.
- +-->
- <xsl:if test="ingredient[@condition != '']">
- <xsl:text>\begin{preparation}&#xa;</xsl:text>
- <xsl:apply-templates select="ingredient[@condition != '']" mode="prep" />
- <xsl:text>\end{preparation}&#xa;</xsl:text>
- </xsl:if>
-</xsl:template>
-
-<xsl:template match="ingredient">
- <xsl:text> \ingred{</xsl:text>
-
- <xsl:call-template name="utf-fraction">
- <xsl:with-param name="quantity" select="@min-quantity" />
- </xsl:call-template>
-
- <xsl:if test="@max-quantity">
- <xsl:text>--</xsl:text>
-
- <xsl:call-template name="utf-fraction">
- <xsl:with-param name="quantity" select="@max-quantity" />
- </xsl:call-template>
- </xsl:if>
- <xsl:text>}{</xsl:text>
- <xsl:value-of select="@unit" />
- <xsl:text>}{</xsl:text>
- <xsl:apply-templates select="key('ingredient-id', @id)/@name" />
- <xsl:text>}%&#xa;</xsl:text>
-
- <!-- Put the ingredients in a categorized list. -->
- <xsl:if test="key('ingredient-id',@id)/categories/category">
- <xsl:for-each select="key('ingredient-id',@id)/categories/category">
- <xsl:text> \index[catingred]{</xsl:text>
- <xsl:call-template name="replace">
- <xsl:with-param name="pText" select="@name" />
- <xsl:with-param name="pToken" select="','" />
- <xsl:with-param name="pSubst" select="'!'" />
- </xsl:call-template>
- <xsl:text>!</xsl:text>
- <xsl:apply-templates select="../../@name" />
- <xsl:text>}%&#xa;</xsl:text>
- </xsl:for-each>
- </xsl:if>
-
- <!-- Put the ingredients in a flat list. -->
+<!-- If true, the page number appears on full-page photo pages. -->
+<xsl:param name="page-photo-footer" select="false()" />
+
+<!--
+ | Citation style format; valid values:
+ | endcitations (default)
+ | page-photo-footercitations
+ | inlinecitations
+ +-->
+<xsl:param name="citation-style" select="'page-photo-footercitations'" />
+
+<!-- These will come from the XML...
+<xsl:param name="book-back-cover" select="true()" />
+-->
+
+<!-- Keys -->
+<xsl:key name="ingredient-id" match="/recipe-book/ingredients/ingredient" use="@id" />
+<xsl:key name="recipe-by-category" match="recipe" use="tags/tag[1]" />
+
+<!--
+ | A recipe book consists of book details, recipes, categories, and tags.
+ +-->
+<xsl:template match="/recipe-book">
+ <xsl:text>\documentclass</xsl:text>
+ <xsl:text>[</xsl:text>
+ <xsl:if test="not($ebook)">
+ <xsl:text>print,</xsl:text>
+ </xsl:if>
+ <xsl:if test="$page-photo-footer">
+ <xsl:text>fullpagepage-photo-footer,</xsl:text>
+ </xsl:if>
+ <xsl:value-of select="$citation-style"/>
+ <xsl:text>]</xsl:text>
+ <xsl:text>{recipe-book}&#xa;</xsl:text>
+ <xsl:text>\usepackage{hyperref}&#xa;</xsl:text>
+ <xsl:value-of select="$preamble" />
+ <xsl:text>\makeindex[flatingred]&#xa;</xsl:text>
+ <xsl:text>\makeindex[catingred]&#xa;</xsl:text>
+ <xsl:apply-templates select='book' />
+ <xsl:text>\begin{document}&#xa;</xsl:text>
+ <xsl:text>\frontmatter&#xa;</xsl:text>
+ <xsl:if test="$book-front-cover">
+ <xsl:text>\makecover</xsl:text>
+ <xsl:if test="$book-copyright">
+ <xsl:text>[copyrightpage]</xsl:text>
+ </xsl:if>
+ <xsl:text>&#xa;</xsl:text>
+ </xsl:if>
+ <xsl:apply-templates select="book/overview" mode="book-overview" />
+ <xsl:if test="$recipe-toc">
+ <xsl:text>\cleartoverso\tableofcontents*&#xa;</xsl:text>
+ </xsl:if>
+ <xsl:text>\mainmatter&#xa;</xsl:text>
+
+ <!--
+ | "Muenchian Method" as described in
+ | XSLT Cookbook, by Sal Mangano, O'Reilly, pg195
+ | for sorting tagged recipes into "chapters"
+ +-->
+ <xsl:for-each select="recipe[count(. | key('recipe-by-category',tags/tag[1])[1]) = 1]">
+ <xsl:variable name="current-grouping-key" select="tags/tag[1]"/>
+ <xsl:if test="$current-grouping-key != ''">
+ <xsl:text>&#xa;\recipecategory{</xsl:text>
+ <xsl:apply-templates select="$current-grouping-key" mode="escape-capitalize"/>
+ <xsl:text>}&#xa;&#xa;</xsl:text>
+ <xsl:variable name="current-group"
+ select="key('recipe-by-category', $current-grouping-key)" />
+ <xsl:for-each select="$current-group">
+ <xsl:apply-templates select="." />
+ </xsl:for-each>
+ </xsl:if>
+ </xsl:for-each>
+
+ <!--
+ | All untagged recipes to go into a "Recipes" chapter.
+ +-->
+ <xsl:if test="recipe[tags/tag = '' or not(tags/tag)]">
+ <xsl:text>&#xa;\recipecategory{Recipes}&#xa;&#xa;</xsl:text>
+ <xsl:apply-templates select="recipe[tags/tag = '' or not(tags/tag)]" />
+ </xsl:if>
+
+ <xsl:text>\backmatter&#xa;</xsl:text>
+ <xsl:text>\renewcommand{\clearforchapter}{\newpage}&#xa;</xsl:text>
+ <xsl:if test="$ingredient-index">
+ <xsl:text>\renewcommand{\indexname}{Ingredients in Alphabetic Order}&#xa;</xsl:text>
+ <xsl:text>\printindex[flatingred]&#xa;</xsl:text>
+ <xsl:text>\renewcommand{\indexname}{Ingredients by Categories}&#xa;</xsl:text>
+ <xsl:text>\reduceindexindent&#xa;</xsl:text>
+ <xsl:text>\printindex[catingred]&#xa;</xsl:text>
+ </xsl:if>
+ <xsl:text>\end{document}&#xa;</xsl:text>
+</xsl:template>
+
+<!--
+ | Meta information about the book.
+ +-->
+<xsl:template match="book">
+ <xsl:text>\title{</xsl:text>
+ <xsl:apply-templates select="title" mode="escape-capitalize" />
+ <xsl:text>}&#xa;</xsl:text>
+ <xsl:text>\date{</xsl:text>
+ <xsl:apply-templates select="created" mode="escape-capitalize" />
+ <xsl:text>}&#xa;</xsl:text>
+ <xsl:text>\author{</xsl:text>
+ <xsl:apply-templates select="author" mode="escape-capitalize" />
+ <xsl:text>}&#xa;</xsl:text>
+ <xsl:apply-templates select="photo" mode="book" />
+</xsl:template>
+
+<xsl:template match="overview" mode="book-overview">
+ <xsl:text>&#xa;\begin{overview}{</xsl:text>
+ <xsl:apply-templates select="@label" mode="escape-capitalize" />
+ <xsl:text>}&#xa;</xsl:text>
+ <xsl:if test="../photo[@use='overview']">
+ <xsl:apply-templates select="../photo[@use='overview']/uri" mode="book-overview"/>
+ </xsl:if>
+ <xsl:apply-templates select="p" />
+ <xsl:text>\end{overview}&#xa;&#xa;</xsl:text>
+</xsl:template>
+
+<!--
+ | Allows users to provide descriptive text for the book.
+ +-->
+<xsl:template match="p">
+ <xsl:apply-templates modes="escape" />
+ <xsl:text>&#xa;&#xa;</xsl:text>
+</xsl:template>
+
+<!--
+ | Transforms a recipe from XML into LaTeX.
+ +-->
+<xsl:template match="recipe">
+ <!--
+ | If a facing full-page photo is used, check whether a filler photo
+ | (e.g., advertsement) is required to make up the page number.
+ +-->
+ <xsl:if test="description/photo[@use='one-page' or @use='two-page']">
+ <xsl:text>\checkfiller&#xa;</xsl:text>
+ </xsl:if>
+ <xsl:text>\begin{recipe}{</xsl:text>
+ <xsl:apply-templates select="description/title" />
+ <xsl:text>}&#xa;</xsl:text>
+ <xsl:apply-templates select="description/photo[@use='recipe-inset']" mode="recipe" />
+ <xsl:apply-templates />
+ <xsl:apply-templates select="description/photo[@use='one-page' or @use='two-page']" mode="recipe" />
+ <xsl:text>\end{recipe}&#xa;&#xa;</xsl:text>
+</xsl:template>
+
+<xsl:template match="photo[@use='front-cover']" mode="book">
+ <xsl:apply-templates select="citation[descendant::*]" />
+ <xsl:apply-templates select="uri" mode="book" />
+</xsl:template>
+
+<xsl:template match="photo[@use='overview']" mode="book" />
+
+<xsl:template match="photo[@use='recipe-inset']" mode="recipe">
+ <xsl:apply-templates select="citation[descendant::*]" />
+ <xsl:apply-templates select="uri" mode="recipe-inset" />
+</xsl:template>
+
+<xsl:template match="photo[@use='one-page']" mode="recipe">
+ <xsl:apply-templates select="citation[descendant::*]" />
+ <xsl:apply-templates select="uri" mode="one-page" />
+</xsl:template>
+
+<xsl:template match="photo[@use='two-page']" mode="recipe">
+ <xsl:apply-templates select="citation[descendant::*]" />
+ <xsl:apply-templates select="uri" mode="two-page" />
+</xsl:template>
+
+<xsl:template match="uri" mode="book-overview">
+ <xsl:text>\begin{wrapfigure}{l}{.45\textwidth}&#xa;</xsl:text>
+ <xsl:text>\insetphoto[\linewidth]{</xsl:text>
+ <xsl:apply-templates />
+ <xsl:text>}&#xa;</xsl:text>
+ <xsl:text>\end{wrapfigure}&#xa;&#xa;</xsl:text>
+</xsl:template>
+
+<xsl:template match="uri" mode="book">
+ <xsl:if test="$book-front-cover">
+ <xsl:text>\frontcoverphoto{</xsl:text>
+ <xsl:apply-templates />
+ <xsl:text>}&#xa;</xsl:text>
+ </xsl:if>
+</xsl:template>
+
+<xsl:template match="uri" mode="recipe-inset">
+ <xsl:text>\insetphoto{</xsl:text>
+ <xsl:apply-templates />
+ <xsl:text>}&#xa;</xsl:text>
+</xsl:template>
+
+<xsl:template match="uri" mode="one-page">
+ <xsl:text>\fullpagephoto{</xsl:text>
+ <xsl:apply-templates />
+ <xsl:text>}&#xa;</xsl:text>
+</xsl:template>
+
+<xsl:template match="uri" mode="two-page">
+ <xsl:text>\twopagespreadphoto{</xsl:text>
+ <xsl:apply-templates />
+ <xsl:text>}&#xa;</xsl:text>
+</xsl:template>
+
+<xsl:template match="photo/citation[descendant::*]">
+ <xsl:if test="author">
+ <xsl:text>\photocredit</xsl:text>
+ <xsl:if test="author/@url">
+ <xsl:text>[</xsl:text>
+ <xsl:apply-templates select="author/@url" mode="escape" />
+ <xsl:text>]</xsl:text>
+ </xsl:if>
+ <xsl:text>{</xsl:text>
+ <xsl:apply-templates select="author" mode="escape" />
+ <xsl:text>}&#xa;</xsl:text>
+ </xsl:if>
+
+ <xsl:if test="license">
+ <xsl:text>\photolicense</xsl:text>
+ <xsl:if test="license/@url">
+ <xsl:text>[</xsl:text>
+ <xsl:apply-templates select="license/@url" mode="escape" />
+ <xsl:text>]</xsl:text>
+ </xsl:if>
+ <xsl:text>{</xsl:text>
+ <xsl:apply-templates select="license" mode="escape" />
+ <xsl:text>}&#xa;</xsl:text>
+ </xsl:if>
+</xsl:template>
+
+<xsl:template match="description/title">
+ <xsl:apply-templates mode="escape-capitalize" />
+</xsl:template>
+
+<!-- Pre-heated oven temperature, not to be confused with ingredient prep. -->
+<xsl:template match="preparation">
+ <xsl:apply-templates />
+</xsl:template>
+
+<xsl:template match="oven">
+ <xsl:text>\oven{</xsl:text>
+ <xsl:value-of select="@temperature" />
+ <xsl:text>\,</xsl:text>
+ <xsl:choose>
+ <xsl:when test="@unit='C' or @unit='F'">
+ <xsl:text>\textdegree </xsl:text>
+ </xsl:when>
+ </xsl:choose>
+ <xsl:value-of select="@unit" />
+ <xsl:text>}&#xa;&#xa;</xsl:text>
+</xsl:template>
+
+<xsl:template match="equipment[descendant::text()]">
+ <xsl:text>\begin{equipment}&#xa;</xsl:text>
+ <!-- Select non-empty child nodes. -->
+ <xsl:for-each select="*[child::*]">
+ <xsl:text> \item[</xsl:text>
+ <xsl:call-template name="escape-capitalize">
+ <xsl:with-param name="ec" select="name()" />
+ </xsl:call-template>
+ <xsl:text>] </xsl:text>
+ <xsl:call-template name="escape-capitalize">
+ <xsl:with-param name="ec" select="." />
+ </xsl:call-template>
+ <xsl:text>&#xa;</xsl:text>
+ </xsl:for-each>
+ <xsl:text>\end{equipment}&#xa;&#xa;</xsl:text>
+</xsl:template>
+
+<!--
+ | Puts the value of all labels (ingredients and directions) in brackets.
+ +-->
+<xsl:template match="@label">
+ <xsl:text>[</xsl:text>
+ <xsl:call-template name="escape-capitalize">
+ <xsl:with-param name="ec" select="." />
+ </xsl:call-template>
+ <xsl:text>]</xsl:text>
+ <xsl:text>&#xa;</xsl:text>
+</xsl:template>
+
+<xsl:template match="ingredients[parent::recipe]">
+ <xsl:text>\begin{ingredients}&#xa;</xsl:text>
+ <xsl:apply-templates select="@label" />
+ <xsl:apply-templates select="ingredient" />
+ <xsl:text>\end{ingredients}&#xa;&#xa;</xsl:text>
+
+ <!--
+ | If non-empty conditions exist, insert a preparation section.
+ +-->
+ <xsl:if test="ingredient[@condition != '']">
+ <xsl:text>\begin{preparation}&#xa;</xsl:text>
+ <xsl:apply-templates select="ingredient[@condition != '']" mode="prep" />
+ <xsl:text>\end{preparation}&#xa;</xsl:text>
+ </xsl:if>
+</xsl:template>
+
+<xsl:template match="ingredient">
+ <xsl:text> \ingred{</xsl:text>
+
+ <xsl:call-template name="utf-fraction">
+ <xsl:with-param name="quantity" select="@min-quantity" />
+ </xsl:call-template>
+
+ <xsl:if test="@max-quantity">
+ <xsl:text>--</xsl:text>
+
+ <xsl:call-template name="utf-fraction">
+ <xsl:with-param name="quantity" select="@max-quantity" />
+ </xsl:call-template>
+ </xsl:if>
+ <xsl:text>}{</xsl:text>
+ <xsl:value-of select="@unit" />
+ <xsl:text>}{</xsl:text>
+ <xsl:apply-templates select="key('ingredient-id', @id)/@name" />
+ <xsl:text>}%&#xa;</xsl:text>
+
+ <!-- Put the ingredients in a categorized list. -->
+ <xsl:if test="key('ingredient-id',@id)/categories/category">
+ <xsl:for-each select="key('ingredient-id',@id)/categories/category">
+ <xsl:text> \index[catingred]{</xsl:text>
+ <xsl:call-template name="replace">
+ <xsl:with-param name="pText" select="@name" />
+ <xsl:with-param name="pToken" select="','" />
+ <xsl:with-param name="pSubst" select="'!'" />
+ </xsl:call-template>
+ <xsl:text>!</xsl:text>
+ <xsl:apply-templates select="../../@name" />
+ <xsl:text>}%&#xa;</xsl:text>
+ </xsl:for-each>
+ </xsl:if>
+
+ <!-- Index ingredients into a flat list. -->
<xsl:text> \index[flatingred]{</xsl:text>
<xsl:apply-templates select="key('ingredient-id', @id)/@name" />
Delta333 lines added, 327 lines removed, 6-line increase