merge-source-into-deployment-object.xslt 3.8 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. <!--
  13. NOTE: .
  14. -->
  15. <xsl:stylesheet version="1.0"
  16. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  17. xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt"
  18. exclude-result-prefixes="xsl">
  19. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  20. <xsl:key name="target-parent" match="/root/*[local-name() = 'queryResponse']/*[local-name() = 'queryReply']/*[local-name() = 'package' or local-name() = 'folder' or local-name() = 'content']" use="*[local-name()='searchPath']"/>
  21. <xsl:template match="/root" priority="1">
  22. <xsl:apply-templates select="*"/>
  23. </xsl:template>
  24. <xsl:template match="*[local-name()='queryReply']" priority="1">
  25. </xsl:template>
  26. <xsl:template match="*[local-name()='packageDeploymentInfo']" priority="2">
  27. <xsl:copy>
  28. <xsl:copy-of select="*[local-name()='targetName']"/>
  29. <xsl:copy-of select="*[local-name()='archiveSearchPath']"/>
  30. <xsl:copy-of select="*[local-name()='storeID']"/>
  31. <xsl:copy-of select="*[local-name()='targetLocation']"/>
  32. <xsl:variable name="storeID" select="*[local-name()='archiveSearchPath']"/>
  33. <!-- following 2 variables used to convert a storeID to the format storeID('XXXXXXXXX') -->
  34. <xsl:variable name="storeIDPrefix"><xsl:text>storeID(&apos;</xsl:text></xsl:variable>
  35. <xsl:variable name="storeIDSuffix"><xsl:text>&apos;)</xsl:text></xsl:variable>
  36. <!-- get the searchPath from the storeID-searchPath map generated in a previous block -->
  37. <xsl:variable name="searchPathValue" select="/root/*[local-name() = 'storeIDMap']/*[local-name() = 'queryResponse']/*[local-name() = 'queryReply']/*[(local-name() = 'package' or local-name() = 'folder')][concat($storeIDPrefix,*[local-name()='storeID'],$storeIDSuffix)=$storeID]/*[local-name()='searchPath']"/>
  38. <xsl:element name="enabled" namespace="{namespace-uri()}">
  39. <xsl:copy-of select="*[local-name()='enabled']"/>
  40. </xsl:element>
  41. <xsl:element name="ancestors" namespace="{namespace-uri()}">
  42. <xsl:copy-of select="*[local-name()='ancestorInfo']"/>
  43. </xsl:element>
  44. <xsl:element name="sourceName" namespace="{namespace-uri()}">
  45. <xsl:copy-of select="key('target-parent',$searchPathValue)/*[local-name()='name']/*[local-name()='multilingualToken']"/>
  46. </xsl:element>
  47. <xsl:element name="ancestorsSource" namespace="{namespace-uri()}">
  48. <xsl:element name="ancestorInfo" namespace="{namespace-uri()}">
  49. <xsl:copy-of select="key('target-parent',$searchPathValue)/*[local-name()='ancestors']/*[local-name()='ancestorInfo']/*[local-name()='title']"/>
  50. <xsl:copy-of select="key('target-parent',$searchPathValue)/*[local-name()='ancestors']/*[local-name()='ancestorInfo']/*[local-name()='searchPath']"/>
  51. <xsl:copy-of select="key('target-parent',$searchPathValue)/*[local-name()='ancestors']/*[local-name()='ancestorInfo']/*[local-name()='storeID']"/>
  52. </xsl:element>
  53. </xsl:element>
  54. <xsl:copy-of select="key('target-parent',$searchPathValue)/*[local-name()='defaultName']"/>
  55. <xsl:copy-of select="key('target-parent',$searchPathValue)/*[local-name()='storeID']"/>
  56. </xsl:copy>
  57. </xsl:template>
  58. <!-- match all unmatched nodes -->
  59. <xsl:template match="node()" priority="0">
  60. <xsl:copy>
  61. <xsl:copy-of select="@*"/>
  62. <xsl:apply-templates/>
  63. </xsl:copy>
  64. </xsl:template>
  65. <!-- copy just the text -->
  66. <xsl:template match="text()" priority="0">
  67. <xsl:copy-of select="."/>
  68. </xsl:template>
  69. </xsl:stylesheet>