drill-from-pdf.xts 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. Licensed Materials - Property of IBM
  4. IBM Cognos Products: Viewer
  5. (C) Copyright IBM Corp. 2001, 2019
  6. US Government Users Restricted Rights - Use, duplication or
  7. disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  8. -->
  9. <xts:morphlet xmlns:xts="http://developer.cognos.com/schemas/xts/" messageBase="messages/viewer.xml, messages/portal.xml, messages/portalRL.xml">
  10. <xts:block id="drillTargets" mode="interpret" processor="XSLT" type="exec" condition=".[/root/env/param[@name='drillTargets'] != '']" mandatory="false">
  11. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  12. <!-- Convert drill specification from XML string to document form -->
  13. <xsl:template match="/">
  14. <xts:sequence>
  15. <xts:append>
  16. <drillTargets>
  17. <xsl:value-of select="/root/env/param[@name='drillTargets']" disable-output-escaping="yes"/>
  18. </drillTargets>
  19. <drillSpecs>
  20. <xsl:value-of select="/root/env/param[@name='drillSpecs']" disable-output-escaping="yes"/>
  21. </drillSpecs>
  22. </xts:append>
  23. </xts:sequence>
  24. </xsl:template>
  25. </xsl:stylesheet>
  26. </xts:block>
  27. <xts:block id="drillSpecs" dependency="drillTargets" mode="interpret" processor="XSLT" type="exec" condition=".[/root/env/param[@name='drillSpecs']!='']" mandatory="false">
  28. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  29. <xsl:template match="/root">
  30. <xts:sequence>
  31. <xsl:choose>
  32. <xsl:when test="count(/root/*[local-name()='drillTargets']/*) > 1">
  33. <xts:replace select="/root/*[local-name()='drillTargets']">
  34. <drillTargets>
  35. <xts:transform src="portal/drillthrough.xslt" processor="XSLT">
  36. <appendDrillSpecs>
  37. <xsl:copy-of select="/root/*[local-name()='drillTargets']"/>
  38. <xsl:copy-of select="/root/*[local-name()='drillSpecs']"/>
  39. </appendDrillSpecs>
  40. </xts:transform>
  41. </drillTargets>
  42. </xts:replace>
  43. </xsl:when>
  44. <xsl:otherwise>
  45. <xsl:variable name="sourceContextIdx">
  46. <xsl:value-of select="/root/*[local-name()='drillTargets']/*[local-name()='drillTarget']/@drillIdx"/>
  47. </xsl:variable>
  48. <xts:append select="/root">
  49. <sourceContext>
  50. <xsl:copy-of select="/root/*[local-name()='drillSpecs']/*/DRILL[(position()-1)=$sourceContextIdx]/*[local-name()='parameters']"/>
  51. </sourceContext>
  52. <objectPaths>
  53. <xsl:copy-of select="/root/*[local-name()='drillSpecs']/*/DRILL[(position()-1)=$sourceContextIdx]/*[local-name()='objectPaths']"/>
  54. </objectPaths>
  55. <sendFilterContext>
  56. <xsl:value-of select="/root/*[local-name()='drillSpecs']/*/DRILL[(position()-1)=$sourceContextIdx]/@sendFilterContext"/>
  57. </sendFilterContext>
  58. </xts:append>
  59. <xts:replace select="/root/*[local-name()='drillTargets']/*[local-name()='drillTarget']">
  60. <drillTarget>
  61. <xsl:for-each select="/root/*[local-name()='drillSpecs']/*/DRILL[(position()-1)=$sourceContextIdx]/@*">
  62. <xsl:attribute name="{name()}">
  63. <xsl:value-of select="."/>
  64. </xsl:attribute>
  65. </xsl:for-each>
  66. <xsl:copy-of select="/root/*[local-name()='drillTargets']/*[local-name()='drillTarget']/*"/>
  67. </drillTarget>
  68. </xts:replace>
  69. </xsl:otherwise>
  70. </xsl:choose>
  71. </xts:sequence>
  72. </xsl:template>
  73. </xsl:stylesheet>
  74. </xts:block>
  75. <!--
  76. ===============================================================================================
  77. drill_from_pdf
  78. ===============================================================================================
  79. -->
  80. <xts:block id="drill_from_pdf" type="exec" mode="output" processor="XSLT" mimeType="text/html; charset=utf-8" dependency="drillSpecs">
  81. <xts:logicsheet path="logicsheets/portal.xsl"/>
  82. <xts:logicsheet path="rv/logicsheets/rvlogic.xsl"/>
  83. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  84. xmlns:rvl="http://developer.cognos.com/schemas/xts/logicsheets/xslt/presentation/rv/rvlogic/"
  85. xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt"
  86. xmlns:pf="http://developer.cognos.com/schemas/xts/pf">
  87. <xsl:output method="html" indent="no" encoding="UTF-8"/>
  88. <pf:variables/>
  89. <xsl:template match="/root">
  90. <html>
  91. <head>
  92. <meta name="Copyright" content="(C) Copyright IBM Corporation and its licensors 2001, 2011."/>
  93. <meta name="Trademark" content="IBM, the IBM logo, and Cognos are trademarks of IBM Corp., registered in many jurisdictions worldwide."/>
  94. <script language="javascript">
  95. <!--
  96. taken from CDrillThroughTarget.js
  97. Need to inline this script since if the user drills from a PDF file, a temp .htm file will
  98. get generated in the users temp directory, so trying to bring is a js file using the webRoot will not
  99. always work.
  100. -->
  101. function CDrillThroughTarget(label, outputFormat, outputLocale, showInNewWindow, method, path, bookmark, parameters, objectPaths, sPrompt, dynamicDrillThrough, parameterProperties)
  102. {
  103. this.m_label = label;
  104. this.m_outputFormat = outputFormat;
  105. this.m_outputLocale = outputLocale;
  106. this.m_showInNewWindow = showInNewWindow;
  107. this.m_method = method;
  108. this.m_path = path;
  109. this.m_bookmark = bookmark;
  110. this.m_parameters = parameters;
  111. this.m_objectPaths = objectPaths;
  112. this.m_prompt = "false";
  113. this.m_parameterProperties = parameterProperties;
  114. if (typeof sPrompt != 'undefined' &amp;&amp; sPrompt != null)
  115. {
  116. if (sPrompt == 'yes')
  117. {
  118. this.m_prompt = "true";
  119. }
  120. else if (sPrompt == 'target')
  121. {
  122. this.m_prompt = '';
  123. }
  124. }
  125. if(typeof dynamicDrillThrough != 'undefined' &amp;&amp; dynamicDrillThrough != null)
  126. {
  127. this.m_dynamicDrillThrough = dynamicDrillThrough;
  128. }
  129. }
  130. function CDrillThroughTarget_getParameterProperties()
  131. {
  132. return this.m_parameterProperties;
  133. }
  134. function CDrillThroughTarget_getLabel()
  135. {
  136. return this.m_label;
  137. }
  138. function CDrillThroughTarget_getOutputFormat()
  139. {
  140. return this.m_outputFormat;
  141. }
  142. function CDrillThroughTarget_getOutputLocale()
  143. {
  144. return this.m_outputLocale;
  145. }
  146. function CDrillThroughTarget_getShowInNewWindow()
  147. {
  148. return this.m_showInNewWindow;
  149. }
  150. function CDrillThroughTarget_getMethod()
  151. {
  152. return this.m_method;
  153. }
  154. function CDrillThroughTarget_getPath()
  155. {
  156. return this.m_path;
  157. }
  158. function CDrillThroughTarget_getBookmark()
  159. {
  160. return this.m_bookmark;
  161. }
  162. function CDrillThroughTarget_getParameters()
  163. {
  164. return this.m_parameters;
  165. }
  166. function CDrillThroughTarget_getObjectPaths()
  167. {
  168. return this.m_objectPaths;
  169. }
  170. function CDrillThroughTarget_getPrompt()
  171. {
  172. return this.m_prompt;
  173. }
  174. function CDrillThroughTarget_isDynamicDrillThrough()
  175. {
  176. return this.m_dynamicDrillThrough;
  177. }
  178. CDrillThroughTarget.prototype.getLabel = CDrillThroughTarget_getLabel;
  179. CDrillThroughTarget.prototype.getOutputFormat = CDrillThroughTarget_getOutputFormat;
  180. CDrillThroughTarget.prototype.getOutputLocale = CDrillThroughTarget_getOutputLocale;
  181. CDrillThroughTarget.prototype.getShowInNewWindow = CDrillThroughTarget_getShowInNewWindow;
  182. CDrillThroughTarget.prototype.getMethod = CDrillThroughTarget_getMethod;
  183. CDrillThroughTarget.prototype.getPath = CDrillThroughTarget_getPath;
  184. CDrillThroughTarget.prototype.getBookmark = CDrillThroughTarget_getBookmark;
  185. CDrillThroughTarget.prototype.getParameters = CDrillThroughTarget_getParameters;
  186. CDrillThroughTarget.prototype.getObjectPaths = CDrillThroughTarget_getObjectPaths;
  187. CDrillThroughTarget.prototype.getPrompt = CDrillThroughTarget_getPrompt;
  188. CDrillThroughTarget.prototype.isDynamicDrillThrough = CDrillThroughTarget_isDynamicDrillThrough;
  189. CDrillThroughTarget.prototype.getParameterProperties = CDrillThroughTarget_getParameterProperties;
  190. <!-- end of CDrillThroughTarget.js -->
  191. function getCvId()
  192. {
  193. var cvId = "";
  194. // temp function until RSVP passes in the cvid to this morphlet
  195. try
  196. {
  197. if(typeof parent.oCV_NS_ != "undefined")
  198. {
  199. cvId = "_NS_";
  200. }
  201. else if(typeof parent.oCV_THIS_ != "undefined")
  202. {
  203. cvId = "_THIS_";
  204. }
  205. else if(typeof parent.oCVRS != "undefined")
  206. {
  207. cvId = "RS";
  208. }
  209. else if (typeof this.frameElement != "undefined" &amp;&amp; this.frameElement != null)
  210. {
  211. if (typeof this.frameElement.id != "undefined" &amp;&amp; this.frameElement.id.indexOf("CVIFrame") == 0)
  212. {
  213. cvId = this.frameElement.id.substring(8);
  214. }
  215. }
  216. }
  217. catch(e)
  218. {
  219. cvId = "";
  220. }
  221. return cvId;
  222. }
  223. function pdfDrill()
  224. {
  225. <xsl:choose>
  226. <xsl:when test="count(drillTargets/*) &gt; 1">
  227. try
  228. {
  229. <xsl:variable name="drillTargets">
  230. <xsl:call-template name="serialize-xml">
  231. <xsl:with-param name="node-set" select="/root/*[local-name()='drillTargets']/*"/>
  232. </xsl:call-template>
  233. </xsl:variable>
  234. <xsl:text disable-output-escaping="yes">if (parent != this &amp;&amp; typeof parent.doMultipleDrills == "function") {</xsl:text>
  235. <xsl:text>parent.doMultipleDrills("&lt;rvDrillTargets&gt;</xsl:text>
  236. <xsl:value-of select="xtsext:javascriptencode(string($drillTargets))" disable-output-escaping="yes"/>
  237. <xsl:text>&lt;/rvDrillTargets&gt;", getCvId());</xsl:text>
  238. <xsl:text>}
  239. else {
  240. </xsl:text>
  241. <xsl:call-template name="genMultiDrill"/>
  242. <xsl:text>
  243. }</xsl:text>
  244. }
  245. catch (e)
  246. {
  247. <xsl:call-template name="genMultiDrill"/>
  248. }
  249. </xsl:when>
  250. <xsl:otherwise>
  251. try
  252. {
  253. <!-- Let parent handle drill if it can otherwise
  254. - process it localy by opening a new window -->
  255. <xsl:text disable-output-escaping="yes">if (parent != this &amp;&amp; typeof parent.doSingleDrill == "function") {
  256. parent.doSingleDrill(</xsl:text>
  257. <xsl:apply-templates select="drillTargets/drillTarget"/>
  258. <xsl:text>);</xsl:text>
  259. <xsl:if test="drillTargets/drillTarget/@outputFormat='XLS' or
  260. drillTargets/drillTarget/@outputFormat='CSV' or
  261. drillTargets/drillTarget/@outputFormat='XLWA' or
  262. drillTargets/drillTarget/@outputFormat='singleXLS' or
  263. drillTargets/drillTarget/@outputFormat='spreadsheetML' or
  264. drillTargets/drillTarget/@showInNewWindow = 'true'">
  265. <xsl:call-template name="returnToPDF"/>
  266. </xsl:if>
  267. <xsl:text disable-output-escaping="yes">} else if (parent != this &amp;&amp; parent.Application &amp;&amp; typeof parent.Application.LaunchDrillTargetFromPdf =="function") {
  268. //Handle drill-through in authoring perspective
  269. parent.Application.LaunchDrillTargetFromPdf(</xsl:text>
  270. <xsl:apply-templates select="drillTargets/drillTarget"/>
  271. <xsl:text>);} else { </xsl:text>
  272. <xsl:for-each select="drillTargets/drillTarget[position()=1]">
  273. <xsl:call-template name="genSingleDrill"/>
  274. </xsl:for-each>
  275. <xsl:text>
  276. }</xsl:text>
  277. }
  278. catch(e)
  279. {
  280. <xsl:for-each select="drillTargets/drillTarget[position()=1]">
  281. <xsl:call-template name="genSingleDrill"/>
  282. </xsl:for-each>
  283. }
  284. </xsl:otherwise>
  285. </xsl:choose>
  286. }
  287. </script>
  288. </head>
  289. <body onload="javascript:pdfDrill()">
  290. <xsl:variable name="formAction">
  291. <xsl:choose>
  292. <xsl:when test="string(/root/env/param[@name='gateway']) != ''">
  293. <xsl:value-of select="/root/env/param[@name='gateway']"/>
  294. </xsl:when>
  295. <xsl:otherwise>
  296. <xsl:value-of select="/root/env/param[@name='ui.gateway']"/>
  297. </xsl:otherwise>
  298. </xsl:choose>
  299. </xsl:variable>
  300. <xsl:choose>
  301. <xsl:when test="count(drillTargets/*) &gt; 1">
  302. <form name="multiDrillForm" id="multiDrillForm" method="post" action="{$formAction}" style="height:100%;margin:0px">
  303. <input type="hidden" name="b_action" value="xts.run"/>
  304. <input type="hidden" name="m" value="portal/drillthrough.xts"/>
  305. <input type="hidden" name="drillTargets"/>
  306. <input type="hidden" name="ui.errURL" value="javascript:window.close()"/>
  307. <input type="hidden" name="ui.backURL" value="javascript:window.close()"/>
  308. <input type="hidden" name="dfextpdf" value="1"/>
  309. <input type="hidden" name="invokeGotoPage" value="true"/>
  310. </form>
  311. </xsl:when>
  312. <xsl:otherwise>
  313. <xsl:variable name="sourceContext">
  314. <xsl:call-template name="serialize-xml">
  315. <xsl:with-param name="node-set" select="/root/*[local-name()='sourceContext']/*"/>
  316. </xsl:call-template>
  317. </xsl:variable>
  318. <xsl:variable name="objectPaths">
  319. <xsl:call-template name="serialize-xml">
  320. <xsl:with-param name="node-set" select="/root/*[local-name()='objectPaths']/*"/>
  321. </xsl:call-template>
  322. </xsl:variable>
  323. <xsl:variable name="sendFilterContext">
  324. <xsl:value-of select="/root/*[local-name()='sendFilterContext']"/>
  325. </xsl:variable>
  326. <form name="multiDrillForm" id="multiDrillForm" method="post" action="{$formAction}" style="height:100%;margin:0px">
  327. <input type="hidden" name="b_action" value="xts.run"/>
  328. <input type="hidden" name="m" value="portal/drillthrough.xts"/>
  329. <input type="hidden" name="ui.errURL" value="javascript:window.close()"/>
  330. <input type="hidden" name="ui.backURL" value="javascript:window.close()"/>
  331. <input type="hidden" name="ui.action" value=""/>
  332. <input type="hidden" name="ui.object" value=""/>
  333. <input type="hidden" name="run.outputFormat" value=""/>
  334. <input type="hidden" name="run.outputLocale" value=""/>
  335. <input type="hidden" name="run.prompt" value="false"/>
  336. <input type="hidden" name="sourceContext" value="{string($sourceContext)}"/>
  337. <input type="hidden" name="objectPaths" value="{string($objectPaths)}"/>
  338. <input type="hidden" name="dynamicDrill" value="{string($sendFilterContext)}"/>
  339. </form>
  340. </xsl:otherwise>
  341. </xsl:choose>
  342. </body>
  343. </html>
  344. </xsl:template>
  345. <xsl:template match="drillTarget">
  346. <!-- Generate parameters for doSingleDrill call -->
  347. <xsl:variable name="sourceContext">
  348. <xsl:call-template name="serialize-xml">
  349. <xsl:with-param name="node-set" select="/root/*[local-name()='sourceContext']/*"/>
  350. </xsl:call-template>
  351. </xsl:variable>
  352. <xsl:variable name="objectPaths">
  353. <xsl:call-template name="serialize-xml">
  354. <xsl:with-param name="node-set" select="/root/*[local-name()='objectPaths']/*"/>
  355. </xsl:call-template>
  356. </xsl:variable>
  357. <xsl:variable name="sendFilterContext">
  358. <xsl:value-of select="/root/*[local-name()='sendFilterContext']"/>
  359. </xsl:variable>
  360. <xsl:text>"</xsl:text>
  361. <xsl:if test="@showInNewWindow = 'true'">_blank</xsl:if>
  362. <xsl:text>",new Array( new Array( "ui.object", "</xsl:text><xsl:value-of select="xtsext:javascriptencode(string(@path))"/><xsl:text>")</xsl:text>
  363. <xsl:for-each select="drillParameter">
  364. <xsl:variable name="selectChoices">
  365. <rvl:selectChoices/>
  366. </xsl:variable>
  367. <xsl:text>, new Array("</xsl:text><xsl:value-of select="xtsext:javascriptencode(string(concat('p_', @name)))"/><xsl:text>", "</xsl:text><xsl:value-of select="xtsext:javascriptencode(string($selectChoices))"/><xsl:text>")</xsl:text>
  368. </xsl:for-each>
  369. <xsl:choose>
  370. <xsl:when test="@method = ''">
  371. <xsl:text>),"execute"</xsl:text>
  372. </xsl:when>
  373. <xsl:otherwise>
  374. <xsl:text>),"</xsl:text><xsl:value-of select="xtsext:javascriptencode(string(@method))"/><xsl:text>"</xsl:text>
  375. </xsl:otherwise>
  376. </xsl:choose>
  377. <xsl:text disable-output-escaping="yes">,"</xsl:text><xsl:value-of select="xtsext:javascriptencode(string(@outputFormat))"/><xsl:text disable-output-escaping="yes">"</xsl:text>
  378. <xsl:text disable-output-escaping="yes">,"</xsl:text><xsl:value-of select="xtsext:javascriptencode(string(@outputLocale))"/><xsl:text disable-output-escaping="yes">"</xsl:text>
  379. <!-- Do not urlencode bookmark since RSVP has already done it when the PDF is generated -->
  380. <xsl:text disable-output-escaping="yes">,"</xsl:text><xsl:value-of select="xtsext:javascriptencode(string(@bookmark))"/><xsl:text disable-output-escaping="yes">"</xsl:text>
  381. <xsl:text disable-output-escaping="yes">,"</xsl:text><xsl:value-of select="xtsext:javascriptencode(string($sourceContext))" disable-output-escaping="yes"/><xsl:text disable-output-escaping="yes">"</xsl:text>
  382. <xsl:text disable-output-escaping="yes">,"</xsl:text><xsl:value-of select="xtsext:javascriptencode(string($objectPaths))" disable-output-escaping="yes"/><xsl:text disable-output-escaping="yes">"</xsl:text>
  383. <xsl:text>,getCvId()</xsl:text>
  384. <xsl:variable name="promptOption">
  385. <xsl:choose>
  386. <xsl:when test="string(@prompt)='yes'">true</xsl:when>
  387. <xsl:when test="string(@prompt)='target'"></xsl:when>
  388. <xsl:otherwise>false</xsl:otherwise>
  389. </xsl:choose>
  390. </xsl:variable>
  391. <xsl:text disable-output-escaping="yes">,"</xsl:text><xsl:value-of select="xtsext:javascriptencode(string($promptOption))"/><xsl:text disable-output-escaping="yes">"</xsl:text>
  392. <xsl:text disable-output-escaping="yes">,"</xsl:text><xsl:value-of select="xtsext:javascriptencode(string(@sendFilterContext))"/><xsl:text disable-output-escaping="yes">"</xsl:text>
  393. </xsl:template>
  394. <xsl:template name="genSingleDrill">
  395. <!-- Generate code to perform drill in a new window and then
  396. do a 'back' to restore the PDF that this document replaced. -->
  397. var f = document.multiDrillForm;
  398. <xsl:choose>
  399. <xsl:when test="@method = 'view'">
  400. f[&quot;ui.action&quot;].value = &quot;view&quot;;
  401. f[&quot;ui.object&quot;].value = &quot;defaultOutput(<xsl:value-of select="xtsext:javascriptencode(string(@path))"/>,\&quot;<xsl:value-of select="xtsext:javascriptencode(string(@outputFormat))"/>\&quot;,\&quot;\&quot;)&quot;;
  402. </xsl:when>
  403. <xsl:otherwise>
  404. <!-- Do an execute -->
  405. f[&quot;ui.action&quot;].value = &quot;execute&quot;;
  406. <xsl:choose>
  407. <xsl:when test="/root/system/param[@name='pdfDrilBaltic']='true'">
  408. f[&quot;ui.object&quot;].value = &quot;<xsl:value-of select="xtsext:javascriptencode(xtsext:urldecode(string(@path)))"/>&quot;;
  409. </xsl:when>
  410. <xsl:otherwise>
  411. f[&quot;ui.object&quot;].value = &quot;<xsl:value-of select="xtsext:javascriptencode(string(@path))"/>&quot;;
  412. </xsl:otherwise>
  413. </xsl:choose>
  414. f[&quot;run.outputFormat&quot;].value = &quot;<xsl:value-of select="xtsext:javascriptencode(string(@outputFormat))"/>&quot;
  415. f[&quot;run.outputLocale&quot;].value = &quot;<xsl:value-of select="xtsext:javascriptencode(string(@outputLocale))"/>&quot;
  416. <xsl:if test="string(@prompt)='yes'">
  417. f[&quot;run.prompt&quot;].value = &quot;true&quot;;
  418. </xsl:if>
  419. var formField;
  420. <xsl:for-each select="drillParameter">
  421. <xsl:choose>
  422. <xsl:when test="./@value!=''">
  423. formField = document.createElement(&quot;input&quot;);
  424. formField.setAttribute(&quot;type&quot;, &quot;hidden&quot;);
  425. formField.setAttribute(&quot;name&quot;, &quot;<xsl:value-of select="xtsext:javascriptencode(string(concat('p_', @name)))"/>&quot;);
  426. <xsl:variable name="selectChoices">
  427. <rvl:selectChoices/>
  428. </xsl:variable>
  429. formField.setAttribute(&quot;value&quot;, &quot;<xsl:value-of select="xtsext:javascriptencode(string($selectChoices))"/>&quot;);
  430. f.appendChild(formField);
  431. </xsl:when>
  432. <xsl:otherwise>
  433. formField = document.createElement(&quot;input&quot;);
  434. formField.setAttribute(&quot;type&quot;, &quot;hidden&quot;);
  435. formField.setAttribute(&quot;name&quot;, &quot;<xsl:value-of select="xtsext:javascriptencode(string(concat('p_', @name)))"/>&quot;);
  436. <xsl:variable name="selectChoices">
  437. <rvl:selectChoicesNil/>
  438. </xsl:variable>
  439. formField.setAttribute(&quot;value&quot;, &quot;<xsl:value-of select="xtsext:javascriptencode(string($selectChoices))"/>&quot;);
  440. f.appendChild(formField);
  441. </xsl:otherwise>
  442. </xsl:choose>
  443. </xsl:for-each>
  444. </xsl:otherwise>
  445. </xsl:choose>
  446. <xsl:if test="@bookmark != ''">
  447. <!-- Do not urlencode bookmark since RSVP has already done it when the PDF is generated -->
  448. var bookMarkFormField = document.createElement(&quot;input&quot;);
  449. bookMarkFormField.setAttribute(&quot;type&quot;, &quot;hidden&quot;);
  450. bookMarkFormField.setAttribute(&quot;name&quot;, &quot;bookmark&quot;);
  451. bookMarkFormField.setAttribute(&quot;value&quot;, &quot;<xsl:value-of select="xtsext:javascriptencode(string(@bookmark))"/>&quot;);
  452. </xsl:if>
  453. <xsl:text>if (getCvId() != "") {</xsl:text>
  454. <xsl:call-template name="launchDrillTargetInNewWindow"/>
  455. <xsl:text>} else {f.submit();}</xsl:text>
  456. </xsl:template>
  457. <xsl:template name="genMultiDrill">
  458. <!-- Generate code to perform multiple drills in a new window and then
  459. do a 'back' to restore the PDF that this document replaced. -->
  460. <xsl:variable name="drillTargets">
  461. <xsl:call-template name="serialize-xml">
  462. <xsl:with-param name="node-set" select="/root/*[local-name()='drillTargets']/*"/>
  463. </xsl:call-template>
  464. </xsl:variable>
  465. <xsl:text>var f = document.multiDrillForm;</xsl:text>
  466. <xsl:text>f.drillTargets.value = "&lt;rvDrillTargets&gt;" + "</xsl:text><xsl:value-of select="xtsext:javascriptencode(string($drillTargets))" disable-output-escaping="yes"/><xsl:text>" + "&lt;/rvDrillTargets&gt;";</xsl:text>
  467. <xsl:text>if (getCvId() != "") {</xsl:text>
  468. <xsl:call-template name="launchDrillTargetInNewWindow"/>
  469. <xsl:text>} else {f.submit();}</xsl:text>
  470. </xsl:template>
  471. <xsl:template name="launchDrillTargetInNewWindow">
  472. <xsl:call-template name="launchClassicViewerPerspective"/>
  473. </xsl:template>
  474. <xsl:template name="launchClassicViewerPerspective">
  475. // window.location.href would look similar to the following
  476. // http://localhost/ibmcognos/bidev/v1/disp/repository/sid/cm/oid/id68a0f47a5a24cfd98a120bdba15882b/content
  477. // we want to get everything from the beginning of the string to /v1
  478. var sPath = window.location.href.substring(0,window.location.href.indexOf("/v1"));
  479. // sPath now equals
  480. // http://localhost/ibmcognos/bidev
  481. // tack on the classic viewer perspective
  482. sPath += "/?perspective=classicviewer";
  483. // we want to use the alternative drill path
  484. sPath += "&amp;altDrillFlag=true";
  485. // add the format (really for PDF so the perspective can react accordingly)
  486. sPath += "&amp;format=" + document.multiDrillForm["run.outputFormat"].value;
  487. // add search path so that we can get the rest of the CM info for the perspective
  488. sPath += "&amp;searchPath=" + document.multiDrillForm["ui.object"].value;
  489. // Give the form a unique name
  490. var v_sLabel = document.multiDrillForm.getAttribute("name") + Date.now().toString();
  491. document.multiDrillForm.setAttribute("name", v_sLabel);
  492. // store the form (in string form) into the browser storage
  493. if (typeof(Storage) !== "undefined") {
  494. localStorage.setItem(v_sLabel, document.multiDrillForm.outerHTML);
  495. // put this unique identifer into the parameters to pass
  496. sPath += "&amp;drillFormLabel=" + v_sLabel;
  497. }
  498. else
  499. {
  500. console.log("Sorry! No Web Storage support...");
  501. }
  502. var parentWindow = window.parent ? window.parent : window;
  503. var __goto_win = parentWindow.open(sPath, "_blank");
  504. </xsl:template>
  505. <xsl:template name="returnToPDF">
  506. // Only do this for legacy portal. Otherwise, let the viewer content view do the restore.
  507. if (parent == this || typeof parent.f_restorePDF != "function") {
  508. var historyStackIdx = 0;
  509. var oCV = null;
  510. try
  511. {
  512. oCV = eval("parent.oCV" + getCvId());
  513. }
  514. catch(exception)
  515. {
  516. oCV = null;
  517. }
  518. if(oCV != null &amp;&amp; typeof oCV.rvMainWnd != &quot;undefined&quot; &amp;&amp; typeof oCV.m_viewerFragment == "undefined")
  519. {
  520. historyStackIdx -= (parent.history.length - oCV.rvMainWnd.m_browserHistoryIndex);
  521. }
  522. else
  523. {
  524. historyStackIdx -= 1;
  525. }
  526. setTimeout('history.go(' + historyStackIdx + ')',1);
  527. }
  528. </xsl:template>
  529. <pf:serialize-xml/>
  530. </xsl:stylesheet>
  531. </xts:block>
  532. <!-- Debug -->
  533. <!-- ============================================================================= -->
  534. <xts:block id="debug" dependency="drill_from_pdf" condition=".[ /root/session/param[@name='debug'] = '1' or /root/env/param[@name='ui.debug'] = 'true' ]"
  535. type="exec" mode="output" processor="XSLT" mandatory="false" mimeType="text/html">
  536. <xts:logicsheet path="logicsheets/debuglogic.xslt"/>
  537. <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/" exclude-result-prefixes="xsl dbg">
  538. <xsl:output method="html" version="1.0" encoding="UTF-8" indent="no"/>
  539. <dbg:templates/>
  540. <xsl:template match="/">
  541. <dbg:dumpxml select="/root"/>
  542. </xsl:template>
  543. </xsl:stylesheet>
  544. </xts:block>
  545. </xts:morphlet>