search.xts 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. Licensed Materials - Property of IBM
  4. IBM Cognos Products: cpscrn
  5. (C) Copyright IBM Corp. 2005, 2011
  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. <xts:morphlet version="1.0" xmlns:xts="http://developer.cognos.com/schemas/xts/">
  13. <xts:block id="build-search-request"
  14. condition=".[not(/root/env/param[@name='frag-directive']='meta-only')]"
  15. type="exec" mode="interpret" processor="XSLT">
  16. <xsl:stylesheet version="1.0"
  17. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  18. xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt"
  19. xmlns:xts="http://developer.cognos.com/schemas/xts/"
  20. xmlns:xos="http://developer.cognos.com/schemas/xts/output/"
  21. xmlns:bus="http://developer.cognos.com/schemas/bibus/3/"
  22. xmlns:nav="http://developer.cognos.com/schemas/cps/navigation/1/"
  23. xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
  24. exclude-result-prefixes="xts xos bus nav SOAP-ENV">
  25. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  26. <xsl:include href="/fragments/mvc/includes/common-include.xslt"/>
  27. <xsl:template match="/">
  28. <xts:sequence>
  29. <xts:append select="/root">
  30. <xsl:variable name="path">
  31. <xsl:variable name="mvc-sfolder" select="string($params[@name='mvc-sfolder'])"/>
  32. <xsl:choose>
  33. <xsl:when test="$mvc-sfolder != ''">
  34. <xsl:choose>
  35. <xsl:when test="starts-with($mvc-sfolder, '_')">
  36. <xsl:text/>storeID('<xsl:value-of select="substring-after($mvc-sfolder, '_')"/>')<xsl:text/>
  37. </xsl:when>
  38. <xsl:otherwise>
  39. <xsl:value-of select="$mvc-sfolder"/>
  40. </xsl:otherwise>
  41. </xsl:choose>
  42. </xsl:when>
  43. <xsl:otherwise>
  44. <xsl:text/>systemDefault<xsl:text/>
  45. </xsl:otherwise>
  46. </xsl:choose>
  47. </xsl:variable>
  48. <nav-search-query>
  49. <xsl:if test="string($params[@name='stext']) != ''">
  50. <nav:string><xsl:value-of select="$params[@name='stext']"/></nav:string>
  51. </xsl:if>
  52. <nav:searchType>normal</nav:searchType>
  53. <!-- scope -->
  54. <xsl:variable name="sscope" select="$params[@name='sscope']"/>
  55. <nav:scope>
  56. <xsl:choose>
  57. <xsl:when test="$sscope = 'p'">
  58. <xsl:value-of select="'systemDefault'"/>
  59. </xsl:when>
  60. <xsl:when test="$sscope = 'm'">
  61. <xsl:value-of select="'userDefault'"/>
  62. </xsl:when>
  63. <xsl:when test="$sscope = 'fo'">
  64. <xsl:value-of select="$path"/>
  65. </xsl:when>
  66. <xsl:when test="$sscope = 'fb'">
  67. <xsl:value-of select="$path"/>
  68. </xsl:when>
  69. <xsl:otherwise>
  70. <xsl:value-of select="'systemDefault'"/>
  71. </xsl:otherwise>
  72. </xsl:choose>
  73. </nav:scope>
  74. <!-- recursive scope: whether to search subfolders -->
  75. <nav:recursive>
  76. <xsl:choose>
  77. <xsl:when test="string($params[@name='sscope']) = 'fo'">
  78. <xsl:value-of select="'false'"/>
  79. </xsl:when>
  80. <xsl:otherwise>
  81. <xsl:value-of select="'true'"/>
  82. </xsl:otherwise>
  83. </xsl:choose>
  84. </nav:recursive>
  85. <!-- field -->
  86. <nav:fields>
  87. <xsl:choose>
  88. <xsl:when test="$params[@name = 'sfield'] = 'n'">
  89. <xsl:value-of select="'nf'"/>
  90. </xsl:when>
  91. <xsl:when test="$params[@name = 'sfield'] = 'd'">
  92. <xsl:value-of select="'df'"/>
  93. </xsl:when>
  94. <xsl:when test="$params[@name = 'sfield'] = 'nd'">
  95. <xsl:value-of select="'ndf'"/>
  96. </xsl:when>
  97. </xsl:choose>
  98. </nav:fields>
  99. <!-- match criteria -->
  100. <xsl:variable name="smethod" select="$params[@name='smethod']"/>
  101. <nav:match>
  102. <xsl:choose>
  103. <xsl:when test="$smethod = '1'">
  104. <xsl:value-of select="'contains'"/>
  105. </xsl:when>
  106. <xsl:when test="$smethod = '2'">
  107. <xsl:value-of select="'starts'"/>
  108. </xsl:when>
  109. <xsl:when test="$smethod = '3'">
  110. <xsl:value-of select="'exact'"/>
  111. </xsl:when>
  112. <xsl:otherwise>
  113. <xsl:value-of select="'contains'"/>
  114. </xsl:otherwise>
  115. </xsl:choose>
  116. </nav:match>
  117. <!-- modified since -->
  118. <xsl:variable name="smodified" select="$params[@name='smodified']"/>
  119. <xsl:if test="$smodified != 'any'">
  120. <nav:itemModified>
  121. <xsl:choose>
  122. <xsl:when test="$smodified = 't'">0</xsl:when>
  123. <xsl:when test="$smodified = 'l3d'">259200</xsl:when>
  124. <xsl:when test="$smodified = 'lw'">604800</xsl:when>
  125. <xsl:when test="$smodified = 'lm'">2629743</xsl:when>
  126. <xsl:when test="$smodified = 'l3m'">7889231</xsl:when>
  127. <xsl:when test="$smodified = 'l6m'">15778463</xsl:when>
  128. <xsl:when test="$smodified = 'ly'">31556926</xsl:when>
  129. <xsl:when test="$smodified = 'l3y'">94670777</xsl:when>
  130. </xsl:choose>
  131. </nav:itemModified>
  132. </xsl:if>
  133. <!-- item type(s) to restrict search to -->
  134. <xsl:variable name="stype" select="string($params[@name='stype'])"/>
  135. <xsl:if test="$stype != ''">
  136. <nav:itemType><xsl:value-of select="$stype"/></nav:itemType>
  137. </xsl:if>
  138. </nav-search-query>
  139. </xts:append>
  140. </xts:sequence>
  141. </xsl:template>
  142. </xsl:stylesheet>
  143. </xts:block>
  144. <xts:block id="getContent"
  145. condition=".[not(/root/env/param[@name='frag-directive']='meta-only')]"
  146. dependency="build-search-request" type="exec" mode="interpret" processor="XSLT">
  147. <xsl:stylesheet version="1.0"
  148. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  149. xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt"
  150. xmlns:xts="http://developer.cognos.com/schemas/xts/"
  151. xmlns:xos="http://developer.cognos.com/schemas/xts/output/"
  152. xmlns:bus="http://developer.cognos.com/schemas/bibus/3/"
  153. xmlns:nav="http://developer.cognos.com/schemas/cps/navigation/1/"
  154. xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
  155. exclude-result-prefixes="xts xos bus nav SOAP-ENV">
  156. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  157. <xsl:include href="/fragments/mvc/includes/common-include.xslt"/>
  158. <xsl:template match="/">
  159. <xts:sequence>
  160. <xts:append select="/root/output">
  161. <xos:part>
  162. <xos:entityHeader>
  163. <xos:param name="Content-Type">text/xml; charset=UTF-8</xos:param>
  164. </xos:entityHeader>
  165. <xos:entityBody>
  166. <response>
  167. <logic>
  168. <configured-gateway><xts:function name="getConfiguration"><xts:param name="gateway"/></xts:function></configured-gateway>
  169. <xsl:copy-of select="/root/state"/>
  170. <xts:request name="NAV" faultBlock="requestFault">
  171. <SOAP-ENV:Envelope>
  172. <SOAP-ENV:Header>
  173. <xsl:copy-of select="/root/bus:biBusHeader"/>
  174. </SOAP-ENV:Header>
  175. <SOAP-ENV:Body>
  176. <nav:search>
  177. <!-- nav options -->
  178. <nav:validateTag fault="true"/>
  179. <xsl:copy-of select="/root/nav-search-query/*"/>
  180. <xsl:call-template name="build-pagination-params"/>
  181. <nav:param name="postUrl"/>
  182. <nav:param name="backUrl">rewrite</nav:param>
  183. <nav:param name="browserAgent"><xsl:value-of select="$browser"/></nav:param>
  184. <!-- properties -->
  185. <xsl:call-template name="build-navQuery-properties"/>
  186. </nav:search>
  187. </SOAP-ENV:Body>
  188. </SOAP-ENV:Envelope>
  189. </xts:request>
  190. </logic>
  191. </response>
  192. </xos:entityBody>
  193. </xos:part>
  194. </xts:append>
  195. </xts:sequence>
  196. </xsl:template>
  197. </xsl:stylesheet>
  198. </xts:block>
  199. <xts:block id="requestFault" type="fault" processor="XSLT">
  200. <xsl:stylesheet version="1.0"
  201. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  202. xmlns:xts="http://developer.cognos.com/schemas/xts/"
  203. exclude-result-prefixes="xts">
  204. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  205. <xsl:include href="/fragments/mvc/includes/common-include.xslt"/>
  206. <xsl:template match="/">
  207. <xsl:call-template name="handleException"/>
  208. </xsl:template>
  209. </xsl:stylesheet>
  210. </xts:block>
  211. </xts:morphlet>