edit-recipe.xsl 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605
  1. <?xml version="1.0"?>
  2. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3. xmlns:eat="http://msqr.us/xsd/ieat"
  4. xmlns:xweb="http://msqr.us/xsd/jaxb-web"
  5. exclude-result-prefixes="eat xweb">
  6. <!-- imports -->
  7. <xsl:import href="tmpl/default-layout.xsl"/>
  8. <!-- layout variables -->
  9. <xsl:variable name="layout.global.nav.page" select="'add-recipe'"/>
  10. <!-- helper vars -->
  11. <xsl:variable name="recipe" select="xweb:x-data/xweb:x-model/eat:edit/eat:recipe"/>
  12. <xsl:variable name="is-new" select="not(boolean($recipe/@recipeId))"/>
  13. <xsl:template match="xweb:x-data" mode="page-title">
  14. <xsl:choose>
  15. <xsl:when test="$is-new = 'true'">
  16. <xsl:value-of select="key('i18n','edit-recipe.create.title')"/>
  17. </xsl:when>
  18. <xsl:otherwise>
  19. <xsl:value-of select="key('i18n','edit-recipe.edit.title')"/>
  20. </xsl:otherwise>
  21. </xsl:choose>
  22. </xsl:template>
  23. <xsl:template match="xweb:x-data" mode="page-head-content">
  24. <link rel="stylesheet" type="text/css" href="{$web-context}/css/edit-recipe.css" media="screen" />
  25. <link rel="stylesheet" type="text/css" href="{$web-context}/css/jquery.autocomplete.css" media="screen" />
  26. <script type="text/javascript" src="{$web-context}/js/jquery-1.3.2.js" xml:space="preserve"> </script>
  27. <script type="text/javascript" src="{$web-context}/js/jquery.ajaxQueue.js" xml:space="preserve"> </script>
  28. <script type="text/javascript" src="{$web-context}/js/jquery.autocomplete.js" xml:space="preserve"> </script>
  29. <script type="text/javascript" src="{$web-context}/js/xweb-locale.js" xml:space="preserve"> </script>
  30. <script type="text/javascript" src="{$web-context}/js/jquery.tablednd.js" xml:space="preserve"> </script>
  31. <script type="text/javascript" src="{$web-context}/js/ieat-util.js" xml:space="preserve"> </script>
  32. <script type="text/javascript" src="{$web-context}/js/edit-recipe.js" xml:space="preserve"> </script>
  33. </xsl:template>
  34. <xsl:template match="xweb:x-data" mode="page-body">
  35. <div class="intro">
  36. <xsl:choose>
  37. <xsl:when test="$is-new = 'true'">
  38. <xsl:value-of select="key('i18n','edit-recipe.create.intro')"/>
  39. </xsl:when>
  40. <xsl:otherwise>
  41. <xsl:value-of select="key('i18n','edit-recipe.edit.intro')"/>
  42. </xsl:otherwise>
  43. </xsl:choose>
  44. </div>
  45. <form method="post" action="{$web-context}{$ctx/xweb:path}">
  46. <xsl:attribute name="action">
  47. <xsl:value-of select="$web-context"/>
  48. <xsl:choose>
  49. <xsl:when test="$is-new = 'true'">
  50. <xsl:text>/addRecipe.do</xsl:text>
  51. </xsl:when>
  52. <xsl:otherwise>
  53. <xsl:text>/editRecipe.do</xsl:text>
  54. </xsl:otherwise>
  55. </xsl:choose>
  56. </xsl:attribute>
  57. <table class="form">
  58. <tr>
  59. <th>
  60. <xsl:if test="$err[@field='recipe.name']">
  61. <xsl:attribute name="class">error</xsl:attribute>
  62. </xsl:if>
  63. <xsl:value-of select="key('i18n','recipe.name.displayName')"/>
  64. </th>
  65. <td colspan="3">
  66. <input type="text" name="recipe.name" value="{$recipe/eat:name}"
  67. maxlength="128"/>
  68. </td>
  69. </tr>
  70. <tr>
  71. <th>
  72. <xsl:value-of select="key('i18n','recipe.source.displayName')"/>
  73. </th>
  74. <td colspan="3">
  75. <input type="text" name="recipe.source" value="{$recipe/eat:source}"
  76. maxlength="64"/>
  77. <xsl:text> </xsl:text>
  78. <span class="caption">
  79. <xsl:value-of select="key('i18n','optional.caption')"/>
  80. </span>
  81. </td>
  82. </tr>
  83. <tr>
  84. <th>
  85. <xsl:value-of select="key('i18n','recipe.base.displayName')"/>
  86. </th>
  87. <td>
  88. <select name="recipe.base.baseId">
  89. <xsl:apply-templates select="$aux/*/eat:base"/>
  90. </select>
  91. </td>
  92. <th>
  93. <xsl:value-of select="key('i18n','recipe.prepTime.displayName')"/>
  94. </th>
  95. <td>
  96. <select name="recipe.prepTime.prepTimeId">
  97. <xsl:apply-templates select="$aux/*/eat:prep-time"/>
  98. </select>
  99. </td>
  100. </tr>
  101. <tr>
  102. <th>
  103. <xsl:value-of select="key('i18n','recipe.ethnicity.displayName')"/>
  104. </th>
  105. <td>
  106. <select name="recipe.ethnicity.ethnicityId">
  107. <xsl:apply-templates select="$aux/*/eat:ethnicity"/>
  108. </select>
  109. </td>
  110. <th>
  111. <xsl:value-of select="key('i18n','recipe.difficulty.displayName')"/>
  112. </th>
  113. <td>
  114. <select name="recipe.difficulty.difficultyId">
  115. <xsl:apply-templates select="$aux/*/eat:difficulty"/>
  116. </select>
  117. </td>
  118. </tr>
  119. <tr>
  120. <th>
  121. <xsl:value-of select="key('i18n','recipe.course.displayName')"/>
  122. </th>
  123. <td>
  124. <select name="recipe.course.courseId">
  125. <xsl:apply-templates select="$aux/*/eat:course"/>
  126. </select>
  127. </td>
  128. <th>
  129. <xsl:if test="$err[@field='recipe.servingSize']">
  130. <xsl:attribute name="class">error</xsl:attribute>
  131. </xsl:if>
  132. <xsl:value-of select="key('i18n','recipe.servings.displayName')"/>
  133. </th>
  134. <td>
  135. <input type="text" name="recipe.servingSize" value="{$recipe/@servingSize}" class="vsmallnum"/>
  136. </td>
  137. </tr>
  138. </table>
  139. <table class="form">
  140. <tr>
  141. <th>
  142. <xsl:if test="$err[@field='recipe.excerpt']">
  143. <xsl:attribute name="class">error</xsl:attribute>
  144. </xsl:if>
  145. <xsl:value-of select="key('i18n','recipe.excerpt.displayName')"/>
  146. </th>
  147. <td>
  148. <textarea name="recipe.excerpt" class="big">
  149. <xsl:value-of select="$recipe/eat:excerpt"/>
  150. <!-- the following space prevents browser rendering mishaps -->
  151. <xsl:if test="string-length($recipe/eat:excerpt) &lt; 1">
  152. <xsl:text> </xsl:text>
  153. </xsl:if>
  154. </textarea>
  155. <br/>
  156. <span class="caption">
  157. <xsl:value-of select="key('i18n','recipe.excerpt.caption')"/>
  158. </span>
  159. </td>
  160. </tr>
  161. <tr>
  162. <th>
  163. <xsl:if test="$err[@field='recipe.directions']">
  164. <xsl:attribute name="class">error</xsl:attribute>
  165. </xsl:if>
  166. <xsl:value-of select="key('i18n','recipe.directions.displayName')"/>
  167. </th>
  168. <td>
  169. <textarea name="recipe.directions" class="big">
  170. <xsl:value-of select="$recipe/eat:directions"/>
  171. <!-- the following space prevents browser rendering mishaps -->
  172. <xsl:if test="string-length($recipe/eat:directions) &lt; 1">
  173. <xsl:text> </xsl:text>
  174. </xsl:if>
  175. </textarea>
  176. <br/>
  177. <span class="caption">
  178. <xsl:value-of select="key('i18n','recipe.directions.caption')"/>
  179. <xsl:text> </xsl:text>
  180. <xsl:value-of select="key('i18n','optional.caption')"/>
  181. </span>
  182. </td>
  183. </tr>
  184. </table>
  185. <hr class="sep" />
  186. <div class="formLabel">
  187. <xsl:value-of select="key('i18n','recipe.system.displayName')"/>
  188. </div>
  189. <div class="read-only">
  190. <xsl:value-of select="$aux/eat:ui/eat:system[@systemId = $recipe/eat:system/@systemId]"/>
  191. </div>
  192. <br clear="left" />
  193. <p>
  194. <xsl:value-of select="key('i18n','recipe.ingredients.explain')"
  195. disable-output-escaping="yes"/>
  196. </p>
  197. <p>
  198. <xsl:value-of select="key('i18n','edit-recipe.units.explain')"
  199. disable-output-escaping="yes"/>
  200. </p>
  201. <!--
  202. Recipe ingredients
  203. -->
  204. <div class="formLabel">
  205. <xsl:choose>
  206. <xsl:when test="$err[starts-with(@field,'recipe.ingredient')]">
  207. <span class="error">
  208. <xsl:value-of select="key('i18n','recipe.ingredients.displayName')"/>
  209. </span>
  210. </xsl:when>
  211. <xsl:otherwise>
  212. <xsl:value-of select="key('i18n','recipe.ingredients.displayName')"/>:
  213. </xsl:otherwise>
  214. </xsl:choose>
  215. </div>
  216. <table class="form" id="ingredient_table">
  217. <xsl:for-each select="$recipe/eat:ingredient">
  218. <xsl:call-template name="recipe-ingredient"/>
  219. </xsl:for-each>
  220. <xsl:if test="not($recipe/eat:ingredient)">
  221. <xsl:call-template name="recipe-ingredient">
  222. <xsl:with-param name="index" select="0"/>
  223. </xsl:call-template>
  224. </xsl:if>
  225. <tr id="ingredient_add_row">
  226. <td>
  227. <a id="ingredient_add_link" href="#"
  228. title="{key('i18n','recipe.ingredients.add')}" class="plus">
  229. <span class="alt">
  230. <xsl:value-of select="key('i18n','recipe.ingredients.add')"/>
  231. </span>
  232. </a>
  233. </td>
  234. <td></td>
  235. </tr>
  236. </table>
  237. <hr class="sep"/>
  238. <!--
  239. Recipe instruction steps
  240. -->
  241. <div class="formLabel">
  242. <xsl:choose>
  243. <xsl:when test="$err[starts-with(@field,'recipe.step')]">
  244. <span class="error">
  245. <xsl:value-of select="key('i18n','recipe.steps.displayName')"/>
  246. </span>
  247. </xsl:when>
  248. <xsl:otherwise>
  249. <xsl:value-of select="key('i18n','recipe.steps.displayName')"/>:
  250. </xsl:otherwise>
  251. </xsl:choose>
  252. </div>
  253. <table class="form" id="step_table">
  254. <xsl:for-each select="$recipe/eat:step">
  255. <xsl:call-template name="recipe-step"/>
  256. </xsl:for-each>
  257. <xsl:if test="not($recipe/eat:step)">
  258. <xsl:call-template name="recipe-step">
  259. <xsl:with-param name="index" select="0"/>
  260. </xsl:call-template>
  261. </xsl:if>
  262. <tr id="step_add_row">
  263. <td>
  264. <a href="#"
  265. id="step_add_link"
  266. title="{key('i18n','recipe.steps.add')}" class="plus">
  267. <span class="alt">
  268. <xsl:value-of select="key('i18n','recipe.steps.add')"/>
  269. </span>
  270. </a>
  271. </td>
  272. <td></td>
  273. </tr>
  274. </table>
  275. <table class="form">
  276. <tr>
  277. <th/>
  278. <td>
  279. <input type="submit" value="{key('i18n','continue.displayName')}">
  280. <xsl:choose>
  281. <xsl:when test="$is-new = 'true'">
  282. <xsl:attribute name="name">_target2</xsl:attribute>
  283. </xsl:when>
  284. <xsl:otherwise>
  285. <xsl:attribute name="name">_target1</xsl:attribute>
  286. </xsl:otherwise>
  287. </xsl:choose>
  288. </input>
  289. <xsl:text> </xsl:text>
  290. <input type="submit" name="_cancel" value="{key('i18n','cancel.displayName')}"/>
  291. </td>
  292. </tr>
  293. </table>
  294. <!-- handle contextual navigation -->
  295. <xsl:apply-templates select="eat:edit/eat:search-results"
  296. mode="search-results-contextual-navigation"/>
  297. </form>
  298. </xsl:template>
  299. <xsl:template name="recipe-step">
  300. <xsl:param name="row-index">
  301. <xsl:value-of select="position() - 1"/>
  302. </xsl:param>
  303. <xsl:variable name="me" select="."/>
  304. <xsl:variable name="errkey">
  305. <xsl:text>recipe.step[</xsl:text>
  306. <xsl:value-of select="$row-index"/>
  307. <xsl:text>]</xsl:text>
  308. </xsl:variable>
  309. <tr>
  310. <xsl:attribute name="class">
  311. <xsl:text>recipe-step</xsl:text>
  312. <xsl:if test="$err[starts-with(@field,$errkey)]">
  313. <xsl:text> error</xsl:text>
  314. </xsl:if>
  315. </xsl:attribute>
  316. <td class="drag-dot">
  317. <div class="drag-dot" title="{key('i18n','edit.recipe.drag.step.row.title')}"/>
  318. </td>
  319. <td>
  320. <textarea name="recipe.step[{$row-index}].value" class="recipeStep">
  321. <xsl:choose>
  322. <xsl:when test="self::eat:step and string-length(.) &gt; 0">
  323. <xsl:value-of select="."/>
  324. </xsl:when>
  325. <xsl:otherwise>
  326. <xsl:text> </xsl:text>
  327. </xsl:otherwise>
  328. </xsl:choose>
  329. </textarea>
  330. </td>
  331. <td>
  332. <a href="javascript:removeStep({$row-index})"
  333. title="{key('i18n','recipe.steps.remove')}" class="minus">
  334. <xsl:if test="not(self::eat:step) or position() = 1">
  335. <xsl:attribute name="style">display: none</xsl:attribute>
  336. </xsl:if>
  337. <span class="alt">
  338. <xsl:value-of select="key('i18n','recipe.steps.remove')"/>
  339. </span>
  340. </a>
  341. </td>
  342. </tr>
  343. </xsl:template>
  344. <xsl:template name="recipe-ingredient">
  345. <xsl:param name="index"/>
  346. <xsl:variable name="row-index">
  347. <xsl:choose>
  348. <xsl:when test="string-length($index) &gt; 0">
  349. <xsl:value-of select="$index"/>
  350. </xsl:when>
  351. <xsl:otherwise>
  352. <xsl:value-of select="position() - 1"/>
  353. </xsl:otherwise>
  354. </xsl:choose>
  355. </xsl:variable>
  356. <xsl:variable name="me" select="."/>
  357. <xsl:variable name="errkey">
  358. <xsl:text>recipe.ingredient[</xsl:text>
  359. <xsl:value-of select="$row-index"/>
  360. <xsl:text>]</xsl:text>
  361. </xsl:variable>
  362. <tr valign="middle" class="recipe-ingredient">
  363. <xsl:attribute name="class">
  364. <xsl:text>recipe-ingredient</xsl:text>
  365. <xsl:if test="$err[starts-with(@field,$errkey)]">
  366. <xsl:text> error</xsl:text>
  367. </xsl:if>
  368. </xsl:attribute>
  369. <td class="drag-dot">
  370. <div class="drag-dot" title="{key('i18n','edit.recipe.drag.step.row.title')}"/>
  371. </td>
  372. <td>
  373. <input type="text" name="recipe.ingredient[{$row-index}].quantity" class="smallnum"
  374. value="{@quantity}" maxlength="8"/>
  375. </td>
  376. <td>
  377. <select name="recipe.ingredient[{$row-index}].unit.unitId">
  378. <option value="0"></option>
  379. <xsl:for-each select="$aux/eat:ui/eat:unit">
  380. <xsl:call-template name="ingredient.unit">
  381. <xsl:with-param name="ingredient" select="$me"/>
  382. </xsl:call-template>
  383. </xsl:for-each>
  384. </select>
  385. </td>
  386. <td>
  387. <a class="ingredient-type-chooser ingredient" href="#"
  388. title="Click to use a recipe for this ingredient">
  389. <xsl:attribute name="class">
  390. <xsl:text>ingredient-type-chooser </xsl:text>
  391. <xsl:choose>
  392. <xsl:when test="eat:recipe/@recipeId">
  393. <xsl:text>recipe</xsl:text>
  394. </xsl:when>
  395. <xsl:otherwise>
  396. <xsl:text>ingredient</xsl:text>
  397. </xsl:otherwise>
  398. </xsl:choose>
  399. </xsl:attribute>
  400. <xsl:attribute name="title">
  401. <xsl:choose>
  402. <xsl:when test="eat:recipe/@recipeId">
  403. <xsl:value-of select="key('i18n','edit.recipe.ingredientTypeChooser.recipe.title')"/>
  404. </xsl:when>
  405. <xsl:otherwise>
  406. <xsl:value-of select="key('i18n','edit.recipe.ingredientTypeChooser.ingredient.title')"/>
  407. </xsl:otherwise>
  408. </xsl:choose>
  409. </xsl:attribute>
  410. <span class="alt">
  411. <xsl:value-of select="key('i18n','ingredient.type.chooser.displayName')"/>
  412. </span>
  413. </a>
  414. <div id="recipe.ingredient[{$row-index}].ingredient">
  415. <xsl:attribute name="style">
  416. <xsl:text>float: left;</xsl:text>
  417. <xsl:if test="eat:recipe/@recipeId">
  418. <xsl:text> display: none;</xsl:text>
  419. </xsl:if>
  420. </xsl:attribute>
  421. <input type="text"
  422. name="recipe.ingredient[{$row-index}].ingredient.name"
  423. id="recipe.ingredient[{$row-index}].ingredient.name"
  424. class="ingredient-autocomplete">
  425. <xsl:choose>
  426. <xsl:when test="eat:recipe/@recipeId">
  427. <xsl:attribute name="disabled">
  428. <xsl:text>disabled</xsl:text>
  429. </xsl:attribute>
  430. </xsl:when>
  431. <xsl:otherwise>
  432. <xsl:attribute name="value">
  433. <xsl:value-of select="eat:ingredient/eat:name"/>
  434. </xsl:attribute>
  435. </xsl:otherwise>
  436. </xsl:choose>
  437. </input>
  438. <input type="hidden"
  439. name="recipe.ingredient[{$row-index}].ingredient.ingredientId"
  440. id="recipe.ingredient[{$row-index}].ingredient.ingredientId">
  441. <xsl:choose>
  442. <xsl:when test="eat:recipe/@recipeId">
  443. <xsl:attribute name="disabled">
  444. <xsl:text>disabled</xsl:text>
  445. </xsl:attribute>
  446. </xsl:when>
  447. <xsl:otherwise>
  448. <xsl:attribute name="value">
  449. <xsl:value-of select="eat:ingredient/@ingredientId"/>
  450. </xsl:attribute>
  451. </xsl:otherwise>
  452. </xsl:choose>
  453. </input>
  454. </div>
  455. <div id="recipe.ingredient[{$row-index}].recipe">
  456. <xsl:attribute name="style">
  457. <xsl:text>float: left;</xsl:text>
  458. <xsl:if test="not(eat:recipe/@recipeId)">
  459. <xsl:text> display: none;</xsl:text>
  460. </xsl:if>
  461. </xsl:attribute>
  462. <input type="text"
  463. name="recipe.ingredient[{$row-index}].recipe.name"
  464. id="recipe.ingredient[{$row-index}].recipe.name"
  465. class="recipe-autocomplete">
  466. <xsl:choose>
  467. <xsl:when test="eat:recipe/@recipeId">
  468. <xsl:attribute name="value">
  469. <xsl:value-of select="eat:recipe/eat:name"/>
  470. </xsl:attribute>
  471. </xsl:when>
  472. <xsl:otherwise>
  473. <xsl:attribute name="disabled">
  474. <xsl:text>disabled</xsl:text>
  475. </xsl:attribute>
  476. </xsl:otherwise>
  477. </xsl:choose>
  478. </input>
  479. <input type="hidden"
  480. name="recipe.ingredient[{$row-index}].recipe.recipeId"
  481. id="recipe.ingredient[{$row-index}].recipe.recipeId">
  482. <xsl:choose>
  483. <xsl:when test="eat:recipe/@recipeId">
  484. <xsl:attribute name="value">
  485. <xsl:value-of select="eat:recipe/@recipeId"/>
  486. </xsl:attribute>
  487. </xsl:when>
  488. <xsl:otherwise>
  489. <xsl:attribute name="disabled">
  490. <xsl:text>disabled</xsl:text>
  491. </xsl:attribute>
  492. </xsl:otherwise>
  493. </xsl:choose>
  494. </input>
  495. </div>
  496. </td>
  497. <td>
  498. <input type="text" name="recipe.ingredient[{$row-index}].qualifier"
  499. value="{@qualifier}" maxlength="128"/>
  500. </td>
  501. <td>
  502. <a href="#"
  503. title="{key('i18n','recipe.ingredients.remove')}"
  504. class="minus">
  505. <xsl:if test="not(self::eat:ingredient) or position() = 1">
  506. <xsl:attribute name="style">display: none</xsl:attribute>
  507. </xsl:if>
  508. <span class="alt">
  509. <xsl:value-of select="key('i18n','recipe.ingredients.remove')"/>
  510. </span>
  511. </a>
  512. </td>
  513. </tr>
  514. </xsl:template>
  515. <xsl:template match="eat:base">
  516. <option value="{@baseId}">
  517. <xsl:if test="@baseId = $recipe/eat:base/@baseId">
  518. <xsl:attribute name="selected">selected</xsl:attribute>
  519. </xsl:if>
  520. <xsl:value-of select="."/>
  521. </option>
  522. </xsl:template>
  523. <xsl:template match="eat:course">
  524. <option value="{@courseId}">
  525. <xsl:if test="@courseId = $recipe/eat:course/@courseId">
  526. <xsl:attribute name="selected">selected</xsl:attribute>
  527. </xsl:if>
  528. <xsl:value-of select="."/>
  529. </option>
  530. </xsl:template>
  531. <xsl:template match="eat:difficulty">
  532. <option value="{@difficultyId}">
  533. <xsl:if test="@difficultyId = $recipe/eat:difficulty/@difficultyId">
  534. <xsl:attribute name="selected">selected</xsl:attribute>
  535. </xsl:if>
  536. <xsl:value-of select="."/>
  537. </option>
  538. </xsl:template>
  539. <xsl:template match="eat:ethnicity">
  540. <option value="{@ethnicityId}">
  541. <xsl:if test="@ethnicityId = $recipe/eat:ethnicity/@ethnicityId">
  542. <xsl:attribute name="selected">selected</xsl:attribute>
  543. </xsl:if>
  544. <xsl:value-of select="."/>
  545. </option>
  546. </xsl:template>
  547. <xsl:template match="eat:prep-time">
  548. <option value="{@prepTimeId}">
  549. <xsl:if test="@prepTimeId = $recipe/eat:prep-time/@prepTimeId">
  550. <xsl:attribute name="selected">selected</xsl:attribute>
  551. </xsl:if>
  552. <xsl:value-of select="."/>
  553. </option>
  554. </xsl:template>
  555. <xsl:template name="ingredient-ingredient">
  556. <xsl:param name="ingredient"/>
  557. <option value="{@ingredientId}">
  558. <xsl:if test="@ingredientId = $ingredient/eat:ingredient/@ingredientId">
  559. <xsl:attribute name="selected">selected</xsl:attribute>
  560. </xsl:if>
  561. <xsl:value-of select="eat:name"/>
  562. </option>
  563. </xsl:template>
  564. <xsl:template name="ingredient.unit">
  565. <xsl:param name="ingredient"/>
  566. <option value="{@unitId}">
  567. <xsl:if test="@unitId = $ingredient/eat:unit/@unitId">
  568. <xsl:attribute name="selected">selected</xsl:attribute>
  569. </xsl:if>
  570. <xsl:value-of select="."/>
  571. </option>
  572. </xsl:template>
  573. </xsl:stylesheet>