unpack_pagelet_layout.xslt 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. Licensed Materials - Property of IBM
  4. IBM Cognos Products: ps
  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:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  14. <xsl:template match="myroot/layout">
  15. <xsl:variable name="userContentLocale" select="../userLocale"/>
  16. <!-- Determine the language we want to set focus to
  17. If one of the languages set matches the use's current content locale then give focus to it.
  18. Otherwize give focus to the first language.
  19. -->
  20. <xsl:variable name="lang">
  21. <xsl:choose>
  22. <xsl:when test="title/value[@xml:lang = $userContentLocale]">
  23. <xsl:value-of select="title/value[@xml:lang = $userContentLocale]/@xml:lang"/>
  24. </xsl:when>
  25. <xsl:when test="title/value[1][@xml:lang != '']">
  26. <xsl:value-of select="title/value[1]/@xml:lang"/>
  27. </xsl:when>
  28. <!-- There are no languages entered for the title field start a new field using the usr's content locale -->
  29. <xsl:otherwise>
  30. <xsl:value-of select="$userContentLocale"/>
  31. </xsl:otherwise>
  32. </xsl:choose>
  33. </xsl:variable>
  34. <xsl:if test="layoutProperties/param[@name='flexibleColumnLayout']">
  35. <param name="m_mp_flexibleColWidth"><xsl:value-of select="layoutProperties/param[@name='flexibleColumnLayout']"/></param>
  36. </xsl:if>
  37. <!-- titles -->
  38. <xsl:if test="title/@hidden = 'true'">
  39. <param name="m_mp_hideTitle">true</param>
  40. </xsl:if>
  41. <xsl:if test="title/@font">
  42. <param name="m_mp_titleFont"><xsl:value-of select="title/@font"/></param>
  43. </xsl:if>
  44. <xsl:if test="title/@size">
  45. <param name="m_mp_titleFontSize"><xsl:value-of select="title/@size"/></param>
  46. </xsl:if>
  47. <xsl:if test="title/@colour">
  48. <param name="m_mp_titleColour"><xsl:value-of select="title/@colour"/></param>
  49. </xsl:if>
  50. <xsl:if test="title/@bold">
  51. <param name="m_mp_titleBold"><xsl:value-of select="title/@bold"/></param>
  52. </xsl:if>
  53. <xsl:if test="title/@align">
  54. <param name="m_mp_titleAlign"><xsl:value-of select="title/@align"/></param>
  55. </xsl:if>
  56. <xsl:if test="title/@italic">
  57. <param name="m_mp_titleItalic"><xsl:value-of select="title/@italic"/></param>
  58. </xsl:if>
  59. <xsl:if test="title/@underline">
  60. <param name="m_mp_titleUnderline"><xsl:value-of select="title/@underline"/></param>
  61. </xsl:if>
  62. <param name="m_mp_titleStyle">
  63. <xsl:choose>
  64. <xsl:when test="title/@colour and title/@colour != ''">custom</xsl:when>
  65. <xsl:otherwise>default</xsl:otherwise>
  66. </xsl:choose>
  67. </param>
  68. <xsl:for-each select="title/value[@xml:lang != $lang]">
  69. <param name="m_mp_title_{@xml:lang}"><xsl:value-of select="."/></param>
  70. </xsl:for-each>
  71. <!-- instructions -->
  72. <xsl:if test="instructions/@hidden = 'true'">
  73. <param name="m_mp_hideInstructions">true</param>
  74. </xsl:if>
  75. <xsl:if test="instructions/@font">
  76. <param name="m_mp_instructionsFont"><xsl:value-of select="instructions/@font"/></param>
  77. </xsl:if>
  78. <xsl:if test="instructions/@size">
  79. <param name="m_mp_instructionsFontSize"><xsl:value-of select="instructions/@size"/></param>
  80. </xsl:if>
  81. <xsl:if test="instructions/@colour">
  82. <param name="m_mp_instructionsColour"><xsl:value-of select="instructions/@colour"/></param>
  83. </xsl:if>
  84. <xsl:if test="instructions/@bold">
  85. <param name="m_mp_instructionsBold"><xsl:value-of select="instructions/@bold"/></param>
  86. </xsl:if>
  87. <xsl:if test="instructions/@italic">
  88. <param name="m_mp_instructionsItalic"><xsl:value-of select="instructions/@italic"/></param>
  89. </xsl:if>
  90. <xsl:if test="instructions/@underline">
  91. <param name="m_mp_instructionsUnderline"><xsl:value-of select="instructions/@underline"/></param>
  92. </xsl:if>
  93. <xsl:if test="instructions/@align">
  94. <param name="m_mp_instructionsAlign"><xsl:value-of select="instructions/@align"/></param>
  95. </xsl:if>
  96. <param name="m_mp_instructionsStyle">
  97. <xsl:choose>
  98. <xsl:when test="instructions/@colour and instructions/@colour != ''">custom</xsl:when>
  99. <xsl:otherwise>default</xsl:otherwise>
  100. </xsl:choose>
  101. </param>
  102. <xsl:for-each select="instructions/value[@xml:lang != $lang]">
  103. <param name="m_mp_instructions_{@xml:lang}"><xsl:value-of select="."/></param>
  104. </xsl:for-each>
  105. <!-- portlet options -->
  106. <xsl:if test="portletOptions/@hideBorders = 'true'">
  107. <param name="m_mp_hideBorders">true</param>
  108. </xsl:if>
  109. <xsl:if test="portletOptions/@hideTitleBars = 'true'">
  110. <param name="m_mp_hideTitleBars">true</param>
  111. </xsl:if>
  112. <xsl:if test="portletOptions/@hideEditMode = 'true'">
  113. <param name="m_mp_hideEditMode">true</param>
  114. </xsl:if>
  115. <!-- Unpack the column layout XML into form fields when handling 1.0 layouts -->
  116. <xsl:if test="@version = 1.0">
  117. <param name="m_mp_columns"><xsl:value-of select="count(column)"/></param>
  118. <param name="m_mp_firstColumnWidth"><xsl:value-of select="column[1]/@width"/></param>
  119. <xsl:if test="column[2]">
  120. <param name="m_mp_secondColumnWidth"><xsl:value-of select="column[2]/@width"/></param>
  121. </xsl:if>
  122. <xsl:if test="column[3]">
  123. <param name="m_mp_thirdColumnWidth"><xsl:value-of select="column[3]/@width"/></param>
  124. </xsl:if>
  125. <xsl:for-each select="column[1]/portlet">
  126. <param name="m_mp_col1sort"><xsl:value-of select="concat(position(), ',', @id)"/></param>
  127. </xsl:for-each>
  128. <xsl:for-each select="column[2]/portlet">
  129. <param name="m_mp_col2sort"><xsl:value-of select="concat(position(), ',', @id)"/></param>
  130. </xsl:for-each>
  131. <xsl:for-each select="column[3]/portlet">
  132. <param name="m_mp_col3sort"><xsl:value-of select="concat(position(), ',', @id)"/></param>
  133. </xsl:for-each>
  134. </xsl:if>
  135. <!-- language and edit fields -->
  136. <param name="m_mp_language"><xsl:value-of select="$lang"/></param>
  137. <param name="m_mp_mlt_title_{$lang}"><xsl:value-of select="title/value[@xml:lang = $lang]"/></param>
  138. <param name="m_mp_mlt_instructions_{$lang}"><xsl:value-of select="instructions/value[@xml:lang = $lang]"/></param>
  139. </xsl:template>
  140. <!-- Remove the userLocale element -->
  141. <xsl:template match="myroot/userLocale"/>
  142. </xsl:stylesheet>