Loquicom 5 lat temu
rodzic
commit
109c5bff3d
1 zmienionych plików z 135 dodań i 0 usunięć
  1. 135 0
      convert.xsl

+ 135 - 0
convert.xsl

@@ -0,0 +1,135 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+  <xsl:output method="html" indent="yes"/>
+
+  <!-- Variable -->
+  <xsl:variable name="title" select="/extract/name" />
+  <xsl:variable name="nbArticle" select="count(/extract/article)" />
+  <xsl:variable name="nbInpro" select="count(/extract/inproceedings)" />
+  <xsl:variable name="nbTotal" select="$nbArticle + $nbInpro" />
+  <xsl:variable name="nbCoauthor" select="count(/extract/coauthors/author)" />
+
+  <!-- Rendu Html -->
+  <!-- <!DOCTYPE html> -->
+  <!--<html xsl:version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> -->
+
+  <xsl:template match="/extract">
+
+    <head>
+      <meta charset="UTF-8"/>
+      <title>
+        <xsl:value-of select="$title" />
+      </title>
+    </head>
+
+    <body>
+
+      <h1>
+        <xsl:value-of select="$title" />
+      </h1>
+
+      <!--Les Coauteurs -->
+      <h2>Coauteurs</h2>
+      <div>
+        <p>
+          <xsl:value-of select="$title" />
+          a écrit avec
+          <xsl:value-of select="$nbCoauthor"/> auteur<xsl:if test="$nbCoauthor &gt; 1">s</xsl:if> :
+        </p>
+
+        <!-- recupération des coauteurs -->
+        <ul>
+          <xsl:for-each select="coauthors/author">
+            <xsl:sort select="." data-type="text" />
+            <li>
+              <xsl:value-of select="." />
+            </li>
+          </xsl:for-each>
+        </ul>
+
+      </div>
+
+      <!--Les Articles -->
+      <h2>Articles</h2>
+      <div>
+        <p>
+          <xsl:value-of select="$title" />
+          a écrit 
+          <xsl:value-of select="count(article)" /> 
+          article<xsl:if test="$nbArticle &gt; 1">s</xsl:if> :
+        </p>
+
+        <ul>
+          <xsl:for-each select="article">
+            <xsl:sort select="year" data-type="text" />
+            <li>
+              Article "<xsl:value-of select="title" />", publié en <xsl:value-of select="year" />, auteur<xsl:if test="count(author) &gt; 1">s</xsl:if> :
+              <ul>
+                <xsl:for-each select="author">
+                  <li>
+                    <xsl:value-of select="." />
+                  </li>
+                </xsl:for-each>
+              </ul>
+            </li>
+          </xsl:for-each>
+        </ul>
+
+      </div>
+
+      <!--Les InProceedings-->
+      <h2>InProceeding</h2>
+      <div>
+        <xsl:choose>
+          <xsl:when test="$nbInpro &gt; 0">
+            <p>
+              <xsl:value-of select="$title" />
+              a écrit 
+              <xsl:value-of select="$nbInpro" />
+              article<xsl:if test="$nbInpro &gt; 1">s</xsl:if> de type inproceeding :
+            </p>
+            <ul>
+              <xsl:for-each select="inproceedings">
+                <xsl:sort select="year" data-type="text" />
+                <li>
+                  InProceeding article "<xsl:value-of select="title" />", publié en <xsl:value-of select="year" />, auteur<xsl:if test="count(author) &gt; 1">s</xsl:if> :
+                  <ul>
+                    <xsl:for-each select="author">
+                      <li>
+                        <xsl:value-of select="." />
+                      </li>
+                    </xsl:for-each>
+                  </ul>
+                </li>
+              </xsl:for-each>
+            </ul>
+          </xsl:when>
+          <xsl:otherwise>
+            <p><xsl:value-of select="$title" /> n'a pas d'article de type inproceedings.</p>
+          </xsl:otherwise>
+        </xsl:choose>
+      </div>
+
+      <!-- Statistique -->
+      <h3>Statistiques sur les articles</h3>
+      <ul>
+        <li>Il y a <xsl:value-of select="$nbArticle" /> article<xsl:if test="$nbArticle &gt; 1">s</xsl:if>.</li>
+        <li>Il y a <xsl:value-of select="$nbInpro" /> article<xsl:if test="$nbInpro &gt; 1">s</xsl:if> de type Inprocessing.</li>
+        <li>Il y a <xsl:value-of select="$nbTotal" /> article<xsl:if test="$nbTotal &gt; 1">s</xsl:if> de tous les types.</li>
+        <xsl:for-each select="article">
+          <xsl:sort select="year"/>
+          <li>En <xsl:value-of select="year" />, il y a eu <xsl:value-of select="count(../article[year = year])" /> article.</li>
+        </xsl:for-each>
+        <xsl:for-each select="inproceedings">
+          <xsl:sort select="year"/>
+          <li>En <xsl:value-of select="year" />, il y a eu <xsl:value-of select="count(../inproceedings[year = ./year])" /> article.</li>
+        </xsl:for-each>
+      </ul>
+
+    </body>
+
+  </xsl:template>
+  
+  <!--</html>-->
+
+</xsl:stylesheet>