Dave Jarvis' Repositories

git clone https://repo.autonoma.ca/repo/recipe-fiddle.git
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:r="http://www.whitemagicsoftware.com/software/recipe"
  xmlns:string="http://symphony-cms.com/functions"
  xmlns:str="http://exslt.org/strings"
  exclude-result-prefixes="r str string">

<xsl:output
  method="xml" encoding="utf-8" indent="yes"
  omit-xml-declaration="yes" standalone="yes" media-type="text/xhtml"
  doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
  doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" />

<!--
 | STYLESHEET PARAMETERS
 +-->
<xsl:param name="editable">false</xsl:param>

<xsl:strip-space elements="*" /> 

<xsl:key name="category-name" match="ingredient/categories/category" use="@name" />

<!--
 | Discard empty nodes (e.g., <bakeware />).
 +-->
<xsl:template match="*[not(@*) and not(*) and not(text())]" />

<xsl:variable name="base">/recipes/</xsl:variable>
<xsl:variable name="base-admin">/recipes/admin/</xsl:variable>

<xsl:template match="//admin">
<html xml:lang="en" lang="en">
<head>
  <title>Recipe Zeal</title>
  <meta name="copyright" content="Copyright 2012" /> 
  <base href="{$base-admin}" />

  <link rel="stylesheet" href="{$base-admin}css/jquery.shuttle.css" type="text/css" />
  <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
  <script type="text/javascript" src="{$base}common/js/shuttle.admin/diacritics.js"></script>
  <script type="text/javascript" src="{$base}common/js/shuttle.admin/jquery.shuttle.js"></script>
  <script type="text/javascript" src="{$base-admin}js/rz.admin.js"></script>
</head>
<body id="doc">
<form id="category" name="category" method="post">
  <label for="ingredients">Ingredients</label>
  <br />
  <select id="ingredients" name="ingredients[]" multiple="multiple" size="15">
    <xsl:apply-templates select="ingredients" />
  </select>
  <br />

  <button id="button-invert" name="command" value="">Invert Selection</button>

  <button id="button-delete" name="command" value="delete.ingredient">Delete Ingredient</button>

  <input type="text" name="ingredient" id="ingredient" value="" max="30" size="30" />

  <button id="button-rename" name="command" value="rename.ingredient">Rename Ingredient</button>
  <br />

  <p></p>
  <table border="0" cellpadding="2" cellspacing="2">
  <tr>
  <td>
    <label for="categories">Categories</label>
  </td>
  </tr>
  <tr>
    <td valign="top">
      <select id="categories" name="category" size="15">
      <xsl:apply-templates select="categories" />
  <!--
        <xsl:for-each select="ingredient/categories/category">
          <xsl:variable name="name" select="@name" />
          <xsl:if test="generate-id() = generate-id( key( 'category-name', $name )[1] )">
            <option><xsl:value-of select="$name" /></option>
          </xsl:if>
        </xsl:for-each>
  -->
      </select>
      <p>
      <button id="button-assign" name="command" value="assign">Assign Category</button>
      <xsl:text>&#10;</xsl:text>
      <label>Auto-select <input type="checkbox" name="auto-select" id="auto-select" checked="true" /></label>
      </p>
    </td>
    <td valign="top">
      <div id="wikipedia" style="display: inline; vertical-align: top">
      </div>
    </td>
  </tr>
  </table>
</form>
Category Databases: <a href="http://www.foodsubs.com">FoodSubs</a> |
<a href="http://www.health-calc.com/food-database">Food Facts</a> |
<a href="http://www.truestarhealth.com/Notes/4026005.html">TrueStar</a> |
<a href="http://www.openfooddata.com/">OpenFoodData</a>
</body>
</html>
</xsl:template>

<xsl:template match="ingredients">
  <xsl:apply-templates />
</xsl:template>

<xsl:template match="categories">
  <xsl:apply-templates />
</xsl:template>

<!-- Capture the list of ingredients and their categories. -->
<xsl:template match="ingredient">
  <option>
    <xsl:attribute name="value">
      <xsl:value-of select="@id" />::<xsl:apply-templates select="categories/category" mode="id" />
    </xsl:attribute>
    <xsl:value-of select="@name" />
  </option>
</xsl:template>

<!-- Used to list the categories for each ingredient. -->
<xsl:template match="category" mode="id"><xsl:value-of select="@id"/>,</xsl:template>

<xsl:template match="category">
  <option value="{@id}"><xsl:value-of select="@name" /></option>
</xsl:template>

<!--
<xsl:template match="category">
  <option value="{@id}"><xsl:value-of select="@name" /></option>
</xsl:template>
-->

<xsl:template match="*" />

</xsl:stylesheet>