Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- lien xml: https://drive.google.com/file/d/1FBjrUK_rXLWJnZpNz8_LAieaEHnKQfJt/view
- Qst 1, 2: https://gyazo.com/d61c2b82617b46355fe68887b7c4a3ab
- Qst 3, 4: https://gyazo.com/94ead5870beac1fc62d8ec56b715ca06
- solutions:
- ################################### Qst1 #
- <?xml version="1.0" encoding="UTF-8"?>
- <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
- <xs:element name="matchs" type="matchs_type"/>
- <xs:complexType name="matchs_type">
- <xs:sequence>
- <xs:element name="match" type="match_type" maxOccurs="unbounded"/>
- </xs:sequence>
- </xs:complexType>
- <xs:complexType name="match_type">
- <xs:sequence>
- <xs:element name="stade" type="stade_type"/>
- <xs:element name="équipe" type="équipe_type" minOccurs="2" maxOccurs="2"/>
- </xs:sequence>
- <xs:attribute name="numéro" type="xs:integer"/>
- <xs:attribute name="date" type="xs:date"/>
- <xs:attribute name="heure" type="xs:string"/> <!-- check -->
- <xs:attribute name="tour" type="xs:string"/>
- </xs:complexType>
- <xs:complexType name="stade_type">
- <xs:simpleContent>
- <xs:extension base="xs:string">
- <xs:attribute name="nom" type="xs:string"/>
- <xs:attribute name="ville" type="xs:string"/>
- </xs:extension>
- </xs:simpleContent>
- </xs:complexType>
- <xs:complexType name="équipe_type">
- <xs:sequence>
- <xs:element name="but" type="but_type" minOccurs="0" maxOccurs="unbounded"/>
- </xs:sequence>
- <xs:attribute name="nom" type="xs:string"/>
- <xs:attribute name="score" type="xs:integer"/>
- <xs:attribute name="penalties" type="xs:integer"/>
- </xs:complexType>
- <xs:complexType name="but_type">
- <xs:simpleContent>
- <xs:extension base="xs:string">
- <xs:attribute name="minute" type="xs:string" use="required"/>
- <xs:attribute name="buteur" type="xs:string" use="required"/>
- <xs:attribute name="passeur" type="xs:string"/>
- <xs:attribute name="csc" type="xs:boolean" default="true"/>
- <xs:attribute name="penalty" type="xs:boolean" default="true"/>
- </xs:extension>
- </xs:simpleContent>
- </xs:complexType>
- </xs:schema>
- ################################### Qst2 #
- <?xml version="1.0" encoding="UTF-8"?>
- <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- xmlns:xs="http://www.w3.org/2001/XMLSchema"
- exclude-result-prefixes="xs"
- version="2.0">
- <xsl:output method="html" indent="yes"/>
- <xsl:template match="/matchs">
- <html>
- <head/>
- <body>
- <table border="1" style="border-collapse: collapse;">
- <thead>
- <th>Tour</th>
- <th>Nombre de matchs joués</th>
- <th>Nombre de buts marqués</th>
- <th>Nombre de buts marqués CSC</th>
- <th>Nombre de buts marqués en penalty</th>
- </thead>
- <tbody>
- <xsl:for-each-group select="//match" group-by="@tour">
- <tr>
- <td>
- <xsl:value-of select="current-grouping-key()"/>
- </td>
- <td>
- <xsl:value-of select="count(current-group())"/>
- </td>
- <td>
- <xsl:value-of select="count(current-group()//but)"/>
- </td>
- <td>
- <xsl:value-of select="count(current-group()//@csc)"/>
- </td>
- <td>
- <xsl:value-of select="count(current-group()//@penalty)"/>
- </td>
- </tr>
- </xsl:for-each-group>
- </tbody>
- </table>
- </body>
- </html>
- </xsl:template>
- </xsl:stylesheet>
- ################################### Qst3 #
- <?xml version="1.0" encoding="UTF-8"?>
- <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- xmlns:xs="http://www.w3.org/2001/XMLSchema"
- exclude-result-prefixes="xs"
- version="2.0">
- <xsl:output method="text" indent="yes"/>
- <xsl:template match="/matchs">
- <xsl:text>[</xsl:text>
- <xsl:for-each-group select="//équipe" group-by="./but/@passeur">
- <xsl:text>{</xsl:text>
- "joueur": "<xsl:value-of select="current-grouping-key()"/>",
- "pays": "<xsl:value-of select="current-group()/@nom"/>",
- "nombre_passes": <xsl:value-of select="count(current-group())"/>
- <xsl:text>}</xsl:text><xsl:if test="position() ne last()">,</xsl:if>
- </xsl:for-each-group>
- <xsl:text>]</xsl:text>
- </xsl:template>
- </xsl:stylesheet>
- ################################### Qst4 #
- let $match := doc("matchs-russie-2018")//match
- return <buteurs>
- {
- for $joueur in $match//but/@buteur
- group by $joueur
- let $nbrButs := count( $match//but[@buteur = $joueur and not(@csc)] )
- order by $nbrButs descending
- where $nbrButs > 0
- return <joueur nom = "{$joueur}" pays="{
- distinct-values($match/équipe[but/@buteur = $joueur and not(but/@csc)]/@nom)
- }" nombre_buts = "{$nbrButs}"/>
- }
- </buteurs>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement