addAdvancedSettings.xslt 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. Licensed Materials - Property of IBM
  4. IBM Cognos Products: cogadmin
  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:xts="http://developer.cognos.com/schemas/xts/"
  15. xmlns:cm="http://developer.cognos.com/schemas/bibus/3/"
  16. xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
  17. exclude-result-prefixes="cm xsl xts SOAP-ENV">
  18. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
  19. <xsl:variable name="xtscm" select="'http://developer.cognos.com/schemas/xts-cm/1/'"/>
  20. <xsl:key name="installed-components" match="/root/cm:queryResponse/*/item[2]/queryResult/item/componentID/value" use="."/>
  21. <xsl:template match="/root">
  22. <xsl:apply-templates/>
  23. </xsl:template>
  24. <!-- eat the soap header, if present -->
  25. <xsl:template match="SOAP-ENV:Header"/>
  26. <xsl:template match="advancedSettings" priority="3">
  27. <xsl:element name="advancedSettings">
  28. <xsl:copy-of select="@*"/>
  29. <xsl:element name="value">
  30. <xsl:value-of select="value" disable-output-escaping="yes"/>
  31. </xsl:element>
  32. </xsl:element>
  33. </xsl:template>
  34. <xsl:template match="config">
  35. <xsl:variable name="environment" select="/root/config/section[@name = 'environment']"/>
  36. <xsl:element name="config">
  37. <xsl:element name="section">
  38. <xsl:attribute name="name">advancedSettings</xsl:attribute>
  39. <xsl:attribute name="label"><xsl:value-of select="$environment/parameter[@name = 'advancedSettings']/@label"/></xsl:attribute>
  40. <xsl:element name="parameter">
  41. <xsl:copy-of select="$environment/parameter[@name = 'advancedSettings']/@*"/>
  42. </xsl:element>
  43. </xsl:element>
  44. <xsl:apply-templates/>
  45. </xsl:element>
  46. </xsl:template>
  47. <xsl:template match="parameter[@name = 'advancedSettings']"/>
  48. <xsl:template match="*" priority="-2">
  49. <xsl:variable name="objectClass" select="../objectClass/value/."/>
  50. <xsl:choose>
  51. <xsl:when test="($objectClass = 'configuration') or ($objectClass = 'dispatcher')">
  52. <xsl:variable name="isAcquired" select="string(./schemaInfo/acquired/.) = 'true'"/>
  53. <xsl:variable name="propertyName" select="local-name()"/>
  54. <xsl:variable name="serviceDependency" select="string(/root/config/section/parameter[@name = $propertyName]/@serviceDependency)"/>
  55. <xsl:choose>
  56. <!-- Copy the local element when the service dependency is empty i.e. the element might or might not be related to the settings -->
  57. <xsl:when test="$serviceDependency = ''">
  58. <xsl:copy>
  59. <xsl:copy-of select="@*"/>
  60. <xsl:apply-templates/>
  61. </xsl:copy>
  62. </xsl:when>
  63. <!-- Copy the local element: The element is related to the settings and satisfy the conditions. -->
  64. <xsl:when test="($serviceDependency != '') and (key('installed-components', string($serviceDependency)) != '') and not($isAcquired)">
  65. <xsl:copy>
  66. <xsl:copy-of select="@*"/>
  67. <xsl:apply-templates/>
  68. </xsl:copy>
  69. </xsl:when>
  70. </xsl:choose>
  71. </xsl:when>
  72. <xsl:otherwise>
  73. <xsl:copy>
  74. <xsl:copy-of select="@*"/>
  75. <xsl:apply-templates/>
  76. </xsl:copy>
  77. </xsl:otherwise>
  78. </xsl:choose>
  79. </xsl:template>
  80. </xsl:stylesheet>