RSUpgradeDrillTarget.xsl 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. Licensed Materials - Property of IBM
  4. IBM Cognos Products: rspecupgrade
  5. (C) Copyright IBM Corp. 2005, 2010
  6. US Government Users Restricted Rights - Use, duplication or disclosure
  7. restricted by GSA ADP Schedule Contract with IBM Corp.
  8. -->
  9. <!-- COPYRIGHT_DATA { 'YEAR':[2005, 2009], 'RELEASE':['colorado_wave1'], 'VISIBLE':'YES', 'COMPONENT':'rspecupgrade' }-->
  10. <!--All lines above the COPYRIGHT_DATA line will be replaced when copyright notices are generated. -->
  11. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:baltic="http://developer.cognos.com/schemas/report/1/" xmlns="http://developer.cognos.com/schemas/report/2.0/" xmlns:date="http://exslt.org/dates-and-times" xmlns:exsl="http://exslt.org/common" xmlns:xalan="http://xml.apache.org/xalan" xmlns:java="http://xml.apache.org/xalan/java" extension-element-prefixes="xalan date exsl" exclude-result-prefixes="xalan java baltic date exsl">
  12. <!--
  13. drillTarget -> reportDrill
  14. drillTarget@name -> reportDrill@name
  15. drillTarget@path -> reportDrill/drillTarget/reportPath@path
  16. drillTarget@showInNewWindow -> reportDrill/drillTarget@showInNewWindow
  17. drillTarget@method -> reportDrill/drillTarget@method
  18. drillTarget@outputFormat -> reportDrill/drillTarget@outputFormat
  19. drillParameter -> drillLink
  20. drillParameter@name -> drillLink/drillTargetContext/parameterContext@parameter
  21. drillParameter@value -> Not Supported
  22. drillParameter/queryItemRef@refItem -> drillLink/drillSourceContext/dataItemContext@refDataItem
  23. bookmarkRef -> bookmarkRef
  24. bookmarkRef/label -> bookmarkRef/dataSource/staticValue
  25. bookmarkRef/queryItemRef@refItem -> bookmarkRef/dataSource/dataItemValue@refDataItem
  26. bookmarkRef/expression -> bookmarkRef/dataSource/reportExpression
  27. label -> drillLabel/dataSource/staticValue
  28. -->
  29. <xsl:template name="drillTargetTemplate">
  30. <xsl:param name="p_drillTargets" select="baltic:drillTarget"/>
  31. <xsl:if test="$p_drillTargets">
  32. <reportDrills>
  33. <xsl:apply-templates select="$p_drillTargets"/>
  34. </reportDrills>
  35. </xsl:if>
  36. </xsl:template>
  37. <xsl:template match="baltic:drillTarget">
  38. <reportDrill name="{@name}">
  39. <!-- label ==> drillLabel -->
  40. <xsl:apply-templates select="baltic:label"/>
  41. <!-- Even though the schema allows it (trakker 531099) it is not permissable to have
  42. * both a bookmarkRef and a drillTarget.
  43. -->
  44. <xsl:if test="count(@path) > 0 or count(baltic:drillParameter) > 0">
  45. <xsl:variable name="v_path">
  46. <xsl:call-template name="upgradeDrillTargetPathTemplate">
  47. <xsl:with-param name="p_v4DrillTargetName" select="@name"/>
  48. <xsl:with-param name="p_v4DrillTargetPath" select="@path"/>
  49. </xsl:call-template>
  50. </xsl:variable>
  51. <xsl:if test="$v_path != ''">
  52. <drillTarget>
  53. <!-- showInNewWIndow -->
  54. <xsl:variable name="v_showInNewWindow" select="@showInNewWindow"/>
  55. <xsl:if test="$v_showInNewWindow = 'true'">
  56. <xsl:attribute name="showInNewWindow"><xsl:value-of select="$v_showInNewWindow"/></xsl:attribute>
  57. </xsl:if>
  58. <!-- method -->
  59. <xsl:variable name="v_method" select="@method"/>
  60. <xsl:attribute name="method"><xsl:choose><xsl:when test="$v_method != ''"><xsl:value-of select="$v_method"/></xsl:when><xsl:otherwise>execute</xsl:otherwise></xsl:choose></xsl:attribute>
  61. <!-- outputFormat -->
  62. <xsl:variable name="v_outputFormat" select="@outputFormat"/>
  63. <xsl:if test="$v_outputFormat != ''">
  64. <xsl:attribute name="outputFormat"><xsl:value-of select="$v_outputFormat"/></xsl:attribute>
  65. </xsl:if>
  66. <!-- reportPath -->
  67. <reportPath path="{$v_path}">
  68. <XMLAttributes>
  69. <xsl:variable name="v_after">report[@name='</xsl:variable>
  70. <xsl:variable name="v_before">']</xsl:variable>
  71. <XMLAttribute name="ReportName" value="{substring-before(substring-after($v_path,$v_after),$v_before)}" render="false"/>
  72. </XMLAttributes>
  73. </reportPath>
  74. <!-- drillLinks -->
  75. <xsl:if test="count(baltic:drillParameter) > 0">
  76. <drillLinks>
  77. <xsl:for-each select="baltic:drillParameter">
  78. <drillLink>
  79. <xsl:if test="count(baltic:queryItemRef) > 0">
  80. <xsl:variable name="v_dic" select="baltic:queryItemRef/@refItem"/>
  81. <xsl:if test="$v_dic != ''">
  82. <drillSourceContext>
  83. <dataItemContext refDataItem="{$v_dic}"/>
  84. </drillSourceContext>
  85. </xsl:if>
  86. </xsl:if>
  87. <drillTargetContext>
  88. <parameterContext parameter="{@name}"/>
  89. </drillTargetContext>
  90. </drillLink>
  91. </xsl:for-each>
  92. </drillLinks>
  93. </xsl:if>
  94. </drillTarget>
  95. </xsl:if>
  96. </xsl:if>
  97. <!-- bookmarkRef ==> bookmarkRef -->
  98. <xsl:apply-templates select="baltic:bookmarkRef"/>
  99. </reportDrill>
  100. </xsl:template>
  101. <xsl:template match="baltic:drillTarget/baltic:label">
  102. <drillLabel>
  103. <dataSource>
  104. <staticValue>
  105. <xsl:apply-templates/>
  106. </staticValue>
  107. </dataSource>
  108. </drillLabel>
  109. </xsl:template>
  110. <xsl:template match="baltic:bookmarkRef">
  111. <bookmarkRef>
  112. <xsl:call-template name="bookmarkTypeTemplate"/>
  113. </bookmarkRef>
  114. </xsl:template>
  115. <xsl:template name="upgradeDrillTargetPathTemplate">
  116. <xsl:param name="p_v4DrillTargetName"/>
  117. <xsl:param name="p_v4DrillTargetPath"/>
  118. <xsl:if test="$p_v4DrillTargetPath != ''">
  119. <xsl:variable name="v_path">
  120. <xsl:value-of select="/baltic:report/baltic:paths/baltic:value/baltic:item/baltic:target/baltic:item//baltic:searchPath/baltic:value[../../../../baltic:name/baltic:item/baltic:value = $p_v4DrillTargetName]"/>
  121. </xsl:variable>
  122. <xsl:choose>
  123. <xsl:when test="$v_path != ''">
  124. <xsl:value-of select="$v_path"/>
  125. </xsl:when>
  126. <xsl:otherwise>
  127. <xsl:value-of select="$p_v4DrillTargetPath"/>
  128. </xsl:otherwise>
  129. </xsl:choose>
  130. </xsl:if>
  131. </xsl:template>
  132. </xsl:stylesheet>