PRMTXmlToJavascript2.xslt 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!--
  3. +=========================================================================+
  4. | Licensed Materials - Property of IBM |
  5. | BI and PM: prmt |
  6. | (C) Copyright IBM Corp. 2016 |
  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> *| IBM Confidential |&#x0a;</text>
  19. <text> *| Licensed Materials - Property of IBM |&#x0a;</text>
  20. <text> *| BI and PM: prmt |&#x0a;</text>
  21. <text> *| (C) Copyright IBM Corp. 2016 |&#x0a;</text>
  22. <text> *| |&#x0a;</text>
  23. <text> *| US Government Users Restricted Rights - Use, duplication or |&#x0a;</text>
  24. <text> *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp. |&#x0a;</text>
  25. <text> *| |&#x0a;</text>
  26. <text> *+=========================================================================+&#x0a;</text>
  27. <text>*/&#x0a;</text>
  28. <text>define([], {&#x0a;</text>
  29. <for-each select="stringTable/component">
  30. <variable name="comp_name" select="@name" />
  31. <for-each select="section">
  32. <variable name="sect_name" select="@name" />
  33. <if test="$sect_name != 'STC' and $sect_name != 'DFP' and $sect_name != 'CON'">
  34. <for-each select="string">
  35. <text> </text><value-of select="$comp_name" />_<value-of select="$sect_name" />_<value-of select="@id" />
  36. <text>: &quot;</text>
  37. <call-template name="replaceChar">
  38. <with-param name="text">
  39. <call-template name="replaceChar">
  40. <with-param name="text" select="." />
  41. <with-param name="toReplace">\</with-param>
  42. <with-param name="replaceWith">\\</with-param>
  43. </call-template>
  44. </with-param>
  45. <with-param name="toReplace">"</with-param>
  46. <with-param name="replaceWith">\"</with-param>
  47. </call-template>
  48. <text>&quot;,&#x0a;</text>
  49. </for-each>
  50. </if>
  51. </for-each>
  52. </for-each>
  53. <!-- The following is a hack to avoid having a trailing comma on the last item generated above.
  54. If someone can determine how to figure out the logic in xslt that would prevent outputing the trailing comma
  55. in the loops above then the line below could be removed. -->
  56. <text> DUMMY: &quot;&quot;&#x0a;</text>
  57. <text>});&#x0a;</text>
  58. </template>
  59. <template name="replaceChar">
  60. <param name="text" />
  61. <param name="toReplace" />
  62. <param name="replaceWith" />
  63. <choose>
  64. <when test="contains($text, $toReplace)">
  65. <variable name="beforeChar" select="substring-before($text,$toReplace)" />
  66. <variable name="afterChar">
  67. <call-template name="replaceChar">
  68. <with-param name="text" select="substring-after($text,$toReplace)" />
  69. <with-param name="toReplace" select="$toReplace" />
  70. <with-param name="replaceWith" select="$replaceWith" />
  71. </call-template>
  72. </variable>
  73. <value-of select="concat($beforeChar, $replaceWith, $afterChar)" />
  74. </when>
  75. <otherwise>
  76. <value-of select="$text" />
  77. </otherwise>
  78. </choose>
  79. </template>
  80. </stylesheet>