debuglogic.xslt 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  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. 2005, 2010
  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. <!--
  13. This logic sheet contains common debug features useful for morphlets.
  14. The elements are
  15. dbg:dumpxml - Displays xml in an easily readable format.
  16. -->
  17. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:dbg="http://developer.cognos.com/schemas/xts/logicsheets/xslt/debug/" xmlns:out="dummy-uri" xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt">
  18. <xsl:output method="xml" encoding="UTF-8" indent="no"/>
  19. <xsl:namespace-alias stylesheet-prefix="out" result-prefix="xsl"/>
  20. <!--
  21. ===============================================================================================
  22. dbg:dumpxml - displays xml in an easily readable format
  23. ===============================================================================================
  24. -->
  25. <xsl:template match="dbg:dumpxml">
  26. <out:if test="string(/root/debug/debugSwitch) != 'disable' ">
  27. <out:variable name="gateway" select="xtsext:substringAfterLast( string( /root/http/param[@name='SCRIPT_NAME'] ), '/' )"/>
  28. <!-- the script used by the debugger -->
  29. <out:if test="string(/root/debug/debugSwitch)='request' or string(/root/debug/traceOutput)='true'">
  30. <script type="text/javascript">
  31. var sDebugCookie = "XTS_DEBUG";
  32. function debugSwitch() {
  33. var s = getCookie(sDebugCookie );
  34. if ('<out:value-of select="xtsext:javascriptencode(string(/root/debug/traceOutput))"/>' == 'true')
  35. {
  36. setCookie(sDebugCookie , "false");
  37. location.reload();
  38. }
  39. else
  40. {
  41. setCookie(sDebugCookie , "true");
  42. location.reload();
  43. }
  44. }
  45. function launchDebugger(sURL) {
  46. windowDebug = window.open(sURL, "debugWindow", "toolbar=no,location=yes,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=750,height=600");
  47. windowDebug.focus();
  48. }
  49. </script>
  50. </out:if>
  51. <!-- this will output the debug switch if necessary and the link to launch the debugger -->
  52. <out:choose>
  53. <out:when test="string(/root/debug/traceOutput)='true'">
  54. <p align="right" class="text">
  55. <out:if test="string(/root/debug/debugSwitch)='request'">
  56. <a href="javascript:debugSwitch()">turn trace off</a>&#160;&#160;|&#160;&#160;<xsl:text/>
  57. </out:if>
  58. <a>
  59. <xsl:attribute name="href">javascript:launchDebugger('<xsl:value-of select="'{$gateway}'"/>?b_action=xts.run&amp;m=debug/traceview.xts&amp;d_request=<xsl:value-of select="'{/root/debug/traceRequestPath}'"/>')</xsl:attribute>
  60. <xsl:text/>launch trace viewer<xsl:text/>
  61. </a>
  62. </p>
  63. </out:when>
  64. <out:when test="string(/root/debug/debugSwitch) = 'request'">
  65. <p align="right" class="text">
  66. <a href="javascript:debugSwitch()">turn trace on</a>&#160;&#160;|&#160;&#160;<xsl:text/>
  67. <span class="inactiveText">launch trace viewer</span>
  68. </p>
  69. </out:when>
  70. </out:choose>
  71. <table cellpadding="0" cellspacing="3" width="100%">
  72. <tr bgcolor="#3333FF">
  73. <td>
  74. <xsl:choose>
  75. <xsl:when test="dbg:title">
  76. <span style="font: 14pt sans-serif; color: #FFFFFF">Dump of [ <xsl:value-of select="dbg:title"/> ]</span>
  77. </xsl:when>
  78. <xsl:otherwise>
  79. <span style="font: 14pt sans-serif; color: #FFFFFF">Dump of [ <xsl:value-of select="@select"/> ]</span>
  80. </xsl:otherwise>
  81. </xsl:choose>
  82. </td>
  83. </tr>
  84. <tr bgcolor="white">
  85. <td>
  86. <div>
  87. <out:apply-templates mode="render">
  88. <xsl:copy-of select="@*"/>
  89. </out:apply-templates>
  90. </div>
  91. </td>
  92. </tr>
  93. </table>
  94. </out:if>
  95. </xsl:template>
  96. <!--
  97. ===============================================================================================
  98. xsl:stylesheet - adds the templates that are called within this logic sheet
  99. ===============================================================================================
  100. -->
  101. <xsl:template match="xsl:stylesheet">
  102. <xsl:copy>
  103. <xsl:copy-of select="@*"/>
  104. <xsl:apply-templates/>
  105. <xsl:call-template name="addTemplates"/>
  106. </xsl:copy>
  107. </xsl:template>
  108. <xsl:template name="addTemplates">
  109. <!--
  110. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  111. render an element
  112. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  113. -->
  114. <out:template match="*" mode="render">
  115. <table cellspacing="0" cellpadding="0" border="0" style="font: 10pt Verdana">
  116. <tr>
  117. <td width="100%">
  118. <out:variable name="name">
  119. <span>
  120. <out:attribute name="style">
  121. <out:choose>
  122. <out:when test="starts-with(name(), 'xts:')">font-weight: bold; color: darkblue;</out:when>
  123. <out:when test="starts-with(name(), 'out:')">font-weight: bold; color: darkred;</out:when>
  124. <out:when test="starts-with(name(), 'utml:')">font-weight: bold; color: darkgreen;</out:when>
  125. <out:otherwise>color: darkred;</out:otherwise>
  126. </out:choose>
  127. </out:attribute>
  128. <out:value-of select="name()"/>
  129. </span>
  130. </out:variable>
  131. <div style="margin-left: 20px;">
  132. <span style="color: blue">&lt;</span>
  133. <out:copy-of select="$name"/>
  134. <out:apply-templates select="@*" mode="render"/>
  135. <out:variable name="pns" select="../namespace::*"/>
  136. <out:if test="$pns[name()=''] and namespace-uri()='' and namespace-uri(..) != namespace-uri()">
  137. <span style="color: red">
  138. <out:text>&#160;xmlns</out:text>
  139. </span>
  140. <out:text>=&quot;&quot;</out:text>
  141. </out:if>
  142. <out:for-each select="namespace::*">
  143. <out:if test="not($pns[name()=name(current()) and .=current()])">
  144. <out:call-template name="render-ns"/>
  145. </out:if>
  146. </out:for-each>
  147. <span style="color: blue">
  148. <out:if test="not(* | text() | comment())">/</out:if>&gt;</span>
  149. <out:apply-templates mode="render"/>
  150. <out:if test="* | text() | comment()">
  151. <span style="color: blue">&lt;/</span>
  152. <out:copy-of select="$name"/>
  153. <span style="color: blue">&gt;</span>
  154. </out:if>
  155. </div>
  156. </td>
  157. </tr>
  158. </table>
  159. </out:template>
  160. <out:template name="render-ns">
  161. <out:if test="name()!='xml'">
  162. <span style="color: red">
  163. <out:text> xmlns</out:text>
  164. <out:if test="name()!=''">
  165. <out:text>:</out:text>
  166. </out:if>
  167. <out:value-of select="name()"/>
  168. </span>
  169. <span style="color: blue">=&quot;</span>
  170. <span style="font-weight: bold; color: red;">
  171. <out:choose>
  172. <out:when test="name()!=''">
  173. <out:attribute name="title">
  174. <out:value-of select="."/>
  175. </out:attribute>
  176. <out:text>...</out:text>
  177. </out:when>
  178. <out:otherwise>
  179. <out:value-of select="."/>
  180. </out:otherwise>
  181. </out:choose>
  182. </span>
  183. <span style="color: blue">&quot;</span>
  184. </out:if>
  185. </out:template>
  186. <!--
  187. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  188. render an attribute
  189. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  190. -->
  191. <out:template match="@*" mode="render">
  192. <span style="color: darkred">&#160;<out:value-of select="name()"/>
  193. </span>
  194. <span style="color: blue">="</span>
  195. <span style="font-weight: bold; color: black;">
  196. <out:value-of select="."/>
  197. </span>
  198. <span style="color: blue">"</span>
  199. </out:template>
  200. <!--
  201. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  202. text nodes
  203. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  204. -->
  205. <out:template match="text()" mode="render">
  206. <span style="font-weight: bold; color: black;">
  207. <out:value-of select="."/>
  208. </span>
  209. </out:template>
  210. <!--
  211. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  212. comment nodes
  213. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  214. -->
  215. <out:template match="comment()" mode="render">
  216. <div style="border: none none 0px; border-right: none none 0px; margin-left: 20px;">
  217. <span style="font-weight: bold; color: darkgray;">
  218. <out:text/>&lt;!-- <out:value-of select="."/>--&gt;<out:text/>
  219. </span>
  220. </div>
  221. </out:template>
  222. <!-- this is the end to get any other debug templates, only temperary -->
  223. <dbg:templates/>
  224. </xsl:template>
  225. <!-- the main engine -->
  226. <xsl:template match="*">
  227. <xsl:copy>
  228. <xsl:copy-of select="@*"/>
  229. <xsl:apply-templates/>
  230. </xsl:copy>
  231. </xsl:template>
  232. <!--
  233. ===============================================================================================
  234. deprecated templates.
  235. ===============================================================================================
  236. -->
  237. <xsl:template match="dbg:templates"/>
  238. </xsl:stylesheet>