post-process.xslt 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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" xmlns:cm="http://developer.cognos.com/schemas/xts-cm/1/">
  13. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  14. <xsl:key name="installed-components" match="/results/cm:queryResponse/cm:queryReply[2]/cm:installedComponent/cm:componentID/cm:value" use="."/>
  15. <xsl:variable name="parameters" select="/results/config//parameter"/>
  16. <xsl:variable name="isDispatcher" select="/results/cm:queryResponse/cm:queryReply[1]/*/cm:objectClass = 'dispatcher'"/>
  17. <xsl:variable name="sort-key" select="/results/sortkey"/>
  18. <xsl:variable name="sort_order">
  19. <xsl:choose>
  20. <xsl:when test="substring($sort-key,2)='d'">
  21. <xsl:value-of select="'descending'"/>
  22. </xsl:when>
  23. <xsl:otherwise>
  24. <xsl:value-of select="'ascending'"/>
  25. </xsl:otherwise>
  26. </xsl:choose>
  27. </xsl:variable>
  28. <xsl:template match="results" priority="1">
  29. <xsl:apply-templates/>
  30. </xsl:template>
  31. <!--we don't want these elements, just eat them -->
  32. <xsl:template match="parentInfo|isService|config|sortkey|productLocale|cm:ancestors|cm:behaviours|cm:creationTime|cm:defaultAction|cm:defaultDescription|cm:defaultName|cm:defaultScreenTip|cm:disabled|cm:displaySequence|cm:hasChildren|cm:modificationTime|cm:owner|cm:properties|cm:searchPath|cm:usage|cm:version" priority="2"/>
  33. <xsl:template match="cm:queryResponse/cm:queryReply[1]/node()" priority="2">
  34. <xsl:variable name="n" select="child::*"/>
  35. <xsl:element name="{local-name()}" namespace="{namespace-uri()}">
  36. <xsl:copy-of select="@*"/>
  37. <xsl:choose>
  38. <xsl:when test="$sort-key = ''">
  39. <xsl:for-each select="$parameters[substring-after(@type,':')!='optionArrayProp'] | $parameters[local-name($n[local-name()=$parameters/@name and substring-after(@type,':')='optionArrayProp']) != '' and substring-after(@type,':')='optionArrayProp']/enum">
  40. <xsl:variable name="p" select="self::node()"/>
  41. <xsl:apply-templates select="$n[local-name()=$p/@name]"/>
  42. <xsl:apply-templates select=".[local-name()='enum']">
  43. <xsl:with-param name="options" select="$n[local-name()='overrideOptions' or local-name()='serviceDefaultOptions' ]"/>
  44. </xsl:apply-templates>
  45. </xsl:for-each>
  46. </xsl:when>
  47. <xsl:when test="starts-with($sort-key,'c')">
  48. <xsl:for-each select="$parameters[substring-after(@type,':')!='optionArrayProp'] | $parameters[local-name($n[local-name()=$parameters/@name and substring-after(@type,':')='optionArrayProp']) != '' and substring-after(@type,':')='optionArrayProp']/enum">
  49. <xsl:sort select="concat(../@label,@label)" order="{$sort_order}" lang="{string(/results/productLocale)}"/>
  50. <xsl:variable name="p" select="self::node()"/>
  51. <xsl:apply-templates select="$n[local-name()=$p/@name] | .[local-name()='enum']"/>
  52. </xsl:for-each>
  53. </xsl:when>
  54. <xsl:otherwise>
  55. <xsl:for-each select="$parameters[substring-after(@type,':')!='optionArrayProp'] | $parameters[local-name($n[local-name()=$parameters/@name and substring-after(@type,':')='optionArrayProp']) != '' and substring-after(@type,':')='optionArrayProp']/enum">
  56. <xsl:sort select="concat(@label,local-name())" order="{$sort_order}" lang="{string(/results/productLocale)}"/>
  57. <xsl:variable name="p" select="self::node()"/>
  58. <xsl:apply-templates select="$n[local-name()=$p/@name] | .[local-name()='enum']"/>
  59. </xsl:for-each>
  60. </xsl:otherwise>
  61. </xsl:choose>
  62. <xsl:apply-templates select="$n[local-name()='permissions']"/>
  63. <xsl:apply-templates select="$n[local-name()='objectClass']"/>
  64. </xsl:element>
  65. </xsl:template>
  66. <!-- the query should be to get the defaultName, so just copy it as is -->
  67. <xsl:template match="cm:queryReply[position()=last()]">
  68. <xsl:copy-of select="."/>
  69. </xsl:template>
  70. <!-- ignore advanced settings property for dispatchers and configuration folders. -->
  71. <xsl:template match="cm:advancedSettings[contains(' dispatcher configurationFolder ', concat(' ', ../cm:objectClass, ' '))]" priority="2"/>
  72. <!--Handle enums for cm:optionArrayProp parameters to facilitate them to appear as 'vitual' parameters within the settings xts eg. accessibility and flash enums for overrideOptiona parm-->
  73. <xsl:template match="enum[./../@type='cm:optionArrayProp']" priority="2">
  74. <xsl:param name="options"/>
  75. <xsl:element name="{concat('optionArrayProp_',substring-after(@value,'#'))}">
  76. <xsl:attribute name="category"><xsl:value-of select="../../@name"/></xsl:attribute>
  77. <xsl:attribute name="group"><xsl:value-of select="../../@label"/></xsl:attribute>
  78. <xsl:attribute name="type"><xsl:value-of select="../@type"/></xsl:attribute>
  79. <xsl:copy-of select="@*"/>
  80. <!-- we've matched our property, so simply copy everything under it -->
  81. <xsl:copy-of select="* | text()"/>
  82. <xsl:element name="options">
  83. <xsl:copy-of select="$options"/>
  84. </xsl:element>
  85. </xsl:element>
  86. </xsl:template>
  87. <!-- process CM properties -->
  88. <xsl:template match="cm:*[@type!='' and @type!='cm:optionArrayProp']" priority="1">
  89. <xsl:variable name="name" select="local-name()"/>
  90. <xsl:variable name="p" select="$parameters[@name=$name]"/>
  91. <xsl:variable name="isROLAPInstalled" select="/results/rolapIntegration/configuration/property[@name='rolapIntegration'] = 'true'"/>
  92. <!--
  93. For services we don't query for the installed components, so just show the runtime parameters for that service.
  94. For configuration, dispatcher and configurationFolder check the installedComponents, and only show the runtime
  95. parameters if the second queryReply isn't empty (i.e make sure there's a dispatcher somewhere).
  96. For a user with read-only permissions on a dispatcher just show the runtime parameters with no service dependencies.
  97. Make sure we always copy permissions.
  98. -->
  99. <xsl:if test="
  100. (not($p/@serviceDependency) and /results/cm:queryResponse/cm:queryReply[2]/*)
  101. or /results/parentInfo = 'true'
  102. or $name = 'permissions'
  103. or /results/isService = 'true'
  104. or (
  105. key('installed-components', $p/@serviceDependency)
  106. and /results/isService = 'false'
  107. and /results/cm:queryResponse/cm:queryReply[2]/*
  108. )
  109. or (not($p/@serviceDependency) and ($isDispatcher or /results/cm:queryResponse/cm:queryReply[3]/*))
  110. ">
  111. <xsl:copy>
  112. <xsl:attribute name="category"><xsl:value-of select="$p/../@name"/></xsl:attribute>
  113. <xsl:attribute name="group"><xsl:value-of select="$p/../@label"/></xsl:attribute>
  114. <xsl:copy-of select="$p/@*"/>
  115. <xsl:copy-of select="@*"/>
  116. <xsl:copy-of select="$p/*[local-name()='enum']"/>
  117. <!-- we've matched our property, so simply copy everything under it -->
  118. <xsl:copy-of select="* | text()"/>
  119. </xsl:copy>
  120. </xsl:if>
  121. </xsl:template>
  122. <!-- match all unmatched nodes -->
  123. <xsl:template match="node()" priority="0">
  124. <xsl:element name="{name()}" namespace="{namespace-uri()}">
  125. <xsl:copy-of select="@*"/>
  126. <xsl:apply-templates/>
  127. </xsl:element>
  128. </xsl:template>
  129. <!-- copy just the text -->
  130. <xsl:template match="text()" priority="0">
  131. <xsl:copy-of select="."/>
  132. </xsl:template>
  133. </xsl:stylesheet>