buildEntries.xslt 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. Licensed Materials - Property of IBM
  4. IBM Cognos Products: HTS
  5. (C) Copyright IBM Corp. 2005, 2010
  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:dlgctrl="http://developer.cognos.com/schemas/xts/logicsheets/xslt/presentation/dialog/controller-templates/" xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt" xmlns:req-params="http://developer.cognos.com/schemas/request/params" exclude-result-prefixes="xsl dlgctrl xtsext req-params">
  9. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  10. <xsl:template match="/">
  11. <selectedEntries>
  12. <xsl:call-template name="decodeEntriesList">
  13. <xsl:with-param name="entriesList">
  14. <xsl:value-of select="/root/env/param[@name='selectedCamIds']"/>
  15. </xsl:with-param>
  16. <xsl:with-param name="type">
  17. <xsl:value-of select="/root/env/param[@name='type']"/>
  18. </xsl:with-param>
  19. <xsl:with-param name="currentEntries">
  20. <xsl:copy-of select="/root/env/param[@name='currentEntries']"/>
  21. </xsl:with-param>
  22. </xsl:call-template>
  23. </selectedEntries>
  24. </xsl:template>
  25. <xsl:template name="getBefore">
  26. <xsl:param name="entriesList"/>
  27. <xsl:variable name="before" select="substring-before($entriesList,',')"/>
  28. <xsl:variable name="after" select="substring-after($entriesList,',')"/>
  29. <xsl:choose>
  30. <!-- if the next entry does not start with CAMID then we must have an LDAP address e.g. CAMID("LDAP:u:uid=sysadmin1,ou=people") which includes a comma(used to delimit the list)-->
  31. <xsl:when test="starts-with($before,'CAMID') and starts-with($after,'CAMID')=false()">
  32. <!-- get the full camid by concatenating the two parts-->
  33. <xsl:variable name="camId">
  34. <xsl:call-template name="getCAMID">
  35. <xsl:with-param name="before" select="$before"/>
  36. <xsl:with-param name="after" select="$after"/>
  37. </xsl:call-template>
  38. </xsl:variable>
  39. <!-- return the 'before ',' entry-->
  40. <xsl:value-of select="$camId"/>
  41. </xsl:when>
  42. <!-- COGNOS namespace camid e.g. CAMID(":Authors")-->
  43. <xsl:otherwise><xsl:value-of select="$before"/></xsl:otherwise>
  44. </xsl:choose>
  45. </xsl:template>
  46. <xsl:template name="getAfter">
  47. <xsl:param name="entriesList"/>
  48. <xsl:variable name="before" select="substring-before($entriesList,',')"/>
  49. <xsl:variable name="after" select="substring-after($entriesList,',')"/>
  50. <xsl:choose>
  51. <!-- if the next entry does not start with CAMID then we must have an LDAP address e.g. CAMID("LDAP:u:uid=sysadmin1,ou=people") which includes a comma(used to delimit the list)-->
  52. <xsl:when test="starts-with($before,'CAMID') and starts-with($after,'CAMID')=false()">
  53. <!-- get the full camid by concatenating the two parts-->
  54. <xsl:variable name="camId">
  55. <xsl:call-template name="getCAMID">
  56. <xsl:with-param name="before" select="$before"/>
  57. <xsl:with-param name="after" select="$after"/>
  58. </xsl:call-template>
  59. </xsl:variable>
  60. <!-- return the 'after ',' entry-->
  61. <xsl:value-of select="substring-after($entriesList,$camId)"/>
  62. </xsl:when>
  63. <!-- COGNOS namespace camid e.g. CAMID(":Authors")-->
  64. <xsl:otherwise><xsl:value-of select="$after"/></xsl:otherwise>
  65. </xsl:choose>
  66. </xsl:template>
  67. <xsl:template name="getCAMID">
  68. <xsl:param name="after"/>
  69. <xsl:param name="before"/>
  70. <xsl:choose>
  71. <xsl:when test="substring-before($after,',')=''"><xsl:value-of select="concat($before,',',$after)"/></xsl:when>
  72. <xsl:otherwise><xsl:value-of select="concat($before,',',substring-before($after,')'),')')"/></xsl:otherwise>
  73. </xsl:choose>
  74. </xsl:template>
  75. <xsl:template name="decodeEntriesList">
  76. <xsl:param name="entriesList"/>
  77. <xsl:param name="type"/>
  78. <xsl:param name="currentEntries"/>
  79. <xsl:choose>
  80. <xsl:when test="contains($entriesList, ',')">
  81. <!-- get the 'before' list -->
  82. <xsl:variable name="before">
  83. <xsl:call-template name="getBefore">
  84. <xsl:with-param name="entriesList" select="$entriesList"/>
  85. </xsl:call-template>
  86. </xsl:variable>
  87. <!-- get the 'after' list -->
  88. <xsl:variable name="after">
  89. <xsl:call-template name="getAfter">
  90. <xsl:with-param name="entriesList" select="$entriesList"/>
  91. </xsl:call-template>
  92. </xsl:variable>
  93. <!-- build the <selectedEntry> structure -->
  94. <xsl:if test="$before != '' ">
  95. <xsl:call-template name="build">
  96. <xsl:with-param name="entriesList"><xsl:value-of select="$before"/></xsl:with-param>
  97. <xsl:with-param name="type"><xsl:value-of select="$type"/></xsl:with-param>
  98. <xsl:with-param name="currentEntries"><xsl:copy-of select="$currentEntries"/></xsl:with-param>
  99. </xsl:call-template>
  100. </xsl:if>
  101. <!--xsl:choose>
  102. <xsl:when test="$currentEntries/param/selectedEntry[./searchPath/text() = $before]">
  103. <selectedEntry>
  104. <type><xsl:value-of select="$type"/></type>
  105. <type><xsl:value-of select="$currentEntries/param/selectedEntry/type"/></type>
  106. <searchPath><xsl:value-of select="$before"/></searchPath>
  107. </selectedEntry>
  108. </xsl:when>
  109. <xsl:otherwise>
  110. <selectedEntry>
  111. <type><xsl:value-of select="$type"/></type>
  112. <searchPath><xsl:value-of select="$before"/></searchPath>
  113. </selectedEntry>
  114. </xsl:otherwise>
  115. </xsl:choose>
  116. </xsl:if-->
  117. <!-- handle the next entry in the list-->
  118. <xsl:if test="$after != '' ">
  119. <xsl:call-template name="decodeEntriesList">
  120. <xsl:with-param name="entriesList"><xsl:value-of select="$after"/></xsl:with-param>
  121. <xsl:with-param name="type"><xsl:value-of select="$type"/></xsl:with-param>
  122. <xsl:with-param name="currentEntries"><xsl:copy-of select="$currentEntries"/></xsl:with-param>
  123. </xsl:call-template>
  124. </xsl:if>
  125. </xsl:when>
  126. <xsl:otherwise>
  127. <xsl:if test="$entriesList != '' ">
  128. <xsl:call-template name="build">
  129. <xsl:with-param name="entriesList"><xsl:value-of select="$entriesList"/></xsl:with-param>
  130. <xsl:with-param name="type"><xsl:value-of select="$type"/></xsl:with-param>
  131. <xsl:with-param name="currentEntries"><xsl:copy-of select="$currentEntries"/></xsl:with-param>
  132. </xsl:call-template>
  133. </xsl:if>
  134. <!--xsl:choose>
  135. <xsl:when test="$currentEntries/param/selectedEntry[./searchPath/text() = $entriesList] ">
  136. <selectedEntry>
  137. <type><xsl:value-of select="$type"/></type>
  138. <type><xsl:value-of select="$currentEntries/param/selectedEntry/type"/></type>
  139. <searchPath><xsl:value-of select="$entriesList"/></searchPath>
  140. </selectedEntry>
  141. </xsl:when>
  142. <xsl:otherwise>
  143. <selectedEntry>
  144. <type><xsl:value-of select="$type"/></type>
  145. <searchPath><xsl:value-of select="$entriesList"/></searchPath>
  146. </selectedEntry>
  147. </xsl:otherwise>
  148. </xsl:choose>
  149. </xsl:if-->
  150. </xsl:otherwise>
  151. </xsl:choose>
  152. </xsl:template>
  153. <xsl:template name="build">
  154. <xsl:param name="entriesList"/>
  155. <xsl:param name="type"/>
  156. <xsl:param name="currentEntries"/>
  157. <xsl:choose>
  158. <xsl:when test="$currentEntries/param/selectedEntry[./searchPath/text() = $entriesList] ">
  159. <selectedEntry>
  160. <type><xsl:value-of select="$type"/></type>
  161. <type><xsl:value-of select="$currentEntries/param/selectedEntry/type"/></type>
  162. <searchPath><xsl:value-of select="$entriesList"/></searchPath>
  163. </selectedEntry>
  164. </xsl:when>
  165. <xsl:otherwise>
  166. <selectedEntry>
  167. <type><xsl:value-of select="$type"/></type>
  168. <searchPath><xsl:value-of select="$entriesList"/></searchPath>
  169. </selectedEntry>
  170. </xsl:otherwise>
  171. </xsl:choose>
  172. </xsl:template>
  173. </xsl:stylesheet>