UpgradeReport.xslt 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538
  1. <?xml version="1.0" encoding="utf-8" ?>
  2. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl='urn:schemas-microsoft-com:xslt'>
  3. <xsl:output omit-xml-declaration="yes" />
  4. <!-- Keys -->
  5. <xsl:key name="ProjectKey" match="Event" use="@Project" />
  6. <!-- String split template -->
  7. <xsl:template name="SplitString">
  8. <xsl:param name="source" select="''" />
  9. <xsl:param name="separator" select="','" />
  10. <xsl:if test="not($source = '' or $separator = '')">
  11. <xsl:variable name="head" select="substring-before(concat($source, $separator), $separator)" />
  12. <xsl:variable name="tail" select="substring-after($source, $separator)" />
  13. <part>
  14. <xsl:value-of select="$head"/>
  15. </part>
  16. <xsl:call-template name="SplitString">
  17. <xsl:with-param name="source" select="$tail" />
  18. <xsl:with-param name="separator" select="$separator" />
  19. </xsl:call-template>
  20. </xsl:if>
  21. </xsl:template>
  22. <!-- Intermediate Templates -->
  23. <xsl:template match="UpgradeReport" mode="ProjectOverviewXML">
  24. <Projects>
  25. <xsl:for-each select="Event[generate-id(.) = generate-id(key('ProjectKey', @Project))]">
  26. <Project>
  27. <xsl:variable name="pNode" select="current()" />
  28. <xsl:variable name="errorCount" select="count(../Event[@Project = current()/@Project and @ErrorLevel=2])" />
  29. <xsl:variable name="warningCount" select="count(../Event[@Project = current()/@Project and @ErrorLevel=1])" />
  30. <xsl:variable name="messageCount" select="count(../Event[@Project = current()/@Project and @ErrorLevel=0])" />
  31. <xsl:variable name="pathSplitSeparator">
  32. <xsl:text>\</xsl:text>
  33. </xsl:variable>
  34. <xsl:variable name="projectName">
  35. <xsl:choose>
  36. <xsl:when test="@Project = ''">Solution</xsl:when>
  37. <xsl:otherwise>
  38. <xsl:value-of select="@Project"/>
  39. </xsl:otherwise>
  40. </xsl:choose>
  41. </xsl:variable>
  42. <xsl:attribute name="IsSolution">
  43. <xsl:value-of select="@Project = ''"/>
  44. </xsl:attribute>
  45. <xsl:attribute name="Project">
  46. <xsl:value-of select="$projectName"/>
  47. </xsl:attribute>
  48. <xsl:attribute name="ProjectDisplayName">
  49. <!-- Sometimes it is possible to have project name set to a path over a real project name,
  50. we split the string on '\' and if we end up with >1 part in the resulting tokens set
  51. we format the ProjectDisplayName as ..\prior\last -->
  52. <xsl:variable name="pathTokens">
  53. <xsl:call-template name="SplitString">
  54. <xsl:with-param name="source" select="$projectName" />
  55. <xsl:with-param name="separator" select="$pathSplitSeparator" />
  56. </xsl:call-template>
  57. </xsl:variable>
  58. <xsl:choose>
  59. <xsl:when test="count(msxsl:node-set($pathTokens)/part) > 1">
  60. <xsl:value-of select="concat('..', $pathSplitSeparator, msxsl:node-set($pathTokens)/part[last() - 1], $pathSplitSeparator, msxsl:node-set($pathTokens)/part[last()])"/>
  61. </xsl:when>
  62. <xsl:otherwise>
  63. <xsl:value-of select="$projectName"/>
  64. </xsl:otherwise>
  65. </xsl:choose>
  66. </xsl:attribute>
  67. <xsl:attribute name="ProjectSafeName">
  68. <xsl:value-of select="translate($projectName, '\', '-')"/>
  69. </xsl:attribute>
  70. <xsl:attribute name="Solution">
  71. <xsl:value-of select="/UpgradeReport/Properties/Property[@Name='Solution']/@Value"/>
  72. </xsl:attribute>
  73. <xsl:attribute name="Source">
  74. <xsl:value-of select="@Source"/>
  75. </xsl:attribute>
  76. <xsl:attribute name="Status">
  77. <xsl:choose>
  78. <xsl:when test="$errorCount > 0">Error</xsl:when>
  79. <xsl:when test="$warningCount > 0">Warning</xsl:when>
  80. <xsl:otherwise>Success</xsl:otherwise>
  81. </xsl:choose>
  82. </xsl:attribute>
  83. <xsl:attribute name="ErrorCount">
  84. <xsl:value-of select="$errorCount" />
  85. </xsl:attribute>
  86. <xsl:attribute name="WarningCount">
  87. <xsl:value-of select="$warningCount" />
  88. </xsl:attribute>
  89. <xsl:attribute name="MessageCount">
  90. <xsl:value-of select="$messageCount" />
  91. </xsl:attribute>
  92. <xsl:attribute name="TotalCount">
  93. <xsl:value-of select="$errorCount + $warningCount + $messageCount"/>
  94. </xsl:attribute>
  95. <xsl:for-each select="../Event[@Project = $pNode/@Project and @ErrorLevel=3]">
  96. <ConversionStatus>
  97. <xsl:value-of select="@Description"/>
  98. </ConversionStatus>
  99. </xsl:for-each>
  100. <Messages>
  101. <xsl:for-each select="../Event[@Project = $pNode/@Project and @ErrorLevel&lt;3]">
  102. <Message>
  103. <xsl:attribute name="Level">
  104. <xsl:value-of select="@ErrorLevel" />
  105. </xsl:attribute>
  106. <xsl:attribute name="Status">
  107. <xsl:choose>
  108. <xsl:when test="@ErrorLevel = 0">Message</xsl:when>
  109. <xsl:when test="@ErrorLevel = 1">Warning</xsl:when>
  110. <xsl:when test="@ErrorLevel = 2">Error</xsl:when>
  111. <xsl:otherwise>Message</xsl:otherwise>
  112. </xsl:choose>
  113. </xsl:attribute>
  114. <xsl:attribute name="Source">
  115. <xsl:value-of select="@Source"/>
  116. </xsl:attribute>
  117. <xsl:attribute name="Message">
  118. <xsl:value-of select="@Description"/>
  119. </xsl:attribute>
  120. </Message>
  121. </xsl:for-each>
  122. </Messages>
  123. </Project>
  124. </xsl:for-each>
  125. </Projects>
  126. </xsl:template>
  127. <!-- Project Overview template -->
  128. <xsl:template match="Projects" mode="ProjectOverview">
  129. <table>
  130. <tr>
  131. <th></th>
  132. <th _locID="ProjectTableHeader">Project</th>
  133. <th _locID="PathTableHeader">Path</th>
  134. <th _locID="ErrorsTableHeader">Errors</th>
  135. <th _locID="WarningsTableHeader">Warnings</th>
  136. <th _locID="MessagesTableHeader">Messages</th>
  137. </tr>
  138. <xsl:for-each select="Project">
  139. <xsl:sort select="@ErrorCount" order="descending" />
  140. <xsl:sort select="@WarningCount" order="descending" />
  141. <!-- Always make solution last within a group -->
  142. <xsl:sort select="@IsSolution" order="ascending" />
  143. <xsl:sort select="@ProjectSafeName" order="ascending" />
  144. <tr>
  145. <td>
  146. <img width="16" height="16">
  147. <xsl:attribute name="src">
  148. <xsl:choose>
  149. <xsl:when test="@Status = 'Error'">_UpgradeReport_Files\UpgradeReport_Error.png</xsl:when>
  150. <xsl:when test="@Status = 'Warning'">_UpgradeReport_Files\UpgradeReport_Warning.png</xsl:when>
  151. <xsl:when test="@Status = 'Success'">_UpgradeReport_Files\UpgradeReport_Success.png</xsl:when>
  152. </xsl:choose>
  153. </xsl:attribute>
  154. <xsl:attribute name="alt">
  155. <xsl:value-of select="@Status" />
  156. </xsl:attribute>
  157. </img>
  158. </td>
  159. <td>
  160. <strong>
  161. <a>
  162. <xsl:attribute name="href">
  163. <xsl:value-of select="concat('#', @ProjectSafeName)"/>
  164. </xsl:attribute>
  165. <xsl:value-of select="@ProjectDisplayName" />
  166. </a>
  167. </strong>
  168. </td>
  169. <td>
  170. <xsl:value-of select="@Source" />
  171. </td>
  172. <td class="textCentered">
  173. <a>
  174. <xsl:if test="@ErrorCount > 0">
  175. <xsl:attribute name="href">
  176. <xsl:value-of select="concat('#', @ProjectSafeName, 'Error')"/>
  177. </xsl:attribute>
  178. </xsl:if>
  179. <xsl:value-of select="@ErrorCount" />
  180. </a>
  181. </td>
  182. <td class="textCentered">
  183. <a>
  184. <xsl:if test="@WarningCount > 0">
  185. <xsl:attribute name="href">
  186. <xsl:value-of select="concat('#', @ProjectSafeName, 'Warning')"/>
  187. </xsl:attribute>
  188. </xsl:if>
  189. <xsl:value-of select="@WarningCount" />
  190. </a>
  191. </td>
  192. <td class="textCentered">
  193. <a href="#">
  194. <xsl:if test="@MessageCount > 0">
  195. <xsl:attribute name="onclick">
  196. <xsl:variable name="apos">
  197. <xsl:text>'</xsl:text>
  198. </xsl:variable>
  199. <xsl:variable name="JS" select="concat('ScrollToFirstVisibleMessage(', $apos, @ProjectSafeName, $apos, ')')" />
  200. <xsl:value-of select="concat($JS, '; return false;')"/>
  201. </xsl:attribute>
  202. </xsl:if>
  203. <xsl:value-of select="@MessageCount" />
  204. </a>
  205. </td>
  206. </tr>
  207. </xsl:for-each>
  208. </table>
  209. </xsl:template>
  210. <!-- Show messages row -->
  211. <xsl:template match="Project" mode="ProjectShowMessages">
  212. <tr>
  213. <xsl:attribute name="name">
  214. <xsl:value-of select="concat('MessageRowHeaderShow', @ProjectSafeName)"/>
  215. </xsl:attribute>
  216. <td>
  217. <img width="16" height="16" src="_UpgradeReport_Files\UpgradeReport_Information.png" />
  218. </td>
  219. <td class="messageCell">
  220. <xsl:variable name="apos">
  221. <xsl:text>'</xsl:text>
  222. </xsl:variable>
  223. <xsl:variable name="toggleRowsJS" select="concat('ToggleMessageVisibility(', $apos, @ProjectSafeName, $apos, ')')" />
  224. <a _locID="ShowAdditionalMessages" href="#">
  225. <xsl:attribute name="name">
  226. <xsl:value-of select="concat(@ProjectSafeName, 'Message')"/>
  227. </xsl:attribute>
  228. <xsl:attribute name="onclick">
  229. <xsl:value-of select="concat($toggleRowsJS, '; return false;')"/>
  230. </xsl:attribute>
  231. Show <xsl:value-of select="@MessageCount" /> additional messages
  232. </a>
  233. </td>
  234. </tr>
  235. </xsl:template>
  236. <!-- Hide messages row -->
  237. <xsl:template match="Project" mode="ProjectHideMessages">
  238. <tr style="display: none">
  239. <xsl:attribute name="name">
  240. <xsl:value-of select="concat('MessageRowHeaderHide', @ProjectSafeName)"/>
  241. </xsl:attribute>
  242. <td>
  243. <img width="16" height="16" src="_UpgradeReport_Files\UpgradeReport_Information.png" />
  244. </td>
  245. <td class="messageCell">
  246. <xsl:variable name="apos">
  247. <xsl:text>'</xsl:text>
  248. </xsl:variable>
  249. <xsl:variable name="toggleRowsJS" select="concat('ToggleMessageVisibility(', $apos, @ProjectSafeName, $apos, ')')" />
  250. <a _locID="HideAdditionalMessages" href="#">
  251. <xsl:attribute name="name">
  252. <xsl:value-of select="concat(@ProjectSafeName, 'Message')"/>
  253. </xsl:attribute>
  254. <xsl:attribute name="onclick">
  255. <xsl:value-of select="concat($toggleRowsJS, '; return false;')"/>
  256. </xsl:attribute>
  257. Hide <xsl:value-of select="@MessageCount" /> additional messages
  258. </a>
  259. </td>
  260. </tr>
  261. </xsl:template>
  262. <!-- Message row templates -->
  263. <xsl:template match="Message">
  264. <tr>
  265. <xsl:attribute name="name">
  266. <xsl:value-of select="concat(@Status, 'RowClass', ../../@ProjectSafeName)"/>
  267. </xsl:attribute>
  268. <xsl:if test="@Level = 0">
  269. <xsl:attribute name="style">display: none</xsl:attribute>
  270. </xsl:if>
  271. <td>
  272. <a>
  273. <xsl:attribute name="name">
  274. <xsl:value-of select="concat(../../@ProjectSafeName, @Status)"/>
  275. </xsl:attribute>
  276. </a>
  277. <img width="16" height="16">
  278. <xsl:attribute name="src">
  279. <xsl:choose>
  280. <xsl:when test="@Status = 'Error'">_UpgradeReport_Files\UpgradeReport_Error.png</xsl:when>
  281. <xsl:when test="@Status = 'Warning'">_UpgradeReport_Files\UpgradeReport_Warning.png</xsl:when>
  282. <xsl:when test="@Status = 'Message'">_UpgradeReport_Files\UpgradeReport_Information.png</xsl:when>
  283. </xsl:choose>
  284. </xsl:attribute>
  285. <xsl:attribute name="alt">
  286. <xsl:value-of select="@Status" />
  287. </xsl:attribute>
  288. </img>
  289. </td>
  290. <td class="messageCell">
  291. <strong>
  292. <xsl:value-of select="@Source"/>:
  293. </strong>
  294. <span>
  295. <xsl:value-of select="@Message"/>
  296. </span>
  297. </td>
  298. </tr>
  299. </xsl:template>
  300. <!-- Project Details Template -->
  301. <xsl:template match="Projects" mode="ProjectDetails">
  302. <xsl:for-each select="Project">
  303. <xsl:sort select="@ErrorCount" order="descending" />
  304. <xsl:sort select="@WarningCount" order="descending" />
  305. <!-- Always make solution last within a group -->
  306. <xsl:sort select="@IsSolution" order="ascending" />
  307. <xsl:sort select="@ProjectSafeName" order="ascending" />
  308. <a>
  309. <xsl:attribute name="name">
  310. <xsl:value-of select="@ProjectSafeName"/>
  311. </xsl:attribute>
  312. </a>
  313. <h3>
  314. <xsl:value-of select="@ProjectDisplayName"/>
  315. </h3>
  316. <table>
  317. <tr>
  318. <xsl:attribute name="id">
  319. <xsl:value-of select="concat(@ProjectSafeName, 'HeaderRow')"/>
  320. </xsl:attribute>
  321. <th></th>
  322. <th class="messageCell" _locID="MessageTableHeader">Message</th>
  323. </tr>
  324. <!-- Errors and warnings -->
  325. <xsl:for-each select="Messages/Message[@Level &gt; 0]">
  326. <xsl:sort select="@Level" order="descending" />
  327. <xsl:apply-templates select="." />
  328. </xsl:for-each>
  329. <xsl:if test="@MessageCount > 0">
  330. <xsl:apply-templates select="." mode="ProjectShowMessages" />
  331. </xsl:if>
  332. <!-- Messages -->
  333. <xsl:for-each select="Messages/Message[@Level = 0]">
  334. <xsl:apply-templates select="." />
  335. </xsl:for-each>
  336. <xsl:choose>
  337. <!-- Additional row as a 'place holder' for 'Show/Hide' additional messages -->
  338. <xsl:when test="@MessageCount > 0">
  339. <xsl:apply-templates select="." mode="ProjectHideMessages" />
  340. </xsl:when>
  341. <!-- No messages at all, show blank row -->
  342. <xsl:when test="@TotalCount = 0">
  343. <tr>
  344. <td>
  345. <img width="16" height="16" src="_UpgradeReport_Files\UpgradeReport_Information.png" />
  346. </td>
  347. <td class="messageCell" _locID="NoMessagesRow">
  348. <xsl:value-of select="@ProjectDisplayName" /> logged no messages.
  349. </td>
  350. </tr>
  351. </xsl:when>
  352. </xsl:choose>
  353. </table>
  354. </xsl:for-each>
  355. </xsl:template>
  356. <!-- Document, matches "UpgradeReport" -->
  357. <xsl:template match="UpgradeReport">
  358. <!-- Output doc type the 'Mark of the web' which disabled prompting to run JavaScript from local HTML Files in IE -->
  359. <!-- NOTE: The whitespace around the 'Mark of the web' is important it must be exact -->
  360. <xsl:text disable-output-escaping="yes"><![CDATA[<!DOCTYPE html>
  361. <!-- saved from url=(0014)about:internet -->
  362. ]]>
  363. </xsl:text>
  364. <html>
  365. <head>
  366. <meta content="en-us" http-equiv="Content-Language" />
  367. <meta content="text/html; charset=utf-16" http-equiv="Content-Type" />
  368. <link type="text/css" rel="stylesheet" href="_UpgradeReport_Files\UpgradeReport.css" />
  369. <title _locID="ConversionReport0">
  370. Migration Report
  371. </title>
  372. <script type="text/javascript" language="javascript">
  373. <xsl:text disable-output-escaping="yes">
  374. <![CDATA[
  375. // Startup
  376. // Hook up the the loaded event for the document/window, to linkify the document content
  377. var startupFunction = function() { linkifyElement("messages"); };
  378. if(window.attachEvent)
  379. {
  380. window.attachEvent('onload', startupFunction);
  381. }
  382. else if (window.addEventListener)
  383. {
  384. window.addEventListener('load', startupFunction, false);
  385. }
  386. else
  387. {
  388. document.addEventListener('load', startupFunction, false);
  389. }
  390. // Toggles the visibility of table rows with the specified name
  391. function toggleTableRowsByName(name)
  392. {
  393. var allRows = document.getElementsByTagName('tr');
  394. for (i=0; i < allRows.length; i++)
  395. {
  396. var currentName = allRows[i].getAttribute('name');
  397. if(!!currentName && currentName.indexOf(name) == 0)
  398. {
  399. var isVisible = allRows[i].style.display == '';
  400. isVisible ? allRows[i].style.display = 'none' : allRows[i].style.display = '';
  401. }
  402. }
  403. }
  404. function scrollToFirstVisibleRow(name)
  405. {
  406. var allRows = document.getElementsByTagName('tr');
  407. for (i=0; i < allRows.length; i++)
  408. {
  409. var currentName = allRows[i].getAttribute('name');
  410. var isVisible = allRows[i].style.display == '';
  411. if(!!currentName && currentName.indexOf(name) == 0 && isVisible)
  412. {
  413. allRows[i].scrollIntoView(true);
  414. return true;
  415. }
  416. }
  417. return false;
  418. }
  419. // Linkifies the specified text content, replaces candidate links with html links
  420. function linkify(text)
  421. {
  422. if(!text || 0 === text.length)
  423. {
  424. return text;
  425. }
  426. // Find {DriveLetter}:\Something or \\{uncshare}\something strings and replace them with file:/// links
  427. // It expects that a path ends in .extension, and that that extension does not have a space within it,
  428. // it does this as not to greedily match in the case of "Text C:\foo\file.txt some other text"
  429. var filePath = /([A-z]\:|\\{2}[A-z].+)\\([^<]+)\.([^<\s]+)/gi;
  430. // Find http, https and ftp links and replace them with hyper links
  431. var urlLink = /(http|https|ftp)\:\/\/[a-zA-Z0-9\-\.]+(:[a-zA-Z0-9]*)?\/?([a-zA-Z0-9\-\._\?\,\/\\\+&%\$#\=~;\{\}])*/gi;
  432. return text.replace(filePath, '<a class="localLink" href="file:///$&">$&</a>')
  433. .replace(urlLink, '<a href="$&">$&</a>') ;
  434. }
  435. // Linkifies the specified element by ID
  436. function linkifyElement(id)
  437. {
  438. var element = document.getElementById(id);
  439. if(!!element)
  440. {
  441. element.innerHTML = linkify(element.innerHTML);
  442. }
  443. }
  444. function ToggleMessageVisibility(projectName)
  445. {
  446. if(!projectName || 0 === projectName.length)
  447. {
  448. return;
  449. }
  450. toggleTableRowsByName("MessageRowClass" + projectName);
  451. toggleTableRowsByName('MessageRowHeaderShow' + projectName);
  452. toggleTableRowsByName('MessageRowHeaderHide' + projectName);
  453. }
  454. function ScrollToFirstVisibleMessage(projectName)
  455. {
  456. if(!projectName || 0 === projectName.length)
  457. {
  458. return;
  459. }
  460. // First try the 'Show messages' row
  461. if(!scrollToFirstVisibleRow('MessageRowHeaderShow' + projectName))
  462. {
  463. // Failed to find a visible row for 'Show messages', try an actual message row
  464. scrollToFirstVisibleRow('MessageRowClass' + projectName);
  465. }
  466. }
  467. ]]>
  468. </xsl:text>
  469. </script>
  470. </head>
  471. <body>
  472. <h1 _locID="ConversionReport">
  473. Migration Report - <xsl:value-of select="Properties/Property[@Name='Solution']/@Value"/>
  474. </h1>
  475. <div id="content">
  476. <h2 _locID="OverviewTitle">Overview</h2>
  477. <xsl:variable name="projectOverview">
  478. <xsl:apply-templates select="self::node()" mode="ProjectOverviewXML" />
  479. </xsl:variable>
  480. <div id="overview">
  481. <xsl:apply-templates select="msxsl:node-set($projectOverview)/*" mode="ProjectOverview" />
  482. </div>
  483. <h2 _locID="SolutionAndProjectsTitle">Solution and projects</h2>
  484. <div id="messages">
  485. <xsl:apply-templates select="msxsl:node-set($projectOverview)/*" mode="ProjectDetails" />
  486. </div>
  487. </div>
  488. </body>
  489. </html>
  490. </xsl:template>
  491. </xsl:stylesheet>