menus.xslt 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. Licensed Materials - Property of IBM
  4. IBM Cognos Products: cpscrn
  5. (C) Copyright IBM Corp. 2005, 2011
  6. US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  7. -->
  8. <!--
  9. Copyright (C) 2008 Cognos ULC, an IBM Company. All rights reserved.
  10. Cognos (R) is a trademark of Cognos ULC, (formerly Cognos Incorporated).
  11. -->
  12. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  13. <xsl:template match="menus">
  14. <script type="text/javascript">
  15. <xsl:for-each select="menu">
  16. <xsl:call-template name="gen-menu"/>
  17. </xsl:for-each>
  18. </script>
  19. </xsl:template>
  20. <xsl:template match="menu">
  21. <script type="text/javascript">
  22. <xsl:call-template name="gen-menu"/>
  23. </script>
  24. </xsl:template>
  25. <xsl:template name="gen-menu">
  26. <xsl:variable name="id" select="@id"/>
  27. <xsl:text>&#10;var menu_</xsl:text>
  28. <xsl:value-of select="$id"/>
  29. <xsl:text>=new ui_menu({id: "</xsl:text>
  30. <xsl:value-of select="$id"/>
  31. <xsl:text>", items:[&#10;</xsl:text>
  32. <xsl:for-each select="menuitem">
  33. <xsl:if test="position() &gt; 1">
  34. <xsl:text>,&#10;</xsl:text>
  35. </xsl:if>
  36. <xsl:text> {</xsl:text>
  37. <xsl:if test="@separatorBefore='true'">
  38. <xsl:text>separatorBefore: true, </xsl:text>
  39. </xsl:if>
  40. <xsl:for-each select="*[not(self::action)]">
  41. <xsl:value-of select="local-name()"/>
  42. <xsl:text>: "</xsl:text>
  43. <xsl:value-of select="."/>
  44. <xsl:text>", </xsl:text>
  45. </xsl:for-each>
  46. <xsl:text>action: </xsl:text>
  47. <xsl:choose>
  48. <xsl:when test="action">
  49. <xsl:text>function(evt) { </xsl:text>
  50. <xsl:value-of select="action"/>
  51. <xsl:text> }</xsl:text>
  52. </xsl:when>
  53. <xsl:otherwise>null</xsl:otherwise>
  54. </xsl:choose>
  55. <xsl:text> }</xsl:text>
  56. </xsl:for-each>
  57. <xsl:text>&#10; ]&#10;});</xsl:text>
  58. </xsl:template>
  59. </xsl:stylesheet>