Advertisement
clevernessisamyth

Controle 1 19/20 BD2C - WS, XML - JSON

Feb 7th, 2021 (edited)
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
XML 5.73 KB | None | 0 0
  1. lien xml: https://drive.google.com/file/d/1FBjrUK_rXLWJnZpNz8_LAieaEHnKQfJt/view
  2. Qst 1, 2: https://gyazo.com/d61c2b82617b46355fe68887b7c4a3ab
  3. Qst 3, 4: https://gyazo.com/94ead5870beac1fc62d8ec56b715ca06
  4. solutions:
  5. ################################### Qst1 #
  6. <?xml version="1.0" encoding="UTF-8"?>
  7. <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
  8.     <xs:element name="matchs" type="matchs_type"/>
  9.    
  10.     <xs:complexType name="matchs_type">
  11.         <xs:sequence>
  12.             <xs:element name="match" type="match_type" maxOccurs="unbounded"/>
  13.         </xs:sequence>
  14.     </xs:complexType>
  15.    
  16.     <xs:complexType name="match_type">
  17.         <xs:sequence>
  18.             <xs:element name="stade" type="stade_type"/>
  19.             <xs:element name="équipe" type="équipe_type" minOccurs="2" maxOccurs="2"/>
  20.         </xs:sequence>
  21.         <xs:attribute name="numéro" type="xs:integer"/>
  22.         <xs:attribute name="date" type="xs:date"/>
  23.         <xs:attribute name="heure" type="xs:string"/> <!-- check -->
  24.         <xs:attribute name="tour" type="xs:string"/>
  25.     </xs:complexType>
  26.    
  27.     <xs:complexType name="stade_type">
  28.         <xs:simpleContent>
  29.             <xs:extension base="xs:string">
  30.                 <xs:attribute name="nom" type="xs:string"/>
  31.                 <xs:attribute name="ville" type="xs:string"/>
  32.             </xs:extension>
  33.         </xs:simpleContent>
  34.     </xs:complexType>
  35.    
  36.     <xs:complexType name="équipe_type">
  37.         <xs:sequence>
  38.             <xs:element name="but" type="but_type" minOccurs="0" maxOccurs="unbounded"/>
  39.         </xs:sequence>
  40.         <xs:attribute name="nom" type="xs:string"/>
  41.         <xs:attribute name="score" type="xs:integer"/>
  42.         <xs:attribute name="penalties" type="xs:integer"/>
  43.     </xs:complexType>
  44.    
  45.     <xs:complexType name="but_type">
  46.        <xs:simpleContent>
  47.            <xs:extension base="xs:string">
  48.                <xs:attribute name="minute" type="xs:string" use="required"/>
  49.                <xs:attribute name="buteur" type="xs:string" use="required"/>
  50.                <xs:attribute name="passeur" type="xs:string"/>
  51.                <xs:attribute name="csc" type="xs:boolean" default="true"/>
  52.                <xs:attribute name="penalty" type="xs:boolean" default="true"/>
  53.            </xs:extension>
  54.        </xs:simpleContent>
  55.     </xs:complexType>
  56. </xs:schema>
  57.  
  58. ################################### Qst2 #
  59. <?xml version="1.0" encoding="UTF-8"?>
  60. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  61.    xmlns:xs="http://www.w3.org/2001/XMLSchema"
  62.    exclude-result-prefixes="xs"
  63.    version="2.0">
  64.     <xsl:output method="html" indent="yes"/>
  65.     <xsl:template match="/matchs">
  66.         <html>
  67.             <head/>
  68.             <body>
  69.                 <table border="1" style="border-collapse: collapse;">
  70.                     <thead>
  71.                         <th>Tour</th>
  72.                         <th>Nombre de matchs joués</th>
  73.                         <th>Nombre de buts marqués</th>
  74.                         <th>Nombre de buts marqués CSC</th>
  75.                         <th>Nombre de buts marqués en penalty</th>
  76.                     </thead>
  77.                     <tbody>
  78.                         <xsl:for-each-group select="//match" group-by="@tour">
  79.                             <tr>
  80.                                 <td>
  81.                                     <xsl:value-of select="current-grouping-key()"/>
  82.                                 </td>
  83.                                 <td>
  84.                                     <xsl:value-of select="count(current-group())"/>
  85.                                 </td>
  86.                                 <td>
  87.                                     <xsl:value-of select="count(current-group()//but)"/>
  88.                                 </td>
  89.                                 <td>
  90.                                     <xsl:value-of select="count(current-group()//@csc)"/>
  91.                                 </td>
  92.                                 <td>
  93.                                     <xsl:value-of select="count(current-group()//@penalty)"/>
  94.                                 </td>
  95.                             </tr>
  96.                         </xsl:for-each-group>
  97.                     </tbody>
  98.                 </table>
  99.             </body>
  100.         </html>
  101.     </xsl:template>
  102. </xsl:stylesheet>
  103.  
  104. ################################### Qst3 #
  105. <?xml version="1.0" encoding="UTF-8"?>
  106. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  107.    xmlns:xs="http://www.w3.org/2001/XMLSchema"
  108.    exclude-result-prefixes="xs"
  109.    version="2.0">
  110.     <xsl:output method="text" indent="yes"/>
  111.     <xsl:template match="/matchs">
  112.         <xsl:text>[</xsl:text>
  113.             <xsl:for-each-group select="//équipe" group-by="./but/@passeur">
  114.                 <xsl:text>{</xsl:text>
  115.                     "joueur": "<xsl:value-of select="current-grouping-key()"/>",
  116.                     "pays": "<xsl:value-of select="current-group()/@nom"/>",
  117.                     "nombre_passes": <xsl:value-of select="count(current-group())"/>
  118.                 <xsl:text>}</xsl:text><xsl:if test="position() ne last()">,</xsl:if>
  119.             </xsl:for-each-group>
  120.         <xsl:text>]</xsl:text>
  121.     </xsl:template>
  122. </xsl:stylesheet>
  123.  
  124.  
  125. ################################### Qst4 #
  126.   let $match := doc("matchs-russie-2018")//match
  127.   return <buteurs>
  128.     {
  129.       for $joueur in $match//but/@buteur
  130.       group by $joueur
  131.       let $nbrButs := count( $match//but[@buteur = $joueur and not(@csc)] )
  132.       order by $nbrButs descending
  133.       where $nbrButs > 0
  134.       return <joueur nom = "{$joueur}" pays="{
  135.        distinct-values($match/équipe[but/@buteur = $joueur and not(but/@csc)]/@nom)
  136.      }" nombre_buts = "{$nbrButs}"/>
  137.     }
  138.   </buteurs>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement