nav2cm.xslt 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  13. xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
  14. xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
  15. xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  16. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  17. xmlns:bus="http://developer.cognos.com/schemas/bibus/3/"
  18. xmlns:nav="http://developer.cognos.com/schemas/cps/navigation/1/"
  19. xmlns:cm="http://developer.cognos.com/schemas/xts-cm/1/"
  20. exclude-result-prefixes="xsd xsi bus nav">
  21. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  22. <!-- global variables -->
  23. <xsl:variable name="xtscm" select="'http://developer.cognos.com/schemas/xts-cm/1/'"/>
  24. <xsl:variable name="xsd-prefix" select="'xsd'"/>
  25. <!-- main entry point -->
  26. <xsl:template match="/">
  27. <queryReply xmlns="http://developer.cognos.com/schemas/xts-cm/1/">
  28. <xsl:attribute name="context">
  29. <xsl:value-of select="nav:searchResponse/nav:context"/>
  30. </xsl:attribute>
  31. <xsl:variable name="startingPos" select="nav:searchResponse/nav:content/@start"/>
  32. <xsl:variable name="hasMoreData" select="nav:searchResponse/nav:content/@more = 'true'"/>
  33. <xsl:for-each select="nav:searchResponse/nav:content/*">
  34. <xsl:call-template name="handle-first-level-children">
  35. <xsl:with-param name="node" select="."/>
  36. <xsl:with-param name="position" select="($startingPos - 1) + (position() - 1)"/>
  37. </xsl:call-template>
  38. <xsl:if test="position() = last()">
  39. <xsl:if test="$hasMoreData">
  40. <navDummyEntry namespace="http://developer.cognos.com/schemas/xts-cm/1/">
  41. <xsl:element name="position" namespace="http://developer.cognos.com/schemas/xts-cm/1/">
  42. <xsl:value-of select="($startingPos - 1) + (position() - 1) + 1"/>
  43. </xsl:element>
  44. </navDummyEntry>
  45. </xsl:if>
  46. </xsl:if>
  47. </xsl:for-each>
  48. </queryReply>
  49. </xsl:template>
  50. <xsl:template name="handle-first-level-children">
  51. <xsl:param name="node"/>
  52. <xsl:param name="position"/>
  53. <xsl:if test="$node and string($node/nav:type) != ''">
  54. <xsl:element name="{$node/nav:type}" namespace="http://developer.cognos.com/schemas/xts-cm/1/">
  55. <xsl:apply-templates select="./*"/>
  56. <xsl:element name="position" namespace="http://developer.cognos.com/schemas/xts-cm/1/">
  57. <xsl:value-of select="$position"/>
  58. </xsl:element>
  59. </xsl:element>
  60. </xsl:if>
  61. </xsl:template>
  62. <xsl:template match="nav:internalId">
  63. <xsl:element name="id" namespace="http://developer.cognos.com/schemas/xts-cm/1/">
  64. <xsl:value-of select="."/>
  65. </xsl:element>
  66. <xsl:element name="storeID" namespace="http://developer.cognos.com/schemas/xts-cm/1/">
  67. <xsl:value-of select="."/>
  68. </xsl:element>
  69. </xsl:template>
  70. <xsl:template match="nav:type">
  71. <xsl:element name="objectClass" namespace="http://developer.cognos.com/schemas/xts-cm/1/">
  72. <xsl:value-of select="."/>
  73. </xsl:element>
  74. </xsl:template>
  75. <xsl:template match="nav:name">
  76. <xsl:element name="defaultName" namespace="http://developer.cognos.com/schemas/xts-cm/1/">
  77. <xsl:value-of select="."/>
  78. </xsl:element>
  79. </xsl:template>
  80. <xsl:template match="nav:imgURL">
  81. <xsl:element name="iconURI" namespace="http://developer.cognos.com/schemas/xts-cm/1/">
  82. <xsl:value-of select="."/>
  83. </xsl:element>
  84. </xsl:template>
  85. <xsl:template match="nav:fullName">
  86. <xsl:element name="{local-name()}" namespace="http://developer.cognos.com/schemas/xts-cm/1/">
  87. <xsl:value-of select="."/>
  88. </xsl:element>
  89. </xsl:template>
  90. <xsl:template match="nav:searchPath | nav:permissions">
  91. <xsl:element name="{local-name()}" namespace="http://developer.cognos.com/schemas/xts-cm/1/">
  92. <xsl:value-of select="."/>
  93. </xsl:element>
  94. </xsl:template>
  95. <xsl:template match="*"/>
  96. </xsl:stylesheet>