gen_pagelet_layout.xslt 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  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
  13. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  14. xmlns:cps="http://developer.cognos.com/schemas/cps/asm/objects/1/"
  15. xmlns:form="http://developer.cognos.com/schemas/xts/portal/iFrmCmd/1/"
  16. version="1.0" exclude-result-prefixes="form cps">
  17. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  18. <!-- Create a namespace - neutral reference to form params -->
  19. <xsl:variable name="nnParam" select="form:env/form:param | env/param"/>
  20. <xsl:template match="form:env | env">
  21. <layout version="1.0">
  22. <!-- Layout properties -->
  23. <layoutProperties>
  24. <param name="flexibleColumnLayout">
  25. <xsl:call-template name="setBoolAttribute">
  26. <xsl:with-param name="value" select="$nnParam[@name = 'm_mp_flexibleColWidth']"/>
  27. </xsl:call-template>
  28. </param>
  29. </layoutProperties>
  30. <!-- Title -->
  31. <title>
  32. <xsl:attribute name="hidden">
  33. <xsl:call-template name="setBoolAttribute">
  34. <xsl:with-param name="value" select="$nnParam[@name = 'm_mp_hideTitle']"/>
  35. </xsl:call-template>
  36. </xsl:attribute>
  37. <!-- font -->
  38. <xsl:call-template name="setITitleStyleAttribute">
  39. <xsl:with-param name="name" select="'font'"/>
  40. <xsl:with-param name="value" select="$nnParam[@name = 'm_mp_titleFont']"/>
  41. </xsl:call-template>
  42. <!-- size -->
  43. <xsl:call-template name="setITitleStyleAttribute">
  44. <xsl:with-param name="name" select="'size'"/>
  45. <xsl:with-param name="value" select="$nnParam[@name = 'm_mp_titleFontSize']"/>
  46. </xsl:call-template>
  47. <!-- colour -->
  48. <xsl:call-template name="setITitleStyleAttribute">
  49. <xsl:with-param name="name" select="'colour'"/>
  50. <xsl:with-param name="value" select="$nnParam[@name = 'm_mp_titleColour']"/>
  51. </xsl:call-template>
  52. <!-- bold -->
  53. <xsl:call-template name="setITitleStyleAttribute">
  54. <xsl:with-param name="name" select="'bold'"/>
  55. <xsl:with-param name="value" select="$nnParam[@name = 'm_mp_titleBold']"/>
  56. </xsl:call-template>
  57. <!-- italic -->
  58. <xsl:call-template name="setITitleStyleAttribute">
  59. <xsl:with-param name="name" select="'italic'"/>
  60. <xsl:with-param name="value" select="$nnParam[@name = 'm_mp_titleItalic']"/>
  61. </xsl:call-template>
  62. <!-- undeline -->
  63. <xsl:call-template name="setITitleStyleAttribute">
  64. <xsl:with-param name="name" select="'underline'"/>
  65. <xsl:with-param name="value" select="$nnParam[@name = 'm_mp_titleUnderline']"/>
  66. </xsl:call-template>
  67. <!-- align -->
  68. <xsl:call-template name="setITitleStyleAttribute">
  69. <xsl:with-param name="name" select="'align'"/>
  70. <xsl:with-param name="value" select="$nnParam[@name = 'm_mp_titleAlign']"/>
  71. </xsl:call-template>
  72. <xsl:for-each select="$nnParam[starts-with(@name, 'm_mp_title_')]">
  73. <value>
  74. <xsl:attribute name="xml:lang"><xsl:value-of select="substring-after(@name, 'm_mp_title_')"/></xsl:attribute>
  75. <xsl:value-of select="."/>
  76. </value>
  77. </xsl:for-each>
  78. <xsl:if test="$nnParam[starts-with(@name, 'm_mp_mlt_title_')]">
  79. <value>
  80. <xsl:attribute name="xml:lang"><xsl:value-of select="$nnParam[@name='m_mp_language']"/></xsl:attribute>
  81. <xsl:value-of select="$nnParam[starts-with(@name, 'm_mp_mlt_title_')]"/>
  82. </value>
  83. </xsl:if>
  84. </title>
  85. <!-- Instructions -->
  86. <instructions>
  87. <xsl:attribute name="hidden">
  88. <xsl:call-template name="setBoolAttribute">
  89. <xsl:with-param name="value" select="$nnParam[@name = 'm_mp_hideInstructions']"/>
  90. </xsl:call-template>
  91. </xsl:attribute>
  92. <!-- font -->
  93. <xsl:call-template name="setInstructionsStyleAttribute">
  94. <xsl:with-param name="name" select="'font'"/>
  95. <xsl:with-param name="value" select="$nnParam[@name = 'm_mp_instructionsFont']"/>
  96. </xsl:call-template>
  97. <!-- size -->
  98. <xsl:call-template name="setInstructionsStyleAttribute">
  99. <xsl:with-param name="name" select="'size'"/>
  100. <xsl:with-param name="value" select="$nnParam[@name = 'm_mp_instructionsFontSize']"/>
  101. </xsl:call-template>
  102. <!-- colour -->
  103. <xsl:call-template name="setInstructionsStyleAttribute">
  104. <xsl:with-param name="name" select="'colour'"/>
  105. <xsl:with-param name="value" select="$nnParam[@name = 'm_mp_instructionsColour']"/>
  106. </xsl:call-template>
  107. <!-- bold -->
  108. <xsl:call-template name="setInstructionsStyleAttribute">
  109. <xsl:with-param name="name" select="'bold'"/>
  110. <xsl:with-param name="value" select="$nnParam[@name = 'm_mp_instructionsBold']"/>
  111. </xsl:call-template>
  112. <!-- italic -->
  113. <xsl:call-template name="setInstructionsStyleAttribute">
  114. <xsl:with-param name="name" select="'italic'"/>
  115. <xsl:with-param name="value" select="$nnParam[@name = 'm_mp_instructionsItalic']"/>
  116. </xsl:call-template>
  117. <!-- undeline -->
  118. <xsl:call-template name="setInstructionsStyleAttribute">
  119. <xsl:with-param name="name" select="'underline'"/>
  120. <xsl:with-param name="value" select="$nnParam[@name = 'm_mp_instructionsUnderline']"/>
  121. </xsl:call-template>
  122. <!-- align -->
  123. <xsl:call-template name="setInstructionsStyleAttribute">
  124. <xsl:with-param name="name" select="'align'"/>
  125. <xsl:with-param name="value" select="$nnParam[@name = 'm_mp_instructionsAlign']"/>
  126. </xsl:call-template>
  127. <xsl:for-each select="$nnParam[starts-with(@name, 'm_mp_instructions_')]">
  128. <value>
  129. <xsl:attribute name="xml:lang"><xsl:value-of select="substring-after(@name, 'm_mp_instructions_')"/></xsl:attribute>
  130. <xsl:value-of select="."/>
  131. </value>
  132. </xsl:for-each>
  133. <xsl:if test="$nnParam[starts-with(@name, 'm_mp_mlt_instructions_')]">
  134. <value>
  135. <xsl:attribute name="xml:lang"><xsl:value-of select="$nnParam[@name='m_mp_language']"/></xsl:attribute>
  136. <xsl:value-of select="$nnParam[starts-with(@name, 'm_mp_mlt_instructions_')]"/>
  137. </value>
  138. </xsl:if>
  139. </instructions>
  140. <!-- Portlet Options -->
  141. <portletOptions>
  142. <xsl:attribute name="hideBorders">
  143. <xsl:call-template name="setBoolAttribute">
  144. <xsl:with-param name="value" select="$nnParam[@name = 'm_mp_hideBorders']"/>
  145. </xsl:call-template>
  146. </xsl:attribute>
  147. <xsl:attribute name="hideTitleBars">
  148. <xsl:call-template name="setBoolAttribute">
  149. <xsl:with-param name="value" select="$nnParam[@name = 'm_mp_hideTitleBars']"/>
  150. </xsl:call-template>
  151. </xsl:attribute>
  152. <xsl:attribute name="hideEditMode">
  153. <xsl:call-template name="setBoolAttribute">
  154. <xsl:with-param name="value" select="$nnParam[@name = 'm_mp_hideEditMode']"/>
  155. </xsl:call-template>
  156. </xsl:attribute>
  157. </portletOptions>
  158. <!-- Column layout -->
  159. <xsl:choose>
  160. <!-- 1.1 page layout -->
  161. <xsl:when test="$nnParam[@name = 'pagexml']">
  162. <xsl:apply-templates select="$nnParam[@name = 'pagexml']/*/cps:layout/*[local-name() = 'layout']/*[local-name() != 'title' and local-name() != 'instructions' and local-name() != 'portletOptions']"/>
  163. </xsl:when>
  164. <!-- 1.0 page layout -->
  165. <xsl:when test="$nnParam[@name = 'm_mp_columns']">
  166. <xsl:choose>
  167. <xsl:when test="$nnParam[@name = 'm_mp_columns'] = '2'">
  168. <column>
  169. <xsl:attribute name="width">
  170. <xsl:value-of select="$nnParam[@name = 'm_mp_firstColumnWidth']"/>
  171. </xsl:attribute>
  172. <xsl:for-each select="$nnParam[@name = 'm_mp_col1sort']">
  173. <portlet id="{substring-after(.,',')}"/>
  174. </xsl:for-each>
  175. </column>
  176. <column>
  177. <xsl:attribute name="width">
  178. <xsl:value-of select="$nnParam[@name = 'm_mp_secondColumnWidth']"/>
  179. </xsl:attribute>
  180. <xsl:for-each select="$nnParam[@name = 'm_mp_col2sort']">
  181. <portlet id="{substring-after(.,',')}"/>
  182. </xsl:for-each>
  183. </column>
  184. </xsl:when>
  185. <xsl:when test="$nnParam[@name = 'm_mp_columns'] = '3'">
  186. <column>
  187. <xsl:attribute name="width">
  188. <xsl:value-of select="$nnParam[@name = 'm_mp_firstColumnWidth']"/>
  189. </xsl:attribute>
  190. <xsl:for-each select="$nnParam[@name = 'm_mp_col1sort']">
  191. <portlet id="{substring-after(.,',')}"/>
  192. </xsl:for-each>
  193. </column>
  194. <column>
  195. <xsl:attribute name="width">
  196. <xsl:value-of select="$nnParam[@name = 'm_mp_secondColumnWidth']"/>
  197. </xsl:attribute>
  198. <xsl:for-each select="$nnParam[@name = 'm_mp_col2sort']">
  199. <portlet id="{substring-after(.,',')}"/>
  200. </xsl:for-each>
  201. </column>
  202. <column>
  203. <xsl:attribute name="width">
  204. <xsl:value-of select="$nnParam[@name = 'm_mp_thirdColumnWidth']"/>
  205. </xsl:attribute>
  206. <xsl:for-each select="$nnParam[@name = 'm_mp_col3sort']">
  207. <portlet id="{substring-after(.,',')}"/>
  208. </xsl:for-each>
  209. </column>
  210. </xsl:when>
  211. <xsl:otherwise>
  212. <column>
  213. <xsl:attribute name="width">
  214. <xsl:choose>
  215. <xsl:when test="$nnParam[@name = 'm_mp_firstColumnWidth']">
  216. <xsl:value-of select="$nnParam[@name = 'm_mp_firstColumnWidth']"/>
  217. </xsl:when>
  218. <xsl:otherwise>100</xsl:otherwise>
  219. </xsl:choose>
  220. </xsl:attribute>
  221. <xsl:for-each select="$nnParam[@name = 'm_mp_col1sort']">
  222. <portlet id="{substring-after(.,',')}"/>
  223. </xsl:for-each>
  224. </column>
  225. </xsl:otherwise>
  226. </xsl:choose>
  227. </xsl:when>
  228. <!-- Gen default col layout -->
  229. <xsl:otherwise>
  230. <xsl:choose>
  231. <xsl:when test="$nnParam[@name = 'pagexml']">
  232. <row>
  233. <column width="100"/>
  234. </row>
  235. </xsl:when>
  236. <xsl:otherwise>
  237. <column width="100"/>
  238. </xsl:otherwise>
  239. </xsl:choose>
  240. </xsl:otherwise>
  241. </xsl:choose>
  242. </layout>
  243. </xsl:template>
  244. <xsl:template name="setBoolAttribute">
  245. <xsl:param name="value"/>
  246. <xsl:choose>
  247. <xsl:when test="$value = 'true'">true</xsl:when>
  248. <xsl:otherwise>false</xsl:otherwise>
  249. </xsl:choose>
  250. </xsl:template>
  251. <xsl:template name="setStyleAttribute">
  252. <xsl:param name="value"/>
  253. <xsl:choose>
  254. <xsl:when test="$value != ''"><xsl:value-of select="$value"/></xsl:when>
  255. <xsl:otherwise>default</xsl:otherwise>
  256. </xsl:choose>
  257. </xsl:template>
  258. <xsl:template name="setInstructionsStyleAttribute">
  259. <xsl:param name="name"/>
  260. <xsl:param name="value"/>
  261. <xsl:if test="$value != '' and $nnParam[@name = 'm_mp_instructionsStyle'] = 'custom'">
  262. <xsl:attribute name="{$name}">
  263. <xsl:value-of select="$value"/>
  264. </xsl:attribute>
  265. </xsl:if>
  266. </xsl:template>
  267. <xsl:template name="setITitleStyleAttribute">
  268. <xsl:param name="name"/>
  269. <xsl:param name="value"/>
  270. <xsl:if test="$value != '' and $nnParam[@name = 'm_mp_titleStyle'] = 'custom'">
  271. <xsl:attribute name="{$name}">
  272. <xsl:value-of select="$value"/>
  273. </xsl:attribute>
  274. </xsl:if>
  275. </xsl:template>
  276. <xsl:template match="*">
  277. <xsl:element name="{local-name()}">
  278. <xsl:copy-of select="@*"/>
  279. <xsl:apply-templates/>
  280. </xsl:element>
  281. </xsl:template>
  282. </xsl:stylesheet>