AGCEventsMC.xsl 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <?xml version='1.0'?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
  3. <xsl:script>
  4. <![CDATA[
  5. function GetPrefix(node)
  6. {
  7. var attr = node.attributes.getNamedItem("Prefix");
  8. if (attr)
  9. return attr.value;
  10. var theParent = node.parentNode;
  11. return theParent ? GetPrefix(theParent) : "__ERROR_NO_PREFIX__";
  12. }
  13. function GetMCFormat(node)
  14. {
  15. var attr = node.attributes.getNamedItem("Format");
  16. if (!attr)
  17. return "";
  18. var strFormat = attr.value;
  19. // Get the array of symbol names used in the format string
  20. var arrNames = GetFormatSymbols(strFormat);
  21. // Perform symbol replacements
  22. for (var i = 0; i < arrNames.length; ++i)
  23. {
  24. var j = i + 1;
  25. strFormat = strFormat.replace(arrNames[i], "%" + j);
  26. }
  27. // Perform special character replacements
  28. var reLF = /\\n/g;
  29. strFormat = strFormat.replace(reLF , "%n");
  30. var reCR = /\\r/g;
  31. strFormat = strFormat.replace(reCR , "%r");
  32. var reSP = / $/;
  33. strFormat = strFormat.replace(reSP , "% ");
  34. var rePeriod = /^\./;
  35. strFormat = strFormat.replace(rePeriod, "%.");
  36. var reExclam = /!/g;
  37. strFormat = strFormat.replace(reExclam, "%!");
  38. var reTab = /\\t/g;
  39. strFormat = strFormat.replace(reTab , " ");
  40. // Return the modified string
  41. return strFormat;
  42. }
  43. function GetFormatSymbols(strFormat)
  44. {
  45. // Find each pair of '%' characters in the format string
  46. var re = /%([^%]*)%/g;
  47. var strTemp = strFormat;
  48. var arrNames = new Array();
  49. while (re.exec(strTemp))
  50. {
  51. strTemp = strTemp.substr(RegExp.lastIndex);
  52. var strSymbol = RegExp.$1;
  53. if (strSymbol.length)
  54. arrNames[arrNames.length] = strSymbol;
  55. }
  56. // Convert each symbol string to a regular expression
  57. var strSpecialChars = "\\~$*+?.()|{}[]-";
  58. for (var i = 0; i < arrNames.length; ++i)
  59. {
  60. var strOld = arrNames[i];
  61. var strNew = "";
  62. for (var j = 0; j < strOld.length; ++j)
  63. {
  64. var ch = strOld.charAt(j);
  65. if (strSpecialChars.indexOf(ch) >= 0)
  66. strNew += "\\";
  67. strNew += ch;
  68. }
  69. arrNames[i] = new RegExp("%" + strNew + "%", "gi");
  70. }
  71. // Return the array of regular expressions
  72. return arrNames;
  73. }
  74. ]]>
  75. </xsl:script>
  76. <xsl:template match="/">
  77. <xsl:apply-templates/>
  78. </xsl:template>
  79. <xsl:template match="AGCEvents" xsl:space="preserve">
  80. ;/////////////////////////////////////////////////////////////////////////////
  81. ;// <xsl:value-of select="@outputfile"/>
  82. ;//
  83. ;// This is an ALWAYS GENERATED file. It should *not* be edited directly.
  84. ;//
  85. ;// It was generated at <xsl:value-of select="@time"/> from the following script:
  86. ;// <xsl:value-of select="@scriptfullname"/>
  87. ;//
  88. ;// The input files were:
  89. ;// <xsl:value-of select="@xmlfile"/>
  90. ;// <xsl:value-of select="@xslfile"/>
  91. ;//
  92. ;// It should be (or was) compiled by the Win32 MC.exe message compiler.
  93. ;//
  94. LanguageNames=(English=0x409:AGC0409)
  95. SeverityNames=(
  96. Success=0x0
  97. Info=0x1
  98. Warning=0x2
  99. Error=0x3
  100. )
  101. <xsl:apply-templates/>
  102. </xsl:template>
  103. <xsl:template match="EventGroup" xml:space="preserve">
  104. <xsl:for-each select="Event">
  105. MessageId=<xsl:value-of select="@id"/>
  106. Severity=<xsl:value-of select="@Severity"/>
  107. SymbolicName=MSG_<xsl:eval>GetPrefix(this)</xsl:eval><xsl:value-of select="@Name"/>
  108. Language=English
  109. <xsl:eval>GetMCFormat(this)</xsl:eval>
  110. .
  111. </xsl:for-each>
  112. <xsl:apply-templates select="EventGroup"/>
  113. </xsl:template>
  114. </xsl:stylesheet>