createDisplayData.xslt 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. Licensed Materials - Property of IBM
  4. IBM Cognos Products: AGS
  5. (C) Copyright IBM Corp. 2005, 2008
  6. US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  7. -->
  8. <xsl:stylesheet version="1.0" xmlns:xts="http://developer.cognos.com/schemas/xts/" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:agsdlg="http://developer.cognos.com/schemas/xts/logicsheets/xslt/ags/dialog/" xmlns:out="http://www.w3.org/1999/XSL/Transform" xmlns:pf="http://developer.cognos.com/schemas/xts/pf" xmlns:bus="http://developer.cognos.com/schemas/bibus/3/" xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:cm="http://developer.cognos.com/schemas/xts-cm/1/" exclude-result-prefixes="xts xsl agsdlg out pf bus xtsext xsi cm">
  9. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  10. <pf:variables/>
  11. <agsdlg:parameterText quote-string="/root/displayedPage/@quote-string"/>
  12. <agsdlg:parameterTextUnTrimmed quote-string="/root/displayedPage/@quote-string"/>
  13. <xsl:template match="/">
  14. <xts:sequence>
  15. <!--when the type is sql....the value selected is entered by the user setting up the sql argument in Framework manager
  16. if none is provided, we cannot call the sp properly, if they are not unique ditto. the parameter value name passed around is the value-->
  17. <xts:append select="/root">
  18. <parametersDisplay>
  19. <objectClass><xsl:value-of select="/root/env/param[@name='objectClass']"/></objectClass>
  20. <!--xsl:apply-templates select="/root/parametersResponse/parameter/item"/-->
  21. <!--This can be used for unique nodes:-->
  22. <xsl:apply-templates select="/root/parametersResponse/parameter/item[not(./name=preceding-sibling::item/name)]"/>
  23. </parametersDisplay>
  24. </xts:append>
  25. </xts:sequence>
  26. </xsl:template>
  27. <xsl:template match="item">
  28. <xsl:variable name="value" select="substring-before(substring-after(./value, '?'),'?')"/>
  29. <xsl:variable name="name">
  30. <xsl:choose>
  31. <xsl:when test="/root/displayedPage = 'sql' and not($value = '')">
  32. <xsl:value-of select="substring-before(substring-after(./value, '?'),'?')"/>
  33. </xsl:when>
  34. <xsl:when test="../simplejavatype='false' and not(../name='parameters')">
  35. <xsl:value-of select="concat(../name,'/',./name)"/>
  36. </xsl:when>
  37. <xsl:otherwise>
  38. <xsl:value-of select="./name"/>
  39. </xsl:otherwise>
  40. </xsl:choose>
  41. </xsl:variable>
  42. <xsl:variable name="disabled">
  43. <xsl:choose>
  44. <xsl:when test="/root/displayedPage = 'sql' and $value = ''">
  45. <xsl:value-of select="'true'"/>
  46. </xsl:when>
  47. <xsl:otherwise>
  48. <xsl:value-of select="'false'"/>
  49. </xsl:otherwise>
  50. </xsl:choose>
  51. </xsl:variable>
  52. <xsl:choose>
  53. <xsl:when test="./name='parameters'">
  54. <!-- doc literals param parent has name as parameters so we dont wrap it with parameter tag-->
  55. <xsl:if test="./simplejavatype='false'">
  56. <!-- complex data found -->
  57. <xsl:apply-templates select="./item"/>
  58. </xsl:if>
  59. </xsl:when>
  60. <xsl:otherwise>
  61. <parameter>
  62. <xsl:variable name="paramName" select="./name"/>
  63. <xsl:attribute name="name"><xsl:value-of select="./name"/></xsl:attribute>
  64. <xsl:attribute name="sqlCredentialValue"><xsl:value-of select="/root/credentialParameters/credentialParameter[@name=$paramName]/dataSource//*[local-name()='dataSourceConnection']/*[local-name()='defaultName']"/></xsl:attribute>
  65. <xsl:attribute name="caption"><xsl:choose><xsl:when test="./type='credential'"><xsl:if test="/root/credentialParameters/credentialParameter[@name=$paramName]/dataSource//*[local-name()='dataSourceConnection']/*[local-name()='defaultName']"><xsl:value-of select="/root/credentialParameters/credentialParameter[@name=$paramName]/dataSource//*[local-name()='dataSourceConnection']/*[local-name()='defaultName']"/></xsl:if></xsl:when><xsl:when test="./caption/item[./locale = $contentLocale]"><xsl:value-of select="./caption/item[./locale = $contentLocale]/value"/></xsl:when><xsl:otherwise><xsl:value-of select="$name"/></xsl:otherwise></xsl:choose></xsl:attribute>
  66. <xsl:attribute name="multivalued"><xsl:choose><xsl:when test="contains(./capabilities, 'multivalued')"><xsl:text>true</xsl:text></xsl:when><xsl:otherwise><xsl:text>false</xsl:text></xsl:otherwise></xsl:choose></xsl:attribute>
  67. <xsl:attribute name="required"><xsl:choose><xsl:when test="contains(./capabilities, 'optional')"><xsl:text>false</xsl:text></xsl:when><xsl:otherwise><xsl:text>true</xsl:text></xsl:otherwise></xsl:choose></xsl:attribute>
  68. <xsl:attribute name="disabled"><xsl:value-of select="$disabled"/></xsl:attribute>
  69. <xsl:attribute name="type"><xsl:call-template name="convertTypeName"><xsl:with-param name="type"><xsl:value-of select="./type"/></xsl:with-param></xsl:call-template></xsl:attribute>
  70. <xsl:attribute name="format"><xsl:call-template name="createFormat"/></xsl:attribute>
  71. <xsl:attribute name="value"><xsl:value-of select="./value"/></xsl:attribute>
  72. <xsl:attribute name="simplejavatype"><xsl:value-of select="./simplejavatype"/></xsl:attribute>
  73. <xsl:if test="/root/agent_item/parameterData/parameterAssignments/parameterAssignment[./parameterName = $name]">
  74. <xsl:attribute name="modelValue"><xsl:value-of select="/root/agent_item/parameterData/parameterAssignments/parameterAssignment[./parameterName = $name]/dataItemName"/></xsl:attribute>
  75. </xsl:if>
  76. <xsl:choose>
  77. <xsl:when test="/root/displayedPage = 'report' and /root/agent_item/parameterData/parameterValues/item[./name = $name]">
  78. <xsl:attribute name="literalValue"><xsl:call-template name="parameterText"><xsl:with-param name="parameter"><xsl:copy-of select="/root/agent_item/parameterData/parameterValues/item[./name = $name]"/></xsl:with-param><xsl:with-param name="parameterTextSize"><xsl:text>75</xsl:text></xsl:with-param></xsl:call-template></xsl:attribute>
  79. </xsl:when>
  80. <xsl:when test="/root/displayedPage != 'report' and /root/agent_item/parameterData/parameterValues/item[./name = $name]">
  81. <xsl:attribute name="literalValue"><xsl:call-template name="parameterTextUnTrimmed"><xsl:with-param name="parameter"><xsl:copy-of select="/root/agent_item/parameterData/parameterValues/item[./name = $name]"/></xsl:with-param></xsl:call-template></xsl:attribute>
  82. </xsl:when>
  83. <xsl:when test="/root/displayedPage = 'sql' and $value = ''">
  84. <xsl:attribute name="literalValue"><!-- we have a non variable literal parameter for a sp--><xsl:value-of select="./value"/></xsl:attribute>
  85. </xsl:when>
  86. </xsl:choose>
  87. <xsl:if test="./simplejavatype='false'">
  88. <!-- complex data found -->
  89. <xsl:apply-templates select="./item"/>
  90. </xsl:if>
  91. </parameter>
  92. </xsl:otherwise>
  93. </xsl:choose>
  94. </xsl:template>
  95. <xsl:template name="createFormat">
  96. <xsl:if test="./size != ''">
  97. <xts:string id="DIALOG_SQL_SP_FORMAT_SIZE"/>
  98. <xsl:text>= </xsl:text>
  99. <xsl:value-of select="./size"/>
  100. <xsl:text>, </xsl:text>
  101. </xsl:if>
  102. <xsl:if test="./precision != ''">
  103. <xts:string id="DIALOG_SQL_SP_FORMAT_PREC"/>
  104. <xsl:text>= </xsl:text>
  105. <xsl:value-of select="./precision"/>
  106. <xsl:text>, </xsl:text>
  107. </xsl:if>
  108. <xsl:if test="./scale != ''">
  109. <xts:string id="DIALOG_SQL_SP_FORMAT_SCALE"/>
  110. <xsl:text>= </xsl:text>
  111. <xsl:value-of select="./scale"/>
  112. </xsl:if>
  113. </xsl:template>
  114. <!--template to get the name for the parameter data type-->
  115. <xsl:template name="convertTypeName">
  116. <xsl:param name="type"/>
  117. <xsl:variable name="displayedPage" select="/root/displayedPage"/>
  118. <xsl:choose>
  119. <xsl:when test="$displayedPage = 'web' or $displayedPage = 'sql' or $type=''">
  120. <xsl:value-of select="$type"/>
  121. </xsl:when>
  122. <xsl:when test="$type = 'xsdString' or $type= 'memberUniqueName' ">
  123. <xsl:text>
  124. <xts:string id="DIALOG_PROMPT_TEXT"/>
  125. </xsl:text>
  126. </xsl:when>
  127. <xsl:when test="$type = 'xsdShort' or $type = 'xsdLong' or $type = 'xsdUnsignedByte' or $type = 'xsdUnsignedInt' or $type = 'xsdUnsignedLong' or $type = 'xsdShort' or $type = 'xsdFloat' or $type = 'xsdInt' or $type = 'xsdByte' or $type = 'xsdDecimal' or $type = 'xsdDouble' or $type = 'xsdUnsignedShort'">
  128. <xsl:text>
  129. <xts:string id="DIALOG_PROMPT_NUMBER"/>
  130. </xsl:text>
  131. </xsl:when>
  132. <xsl:when test="$type = 'xsdDate' or $type = 'xsdTime' or $type = 'xsdDateTime'">
  133. <xsl:text>
  134. <xts:string id="DIALOG_PROMPT_DATE"/>
  135. </xsl:text>
  136. </xsl:when>
  137. <xsl:when test="$type = 'xsdDuration'">
  138. <xsl:text>
  139. <xts:string id="DIALOG_PROMPT_DURATION"/>
  140. </xsl:text>
  141. </xsl:when>
  142. <xsl:when test="$type = 'credential'">
  143. <xsl:text>
  144. <xts:string id="DIALOG_PROMPT_CONNECTION"/>
  145. </xsl:text>
  146. </xsl:when>
  147. <xsl:otherwise>
  148. <xsl:text>
  149. <xts:string id="DIALOG_PROMPT_TEXT"/>
  150. </xsl:text>
  151. </xsl:otherwise>
  152. </xsl:choose>
  153. </xsl:template>
  154. </xsl:stylesheet>