menu.xsl 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. Licensed Materials - Property of IBM
  4. IBM Cognos Products: cogadmin
  5. (C) Copyright IBM Corp. 2012, 2014
  6. US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  7. -->
  8. <xsl:stylesheet version="1.0"
  9. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  10. xmlns:uic="http://developer.cognos.com/schemas/uic/presentation/markup/"
  11. xmlns:xts="http://developer.cognos.com/schemas/xts/"
  12. xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt"
  13. exclude-result-prefixes="xsl uic xts">
  14. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
  15. <!--
  16. contextMenu
  17. -->
  18. <xsl:template match="uic:contextMenu">
  19. <script type="text/javascript">
  20. <xsl:variable name="menu_items">
  21. <xsl:apply-templates/>
  22. </xsl:variable>
  23. <xsl:variable name="normalized" select="normalize-space($menu_items)"/>
  24. var <xsl:value-of select="@menuName"/>=new ui_menu ({id: "actions_<xsl:value-of select="@menuName"/>", title: "<xsl:value-of select="xtsext:javascriptencode(@menuTitle)"/>", items:[
  25. <xsl:choose>
  26. <xsl:when test="$normalized = ''">
  27. {
  28. title: "<xsl:value-of select="$menuNoActions"/>"
  29. }
  30. </xsl:when>
  31. <xsl:otherwise>
  32. <xsl:value-of select="substring($normalized,1,string-length($normalized)-1)"/>
  33. </xsl:otherwise>
  34. </xsl:choose>
  35. <xsl:text>]});</xsl:text>
  36. </script>
  37. </xsl:template>
  38. <xsl:template match="uic:menuItem">
  39. <xsl:text>{</xsl:text>
  40. <xsl:apply-templates/>
  41. <xsl:text>}</xsl:text>
  42. <xsl:text>,</xsl:text>
  43. </xsl:template>
  44. <xsl:template match="uic:menuItemTitle">
  45. <xsl:text>title:"</xsl:text>
  46. <xsl:value-of select="."/>
  47. <xsl:text>",</xsl:text>
  48. </xsl:template>
  49. <xsl:template match="uic:menuItemImage">
  50. <xsl:text>image:"</xsl:text>
  51. <xsl:value-of select="."/>
  52. <xsl:text>",</xsl:text>
  53. </xsl:template>
  54. <xsl:template match="uic:menuItemGroup">
  55. <xsl:variable name="prevGroup" select="ancestor::uic:menuItem/preceding-sibling::uic:menuItem[1]//uic:menuItemGroup"/>
  56. <xsl:text>separatorBefore:</xsl:text>
  57. <xsl:value-of select="$prevGroup != ."/>
  58. <xsl:text>,</xsl:text>
  59. </xsl:template>
  60. <xsl:template match="uic:haspopup">
  61. <xsl:text>haspopup:</xsl:text>
  62. <xsl:value-of select="."/>
  63. <xsl:text>,</xsl:text>
  64. </xsl:template>
  65. <xsl:template match="uic:menuItemAction">
  66. <xsl:text>action:</xsl:text>
  67. <xsl:copy-of select="./node()"/>
  68. </xsl:template>
  69. </xsl:stylesheet>