UpgradeReport.xslt 22 KB

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