swapSearchPaths.xslt 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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: The logic to determine the order of the queries MUST match the logic found in dt:generateInitialUIHelpers
  14. if checkUIHelpers is true, then only build the CM query if the associated UIHelper is empty.
  15. -->
  16. <xsl:stylesheet version="1.0"
  17. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  18. xmlns:cm="http://developer.cognos.com/schemas/xts-cm/1/"
  19. exclude-result-prefixes="xsl">
  20. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  21. <xsl:template match="*[local-name()='root']" priority="1">
  22. <xsl:apply-templates/>
  23. </xsl:template>
  24. <xsl:template match="*[local-name()='searchPath']" priority="1">
  25. <xsl:element name="{name()}" namespace="{namespace-uri()}">
  26. <xsl:copy-of select="@*"/>
  27. <xsl:variable name="parentPos" select="count(parent::*/parent::*/preceding-sibling::*)+1"/>
  28. <xsl:value-of select="/root/*[local-name()='queryBuiltFromOptions']/*[local-name()='query'][position()=$parentPos]/*[local-name()='search']"/>
  29. </xsl:element>
  30. </xsl:template>
  31. <xsl:template match="*[local-name()='queryBuiltFromOptions']" priority="1"/>
  32. <!-- match all unmatched nodes -->
  33. <xsl:template match="node()" priority="0">
  34. <xsl:element name="{name()}" namespace="{namespace-uri()}">
  35. <xsl:copy-of select="@*"/>
  36. <xsl:apply-templates/>
  37. </xsl:element>
  38. </xsl:template>
  39. <!-- copy just the text -->
  40. <xsl:template match="text()" priority="0">
  41. <xsl:copy-of select="."/>
  42. </xsl:template>
  43. </xsl:stylesheet>