convert.xsl 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  3. <xsl:output method="html" indent="yes" version="5"/>
  4. <!-- Variable -->
  5. <xsl:variable name="title" select="/extract/name"/>
  6. <xsl:variable name="nbArticle" select="count(/extract/article)"/>
  7. <xsl:variable name="nbInpro" select="count(/extract/inproceedings)"/>
  8. <xsl:variable name="nbTotal" select="$nbArticle + $nbInpro"/>
  9. <xsl:variable name="nbCoauthor" select="count(/extract/coauthors/author)"/>
  10. <!-- Rendu Html -->
  11. <xsl:template match="/extract">
  12. <html>
  13. <head>
  14. <meta charset="UTF-8"/>
  15. <title>
  16. Extrait concernant
  17. <xsl:value-of select="$title"/>
  18. </title>
  19. </head>
  20. <body>
  21. <h1>
  22. Extrait concernant
  23. <xsl:value-of select="$title"/>
  24. </h1>
  25. <!--Les Coauteurs -->
  26. <h2>Coauteurs</h2>
  27. <div>
  28. <p>
  29. <xsl:value-of select="$title"/>
  30. a écrit avec
  31. <xsl:value-of select="$nbCoauthor"/> personne<xsl:if test="$nbCoauthor &gt; 1">s</xsl:if> :
  32. </p>
  33. <!-- recupération des coauteurs -->
  34. <ul>
  35. <xsl:for-each select="coauthors/author">
  36. <xsl:sort select="." data-type="text"/>
  37. <li>
  38. <xsl:value-of select="."/>
  39. </li>
  40. </xsl:for-each>
  41. </ul>
  42. </div>
  43. <!--Les Articles -->
  44. <h2>Articles</h2>
  45. <div>
  46. <xsl:choose>
  47. <xsl:when test="$nbArticle &gt; 0">
  48. <p>
  49. <xsl:value-of select="$title"/>
  50. a écrit
  51. <xsl:value-of select="count(article)"/>
  52. article<xsl:if test="$nbArticle &gt; 1">s</xsl:if> :
  53. </p>
  54. <ul>
  55. <xsl:for-each select="article">
  56. <xsl:sort select="year" data-type="text"/>
  57. <li>
  58. Article "<xsl:value-of select="title"/>", publié en <xsl:value-of
  59. select="year"/>,
  60. auteur<xsl:if
  61. test="count(author) &gt; 1">s
  62. </xsl:if> :
  63. <ul>
  64. <xsl:for-each select="author">
  65. <li>
  66. <xsl:value-of select="."/>
  67. </li>
  68. </xsl:for-each>
  69. </ul>
  70. </li>
  71. </xsl:for-each>
  72. </ul>
  73. </xsl:when>
  74. <xsl:otherwise>
  75. <p>
  76. <xsl:value-of select="$title"/> n'a pas écrit d'article.
  77. </p>
  78. </xsl:otherwise>
  79. </xsl:choose>
  80. </div>
  81. <!--Les InProceedings-->
  82. <h2>InProceeding</h2>
  83. <div>
  84. <xsl:choose>
  85. <xsl:when test="$nbInpro &gt; 0">
  86. <p>
  87. <xsl:value-of select="$title"/>
  88. a écrit
  89. <xsl:value-of select="$nbInpro"/>
  90. article<xsl:if test="$nbInpro &gt; 1">s</xsl:if> de type inproceeding :
  91. </p>
  92. <ul>
  93. <xsl:for-each select="inproceedings">
  94. <xsl:sort select="year" data-type="text"/>
  95. <li>
  96. InProceeding article "<xsl:value-of select="title"/>", publié en <xsl:value-of
  97. select="year"/>, auteur<xsl:if test="count(author) &gt; 1">s</xsl:if> :
  98. <ul>
  99. <xsl:for-each select="author">
  100. <li>
  101. <xsl:value-of select="."/>
  102. </li>
  103. </xsl:for-each>
  104. </ul>
  105. </li>
  106. </xsl:for-each>
  107. </ul>
  108. </xsl:when>
  109. <xsl:otherwise>
  110. <p>
  111. <xsl:value-of select="$title"/> n'a pas écrit d'article de type inproceedings.
  112. </p>
  113. </xsl:otherwise>
  114. </xsl:choose>
  115. </div>
  116. <!-- Statistique -->
  117. <h3>Statistiques sur les articles</h3>
  118. <ul>
  119. <li>Il y a
  120. <xsl:value-of select="$nbArticle"/> article<xsl:if test="$nbArticle &gt; 1">s</xsl:if>.
  121. </li>
  122. <li>Il y a
  123. <xsl:value-of select="$nbInpro"/> article<xsl:if test="$nbInpro &gt; 1">s</xsl:if> de type
  124. Inprocessing.
  125. </li>
  126. <li>Il y a
  127. <xsl:value-of select="$nbTotal"/> article<xsl:if test="$nbTotal &gt; 1">s</xsl:if> de tous les
  128. types.
  129. </li>
  130. <xsl:for-each select="article/year[not(preceding::year/. = .)]">
  131. <xsl:sort select="."/>
  132. <xsl:variable name="idYear">
  133. <xsl:value-of select="."/>
  134. </xsl:variable>
  135. <li>En <xsl:value-of select="$idYear"/>, il y a eu
  136. <xsl:value-of select="count(/extract/article[year = $idYear])"/> article<xsl:if
  137. test="count(/extract/article[year = $idYear]) &gt; 1">s</xsl:if>.
  138. </li>
  139. </xsl:for-each>
  140. <xsl:for-each select="inproceedings/year[not(preceding::year/. = .)]">
  141. <xsl:sort select="."/>
  142. <xsl:variable name="idYear">
  143. <xsl:value-of select="."/>
  144. </xsl:variable>
  145. <li>En <xsl:value-of select="."/>, il y a eu
  146. <xsl:value-of select="count(/extract/inproceedings[year = $idYear])"/> article<xsl:if
  147. test="count(/extract/inproceedings[year = $idYear]) &gt; 1">s
  148. </xsl:if> de type inproceedings.
  149. </li>
  150. </xsl:for-each>
  151. </ul>
  152. </body>
  153. </html>
  154. </xsl:template>
  155. </xsl:stylesheet>