ANSMergeUpgradeMuns.xsl 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. Licensed Materials - Property of IBM
  4. IBM Cognos Products: ans
  5. (C) Copyright IBM Corp. 2005, 2010
  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. *
  13. *
  14. * This stylesheet merges all Muns in HLS with new Muns in the xml response that has the following format
  15. * <upgradeResponse>
  16. * <members>
  17. * <member mun="xxx" replacement="yyy"/>
  18. * ...
  19. * </members>
  20. * </upgradeResponse>
  21. -->
  22. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:date="http://exslt.org/dates-and-times" xmlns:exsl="http://exslt.org/common" xmlns:xalan="http://xml.apache.org/xalan" xmlns:java="http://xml.apache.org/xalan/java" extension-element-prefixes="xalan date exsl" exclude-result-prefixes="xalan java date exsl">
  23. <xsl:output method="xml" version="1.0" encoding="UTF-8" omit-xml-declaration="yes"/>
  24. <!-- keys -->
  25. <xsl:key name="upgrademun" match="upgradeResponse/members/member" use="@mun"/>
  26. <xsl:template match="member|ci[@type='member']">
  27. <xsl:element name="{name()}">
  28. <!-- copy any attributes -->
  29. <xsl:for-each select="@*">
  30. <xsl:copy-of select="."/>
  31. </xsl:for-each>
  32. <!-- use mun as the key id -->
  33. <xsl:variable name="mun">
  34. <xsl:value-of select="."/>
  35. </xsl:variable>
  36. <xsl:choose>
  37. <xsl:when test="key('upgrademun', $mun)">
  38. <xsl:value-of select="key('upgrademun', $mun)/@replacement"/>
  39. </xsl:when>
  40. <xsl:otherwise>
  41. <xsl:value-of select="."/>
  42. </xsl:otherwise>
  43. </xsl:choose>
  44. </xsl:element>
  45. </xsl:template>
  46. <xsl:template match="upgradeResponse">
  47. <!-- remove upgradeResponse from the HLS -->
  48. </xsl:template>
  49. <!-- Copy anything that is unmatched over to output. -->
  50. <xsl:template match="@*|node()">
  51. <xsl:copy>
  52. <xsl:apply-templates select="@*|node()"/>
  53. </xsl:copy>
  54. </xsl:template>
  55. </xsl:stylesheet>