source: recipecards/trunk/recipe.xsl

Last change on this file was 4, checked in by peter, 11 years ago
  • put the recipe XML into a namespace (http://xmlns.grim.ath.cx/recipe)
  • match "degrees" and turn it into a degree symbol
  • added a recipe.html.xsl stylesheet that transforms recipe XML into HTML marked up with the hRecipe microformat
File size: 1.8 KB
Line 
1<?xml version="1.0" encoding="UTF-8"?>
2
3<xsl:stylesheet version="1.0"
4  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
5  xmlns:recipe="http://xmlns.grim.ath.cx/recipe"
6  xmlns:fo="http://www.w3.org/1999/XSL/Format">
7
8  <!-- TODO: come up with various page configurations,
9       e.g. index card, half letter, full letter hole-punched, etc.
10  -->
11  <xsl:param name="size">5x8</xsl:param>
12  <xsl:variable name="height" select="substring-before($size, 'x')"/>
13  <xsl:variable name="width" select="substring-after($size, 'x')"/>
14
15  <xsl:template match="recipe:recipe">
16    <fo:root font-family="DejaVuSerif" font-size="10pt">
17      <fo:layout-master-set>
18        <fo:simple-page-master master-name="recipe-card" page-height="{$height}in" page-width="{$width}in">
19          <fo:region-body margin=".25in .5in .25in .25in"/>
20        </fo:simple-page-master>
21      </fo:layout-master-set>
22
23      <fo:page-sequence master-reference="recipe-card">
24        <fo:flow flow-name="xsl-region-body">
25          <xsl:apply-templates/>
26        </fo:flow>
27      </fo:page-sequence>
28    </fo:root>
29  </xsl:template>
30
31  <xsl:template match="recipe:title">
32    <fo:block margin-bottom=".5em" font-weight="bold">
33      <xsl:value-of select="."/>
34    </fo:block>
35  </xsl:template>
36
37  <xsl:template match="recipe:ingredients">
38    <fo:block margin-bottom=".5em">
39      <xsl:apply-templates/>
40    </fo:block>
41  </xsl:template>
42
43  <xsl:template match="recipe:ingredient">
44    <fo:block line-height="1.25"><xsl:value-of select="."/></fo:block>
45  </xsl:template>
46
47  <xsl:template match="recipe:note">
48    <fo:block line-height="1.25" margin-left="1em" font-size="90%"><xsl:value-of select="."/></fo:block>
49  </xsl:template>
50
51  <xsl:template match="recipe:para">
52    <fo:block margin-bottom=".5em">
53      <xsl:value-of select="."/>
54    </fo:block>
55  </xsl:template>
56
57</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.