condition-ui-templates.xslt 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. Licensed Materials - Property of IBM
  4. IBM Cognos Products: AGS
  5. (C) Copyright IBM Corp. 2005, 2017
  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:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xts="http://developer.cognos.com/schemas/xts/" xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt" xmlns:utml="http://developer.cognos.com/schemas/xts/logicsheet/xslt/formlogic/" xmlns:lyt="http://developer.cognos.com/schemas/xts/logicsheets/xslt/presentation/layout/" xmlns:dp="http://developer.cognos.com/schemas/xts/logicsheets/xslt/presentation/dialog/presentation/" xmlns:df="http://developer.cognos.com/schemas/xts/logicsheets/xslt/presentation/dialog/framework/" xmlns:agsdlg="http://developer.cognos.com/schemas/xts/logicsheets/xslt/ags/dialog/" xmlns:out="dummy-uri" xmlns:ags="http://developer.cognos.com/schemas/xts/logicsheets/xslt/ags/condition/" xmlns:agscnd="http://developer.cognos.com/schemas/xts/logicsheets/xslt/ags/condition/" xmlns:cp="http://developer.cognos.com/schemas/xts/logicsheets/xslt/presentation/controls/presentation/" xmlns:doc="http://developer.cognos.com/schemas/xts/logicsheets/xslt/ags/doc/" exclude-result-prefixes="doc">
  9. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  10. <xsl:namespace-alias stylesheet-prefix="out" result-prefix="xsl"/>
  11. <doc:group prefix="agscnd">
  12. <doc:location>
  13. <doc:namespace>xmlns:agscnd="http://developer.cognos.com/schemas/xts/logicsheets/xslt/ags/condition/"</doc:namespace>
  14. <doc:ref>ps/ags/logicsheets/condition-ui-templates.xslt</doc:ref>
  15. </doc:location>
  16. </doc:group>
  17. <!-- render the condition UI-->
  18. <doc:template type="ui">
  19. <doc:name>dataItemUI</doc:name>
  20. <doc:desc>This renders the user interface for the specify agent condition dialog</doc:desc>
  21. <doc:attr>
  22. <doc:attr-name>tab-exclusion</doc:attr-name>
  23. <doc:attr-desc>A space separated list of tab ids that should not be rendered. If the list is empty all tabs are rendered.</doc:attr-desc>
  24. </doc:attr>
  25. <doc:notes>This ui component is used by the new agent wizard and the define condition dialog. The tab information is defined in <i>/ps/ags/logicsheets/infoTabData.xsl</i>
  26. </doc:notes>
  27. </doc:template>
  28. <xsl:template match="agscnd:dataItemUI">
  29. <lyt:section>
  30. <out:call-template name="agscnd:script">
  31. <out:with-param name="isDataItem" select="true"/>
  32. </out:call-template>
  33. <out:call-template name="agscnd:expressionBaseUI">
  34. <out:with-param name="textareaId">
  35. <xsl:value-of select="./agscnd:param[@name='textareaId']"/>
  36. </out:with-param>
  37. </out:call-template>
  38. </lyt:section>
  39. <lyt:section>
  40. <out:call-template name="buildInfoSection">
  41. <out:with-param name="errorDivName">
  42. <xsl:value-of select="./agscnd:param[@name='errorDiv']"/>
  43. </out:with-param>
  44. <out:with-param name="infoDivName">
  45. <xsl:value-of select="./agscnd:param[@name='infoDiv']"/>
  46. </out:with-param>
  47. </out:call-template>
  48. </lyt:section>
  49. </xsl:template>
  50. <xsl:template match="agscnd:conditionUI">
  51. <lyt:section>
  52. <out:call-template name="agscnd:script"/>
  53. <out:call-template name="buildConditionTab">
  54. <out:with-param name="buttons">
  55. <xsl:text>Validate Calc Param Select</xsl:text>
  56. </out:with-param>
  57. </out:call-template>
  58. </lyt:section>
  59. <lyt:section>
  60. <out:call-template name="buildInfoSection">
  61. <out:with-param name="errorDivName">
  62. <xsl:value-of select="./agscnd:param[@name='errorDiv']"/>
  63. </out:with-param>
  64. <out:with-param name="infoDivName">
  65. <xsl:value-of select="./agscnd:param[@name='infoDiv']"/>
  66. </out:with-param>
  67. </out:call-template>
  68. </lyt:section>
  69. </xsl:template>
  70. <xsl:template match="agscnd:script">
  71. <out:template name="agscnd:script">
  72. <out:param name="isDataItem" select="false"/>
  73. <!-- create the selected tab variables -->
  74. <out:if test="not($isDataItem)">
  75. <utml:input type="hidden" name="rp_selected_tab" id="rp_selected_tab"/>
  76. </out:if>
  77. <script type="text/javascript">
  78. var cf = parent.getConfigFrame();
  79. function setTabVisible(id,isVisible)
  80. {
  81. if (null != document.getElementById('div_tab_'+id)) {
  82. if (isVisible) {
  83. if (document.documentMode &lt; 10) {
  84. document.getElementById('div_tab_'+id).style.display="block";
  85. } else {
  86. document.getElementById('div_tab_'+id).style.display="table";
  87. }
  88. }
  89. else {
  90. document.getElementById('div_tab_'+id).style.display="none";
  91. }
  92. }
  93. }
  94. <out:if test="not($isDataItem)">
  95. function doConditionTabChange(id)
  96. {
  97. // hide all panes - not the tabs
  98. <out:for-each select="/root/tabset/pane">
  99. setTabVisible('<out:value-of select="@id"/>',false);
  100. </out:for-each>
  101. // set the selected tab pane visible
  102. setTabVisible(id,true);
  103. // set the tab that we want to display - should we move off this page
  104. document.pform.rp_selected_tab.value = id;
  105. }
  106. function popupSelectValueDialog(target) {
  107. var cf = parent.getConfigFrame();
  108. if (!cf.checkCAF()) {
  109. parent.selectValue(target,window.name);
  110. }
  111. }
  112. </out:if>
  113. </script>
  114. </out:template>
  115. </xsl:template>
  116. <xsl:template match="agscnd:expressionBaseUI">
  117. <out:template name="agscnd:expressionBaseUI">
  118. <out:param name="textareaId"/>
  119. <dp:list width="100%" padding="0">
  120. <out:if test="not(contains($textareaId, 'dataItem'))">
  121. <dp:section>
  122. <img height="5" width="1">
  123. <xsl:attribute name="src"><xsl:value-of select="'{$webcontent}'"/>/images/space.gif</xsl:attribute>
  124. </img>
  125. </dp:section>
  126. <dp:section width="100%">
  127. <dp:hint wrap="true">
  128. <out:choose>
  129. <out:when test="contains($textareaId, 'detail')">
  130. <out:text>
  131. <xts:string id="AGENT_CONDITION_DETAIL_INTRO"/>
  132. </out:text>
  133. </out:when>
  134. <out:otherwise>
  135. <out:text>
  136. <xts:string id="AGENT_CONDITION_SUMMARY_INTRO"/>
  137. </out:text>
  138. </out:otherwise>
  139. </out:choose>
  140. </dp:hint>
  141. </dp:section>
  142. <dp:section>
  143. <img height="10" width="1">
  144. <xsl:attribute name="src"><xsl:value-of select="'{$webcontent}'"/>/images/space.gif</xsl:attribute>
  145. </img>
  146. </dp:section>
  147. </out:if>
  148. <dp:section width="100%">
  149. <dp:box width="100%" noSpace="true">
  150. <dp:boxSection type="label" valign="bottom" align="left">
  151. <xts:string id="DIALOG_DATAITEM_EXPRESSION"/>
  152. </dp:boxSection>
  153. <out:if test="contains($textareaId, 'dataItem')">
  154. <dp:boxSection width="100%">
  155. <out:call-template name="buildButtons">
  156. <out:with-param name="buttons">
  157. <xsl:text>Validate Select</xsl:text>
  158. </out:with-param>
  159. <out:with-param name="selectValuesTarget">
  160. <out:value-of select="$textareaId"/>
  161. </out:with-param>
  162. </out:call-template>
  163. </dp:boxSection>
  164. </out:if>
  165. </dp:box>
  166. </dp:section>
  167. <dp:section width="100%">
  168. <agsdlg:insertButton selectValue="true" targetId="{'{$textareaId}'}">
  169. <textarea rows="16" cols="80" style="padding: 0px; width:99%;" name="{'{$textareaId}'}" id="{'{$textareaId}'}">
  170. <!-- Add usage information of textarea when focusing on it by keyboard, so that JAWS can read it out. -->
  171. <out:attribute name="title">
  172. <text><xts:string id="AGENT_CONDITION_TIP"/></text>
  173. </out:attribute>
  174. <out:value-of select="/root/env/param[@name=$textareaId]"/>
  175. </textarea>
  176. </agsdlg:insertButton>
  177. </dp:section>
  178. </dp:list>
  179. </out:template>
  180. </xsl:template>
  181. <xsl:template match="agscnd:buildInfoSection">
  182. <out:template name="buildInfoSection">
  183. <out:param name="errorDivName"/>
  184. <out:param name="infoDivName"/>
  185. <dp:list width="100%" title="AGENT_INFORMATION_LABEL" padding="0">
  186. <dp:section>
  187. <out:call-template name="buildInfoTab">
  188. <out:with-param name="errorDivName" select="$errorDivName"/>
  189. <out:with-param name="infoDivName" select="$infoDivName"/>
  190. </out:call-template>
  191. </dp:section>
  192. </dp:list>
  193. </out:template>
  194. </xsl:template>
  195. <xsl:template match="agscnd:buildButtons">
  196. <out:template name="buildButtons">
  197. <out:param name="buttons"/>
  198. <out:param name="selectValuesTarget"/>
  199. <table border="0" cellspacing="0" cellpadding="0" valign="top" align="right" role="presentation">
  200. <tr width="100%">
  201. <td nowrap="nowrap" align="right">
  202. <img height="16" src="../ags/images/spacer.gif" alt=""/>
  203. </td>
  204. <out:if test="contains($buttons, 'Validate')">
  205. <dp:columnButton>
  206. <img align="middle" height="16" width="16" role="button" onclick="validateSpec();">
  207. <out:attribute name="src">../ags/images/toolbar/16x16/action_validate.gif</out:attribute>
  208. <out:attribute name="alt">
  209. <xts:string id="DIALOG_VALIDATE_BUTTON"/>
  210. </out:attribute>
  211. <out:attribute name="id">
  212. <!-- put the xts string in a variable-->
  213. <out:variable name ="id_string">
  214. <xts:string id="DIALOG_VALIDATE_BUTTON"/>
  215. </out:variable>
  216. <!-- Add this part for ID unique A11Y issue -->
  217. <out:variable name="tab_id">
  218. <out:value-of select="./tabs/tab[@default = 'true']/@id"/>
  219. </out:variable>
  220. <out:value-of select="concat('id_', $tab_id, '_', $id_string)"/>
  221. </out:attribute>
  222. </img>
  223. </dp:columnButton>
  224. <td nowrap="nowrap" align="right">
  225. <img height="16" width="10" src="../ags/images/spacer.gif" alt=""/>
  226. </td>
  227. </out:if>
  228. <out:if test="contains($buttons, 'Calc')">
  229. <dp:columnButton>
  230. <img align="middle" height="16" width="16" role="button" onclick="window.parent.getConfigFrame().getCommandStackManager().initiateCommandStack(&quot;checkCAF()&quot;,&quot;showDataItem('add')&quot;);">
  231. <out:attribute name="src">../ags/images/toolbar/16x16/action_new_calculation.gif</out:attribute>
  232. <out:attribute name="alt">
  233. <xts:string id="DIALOG_CALCULATION_CREATE_NEW_CALCULATION"/>
  234. </out:attribute>
  235. <out:attribute name="id">
  236. <!-- put the xts string in a variable-->
  237. <out:variable name ="id_string">
  238. <xts:string id="DIALOG_CALCULATION_CREATE_NEW_CALCULATION"/>
  239. </out:variable>
  240. <!-- Add this part for ID unique A11Y issue -->
  241. <out:variable name="tab_id">
  242. <out:value-of select="./tabs/tab[@default = 'true']/@id"/>
  243. </out:variable>
  244. <out:value-of select="concat('id_', $tab_id, '_', $id_string)"/>
  245. </out:attribute>
  246. </img>
  247. </dp:columnButton>
  248. <td nowrap="nowrap" align="right">
  249. <img height="16" width="3" src="../ags/images/spacer.gif" alt=""/>
  250. </td>
  251. </out:if>
  252. <out:if test="contains($buttons, 'Param')">
  253. <dp:columnButton>
  254. <img align="middle" height="16" width="16" role="button" onclick="window.parent.getConfigFrame().getCommandStackManager().initiateCommandStack(&quot;checkCAF()&quot;,&quot;showParameters('add')&quot;);">
  255. <out:attribute name="src">../ags/images/toolbar/16x16/action_new_parameter.gif</out:attribute>
  256. <out:attribute name="alt">
  257. <xts:string id="DIALOG_PARAMETER_CREATE_NEW_PARAMETER"/>
  258. </out:attribute>
  259. <out:attribute name="id">
  260. <!-- put the xts string in a variable-->
  261. <out:variable name ="id_string">
  262. <xts:string id="DIALOG_PARAMETER_CREATE_NEW_PARAMETER"/>
  263. </out:variable>
  264. <!-- Add this part for ID unique A11Y issue -->
  265. <out:variable name="tab_id">
  266. <out:value-of select="./tabs/tab[@default = 'true']/@id"/>
  267. </out:variable>
  268. <out:value-of select="concat('id_', $tab_id, '_', $id_string)"/>
  269. </out:attribute>
  270. </img>
  271. </dp:columnButton>
  272. <td nowrap="nowrap" align="right">
  273. <img height="16" width="3" src="../ags/images/spacer.gif" alt=""/>
  274. </td>
  275. </out:if>
  276. <out:if test="contains($buttons, 'Select')">
  277. <dp:columnButton>
  278. <img align="middle" height="16" width="16" role="button">
  279. <!-- set the attributes not in the stylesheet pass but in the final XSL pass - have to be out: attributes instead -->
  280. <out:attribute name="onclick">popupSelectValueDialog('<out:value-of select="$selectValuesTarget"/>');</out:attribute>
  281. <out:attribute name="src">../ags/images/select_values.gif</out:attribute>
  282. <out:attribute name="alt">
  283. <xts:string id="TREEBAR_SELECT_VALUES"/>
  284. </out:attribute>
  285. <out:attribute name="id">
  286. <!-- put the xts string in a variable-->
  287. <out:variable name ="id_string">
  288. <xts:string id="TREEBAR_SELECT_VALUES"/>
  289. </out:variable>
  290. <!-- Add this part for ID unique A11Y issue -->
  291. <out:variable name="tab_id">
  292. <out:value-of select="./tabs/tab[@default = 'true']/@id"/>
  293. </out:variable>
  294. <out:value-of select="concat('id_', $tab_id, '_', $id_string)"/>
  295. </out:attribute>
  296. </img>
  297. </dp:columnButton>
  298. </out:if>
  299. </tr>
  300. </table>
  301. </out:template>
  302. </xsl:template>
  303. <xsl:template match="ags:buildConditionTab">
  304. <out:template name="buildConditionTab">
  305. <out:param name="buttons"/>
  306. <out:apply-templates select="/root/tabset/pane">
  307. <out:with-param name="buttons" select="$buttons"/>
  308. </out:apply-templates>
  309. </out:template>
  310. <out:template match="pane">
  311. <out:param name="buttons"/>
  312. <table cellpadding="0" cellspacing="0" height="100%" role="presentation">
  313. <out:attribute name="style">overflow:auto;width:100%;display:none</out:attribute>
  314. <out:attribute name="id">div_tab_<out:value-of select="@id"/>
  315. </out:attribute>
  316. <out:attribute name="role">presentation</out:attribute>
  317. <tr>
  318. <td valign="bottom" style="display:block;">
  319. <cp:tabset tabwidth="70">
  320. <cp:select>
  321. <out:value-of select="./tabs/tab[@default = 'true']/@id"/>
  322. </cp:select>
  323. <!-- loop through the tabs, exclude any defined in the eclusion list -->
  324. <out:for-each select="./tabs/tab">
  325. <out:choose>
  326. <!-- first tab found (and more tabs are available)-->
  327. <out:when test="position() = 1 and position() != last()">
  328. <cp:tab name="@id" position="start" var-name="true">
  329. <a href="#" onclick="{'doConditionTabChange(&quot;{@id}&quot;);'}" onmouseover="status=''; return true;">
  330. <cp:label>
  331. <out:value-of select="."/>
  332. </cp:label>
  333. </a>
  334. </cp:tab>
  335. </out:when>
  336. <!-- last tab found (or the only tab that has been defined) -->
  337. <out:when test="position() = last()">
  338. <cp:tab name="@id" position="end" var-name="true">
  339. <a href="#" onclick="{'doConditionTabChange(&quot;{@id}&quot;);'}" onmouseover="status=''; return true;">
  340. <cp:label>
  341. <out:value-of select="."/>
  342. </cp:label>
  343. </a>
  344. </cp:tab>
  345. </out:when>
  346. <!-- middle tabs-->
  347. <out:otherwise>
  348. <cp:tab name="@id" var-name="true">
  349. <a href="#" onclick="{'doConditionTabChange(&quot;{@id}&quot;);'}" onmouseover="status=''; return true;">
  350. <cp:label>
  351. <out:value-of select="."/>
  352. </cp:label>
  353. </a>
  354. </cp:tab>
  355. </out:otherwise>
  356. </out:choose>
  357. </out:for-each>
  358. </cp:tabset>
  359. </td>
  360. <out:if test="string-length($buttons) > 0">
  361. <td nowrap="nowarp">
  362. <table border="0" cellspacing="0" cellpadding="0" width="100%" role="presentation">
  363. <tr>
  364. <td class="tabBorder" height="20px" valign="top">
  365. <out:call-template name="buildButtons">
  366. <out:with-param name="buttons">
  367. <out:value-of select="$buttons"/>
  368. </out:with-param>
  369. <out:with-param name="selectValuesTarget">
  370. <out:value-of select="./content/@id"/>
  371. </out:with-param>
  372. </out:call-template>
  373. </td>
  374. </tr>
  375. </table>
  376. </td>
  377. </out:if>
  378. </tr>
  379. <tr>
  380. <td colspan="2" width="100%" height="100%" valign="top" style="white-space: pre-wrap;">
  381. <out:call-template name="agscnd:expressionBaseUI">
  382. <out:with-param name="textareaId">
  383. <out:value-of select="./content/@id"/>
  384. </out:with-param>
  385. </out:call-template>
  386. </td>
  387. </tr>
  388. </table>
  389. </out:template>
  390. </xsl:template>
  391. <!--
  392. This tab is consists of two panes Tips and error. It is coded to display Tips pane by default.
  393. -->
  394. <xsl:template match="ags:buildInfoTab">
  395. <out:template name="buildInfoTab">
  396. <out:param name="errorDivName"/>
  397. <out:param name="infoDivName"/>
  398. <out:call-template name="pane">
  399. <out:with-param name="errorDivName" select="$errorDivName"/>
  400. <out:with-param name="infoDivName" select="$infoDivName"/>
  401. <out:with-param name="tab" select="$infoDivName"/>
  402. </out:call-template>
  403. <out:call-template name="pane">
  404. <out:with-param name="errorDivName" select="$errorDivName"/>
  405. <out:with-param name="infoDivName" select="$infoDivName"/>
  406. <out:with-param name="tab" select="$errorDivName"/>
  407. <out:with-param name="display" select="'none'"/>
  408. </out:call-template>
  409. </out:template>
  410. <out:template name="pane">
  411. <out:param name="errorDivName"/>
  412. <out:param name="infoDivName"/>
  413. <out:param name="tab"/>
  414. <out:param name="display"/>
  415. <table cellpadding="0" cellspacing="0" height="100%">
  416. <out:attribute name="style">overflow:auto;width:100%;display:<out:value-of select="$display"/>
  417. </out:attribute>
  418. <out:attribute name="id">div_tab_<out:value-of select="$tab"/>
  419. </out:attribute>
  420. <out:attribute name="role">presentation</out:attribute>
  421. <tr>
  422. <td width="100%" height="100%" valign="top">
  423. <div class="infoErrorTab" width="100%">
  424. <out:choose>
  425. <out:when test="$tab = $infoDivName">
  426. <div class="infoErrorTabTextBold" style="margin:0px;" name="infoItemSyntax" id="infoItemSyntax"/>
  427. <div class="infoErrorTabText" style="margin:0px;" name="infoItemTip" id="infoItemTip"/>
  428. </out:when>
  429. <out:otherwise>
  430. <div class="infoErrorTabText" style="margin:0px;" name="{'{$errorDivName}'}" id="{'{$errorDivName}'}"/>
  431. </out:otherwise>
  432. </out:choose>
  433. </div>
  434. </td>
  435. </tr>
  436. <tr>
  437. <td valign="bottom">
  438. <cp:tabset inverted="true" tabwidth="70">
  439. <cp:select><out:value-of select="$tab"/></cp:select>
  440. <cp:tab position="start" var-name="true" name="$infoDivName">
  441. <a href="#" onclick="doInfoTabChange('{'{$infoDivName}'}')" onmouseover="status=''; return true;">
  442. <cp:label>
  443. <xts:string id="AGENT_CONDITION_TIPS_TAB"/>
  444. </cp:label>
  445. </a>
  446. </cp:tab>
  447. <cp:tab position="end" var-name="true" name="$errorDivName">
  448. <a href="#" onclick="doInfoTabChange('{'{$errorDivName}'}')" onmouseover="status=''; return true;">
  449. <cp:label>
  450. <xts:string id="AGENT_CONDITION_ERRORS_TAB"/>
  451. </cp:label>
  452. </a>
  453. </cp:tab>
  454. </cp:tabset>
  455. </td>
  456. </tr>
  457. </table>
  458. <script type="text/javascript">
  459. function doInfoTabChange(id)
  460. {
  461. setTabVisible('<out:value-of select="$infoDivName"/>',false);
  462. setTabVisible('<out:value-of select="$errorDivName"/>',false);
  463. if(id == 'infoItemSyntax' || id == 'infoItemTip'){
  464. // set the selected tab pane visible
  465. id = '<out:value-of select="$infoDivName"/>';
  466. }
  467. setTabVisible(id,true);
  468. }
  469. </script>
  470. </out:template>
  471. </xsl:template>
  472. <xsl:template match="agscnd:conditionFormat">
  473. <!-- This takes the report spec v2.0 and the filter string and extracts the text form of the condition -->
  474. <!-- takes a node set of these
  475. <dataitem preamble="sdfsdfsdf"><dimension name="thingy"/><dimension name="thingy2"/></dataitem>
  476. and produces the asdklalsdkj ![name]!
  477. -->
  478. <out:template name="convertCondition">
  479. <out:param name="data-items"/>
  480. <out:for-each select="$data-items/dataitem">
  481. <out:value-of select="./@preamble"/>
  482. <out:if test="count(./dimension) > 0">
  483. <out:text>![</out:text>
  484. <out:value-of select="dimension[last() - 1]/@name"/>
  485. <out:text>.</out:text>
  486. <out:value-of select="dimension[last()]/@name"/>
  487. <out:text>]!</out:text>
  488. </out:if>
  489. </out:for-each>
  490. </out:template>
  491. <!-- takes a node set of these
  492. <dataitem preamble="sdfsdfsdf"><dimension name="thingy"/><dimension name="thingy2"/></dataitem>
  493. and produces the asdklalsdkj ![name]!
  494. -->
  495. <out:template name="convertConditonToText">
  496. <out:param name="report"/>
  497. <out:param name="filter"/>
  498. <out:variable name="data-items">
  499. <out:call-template name="getDataItems">
  500. <out:with-param name="report" select="$report"/>
  501. <out:with-param name="filter" select="$filter"/>
  502. </out:call-template>
  503. </out:variable>
  504. <out:for-each select="$data-items/dataitem">
  505. <out:value-of select="./@preamble"/>
  506. <out:if test="count(./dimension) > 0">
  507. <out:value-of select="dimension[last()]/@name"/>
  508. </out:if>
  509. </out:for-each>
  510. </out:template>
  511. <!-- This takes a portal style condition [sdfsd].[sfsdfsdf].[final]
  512. and gives you back "final"
  513. -->
  514. <out:template name="conditionFormatPortal">
  515. <out:param name="condition"/>
  516. <out:variable name="dimensions">
  517. <out:call-template name="extractDimensions">
  518. <out:with-param name="dataexpressionitems">
  519. <out:value-of select="$condition"/>
  520. </out:with-param>
  521. </out:call-template>
  522. </out:variable>
  523. <out:for-each select="$dimensions/dimension">
  524. <out:if test="position() = last()">
  525. <out:value-of select="@name"/>
  526. </out:if>
  527. </out:for-each>
  528. </out:template>
  529. <!-- converts "blah [dataitemname] blah [Orders.Order month] blah " to the form of a node set
  530. <dataitem preamble="blah "><dimension name="dataexpression"/><dimension name="dataexpression"/></dataitem>
  531. -->
  532. <out:template name="getDataItems">
  533. <out:param name="report"/>
  534. <out:param name="filter"/>
  535. <out:choose>
  536. <out:when test="$filter and contains($filter, '[')">
  537. <out:variable name="data_item_name" select="substring-before(substring-after($filter, '['), ']')"/>
  538. <out:element name="dataitem">
  539. <out:attribute name="preamble">
  540. <out:value-of select="substring-before($filter, '[')"/>
  541. </out:attribute>
  542. <out:attribute name="name">
  543. <out:value-of select="$data_item_name"/>
  544. </out:attribute>
  545. <out:call-template name="extractDimensions">
  546. <out:with-param name="dataexpressionitems" select="$report/*[local-name()='queries']/*[local-name()='query']/*[local-name()='selection']/*[local-name()='dataItem'][@name=$data_item_name]/*[local-name()='expression']"/>
  547. </out:call-template>
  548. </out:element>
  549. <out:call-template name="getDataItems">
  550. <out:with-param name="filter" select="substring-after($filter, ']')"/>
  551. <out:with-param name="report" select="$report"/>
  552. </out:call-template>
  553. </out:when>
  554. <out:otherwise>
  555. <out:element name="dataitem">
  556. <out:attribute name="preamble">
  557. <out:value-of select="$filter"/>
  558. </out:attribute>
  559. <out:attribute name="value"/>
  560. </out:element>
  561. </out:otherwise>
  562. </out:choose>
  563. </out:template>
  564. <!--takes [ds1].[ds1].[query].[table].[column] and makes a node set of <dimension name="ds1"/> etc-->
  565. <out:template name="extractDimensions">
  566. <out:param name="dataexpressionitems"/>
  567. <out:choose>
  568. <out:when test="$dataexpressionitems and contains($dataexpressionitems, ']')">
  569. <out:variable name="dim_name" select="substring-before(substring-after($dataexpressionitems, '['), ']')"/>
  570. <out:element name="dimension">
  571. <out:attribute name="name">
  572. <out:value-of select="$dim_name"/>
  573. </out:attribute>
  574. </out:element>
  575. <out:call-template name="extractDimensions">
  576. <out:with-param name="dataexpressionitems" select="substring-after($dataexpressionitems, '].')"/>
  577. </out:call-template>
  578. </out:when>
  579. </out:choose>
  580. </out:template>
  581. </xsl:template>
  582. <xsl:template match="agscnd:conditionParameters">
  583. <!-- takes the filter from the report and extracts the parameters from it -->
  584. <out:template name="conditionParameters">
  585. <out:param name="filter"/>
  586. <out:if test="$filter and contains($filter , '?')">
  587. <out:variable name="starts_with_param" select="substring-after($filter, '?')"/>
  588. <out:if test="$starts_with_param and contains($starts_with_param , '?')">
  589. <!-- we must have a matching ? -->
  590. <out:element name="item">
  591. <out:element name="name">
  592. <out:value-of select="substring-before($starts_with_param, '?')"/>
  593. </out:element>
  594. </out:element>
  595. <!-- do the recursive call with the remainder -->
  596. <out:call-template name="conditionParameters">
  597. <out:with-param name="filter" select="substring-after($starts_with_param, '?')"/>
  598. </out:call-template>
  599. </out:if>
  600. </out:if>
  601. </out:template>
  602. </xsl:template>
  603. <!-- copy all other elements and attributes into the result-->
  604. <xsl:template match="*">
  605. <xsl:copy>
  606. <xsl:copy-of select="@*"/>
  607. <xsl:apply-templates/>
  608. </xsl:copy>
  609. </xsl:template>
  610. </xsl:stylesheet>