edit.xslt 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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"
  13. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  14. xmlns:x="x"
  15. xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt"
  16. xmlns:cm="http://developer.cognos.com/schemas/xts-cm/1/"
  17. xmlns:xts="http://developer.cognos.com/schemas/xts/">
  18. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  19. <xsl:variable name="op" select="/root/env/param[@name='credential_op']"/>
  20. <xsl:variable name="passport" select="/root/credential/param[@name='CAM']/*[local-name() ='CAM']/*[local-name() = 'CAMPassport']/*[local-name() = 'id']"/>
  21. <xsl:template match="/">
  22. <xts:sequence>
  23. <xsl:choose>
  24. <!-- Delete operation -->
  25. <xsl:when test="$op='delete'">
  26. <xsl:for-each select="/root/env/param[starts-with(@name,'credential_chk_')]">
  27. <xsl:variable name="searchPath" select="."/>
  28. <xts:delete select="root/list/*/*[local-name() = 'searchPath' and . = '{$searchPath}']/.."/>
  29. </xsl:for-each>
  30. <!-- clean up the request -->
  31. <xts:delete select="/root/env/param[starts-with(@name,'credential_chk_')]"/>
  32. </xsl:when>
  33. <!-- Add operation -->
  34. <xsl:when test="/root/newEntries">
  35. <xsl:variable name="fragment">
  36. <xsl:for-each select="/root/newEntries/*">
  37. <xsl:choose>
  38. <xsl:when test="not(*[local-name()='searchPath'] = /root/list/*/cm:searchPath)">
  39. <xts:append select="/root/list">
  40. <xsl:element name="{local-name()}" namespace="http://developer.cognos.com/schemas/xts-cm/1/">
  41. <xsl:element name="objectClass" namespace="http://developer.cognos.com/schemas/xts-cm/1/">
  42. <xsl:value-of select="local-name()"/>
  43. </xsl:element>
  44. <xsl:element name="defaultName" namespace="http://developer.cognos.com/schemas/xts-cm/1/">
  45. <xsl:value-of select="*[local-name()='defaultName']"/>
  46. </xsl:element>
  47. <xsl:element name="searchPath" namespace="http://developer.cognos.com/schemas/xts-cm/1/">
  48. <xsl:value-of select="*[local-name()='searchPath']"/>
  49. </xsl:element>
  50. <xsl:element name="defaultDescription" namespace="http://developer.cognos.com/schemas/xts-cm/1/">
  51. <xsl:value-of select="*[local-name()='defaultDescription']"/>
  52. </xsl:element>
  53. <xsl:element name="defaultScreenTip" namespace="http://developer.cognos.com/schemas/xts-cm/1/">
  54. <xsl:value-of select="*[local-name()='defaultScreenTip']"/>
  55. </xsl:element>
  56. <xsl:element name="ancestors" namespace="http://developer.cognos.com/schemas/xts-cm/1/">
  57. <xsl:copy-of select="*[local-name()='ancestors']"/>
  58. </xsl:element>
  59. <xsl:if test="*[local-name()='userName']">
  60. <xsl:element name="userName" namespace="http://developer.cognos.com/schemas/xts-cm/1/">
  61. <xsl:value-of select="*[local-name()='userName']"/>
  62. </xsl:element>
  63. </xsl:if>
  64. </xsl:element>
  65. </xts:append>
  66. </xsl:when>
  67. <xsl:otherwise>
  68. <xts:append select="/root">
  69. <duplicateEntry/>
  70. </xts:append>
  71. </xsl:otherwise>
  72. </xsl:choose>
  73. </xsl:for-each>
  74. </xsl:variable>
  75. <xsl:if test="$fragment">
  76. <xsl:if test="not(/root/list)">
  77. <xts:append select="root">
  78. <list/>
  79. </xts:append>
  80. </xsl:if>
  81. <xsl:copy-of select="$fragment"/>
  82. <xts:delete select="/root/newItems"/>
  83. </xsl:if>
  84. <xts:delete select="/root/env/param[@name='addentries_list']"/>
  85. </xsl:when>
  86. </xsl:choose>
  87. </xts:sequence>
  88. </xsl:template>
  89. </xsl:stylesheet>