update-target-ancestors-properties.xslt 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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()='content' or local-name()='folder' or local-name()='package']" 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()='queryResponse' or local-name()='queryReply']" priority="1">
  25. </xsl:template>
  26. <xsl:template match="*[local-name()='ancestors']" priority="2">
  27. <xsl:element name="ancestors" namespace="{namespace-uri()}">
  28. <xsl:element name="ancestorInfo" namespace="{namespace-uri()}">
  29. <xsl:variable name="searchPath"><xsl:value-of select="*[local-name()='ancestorInfo']/*[local-name()='searchPath']"/></xsl:variable>
  30. <xsl:element name="objectClass" namespace="{namespace-uri()}">
  31. <xsl:value-of select="key('target-parent',$searchPath)/*[local-name()='objectClass']"/>
  32. </xsl:element>
  33. <xsl:element name="searchPath" namespace="{namespace-uri()}">
  34. <xsl:attribute name="type">
  35. <xsl:text>cm:stringProp</xsl:text>
  36. </xsl:attribute>
  37. <xsl:value-of select="key('target-parent',$searchPath)/*[local-name()='searchPath']"/>
  38. </xsl:element>
  39. <xsl:element name="storeID" namespace="{namespace-uri()}">
  40. <xsl:attribute name="type">
  41. <xsl:text>cm:guid</xsl:text>
  42. </xsl:attribute>
  43. <xsl:value-of select="key('target-parent',$searchPath)/*[local-name()='storeID']"/>
  44. </xsl:element>
  45. <xsl:element name="title" namespace="{namespace-uri()}">
  46. <xsl:value-of select="key('target-parent',$searchPath)/*[local-name()='defaultName']"/>
  47. </xsl:element>
  48. </xsl:element>
  49. </xsl:element>
  50. </xsl:template>
  51. <xsl:template match="*[local-name()='parent']" priority="2">
  52. <xsl:variable name="parentSearchPath"><xsl:value-of select="../*[local-name()='ancestors']/*[local-name()='ancestorInfo']/*[local-name()='searchPath']"/> </xsl:variable>
  53. <xsl:copy>
  54. <xsl:value-of select="key('target-parent',$parentSearchPath)/*[local-name()='storeID']"/>
  55. </xsl:copy>
  56. </xsl:template>
  57. <!-- match all unmatched nodes -->
  58. <xsl:template match="node()" priority="0">
  59. <xsl:copy>
  60. <xsl:copy-of select="@*"/>
  61. <xsl:apply-templates/>
  62. </xsl:copy>
  63. </xsl:template>
  64. <!-- copy just the text -->
  65. <xsl:template match="text()" priority="0">
  66. <xsl:copy-of select="."/>
  67. </xsl:template>
  68. </xsl:stylesheet>