display-meal.xsl 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
  3. xmlns:eat="http://msqr.us/xsd/ieat"
  4. xmlns:xweb="http://msqr.us/xsd/jaxb-web"
  5. exclude-result-prefixes="eat xweb">
  6. <xsl:import href="global-variables.xsl"/>
  7. <xsl:template match="eat:meal" mode="display">
  8. <h2>
  9. <xsl:value-of select="eat:name"/>
  10. </h2>
  11. <xsl:apply-templates select="." mode="display-internal"/>
  12. </xsl:template>
  13. <xsl:template match="eat:meal" mode="display-internal">
  14. <ol>
  15. <!-- Note: the [eat:recipe] clause is to hide "orphaned" meal
  16. recipes that occur after deleting a recipe that belongs
  17. in a meal
  18. -->
  19. <xsl:apply-templates select="eat:recipe[eat:recipe]" mode="meal-display"/>
  20. </ol>
  21. </xsl:template>
  22. <xsl:template match="eat:meal/eat:recipe" mode="meal-display">
  23. <li>
  24. <b>
  25. <xsl:choose>
  26. <xsl:when test="string-length(eat:recipe/eat:name) &gt; 0">
  27. <xsl:value-of select="eat:recipe/eat:name"/>
  28. </xsl:when>
  29. <xsl:otherwise>
  30. <xsl:variable name="recipe-id" select="eat:recipe/@recipeId"></xsl:variable>
  31. <xsl:value-of select="$aux/eat:ui/eat:recipe[@recipeId = $recipe-id]/eat:name"/>
  32. </xsl:otherwise>
  33. </xsl:choose>
  34. </b>
  35. <br/>
  36. <span class="caption">
  37. <xsl:apply-templates select="eat:course"/>
  38. <xsl:text>, </xsl:text>
  39. <xsl:value-of select="key('i18n','mealRecipe.quantity.displayName')"/>
  40. <xsl:text>: </xsl:text>
  41. <xsl:value-of select="@quantity"/>
  42. </span>
  43. <p>
  44. <xsl:choose>
  45. <xsl:when test="string-length(eat:recipe/eat:excerpt) &gt; 0">
  46. <xsl:value-of select="eat:recipe/eat:excerpt"/>
  47. </xsl:when>
  48. <xsl:otherwise>
  49. <xsl:variable name="recipe-id" select="eat:recipe/@recipeId"></xsl:variable>
  50. <xsl:value-of select="$aux/eat:ui/eat:recipe[@recipeId = $recipe-id]/eat:excerpt"/>
  51. </xsl:otherwise>
  52. </xsl:choose>
  53. </p>
  54. </li>
  55. </xsl:template>
  56. </xsl:stylesheet>