post-process.xslt 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  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, 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. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  13. xmlns:xts="http://developer.cognos.com/schemas/xts/"
  14. xmlns:up="http://developer.cognos.com/schemas/upfront/"
  15. xmlns:cogx="http://developer.cognos.com/schemas/cogx/"
  16. xmlns:cm="http://developer.cognos.com/schemas/xts-cm/1/">
  17. <xsl:output method="xml" version="1.0" encoding="UTF-8"/>
  18. <!--
  19. <xsl:template match="*">
  20. <xsl:copy>
  21. <xsl:copy-of select="@*"/>
  22. <xsl:apply-templates/>
  23. </xsl:copy>
  24. </xsl:template>
  25. -->
  26. <xsl:variable name="tab"><xsl:value-of select="concat(/root/tab, '-')"/></xsl:variable>
  27. <xsl:template match="/root">
  28. <xsl:choose>
  29. <xsl:when test="cogx:envelope">
  30. <xsl:apply-templates select="cogx:envelope"/>
  31. </xsl:when>
  32. <xsl:otherwise>
  33. <xsl:copy-of select="."/>
  34. </xsl:otherwise>
  35. </xsl:choose>
  36. </xsl:template>
  37. <xsl:template match="cogx:envelope">
  38. <xsl:choose>
  39. <xsl:when test="cogx:result/up:Result/up:NewsBox">
  40. <cm:queryResponse>
  41. <cm:queryReply>
  42. <xsl:if test="/root/nbid != ''">
  43. <xsl:apply-templates select="cogx:result/up:Result/up:NewsBox"/>
  44. </xsl:if>
  45. </cm:queryReply>
  46. <cm:queryReply>
  47. <xsl:apply-templates select="cogx:result/up:Result/up:NewsBox/*[starts-with(local-name(), 'NewsBox') or starts-with(local-name(), 'NewsItem')]"/>
  48. </cm:queryReply>
  49. </cm:queryResponse>
  50. </xsl:when>
  51. <xsl:when test="cogx:result/up:Result/up:System">
  52. <up:system>
  53. <xsl:apply-templates select="cogx:result/up:Result/up:System"/>
  54. </up:system>
  55. </xsl:when>
  56. <xsl:when test="cogx:result/up:Result/up:User">
  57. <up:user>
  58. <xsl:apply-templates select="cogx:result/up:Result/up:User"/>
  59. </up:user>
  60. </xsl:when>
  61. <xsl:otherwise>
  62. <cm:queryResponse>
  63. <cm:queryReply/>
  64. <cm:queryReply>
  65. <xsl:apply-templates select="cogx:result//up:Result/*[starts-with(local-name(), 'NewsBox') or starts-with(local-name(), 'NewsItem')]"/>
  66. </cm:queryReply>
  67. </cm:queryResponse>
  68. </xsl:otherwise>
  69. </xsl:choose>
  70. </xsl:template>
  71. <xsl:template match="up:NewsBox | up:NewsBoxShortcut">
  72. <cm:folder>
  73. <cm:defaultName>
  74. <xsl:value-of select="up:Name"/>
  75. </cm:defaultName>
  76. <cm:defaultDescription>
  77. <xsl:value-of select="up:Description"/>
  78. </cm:defaultDescription>
  79. <cm:objectClass>folder</cm:objectClass>
  80. <cm:permissions>read traverse</cm:permissions>
  81. <cm:usage>folder</cm:usage>
  82. <cm:nbsid><xsl:value-of select="up:Id"/></cm:nbsid>
  83. <xsl:choose>
  84. <xsl:when test="local-name() = 'NewsBox'">
  85. <cm:nbid><xsl:value-of select="concat($tab, up:Id)"/></cm:nbid>
  86. </xsl:when>
  87. <xsl:otherwise>
  88. <!-- assume that newsboxshortcuts point to public newsboxes - there's no easy way to tell, and this is probably right most of the time -->
  89. <cm:nbid><xsl:value-of select="concat('p-', up:NewsBox/up:Id)"/></cm:nbid>
  90. <cm:upfShortCut>true</cm:upfShortCut>
  91. <!--xsl:copy-of select="up:NewsBox"/-->
  92. </xsl:otherwise>
  93. </xsl:choose>
  94. <xsl:apply-templates select="up:FullPath"/>
  95. <cm:updateDate><xsl:value-of select="up:CreateDate"/></cm:updateDate>
  96. <cm:upfFullName><xsl:value-of select="up:FullName"/></cm:upfFullName>
  97. <!--xsl:copy-of select="*"/-->
  98. </cm:folder>
  99. </xsl:template>
  100. <xsl:template match="up:NewsItem | up:NewsItemShortcut">
  101. <xsl:choose>
  102. <xsl:when test="up:ProviderType = 'Other' or up:NewsItem/up:ProviderType = 'Other' or up:ProviderType ='Upfront' or up:NewsItem/up:ProviderType ='Upfront'">
  103. <cm:URL>
  104. <cm:defaultName>
  105. <xsl:value-of select="up:Name"/>
  106. </cm:defaultName>
  107. <cm:defaultDescription>
  108. <xsl:value-of select="up:Description"/>
  109. </cm:defaultDescription>
  110. <cm:objectClass>URL</cm:objectClass>
  111. <cm:permissions>read</cm:permissions>
  112. <xsl:choose>
  113. <xsl:when test="local-name() = 'NewsItem'">
  114. <cm:uri><xsl:value-of select="up:Action[1]/up:URL"/></cm:uri>
  115. <cm:icon>
  116. <xsl:choose>
  117. <xsl:when test="up:PictureURLText != ''"><xsl:value-of select="up:PictureURLText"/></xsl:when>
  118. <xsl:when test="up:PictureFileName != ''"><xsl:value-of select="up:PictureFileName"/></xsl:when>
  119. </xsl:choose>
  120. </cm:icon>
  121. <cm:updateDate><xsl:value-of select="up:UpdateDate"/></cm:updateDate>
  122. </xsl:when>
  123. <xsl:otherwise>
  124. <cm:uri><xsl:value-of select="up:NewsItem/up:Action[1]/up:URL"/></cm:uri>
  125. <cm:updateDate><xsl:value-of select="up:NewsItem/up:UpdateDate"/></cm:updateDate>
  126. <cm:icon>
  127. <xsl:choose>
  128. <xsl:when test="up:NewsItem/up:PictureURLText != ''"><xsl:value-of select="up:NewsItem/up:PictureURLText"/></xsl:when>
  129. <xsl:when test="up:NewsItem/up:PictureFileName != ''"><xsl:value-of select="up:NewsItem/up:PictureFileName"/></xsl:when>
  130. </xsl:choose>
  131. </cm:icon>
  132. <cm:upfShortCut>true</cm:upfShortCut>
  133. </xsl:otherwise>
  134. </xsl:choose>
  135. <cm:usage>object</cm:usage>
  136. <cm:nid><xsl:value-of select="up:Id"/></cm:nid>
  137. <cm:upfFullName><xsl:value-of select="up:FullName"/></cm:upfFullName>
  138. <!--xsl:copy-of select="*"/-->
  139. </cm:URL>
  140. </xsl:when>
  141. <xsl:otherwise>
  142. <cm:query>
  143. <cm:defaultName>
  144. <xsl:value-of select="up:Name"/>
  145. </cm:defaultName>
  146. <cm:defaultDescription>
  147. <xsl:value-of select="up:Description"/>
  148. </cm:defaultDescription>
  149. <cm:objectClass>query</cm:objectClass>
  150. <cm:permissions>read</cm:permissions>
  151. <xsl:choose>
  152. <xsl:when test="local-name() = 'NewsItem'">
  153. <xsl:variable name="default-action" select="up:DefaultAction"/>
  154. <cm:uri><xsl:value-of select="up:Action[up:Name = $default-action]/up:URL"/></cm:uri>
  155. <cm:updateDate><xsl:value-of select="up:UpdateDate"/></cm:updateDate>
  156. <cm:icon>
  157. <xsl:choose>
  158. <xsl:when test="up:PictureURLText != ''"><xsl:value-of select="up:PictureURLText"/></xsl:when>
  159. <xsl:when test="up:PictureFileName != ''"><xsl:value-of select="up:PictureFileName"/></xsl:when>
  160. </xsl:choose>
  161. </cm:icon>
  162. </xsl:when>
  163. <xsl:otherwise>
  164. <xsl:variable name="default-action" select="up:NewsItem/up:DefaultAction"/>
  165. <cm:uri><xsl:value-of select="up:NewsItem/up:Action[up:Name = $default-action]/up:URL"/></cm:uri>
  166. <cm:updateDate><xsl:value-of select="up:NewsItem/up:UpdateDate"/></cm:updateDate>
  167. <cm:icon>
  168. <xsl:choose>
  169. <xsl:when test="up:NewsItem/up:PictureURLText != ''"><xsl:value-of select="up:NewsItem/up:PictureURLText"/></xsl:when>
  170. <xsl:when test="up:NewsItem/up:PictureFileName != ''"><xsl:value-of select="up:NewsItem/up:PictureFileName"/></xsl:when>
  171. </xsl:choose>
  172. </cm:icon>
  173. <cm:upfShortCut>true</cm:upfShortCut>
  174. </xsl:otherwise>
  175. </xsl:choose>
  176. <xsl:if test="up:PrimaryNewsItemId != ''"><cm:upfCustomView>true</cm:upfCustomView></xsl:if>
  177. <cm:usage>object</cm:usage>
  178. <cm:nid><xsl:value-of select="up:Id"/></cm:nid>
  179. <cm:upfFullName><xsl:value-of select="up:FullName"/></cm:upfFullName>
  180. <cm:upfProviderType><xsl:value-of select="up:ProviderType"/></cm:upfProviderType>
  181. <!--xsl:copy-of select="*"/-->
  182. </cm:query>
  183. </xsl:otherwise>
  184. </xsl:choose>
  185. </xsl:template>
  186. <xsl:template match="up:FullPath">
  187. <cm:ancestors>
  188. <xsl:choose>
  189. <xsl:when test="$tab = 'p-'">
  190. <cm:ancestorInfo>
  191. <cm:objectClass>content</cm:objectClass>
  192. <cm:searchPath>/content</cm:searchPath>
  193. <cm:title><xsl:value-of select="/root/pr"/></cm:title>
  194. <cm:storeID><xsl:value-of select="/root/prid"/></cm:storeID>
  195. </cm:ancestorInfo>
  196. </xsl:when>
  197. <xsl:otherwise>
  198. <cm:ancestorInfo>
  199. <cm:objectClass>directory</cm:objectClass>
  200. <cm:searchPath>/directory</cm:searchPath>
  201. <cm:title><xsl:value-of select="/root/pr"/></cm:title>
  202. <cm:storeID/>
  203. </cm:ancestorInfo>
  204. <cm:ancestorInfo>
  205. <cm:objectClass>folder</cm:objectClass>
  206. <cm:searchPath><xsl:value-of select="/root/mfpath"/></cm:searchPath>
  207. <cm:title><xsl:value-of select="/root/mr"/></cm:title>
  208. <cm:storeID><xsl:value-of select="/root/mrid"/></cm:storeID>
  209. </cm:ancestorInfo>
  210. </xsl:otherwise>
  211. </xsl:choose>
  212. <xsl:for-each select="descendant::up:NewsBoxPath">
  213. <xsl:if test="($tab = 'p-' and position() > 1) or ($tab = 'm-' and position() > 3)">
  214. <cm:ancestorInfo>
  215. <cm:objectClass>folder</cm:objectClass>
  216. <cm:searchPath><xsl:value-of select="/root/mfpath"/></cm:searchPath>
  217. <cm:searchID>
  218. <xsl:choose>
  219. <xsl:when test="($tab = 'p-' and position() > 1) or position() > 3"><xsl:value-of select="concat($tab, up:Id)"/></xsl:when>
  220. <xsl:otherwise><xsl:value-of select="$tab"/></xsl:otherwise>
  221. </xsl:choose>
  222. </cm:searchID>
  223. <cm:title><xsl:value-of select="up:Name"/></cm:title>
  224. </cm:ancestorInfo>
  225. </xsl:if>
  226. </xsl:for-each>
  227. </cm:ancestors>
  228. </xsl:template>
  229. <xsl:template match="up:System">
  230. <BaseNewsBoxId><xsl:value-of select="up:BaseNewsBoxId"/></BaseNewsBoxId>
  231. </xsl:template>
  232. <xsl:template match="up:User">
  233. <PersonalNewsBoxID><xsl:value-of select="up:PersonalNewsBoxId"/></PersonalNewsBoxID>
  234. </xsl:template>
  235. <xsl:template match="text()"/>
  236. </xsl:stylesheet>