generateMetadataAndMetrics.xslt 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. Licensed Materials - Property of IBM
  4. IBM Cognos Products: cogadmin
  5. (C) Copyright IBM Corp. 2005, 2010
  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"
  13. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  14. xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
  15. xmlns:muws2="http://docs.oasis-open.org/wsdm/muws2-2.xsd"
  16. xmlns:resource-prop="http://developer.cognos.com/admin/properties"
  17. xmlns:wsrf-rp="http://docs.oasis-open.org/wsrf/rp-2"
  18. xmlns:nemo="http://developer.cognos.com/nemo"
  19. exclude-result-prefixes="wsrf-rp nemo xsl SOAP-ENV muws2">
  20. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
  21. <xsl:key name="properties" match="/root/input[@name='dataResponse']/wsrf-rp:GetMultipleResourcePropertiesResponse/*" use="local-name()"/>
  22. <xsl:key name="property-metadata-by-group" match="/root/input[@name='metadataResponse']/wsrf-rp:GetMultipleResourcePropertiesResponse/nemo:MetadataDescriptor/nemo:Property" use="nemo:MetricGroup"/>
  23. <xsl:template match="/root">
  24. <response>
  25. <metadataAndDataResponse>
  26. <nemo:Resource>
  27. <xsl:variable name="mdd" select="/root/input[@name='metadataResponse']/wsrf-rp:GetMultipleResourcePropertiesResponse/nemo:MetadataDescriptor"/>
  28. <!-- Properties in a group -->
  29. <xsl:variable name="allGroups" select="$mdd/nemo:PropertiesGroups/nemo:PropertiesGroup"/>
  30. <xsl:for-each select="$allGroups">
  31. <xsl:variable name="group" select="."/>
  32. <xsl:variable name="groupID" select="nemo:URI"/>
  33. <xsl:variable name="propertiesInThatGroup" select="key('property-metadata-by-group', string($groupID))"/>
  34. <xsl:for-each select="$propertiesInThatGroup">
  35. <xsl:if test="position() = 1">
  36. <xsl:text disable-output-escaping="yes">&lt;nemo:PropertiesGroup&gt;</xsl:text>
  37. <xsl:copy-of select="$group/nemo:URI"/>
  38. <xsl:copy-of select="$group/nemo:Caption"/>
  39. <xsl:copy-of select="$group/nemo:Description"/>
  40. <!-- Metric group actions -->
  41. <xsl:copy-of select="$mdd/nemo:Action[starts-with(nemo:Capability, 'http://cognos.com/admin/supportedactions/metricgroup')]"/>
  42. </xsl:if>
  43. <xsl:call-template name="insertProperty">
  44. <xsl:with-param name="metadata" select="."/>
  45. <xsl:with-param name="value" select="key('properties', ./nemo:Name)"/>
  46. </xsl:call-template>
  47. <xsl:if test="position() = last()">
  48. <xsl:text disable-output-escaping="yes">&lt;/nemo:PropertiesGroup&gt;</xsl:text>
  49. </xsl:if>
  50. </xsl:for-each>
  51. </xsl:for-each>
  52. <!-- Properties not in a group -->
  53. <xsl:variable name="propertiesWithoutAGroup" select="$mdd/nemo:Property[not(nemo:MetricGroup)]"/>
  54. <xsl:for-each select="$propertiesWithoutAGroup">
  55. <xsl:call-template name="insertProperty">
  56. <xsl:with-param name="metadata" select="."/>
  57. <xsl:with-param name="value" select="key('properties', ./nemo:Name)"/>
  58. </xsl:call-template>
  59. </xsl:for-each>
  60. <!-- Resource actions -->
  61. <xsl:copy-of select="$mdd/nemo:Action[starts-with(nemo:Capability, 'http://cognos.com/admin/supportedactions/resource')]"/>
  62. </nemo:Resource>
  63. </metadataAndDataResponse>
  64. </response>
  65. </xsl:template>
  66. <xsl:template name="insertProperty">
  67. <xsl:param name="metadata" select="''"/>
  68. <xsl:param name="value" select="''"/>
  69. <nemo:Property>
  70. <xsl:copy-of select="$metadata/*"/>
  71. <nemo:Value/>
  72. </nemo:Property>
  73. </xsl:template>
  74. </xsl:stylesheet>