mergeAddedEntriesLists.xslt 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. <!-- input
  13. <root>
  14. <oldEntries></oldEntries>
  15. <newEntries></newEntries>
  16. <allowDuplicates>false</allowDuplicates>
  17. <trackNewEntries paramName="..." property="..."/>
  18. </root>
  19. -->
  20. <xsl:stylesheet version="1.0"
  21. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  22. xmlns:cm="http://developer.cognos.com/schemas/xts-cm/1/"
  23. exclude-result-prefixes="xsl cm">
  24. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  25. <xsl:template match="/root" priority="1">
  26. <!-- copy all the old entries -->
  27. <xsl:copy-of select="/root/oldEntries/*"/>
  28. <xsl:choose>
  29. <xsl:when test="/root/allowDuplicates = 'false'">
  30. <xsl:for-each select="/root/newEntries/*">
  31. <xsl:variable name="searchPath" select="*[local-name()='searchPath']"/>
  32. <xsl:if test="not(*[local-name()='searchPath'] = /root/oldEntries/*/*[local-name()='searchPath'])">
  33. <xsl:element name="{local-name()}" namespace="http://developer.cognos.com/schemas/xts-cm/1/">
  34. <xsl:copy-of select="*"/>
  35. </xsl:element>
  36. <xsl:if test="/root/trackNewEntries">
  37. <param name="{/root/trackNewEntries/@paramName}">
  38. <xsl:variable name="prop" select="/root/trackNewEntries/@property"/>
  39. <xsl:if test="$prop != ''">
  40. <xsl:value-of select="*[local-name()=$prop]"/>
  41. </xsl:if>
  42. </param>
  43. </xsl:if>
  44. </xsl:if>
  45. </xsl:for-each>
  46. </xsl:when>
  47. <xsl:otherwise>
  48. <xsl:copy-of select="/root/newEntries/*"/>
  49. </xsl:otherwise>
  50. </xsl:choose>
  51. </xsl:template>
  52. </xsl:stylesheet>