CCLInputSource.xslt 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. Licensed Materials - Property of IBM
  4. IBM Cognos Products: localizationkit
  5. (C) Copyright IBM Corp. 2005, 2016
  6. US Government Users Restricted Rights - Use, duplication or disclosure restricted
  7. by GSA ADP Schedule Contract with IBM Corp.
  8. -->
  9. <!--
  10. Module: CCLInputSource.xslt
  11. Purpose:
  12. Insert proper prefix into all strings in Messages section(s) such that the result message file can be
  13. directly consumed by other tools.
  14. Rules:
  15. 1) Only section of type "Messages", or section without the "type" attribute (which default to Messages)
  16. will be transformed, other sections will be dump out in their original format.
  17. 2) Only strings in Messages section with "errorCode" defined will be tranformed. The following format will be
  18. used as prefix:
  19. <component_name>-<section_name>-<errorCode>.
  20. 3) Strings in Messages section that do not have "errorCode" defined will be treated as non-error messages and
  21. will not be transfomed.
  22. 4) To conform with xml specification, non-meaningful whitespaces will be trimmed, and meaningful whitespace must
  23. be kept. The following are some examples:
  24. Example 1:
  25. <string>There are
  26. <param name="count"/> items.
  27. </string>
  28. will be transform to:
  29. <string>CPN-SEN-xxxx There are
  30. <param name="count"/> items.
  31. </string>
  32. Example 2:
  33. <string>
  34. <param name="count"/> items.
  35. </string>
  36. will be transform to:
  37. <string>CPN-SEN-xxxx <param name="count"/> items.
  38. </string>
  39. Example 3:
  40. <string>
  41. <param name="count"/> entries</string>
  42. will be transform to:
  43. <string>CPN-SEN-xxxx <param name="count"/> entries</string>
  44. Note: For readibility, linefeed and tab had been added.
  45. -->
  46. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  47. <xsl:output method="xml" omit-xml-declaration="no" encoding="UTF-8"/>
  48. <!-- Only transform message string with errorCode defined and is resides in the Messages section -->
  49. <xsl:template match="/">
  50. <xsl:comment>
  51. <xsl:text> Licensed Materials - Property of IBM &#x0a;</xsl:text>
  52. <xsl:text> IBM Cognos Products: localizationkit &#x0a;</xsl:text>
  53. <xsl:text>&#x0a; (C) Copyright IBM Corp. 2005, 2016&#x0a;</xsl:text>
  54. <xsl:text> US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.&#x0a;</xsl:text>
  55. </xsl:comment>
  56. <xsl:text>&#x0a;</xsl:text>
  57. <xsl:comment>
  58. <xsl:text>&#x0a; DO NOT EDIT! &#x0a;</xsl:text>
  59. <xsl:text>Generated using:&#x0a;</xsl:text>
  60. <xsl:text>Id: //localizationkit/main/prod/msgsdk/CCLInputSource.xslt &#x0a;</xsl:text>
  61. </xsl:comment>
  62. <xsl:text>&#x0a;</xsl:text>
  63. <xsl:apply-templates select="*|text()"/>
  64. </xsl:template>
  65. <!-- copy everything by default -->
  66. <xsl:template match="*">
  67. <xsl:copy>
  68. <xsl:copy-of select="@*"/>
  69. <xsl:apply-templates select="*|text()"/>
  70. </xsl:copy>
  71. </xsl:template>
  72. <xsl:template match="/stringTable/component/section[not(@type) or @type='Messages']/string[@errorCode]">
  73. <xsl:copy>
  74. <!-- prefix -->
  75. <xsl:copy-of select="@*"/>
  76. <xsl:value-of select="../../@name"/>
  77. <xsl:text>-</xsl:text>
  78. <xsl:value-of select="../@name"/>
  79. <xsl:text>-</xsl:text>
  80. <xsl:value-of select="@errorCode"/>
  81. <!-- make sure we put a space between prefix and the message text -->
  82. <xsl:text>&#32;</xsl:text>
  83. <!-- This is the rule to trim the non-meaningful whitespace -->
  84. <xsl:for-each select="child::node()">
  85. <xsl:if test="not(position()=1 and name()='' and string-length(normalize-space())=0)">
  86. <xsl:apply-templates select="."/>
  87. </xsl:if>
  88. </xsl:for-each>
  89. </xsl:copy>
  90. </xsl:template>
  91. </xsl:stylesheet>