processCommandBlocks.xslt 3.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. <!-- this transform simply gets rid of the Cognos namespace -->
  13. <xsl:stylesheet version="1.0"
  14. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  15. xmlns:xts="http://developer.cognos.com/schemas/xts/"
  16. xmlns:cm="http://developer.cognos.com/schemas/xts-cm/1/"
  17. xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt"
  18. xmlns:x="x">
  19. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  20. <xsl:template match="/">
  21. <commandBlocks>
  22. <xsl:for-each select="/input/commandBlocks/command">
  23. <xsl:element name="command">
  24. <xsl:copy-of select="./*"/>
  25. <xsl:variable name="propertyName" select="propertyName"/>
  26. <xsl:variable name="commandCleared" select="/input/env/param[@name='actionOnCommands']='clear' and /input/env/param[starts-with(@name,'list_checkbox_')]=$propertyName"/>
  27. <xsl:variable name="commandReset" select="/input/env/param[@name='actionOnCommands']='reset' and /input/env/param[starts-with(@name,'list_checkbox_')]=$propertyName"/>
  28. <xsl:variable name="commandChanged" select="/input/env/param[@name=concat('changed_m_cbp_edit_',$propertyName)]='1'"/>
  29. <xsl:element name="value">
  30. <xsl:choose>
  31. <xsl:when test="$commandCleared"/>
  32. <xsl:when test="$commandReset">
  33. <xsl:value-of select="xtsext:xmldecode(string(/input/parentCommands/*[local-name()=$propertyName]))"/>
  34. </xsl:when>
  35. <!-- if we came from the set command dialog -->
  36. <xsl:when test="/input/env/param[@name=concat('m_cbp_edit_', $propertyName)]">
  37. <xsl:value-of select="/input/env/param[@name=concat('m_cbp_edit_', $propertyName)]"/>
  38. </xsl:when>
  39. <xsl:when test="/input/env/param[@name=concat('m_cbp_', $propertyName)]">
  40. <xsl:value-of select="/input/env/param[@name=concat('m_cbp_', $propertyName)]"/>
  41. </xsl:when>
  42. <xsl:when test="/input/currentCommands/*[local-name()=$propertyName]">
  43. <xsl:value-of select="xtsext:xmldecode(string(/input/currentCommands/*[local-name()=$propertyName]))"/>
  44. </xsl:when>
  45. <xsl:when test="/input/parentCommands/*[local-name()=$propertyName]!=''">
  46. <xsl:value-of select="xtsext:xmldecode(string(/input/parentCommands/*[local-name()=$propertyName]))"/>
  47. </xsl:when>
  48. </xsl:choose>
  49. </xsl:element>
  50. <xsl:element name="changed">
  51. <xsl:choose>
  52. <xsl:when test="$commandChanged or $commandCleared or $commandReset">1</xsl:when>
  53. <xsl:when test="/input/env/param[@name=concat('changed_m_cbp_',$propertyName)]">
  54. <xsl:value-of select="/input/env/param[@name=concat('changed_m_cbp_',$propertyName)]"/>
  55. </xsl:when>
  56. <xsl:otherwise>0</xsl:otherwise>
  57. </xsl:choose>
  58. </xsl:element>
  59. <xsl:element name="acquired">
  60. <xsl:choose>
  61. <xsl:when test="$commandReset">true</xsl:when>
  62. <xsl:when test="$commandCleared or $commandChanged">false</xsl:when>
  63. <xsl:when test="/input/env/param[@name=concat('m_acquired_', $propertyName)]">
  64. <xsl:value-of select="/input/env/param[@name=concat('m_acquired_', $propertyName)]"/>
  65. </xsl:when>
  66. <!-- if we're creating a new connection then by default the values are acquired -->
  67. <xsl:when test="/input/env/param[@name='m_new_class']='dataSourceConnection'">true</xsl:when>
  68. <xsl:when test="/input/currentCommands/*[local-name()=$propertyName][@acquired='true']">true</xsl:when>
  69. <xsl:otherwise>false</xsl:otherwise>
  70. </xsl:choose>
  71. </xsl:element>
  72. </xsl:element>
  73. </xsl:for-each>
  74. </commandBlocks>
  75. </xsl:template>
  76. </xsl:stylesheet>