render-error.xsl 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  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, 2019
  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:xsi="http://www.w3.org/2001/XMLSchema-instance"
  11. xmlns:xos="http://developer.cognos.com/schemas/xts/output/"
  12. xmlns:xts="http://developer.cognos.com/schemas/xts/"
  13. xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt"
  14. xmlns:bus="http://developer.cognos.com/schemas/bibus/3/"
  15. exclude-result-prefixes="xsl xsi xos xts bus xtsext">
  16. <xsl:output method="html" version="1.0" encoding="UTF-8" indent="no" omit-xml-declaration="yes"/>
  17. <!-- general -->
  18. <xsl:variable name="webcontent" select="/fault/settings/param[@name='webcontent']"/>
  19. <xsl:variable name="app" select="/fault/settings/param[@name='app']"/>
  20. <xsl:variable name="skin" select="/fault/settings/param[@name='skin']"/>
  21. <xsl:variable name="web" select="/fault/settings/param[@name='web']"/>
  22. <xsl:variable name="gateway" select="/fault/settings/param[@name='gateway']"/>
  23. <xsl:variable name="pathInfo" select="/fault/settings/param[@name='pathInfo']"/>
  24. <xsl:variable name="browser" select="/fault/settings/param[@name='browser']"/>
  25. <xsl:variable name="skin_images" select="/fault/settings/param[@name='skin_images']"/>
  26. <xsl:variable name="isModal" select="/fault/settings/param[@name='isModal']"/>
  27. <xsl:variable name="locale" select="/fault/settings/param[@name='locale']"/>
  28. <xsl:template match="/">
  29. <xsl:text disable-output-escaping='yes'>&lt;!DOCTYPE html></xsl:text>
  30. <html lang="{$locale}">
  31. <head>
  32. <meta http-equiv="expires" content="0"/>
  33. <link rel="stylesheet" type="text/css" href="{$web}/skins/{$skin}/portal/default.css"/>
  34. <link rel="stylesheet" type="text/css" href="{$web}/skins/{$skin}/fonts.css"/>
  35. <!-- Copy over the helper scripts and any associated form(s) -->
  36. <xsl:apply-templates select="fault/presentation/scripts/*" mode="scripts-and-form"/>
  37. <script language="JavaScript">
  38. if (document.addEventListener) {
  39. window.addEventListener("beforeunload", function(){}, false);
  40. } else if (document.attachEvent) {
  41. window.attachEvent("onbeforeunload", function(){});
  42. }
  43. <xsl:apply-templates select="fault[error]" mode="notify"/>
  44. </script>
  45. <title><xsl:value-of select="fault/presentation/title"/></title>
  46. </head>
  47. <body onload="if (window.init) init();" style="margin:3px;" role="region" aria-labelledby="IDS_ERROR_DIALOG_TITLE">
  48. <span id="IDS_ERROR_DIALOG_TITLE" style="position: absolute;margin-left: -9999px; margin-top: -9999px; "><xsl:value-of select="fault/presentation/resources/message[@id='IDS_FAULT_DIALOG_TITLE']"/></span>
  49. <form style="margin:0px;padding:0px;" method="post" action="{concat($gateway,$pathInfo)}" name="pform">
  50. <a href="#maincontent" tabindex="0" class="showOnFocus"><xsl:value-of select="fault/presentation/resources/message[@id='IDS_SECTION508_JUMPTOMAIN']"/></a>
  51. <xsl:call-template name="render"/>
  52. </form>
  53. </body>
  54. </html>
  55. </xsl:template>
  56. <!-- -->
  57. <!-- Render ERROR fault -->
  58. <!-- -->
  59. <xsl:template name="render">
  60. <!-- ******************* -->
  61. <!-- Render the header -->
  62. <!-- ******************* -->
  63. <table border="0" width="100%" cellspacing="0" cellpadding="0" class="dialogHeader" style="height:28px;" role="presentation">
  64. <tr>
  65. <td class="dialogHeaderTitle" nowrap="nowrap">
  66. <xsl:value-of select="fault/presentation/title"/>
  67. </td>
  68. <td width="100%"></td>
  69. <xsl:if test="fault/presentation/actions/action[@type='help']">
  70. <td class="dialogHeaderLink" nowrap="nowrap">
  71. <a href="javascript:{fault/presentation/actions/action[@type='help']/default-command}" class="dialogHeaderLinkColor">
  72. <xsl:value-of select="fault/presentation/actions/action[@type='help']/label"/>
  73. </a>
  74. </td>
  75. </xsl:if>
  76. <xsl:if test="fault/presentation/actions/action[@type='close']">
  77. <td class="dialogHeaderLink">
  78. <a href="javascript:{fault/presentation/actions/action[@type='close']/default-command}" class="dialogHeaderLinkColor">
  79. <img height="16" width="16" vspace="2" border="0" class="dialogHeaderCloseButton"
  80. onmouseover="this.className = 'dialogHeaderCloseButtonOver'"
  81. onmouseout="this.className = 'dialogHeaderCloseButton'"
  82. src="{$skin_images}close.gif" role="button">
  83. <xsl:attribute name="alt">
  84. <xsl:value-of select="fault/presentation/actions/action[@type='close']/label"/>
  85. </xsl:attribute>
  86. <xsl:attribute name="title">
  87. <xsl:value-of select="fault/presentation/actions/action[@type='close']/label"/>
  88. </xsl:attribute>
  89. </img>
  90. </a>
  91. </td>
  92. </xsl:if>
  93. </tr>
  94. </table>
  95. <!-- ******************* -->
  96. <!-- Render the error body -->
  97. <!-- ******************* -->
  98. <xsl:apply-templates select="fault[error]"/>
  99. <!-- ******************* -->
  100. <!-- Render the footer -->
  101. <!-- ******************* -->
  102. <table role="presentation" class="dialogButtonBar" width="100%" cellpadding="0" cellspacing="0" style="margin-top:20px;height:50px;">
  103. <tr>
  104. <xsl:if test="fault/presentation/actions/action[@type='ok']">
  105. <td>
  106. <input id="cmdOK" style="width:70px;"
  107. type="submit" class="cmdButton" onmouseover="this.className='cmdButtonOver'"
  108. onmouseout="this.className='cmdButton'"
  109. value="{fault/presentation/actions/action[@type='ok']/label}"
  110. onclick="javascript:{fault/presentation/actions/action[@type='ok']/default-command}; return false;"/>
  111. </td>
  112. </xsl:if>
  113. <td width="100%"/>
  114. </tr>
  115. </table>
  116. </xsl:template>
  117. <xsl:template match="fault[error]">
  118. <!-- Include the error as a comment so it can be parsed by clients that don't care about the html response (e.g. ajax client) -->
  119. <xsl:text disable-output-escaping="yes">&lt;!--</xsl:text>
  120. <ERROR_COMPONENT>ps</ERROR_COMPONENT>
  121. <ERROR_CODE><xsl:value-of select="./error/errorCodeString"/></ERROR_CODE>
  122. <ERROR_MSG><xsl:value-of select="./error/message"/></ERROR_MSG>
  123. <xsl:text disable-output-escaping="yes">--></xsl:text>
  124. <table width="100%" border="0" cellspacing="0" cellpadding="0" role="presentation">
  125. <tr>
  126. <td>
  127. <img src="{$webcontent}/images/space.gif" alt="" width="1" height="10"/>
  128. </td>
  129. </tr>
  130. </table>
  131. <table width="100%" border="0" cellspacing="0" cellpadding="0" style="padding-left:5px;" role="presentation">
  132. <tr>
  133. <td class="dialogHeaderText">
  134. <xsl:value-of select="./error/errorCodeString"/>
  135. </td>
  136. </tr>
  137. </table>
  138. <table width="100%" border="0" cellspacing="0" cellpadding="0" role="presentation">
  139. <tr>
  140. <td>
  141. <img src="{$webcontent}/images/space.gif" alt="" width="1" height="10"/>
  142. </td>
  143. </tr>
  144. </table>
  145. <table width="100%" border="0" cellspacing="0" cellpadding="0" role="presentation">
  146. <tr>
  147. <td>
  148. <table width="100%" border="0" cellspacing="0" cellpadding="3" role="presentation">
  149. <tr>
  150. <td width="1" height="1">
  151. <img src="{$webcontent}/images/space.gif" width="1" height="1" alt=""/>
  152. </td>
  153. <td width="100%">
  154. <table border="0" cellspacing="0" cellpadding="0" role="presentation">
  155. <tr>
  156. <td>
  157. <img src="{$webcontent}/{$app}/images/msg_error.gif" alt="" width="32" height="32" border="0"/>
  158. </td>
  159. <td class="formText">&#160;&#160;&#160;</td>
  160. <td class="formText" valign="top">
  161. <xsl:call-template name="format-error">
  162. <xsl:with-param name="msg" select="./error/message"/>
  163. </xsl:call-template>
  164. </td>
  165. </tr>
  166. </table>
  167. </td>
  168. </tr>
  169. </table>
  170. <xsl:if test="count(./error/details) > 0">
  171. <script type="text/javascript" language="JavaScript">
  172. var imgExpand = new Image();
  173. var imgCollapse = new Image();
  174. imgExpand.alt = "<xsl:value-of select="presentation/resources/message[@id='IDS_SECTION_EXPAND']"/>";
  175. imgExpand.title = "<xsl:value-of select="presentation/resources/message[@id='IDS_SECTION_EXPAND']"/>";
  176. imgExpand.src = "<xsl:value-of select="xtsext:javascriptencode($skin_images)"/>prompt_option_expand.gif";
  177. imgCollapse.src = "<xsl:value-of select="xtsext:javascriptencode($skin_images)"/>prompt_option_collapse.gif";
  178. imgCollapse.alt = "<xsl:value-of select="presentation/resources/message[@id='IDS_SECTION_COLLAPSE']"/>";
  179. imgCollapse.title = "<xsl:value-of select="presentation/resources/message[@id='IDS_SECTION_COLLAPSE']"/>";
  180. function toggleDynamicSection(name) {
  181. var img = document.getElementById("img_" + name);
  182. if(document.getElementById(name).style.display == 'none') {
  183. document.getElementById(name).style.display = "";
  184. img.src = imgCollapse.src;
  185. } else {
  186. document.getElementById(name).style.display = "none";
  187. img.src = imgExpand.src;
  188. }
  189. }
  190. </script>
  191. <table border="0" cellpadding="0" cellspacing="0" style="margin:10px" role="presentation">
  192. <tr>
  193. <td>
  194. <img src="{$webcontent}/images/space.gif" alt="" width="30" height="30" border="0"/>
  195. </td>
  196. <td class="formText">&#160;&#160;&#160;</td>
  197. <td>
  198. <table role="presentation">
  199. <tr>
  200. <td class="formText" valign="bottom" nowrap="nowrap">
  201. <a href="javascript:toggleDynamicSection('errorPanel')" role="main" id="maincontent">
  202. <xsl:value-of select="presentation/resources/message[@id='IDS_FAULT_DETAILS']"/>
  203. </a>
  204. <a href="javascript:toggleDynamicSection('errorPanel');{@onclick}">
  205. <img name="img_errorPanel" id="img_errorPanel" border="0">
  206. <xsl:attribute name="src"><xsl:value-of select="$skin_images"/>prompt_option_expand.gif</xsl:attribute>
  207. <xsl:attribute name="alt"><xsl:value-of select="presentation/resources/message[@id='IDS_SECTION_EXPAND']"/></xsl:attribute>
  208. <xsl:attribute name="title"><xsl:value-of select="presentation/resources/message[@id='IDS_SECTION_EXPAND']"/></xsl:attribute>
  209. </img>
  210. </a>
  211. </td>
  212. </tr>
  213. <tr>
  214. <td>
  215. <div id="errorPanel" class="errorPanel" style="display:none">
  216. <xsl:call-template name="format-error">
  217. <xsl:with-param name="msg" select="./error/details"/>
  218. </xsl:call-template>
  219. </div>
  220. </td>
  221. </tr>
  222. </table>
  223. </td>
  224. </tr>
  225. </table>
  226. </xsl:if>
  227. </td>
  228. </tr>
  229. </table>
  230. </xsl:template>
  231. <xsl:template match="fault[error]" mode="notify">
  232. <!-- Notify parent window (if it cares) that an error was displayed -->
  233. if (parent.OnErrorPage) {
  234. parent.OnErrorPage("<xsl:value-of select="./error/errorCodeString"/>","<xsl:value-of select="xtsext:javascriptencode(./error/message)"/>",[<xsl:call-template name="format-details"><xsl:with-param name="javascriptencode" select="true()"/></xsl:call-template>]);
  235. }
  236. </xsl:template>
  237. <xsl:template name="format-error">
  238. <xsl:param name="msg"/>
  239. <xsl:param name="suffix" select="'&lt;br/&gt;'"/>
  240. <xsl:param name="quot" select="''"/>
  241. <xsl:param name="javascriptencode" select="false()"/>
  242. <xsl:choose>
  243. <xsl:when test="contains($msg, '&#10;')">
  244. <xsl:variable name="errorDetail" select="substring-before($msg, '&#10;')"/>
  245. <xsl:value-of select="$quot"/>
  246. <xsl:choose>
  247. <xsl:when test="$javascriptencode = 'true'">
  248. <xsl:value-of select="xtsext:javascriptencode($errorDetail)"/>
  249. </xsl:when>
  250. <xsl:otherwise>
  251. <xsl:value-of select="$errorDetail"/>
  252. </xsl:otherwise>
  253. </xsl:choose>
  254. <xsl:value-of select="$quot"/><xsl:value-of select="$suffix"/>
  255. <xsl:call-template name="format-error">
  256. <xsl:with-param name="msg" select="substring-after($msg, '&#10;')"/>
  257. <xsl:with-param name="suffix" select="$suffix"/>
  258. <xsl:with-param name="quot" select="$quot"/>
  259. <xsl:with-param name="javascriptencode" select="$javascriptencode"/>
  260. </xsl:call-template>
  261. </xsl:when>
  262. <xsl:otherwise>
  263. <xsl:value-of select="$quot"/>
  264. <xsl:choose>
  265. <xsl:when test="$javascriptencode = 'true'">
  266. <xsl:value-of select="xtsext:javascriptencode($msg)"/>
  267. </xsl:when>
  268. <xsl:otherwise>
  269. <xsl:value-of select="$msg"/>
  270. </xsl:otherwise>
  271. </xsl:choose>
  272. <xsl:value-of select="$quot"/>
  273. </xsl:otherwise>
  274. </xsl:choose>
  275. </xsl:template>
  276. <xsl:template name="format-details">
  277. <xsl:param name="javascriptencode" select="false()"/>
  278. <xsl:if test="count(./error/details) > 0">
  279. <xsl:call-template name="format-error">
  280. <xsl:with-param name="msg" select="./error/details"/>
  281. <xsl:with-param name="suffix" select="','"/>
  282. <xsl:with-param name="quot" select="'&quot;'"/>
  283. <xsl:with-param name="javascriptencode" select="$javascriptencode"/>
  284. </xsl:call-template>
  285. </xsl:if>
  286. </xsl:template>
  287. <xsl:template match="*" mode="scripts-and-form">
  288. <xsl:copy>
  289. <xsl:copy-of select="@*"/>
  290. <xsl:apply-templates mode="scripts-and-form"/>
  291. </xsl:copy>
  292. </xsl:template>
  293. <xsl:template match="input" mode="scripts-and-form">
  294. <xsl:copy>
  295. <xsl:copy-of select="@*"/>
  296. <xsl:attribute name="value"><xsl:value-of select="."/></xsl:attribute>
  297. </xsl:copy>
  298. </xsl:template>
  299. <xsl:template match="text()"/>
  300. </xsl:stylesheet>