ViewerXmlToJavascript.xslt 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. +=========================================================================+
  4. | Licensed Materials - Property of IBM |
  5. | BI and PM: viewer |
  6. | (C) Copyright IBM Corp. 2002, 2010 |
  7. | |
  8. | US Government Users Restricted Rights - Use, duplication or |
  9. | disclosure restricted by GSA ADP Schedule Contract with IBM Corp. |
  10. | |
  11. +=========================================================================+
  12. -->
  13. <stylesheet version="1.0" xmlns="http://www.w3.org/1999/XSL/Transform">
  14. <output method="text" encoding="UTF-8"/>
  15. <template match="/">
  16. <text>/*&#x0a;</text>
  17. <text> *+------------------------------------------------------------------------+&#x0a;</text>
  18. <text> *| Licensed Materials - Property of IBM&#x0a;</text>
  19. <text> *| IBM Cognos Products: Viewer&#x0a;</text>
  20. <text> *| (C) Copyright IBM Corp. 2013&#x0a;</text>
  21. <text> *|&#x0a;</text>
  22. <text> *| US Government Users Restricted Rights - Use, duplication or&#x0a;</text>
  23. <text> *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.&#x0a;</text>
  24. <text> *|&#x0a;</text>
  25. <text> *+------------------------------------------------------------------------+&#x0a;</text>
  26. <text> */&#x0a;</text>
  27. <for-each select="stringTable/component">
  28. <variable name="comp_name" select="@name"/>
  29. <variable name="comp_name_res">
  30. <value-of select="$comp_name"/>_RES</variable>
  31. <text>if (!</text>
  32. <value-of select="$comp_name_res"/>
  33. <text>) {&#x0a;</text>
  34. <text>var </text>
  35. <value-of select="$comp_name_res"/>
  36. <text> = {};&#x0a;</text>
  37. <text>}&#x0a;</text>
  38. <for-each select="section[@name='JS']">
  39. <variable name="sect_name" select="@name"/>
  40. <if test="$sect_name != 'STC' and $sect_name != 'DFP' and $sect_name != 'CON'">
  41. <for-each select="string">
  42. <!-- Generate the name of the member COMPONENT_NAME_RES.ID, RV_RES.ids....-->
  43. <value-of select="$comp_name_res"/>
  44. <text>.</text>
  45. <value-of select="@id"/>
  46. <text> = &quot;</text>
  47. <!-- generate the message text based on rule #3 and #4 -->
  48. <variable name="msgstring">
  49. <for-each select="child::node()">
  50. <choose>
  51. <when test="name() = 'param'">
  52. <choose>
  53. <when test="@name">
  54. <text disable-output-escaping="yes">{</text>
  55. <value-of select="@name"/>
  56. <text disable-output-escaping="yes">}</text>
  57. </when>
  58. <when test="@index">
  59. <text disable-output-escaping="yes">{</text>
  60. <value-of select="@index - 1"/>
  61. <text disable-output-escaping="yes">}</text>
  62. </when>
  63. <otherwise>
  64. <message terminate="yes">Parameter Substitution Error: Missing name or index.</message>
  65. </otherwise>
  66. </choose>
  67. </when>
  68. <when test="name() = ''">
  69. <value-of select="."/>
  70. </when>
  71. <otherwise>
  72. <copy>
  73. <copy-of select="@*"/>
  74. </copy>
  75. </otherwise>
  76. </choose>
  77. </for-each>
  78. </variable>
  79. <choose>
  80. <when test="@whiteSpace and @whiteSpace='preserve'">
  81. <text disable-output-escaping="yes">\</text>
  82. <value-of select="$msgstring"/>
  83. </when>
  84. <otherwise>
  85. <call-template name="escapeDoubleQuotes">
  86. <with-param name="string"><value-of select="normalize-space($msgstring)"/></with-param>
  87. </call-template>
  88. <!-- value-of select="normalize-space($msgstring)"/ -->
  89. </otherwise>
  90. </choose>
  91. <text>&quot;;&#x0a;</text>
  92. </for-each>
  93. </if>
  94. </for-each>
  95. </for-each>
  96. </template>
  97. <template name="replaceChar">
  98. <param name="text"/>
  99. <param name="toReplace"/>
  100. <param name="replaceWith"/>
  101. <choose>
  102. <when test="contains($text, $toReplace)">
  103. <variable name="beforeChar" select="substring-before($text,$toReplace)"/>
  104. <variable name="afterChar">
  105. <call-template name="replaceChar">
  106. <with-param name="text" select="substring-after($text,$toReplace)"/>
  107. <with-param name="toReplace" select="$toReplace"/>
  108. <with-param name="replaceWith" select="$replaceWith"/>
  109. </call-template>
  110. </variable>
  111. <value-of select="concat($beforeChar, $replaceWith, $afterChar)"/>
  112. </when>
  113. <otherwise>
  114. <value-of select="$text"/>
  115. </otherwise>
  116. </choose>
  117. </template>
  118. <!-- copy everything by default -->
  119. <template name="copyAll" match="*">
  120. <copy>
  121. <copy-of select="@*"/>
  122. <apply-templates/>
  123. </copy>
  124. </template>
  125. <template name="escapeDoubleQuotes">
  126. <param name="string" select="''"/>
  127. <choose>
  128. <when test="contains($string, '&quot;')">
  129. <text/>
  130. <value-of select="substring-before($string, '&quot;')"/>\"<call-template name="escapeDoubleQuotes">
  131. <with-param name="string" select="substring-after($string, '&quot;')"/>
  132. </call-template>
  133. <text/>
  134. </when>
  135. <otherwise>
  136. <text/>
  137. <value-of select="$string"/>
  138. <text/>
  139. </otherwise>
  140. </choose>
  141. </template>
  142. </stylesheet>