layout.xsl 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  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, 2015
  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" xmlns:out="dummy-uri"
  9. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  10. xmlns:lyt="http://developer.cognos.com/schemas/xts/logicsheets/xslt/presentation/layout/"
  11. xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt"
  12. xmlns:xts="http://developer.cognos.com/schemas/xts/"
  13. xmlns:cm="http://developer.cognos.com/schemas/xts-cm/1/" exclude-result-prefixes="xsl lyt xtsext xts cm">
  14. <xsl:output method="xml" encoding="UTF-8" indent="no"/>
  15. <xsl:namespace-alias stylesheet-prefix="out" result-prefix="xsl"/>
  16. <!--
  17. This stylesheet (layout.xsl) consists of the following templates:
  18. lyt:layout - render a particular layout for a portion of the CC web page.
  19. -->
  20. <!--
  21. Template - lyt:layout:
  22. This template is used to render a specific layout on a CC Web page.
  23. A layout can have a title and border at the top of the layout.
  24. A layout can be joined to a previously rendered layout.
  25. A layout must contain at least one lyt:section.
  26. Operation:
  27. Renders a layout based on the specified attributes:
  28. @joinSection - specifies not to produce padding between layouts.
  29. @title - specified to render a title, value is an XTS string ID
  30. @longTitle = specified to render a title, value is a string
  31. @border - specifies to render a separating border
  32. @intro - specifies that there is informational text to be presented
  33. @style - 1) A single section 2) Two parallel sections
  34. @width - specifies the width of the layout.
  35. lyt:section
  36. @width - specifies the width of the section.
  37. @height - specifies the height of the section.
  38. NOTE: CODE WILL NOT PASS BETWEEN THE FOLLOWING TAGS
  39. <lyt:layout> and <lyt:section>
  40. -->
  41. <xsl:template match="lyt:layout">
  42. <xsl:if test="not(@joinSection)">
  43. <table summary="" border="0" cellpadding="0" cellspacing="0" width="100%" role="presentation">
  44. <tr>
  45. <td height="10" width="100%">
  46. </td>
  47. </tr>
  48. </table>
  49. </xsl:if>
  50. <xsl:variable name="titleText">
  51. <xsl:choose>
  52. <xsl:when test="@longTitle and @longTitle!=''">
  53. <out:value-of select="{@longTitle}"/>&#160;
  54. </xsl:when>
  55. <xsl:when test="@title and @title!=''">
  56. <xts:string id="{@title}"/>&#160;
  57. </xsl:when>
  58. </xsl:choose>
  59. </xsl:variable>
  60. <xsl:if test="@title or @longTitle or @border='yes'">
  61. <table summary="" width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation">
  62. <xsl:if test="@tabindex">
  63. <xsl:attribute name="tabindex"><xsl:value-of select="@tabindex"/></xsl:attribute>
  64. </xsl:if>
  65. <tr>
  66. <td width="8">
  67. </td>
  68. <xsl:if test="@title or @longTitle">
  69. <td valign="middle" nowrap="nowrap" class="formLabel">
  70. <xsl:if test="@id">
  71. <xsl:attribute name="id">
  72. <xsl:value-of select="@id"/>
  73. </xsl:attribute>
  74. </xsl:if>
  75. <xsl:copy-of select="$titleText"/>
  76. </td>
  77. </xsl:if>
  78. <xsl:choose>
  79. <xsl:when test="@border = 'yes'">
  80. <td width="100%" valign="middle" align="right">
  81. <table summary="" width="100%" height="1" border="0" cellpadding="0" cellspacing="0">
  82. <tr>
  83. <td class="dialogDivider">
  84. </td>
  85. </tr>
  86. </table>
  87. </td>
  88. </xsl:when>
  89. <xsl:otherwise><td width="100%" valign="middle" align="right"/></xsl:otherwise>
  90. </xsl:choose>
  91. <td width="10">
  92. </td>
  93. </tr>
  94. </table>
  95. <table summary="" width="100%" border="0" cellpadding="0" cellspacing="0">
  96. <tr>
  97. <td height="5" width="1">
  98. </td>
  99. </tr>
  100. </table>
  101. </xsl:if>
  102. <xsl:if test="@intro">
  103. <table summary="" role="presentation" width="100%" border="0" cellpadding="0" cellspacing="0" style="padding-bottom:10px;">
  104. <tr>
  105. <td height="1" width="8"><img height="1" width="8" src="{'{$webcontent}'}/images/space.gif" alt=""/></td>
  106. <td width="100%" valign="top" class="dialogHintText"><xts:string id="{@intro}"/></td>
  107. <td height="5" width="1"><img height="5" width="1" src="{'{$webcontent}'}/images/space.gif" alt=""/></td>
  108. </tr>
  109. </table>
  110. </xsl:if>
  111. <xsl:if test="lyt:intro">
  112. <table summary="" width="100%" border="0" cellpadding="0" cellspacing="0" style="padding-bottom:10px;" role="presentation">
  113. <tr>
  114. <td height="1" width="8">
  115. <img height="1" width="8" src="{'{$webcontent}'}/images/space.gif" alt=""/>
  116. </td>
  117. <td width="100%" valign="top" align="left" class="dialogHintText">
  118. <xsl:apply-templates select="lyt:intro/child::node()"/>
  119. </td>
  120. <td height="5" width="1">
  121. <img height="5" width="1" src="{'{$webcontent}'}/images/space.gif" alt=""/>
  122. </td>
  123. </tr>
  124. </table>
  125. </xsl:if>
  126. <xsl:choose>
  127. <xsl:when test="@style='1'">
  128. <table summary="" border="0" cellspacing="0" cellpadding="3" role="presentation">
  129. <xsl:attribute name="width">
  130. <xsl:choose>
  131. <xsl:when test="@width"><xsl:value-of select="@width"/></xsl:when>
  132. <xsl:otherwise>100%</xsl:otherwise>
  133. </xsl:choose>
  134. </xsl:attribute>
  135. <xsl:variable name="varSuffix" select="generate-id()"/>
  136. <!-- if there is a section title then use that otherwise you the title of the layout -->
  137. <out:variable name="titleText{$varSuffix}">
  138. <xsl:copy-of select="$titleText"/>
  139. </out:variable>
  140. <xsl:for-each select="lyt:section">
  141. <tr>
  142. <td height="1" width="1">
  143. </td>
  144. <td>
  145. <xsl:copy-of select="@*[local-name() != 'width' and local-name() != 'title']"/>
  146. <xsl:attribute name="width">
  147. <xsl:choose>
  148. <xsl:when test="@width"><xsl:value-of select="@width"/></xsl:when>
  149. <xsl:otherwise>100%</xsl:otherwise>
  150. </xsl:choose>
  151. </xsl:attribute>
  152. <xsl:if test="@noTitle != 'true'">
  153. <out:if test="$titleText{$varSuffix} != ''">
  154. <out:attribute name="role">group</out:attribute>
  155. <out:attribute name="aria-label">
  156. <out:variable name="secTitle"><xts:string id="{@title}"/></out:variable>
  157. <out:choose>
  158. <out:when test="$secTitle != ''"><out:value-of select="$secTitle"/></out:when>
  159. <out:otherwise><out:value-of select="$titleText{$varSuffix}"/></out:otherwise>
  160. </out:choose>
  161. </out:attribute>
  162. </out:if>
  163. </xsl:if>
  164. <xsl:apply-templates select="*"/>
  165. </td>
  166. </tr>
  167. </xsl:for-each>
  168. </table>
  169. </xsl:when>
  170. <xsl:when test="@style='2'">
  171. <table summary="" border="0" cellspacing="0" cellpadding="3" role="presentation">
  172. <xsl:if test="@width">
  173. <xsl:attribute name="width"><xsl:value-of select="@width"/></xsl:attribute>
  174. </xsl:if>
  175. <xsl:variable name="varSuffix" select="generate-id()"/>
  176. <out:variable name="titleText{$varSuffix}">
  177. <xsl:copy-of select="$titleText"/>
  178. </out:variable>
  179. <xsl:for-each select="lyt:section[(position() mod 2) = 1]">
  180. <tr>
  181. <out:if test="$titleText{$varSuffix} != ''">
  182. <out:attribute name="role">group</out:attribute>
  183. <out:attribute name="aria-label"><out:value-of select="$titleText{$varSuffix}"/></out:attribute>
  184. </out:if>
  185. <td height="1" width="1">
  186. </td>
  187. <td valign="top">
  188. <xsl:attribute name="width">
  189. <xsl:choose>
  190. <xsl:when test="@width"><xsl:value-of select="@width"/></xsl:when>
  191. <xsl:otherwise>50%</xsl:otherwise>
  192. </xsl:choose>
  193. </xsl:attribute>
  194. <xsl:apply-templates select="*"/>
  195. </td>
  196. <td valign="top">
  197. <xsl:attribute name="width">
  198. <xsl:choose>
  199. <xsl:when test="@width"><xsl:value-of select="following-sibling::*[1]/@width"/></xsl:when>
  200. <xsl:otherwise>50%</xsl:otherwise>
  201. </xsl:choose>
  202. </xsl:attribute>
  203. <xsl:apply-templates select="following-sibling::*[1]/*"/>
  204. </td>
  205. </tr>
  206. </xsl:for-each>
  207. </table>
  208. </xsl:when>
  209. </xsl:choose>
  210. </xsl:template>
  211. <xsl:template match="*">
  212. <xsl:copy>
  213. <xsl:copy-of select="@*"/>
  214. <xsl:apply-templates/>
  215. </xsl:copy>
  216. </xsl:template>
  217. </xsl:stylesheet>