buildPackageAndFolderList.xslt 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. 2010, 2011
  6. US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  7. -->
  8. <!--
  9. This transform generates a list of package and folder entries based on a list of search path
  10. and a list of cm query response
  11. It goes to the actual list of searchPath and checks if a corresponding entry exists, if not an element is
  12. created with an "unavailable name"
  13. The list of entries is sorted by the default name. The expected input is the following:
  14. <packageAndFolderContent>
  15. <content>
  16. <type of object>
  17. <property></property>
  18. ...
  19. </type of object>
  20. <content>
  21. <contentLocale>used for sorting</contentLocale>
  22. </packageAndFolderContent>
  23. -->
  24. <xsl:stylesheet version="1.0"
  25. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  26. xmlns:cm="http://developer.cognos.com/schemas/xts-cm/1/"
  27. xmlns:xts="http://developer.cognos.com/schemas/xts/">
  28. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  29. <xsl:template match="/packageAndFolderContent">
  30. <xsl:element name="content" namespace="http://developer.cognos.com/schemas/xts-cm/1/">
  31. <xsl:variable name="unsortedContent">
  32. <xsl:for-each select="searchPathList/searchPath">
  33. <xsl:variable name="currentSearchPath" select="string(.)"/>
  34. <xsl:variable name="cmEntry" select="/packageAndFolderContent/cm:queryResponse/cm:queryReply/*[string(cm:searchPath)=$currentSearchPath]"/>
  35. <xsl:choose>
  36. <xsl:when test="$cmEntry">
  37. <xsl:copy-of select="$cmEntry"/>
  38. </xsl:when>
  39. <xsl:otherwise>
  40. <cm:folder>
  41. <cm:searchPath><xsl:value-of select="."/></cm:searchPath>
  42. <cm:defaultName><xts:string id="IDS_CONTENT_TASK_UNAVAILABLE_CONTENT"/></cm:defaultName>
  43. </cm:folder>
  44. </xsl:otherwise>
  45. </xsl:choose>
  46. </xsl:for-each>
  47. </xsl:variable>
  48. <xsl:for-each select="$unsortedContent/*">
  49. <xsl:sort lang="{/packageAndFolderContent/contentLocale}" select="cm:defaultName" order="ascending"/>
  50. <xsl:copy-of select="."/>
  51. </xsl:for-each>
  52. </xsl:element>
  53. </xsl:template>
  54. </xsl:stylesheet>