common-include.xslt 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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. <xsl:stylesheet version="1.0"
  13. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  14. xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt"
  15. xmlns:ui="http://developer.cognos.com/schemas/cps/logic/ui/1/"
  16. xmlns:xts="http://developer.cognos.com/schemas/xts/"
  17. xmlns:bus="http://developer.cognos.com/schemas/bibus/3/"
  18. xmlns:nav="http://developer.cognos.com/schemas/cps/navigation/1/">
  19. <xsl:variable name="params" select="/root/interactions/param | /root/state/param | /root/transients/param | /root/customs/param"/>
  20. <!-- Preferences vars -->
  21. <xsl:variable name="preferences" select="/root/bus:biBusHeader/bus:userPreferenceVars"/>
  22. <xsl:variable name="productLocale" select="$preferences/item[name = 'productLocale']/value"/>
  23. <xsl:variable name="contentLocale" select="$preferences/item[name = 'contentLocale']/value"/>
  24. <!-- HTTP env vars -->
  25. <xsl:variable name="environmentVars" select="/root/bus:biBusHeader/*[local-name() = 'hdrSession']/bus:environmentVars"/>
  26. <xsl:variable name="userPrefsDefault" select="/root/system/param[@name='defaultPortalPreferences']"/>
  27. <xsl:variable name="user-agent" select="$environmentVars/item[name='HTTP_USER_AGENT']/value"/>
  28. <xsl:variable name="browser">
  29. <xsl:choose>
  30. <xsl:when test="contains($user-agent , 'MSIE')">ie</xsl:when> <!-- IE 4.xx and above -->
  31. <xsl:when test="contains($user-agent , 'Safari/5') and not(contains($user-agent , 'Chrome'))">safari</xsl:when> <!-- Safari user-agent does not contain Chrome -->
  32. <xsl:when test="contains($user-agent , 'Chrome')">chrome</xsl:when> <!-- Chrome user-agent contains Safari also -->
  33. <xsl:when test="contains($user-agent , 'Mozilla/5.0')">moz</xsl:when> <!-- NS 6.xx and 7.xx -->
  34. <xsl:when test="contains($user-agent , 'Mozilla/4.')">ns4</xsl:when> <!-- NS 4.xx -->
  35. <xsl:when test="string-length($user-agent) = 0">undefined</xsl:when>
  36. <xsl:otherwise>other</xsl:otherwise>
  37. </xsl:choose>
  38. </xsl:variable>
  39. <xsl:template name="build-navQuery-properties">
  40. <nav:property name="screenTip"/>
  41. <nav:property name="description"/>
  42. <nav:property name="parentId"/>
  43. <nav:property name="fullPath"/>
  44. <nav:property name="lastModifiedDate"/>
  45. <nav:property name="status"/>
  46. <nav:property name="newState"/>
  47. <nav:property name="readState"/>
  48. <nav:property name="action"/>
  49. <nav:property name="actionsURL"/>
  50. <nav:property name="icons"/>
  51. </xsl:template>
  52. <xsl:template name="build-pagination-params">
  53. <xsl:variable name="skip">
  54. <xsl:choose>
  55. <xsl:when test="string($params[@name='skip']) != ''">
  56. <xsl:value-of select="$params[@name='skip']"/>
  57. </xsl:when>
  58. <xsl:otherwise>0</xsl:otherwise>
  59. </xsl:choose>
  60. </xsl:variable>
  61. <xsl:variable name="maxObjects">
  62. <xsl:choose>
  63. <xsl:when test="$params[@name='maxobjs'] != ''">
  64. <xsl:value-of select="$params[@name='maxobjs']"/>
  65. </xsl:when>
  66. <xsl:when test="$preferences/item[name = 'linesPerPage']/value">
  67. <xsl:value-of select="$preferences/item[name = 'linesPerPage']/value"/>
  68. </xsl:when>
  69. <xsl:otherwise><xsl:value-of select="$userPrefsDefault/pref[@name='lines']"/></xsl:otherwise>
  70. </xsl:choose>
  71. </xsl:variable>
  72. <xsl:variable name="sort">
  73. <xsl:if test="$params[@name='sort'] != ''">
  74. <xsl:value-of select="$params[@name='sort']"/>
  75. </xsl:if>
  76. </xsl:variable>
  77. <nav:skipObjects>
  78. <xsl:choose>
  79. <xsl:when test="$skip != '' ">
  80. <xsl:value-of select="$skip"/>
  81. </xsl:when>
  82. <xsl:otherwise>0</xsl:otherwise>
  83. </xsl:choose>
  84. </nav:skipObjects>
  85. <nav:maxObjects><xsl:value-of select="$maxObjects"/></nav:maxObjects>
  86. <xsl:choose>
  87. <xsl:when test="starts-with(string($sort),'n')">
  88. <xsl:variable name="order">
  89. <xsl:choose>
  90. <xsl:when test="$sort = 'n_d'">
  91. <xsl:text>descending</xsl:text>
  92. </xsl:when>
  93. <xsl:otherwise>
  94. <xsl:text>ascending</xsl:text>
  95. </xsl:otherwise>
  96. </xsl:choose>
  97. </xsl:variable>
  98. <nav:sort order="{$order}">name</nav:sort>
  99. </xsl:when>
  100. <xsl:when test="starts-with(string($sort),'d')">
  101. <xsl:variable name="order">
  102. <xsl:choose>
  103. <xsl:when test="$sort = 'd_d'">
  104. <xsl:text>descending</xsl:text>
  105. </xsl:when>
  106. <xsl:otherwise>
  107. <xsl:text>ascending</xsl:text>
  108. </xsl:otherwise>
  109. </xsl:choose>
  110. </xsl:variable>
  111. <nav:sort order="{$order}">lastModifiedDate</nav:sort>
  112. </xsl:when>
  113. </xsl:choose>
  114. </xsl:template>
  115. <xsl:template name="handleException">
  116. <xsl:variable name="xts-fault" select="/root/fault/xts:exception[last()]"/>
  117. <xsl:variable name="code" select="$xts-fault/xts:exceptionCode"/>
  118. <xsl:variable name="prefix" select="substring-before( string( $code ), ':' )"/>
  119. <xsl:variable name="local-code" select="substring-after( string( $code ), ':' )"/>
  120. <error>
  121. <xsl:choose>
  122. <xsl:when test="($prefix = 'nav') and ($local-code = 'InvalidCredentials')">
  123. <code>invalidCredentials</code>
  124. </xsl:when>
  125. <xsl:otherwise>
  126. <code xmlns:nav="http://developer.cognos.com/schemas/cps/navigation/1/">
  127. <xsl:value-of select="$code"/>
  128. </code>
  129. </xsl:otherwise>
  130. </xsl:choose>
  131. <message>
  132. <xsl:value-of select="$xts-fault/xts:exceptionMsg"/>
  133. </message>
  134. <details>
  135. <xsl:value-of select="$xts-fault/xts:exceptionDetails"/>
  136. </details>
  137. </error>
  138. </xsl:template>
  139. </xsl:stylesheet>