Meeskond Indiviid: Difference between revisions

From ICO wiki
Jump to navigationJump to search
Sluhtoja (talk | contribs)
Sluhtoja (talk | contribs)
Line 317: Line 317:
</source>
</source>


=xslt xml=
===xslt xml===
<source lang="xml" collapse="true" first-line="2">
<source lang="xml" collapse="true" first-line="2">
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

Revision as of 14:02, 1 April 2015

Meeskond Indiviid

Võrgurakendused 2: Hajussüsteemide loomine

Liikmed: Sten Luhtoja

XML

Siia tulevad nõutud XML´i tööd.

Baas.

<?xml version="1.0" encoding="utf-8" ?>
<võistlused>
  <võistlus id="1" date="2015-09-24" time="09:00:00" type="Seeriavõistlus">
    <name><![CDATA[Rahvapinks 3. etapp]]></name>
    <location linn="Tallinn" tanav="forelli" number="11">Kristiine Spordikeskus</location>
    <contacts>
      <contact type="phone">+3725845845146</contact>
      <contact type="e-mail">Rahvapinks3@etapp.ee</contact>
    </contacts>
    <osalejad>
      <osaleja sugu="male" birthdate="1995-09-02" name="Osaline Yks">
        <club><![CDATA[Klubitu]]></club>
        <contacts>
          <contact type="phone">+37258446</contact>
          <contact type="e-mail">osaline1@etapp.ee</contact>
        </contacts>
      </osaleja>
      <osaleja sugu="male" birthdate="1993-10-05" name="Osaline Kaks">
        <club><![CDATA[Tallinna vesi]]></club>
        <contacts>
          <contact type="e-mail">osaline2@etapp.ee</contact>
        </contacts>
      </osaleja>
    </osalejad>
  </võistlus>

  <võistlus id="2" date="2015-12-24" time="09:00:00" type="Seeriavõistlus">
    <name><![CDATA[Rahvapinks 5. etapp]]></name>
    <location linn="Tallinn" tanav="forelli" number="11">Kristiine Spordikeskus</location>
    <contacts>
      <contact type="phone">+3725845845146</contact>
      <contact type="e-mail">Rahvapinks4@etapp.ee</contact>
    </contacts>
    <osalejad>
      <osaleja sugu="male" birthdate="1995-09-02" name="Osaline Yks">
        <club><![CDATA[Klubitu]]></club>
        <contacts>
          <contact type="phone">+37258446</contact>
          <contact type="e-mail">osaline1@etapp.ee</contact>
        </contacts>
      </osaleja>
      <osaleja sugu="male" birthdate="1993-10-05" name="Osaline Kaks">
        <club><![CDATA[Tallinna vesi]]></club>
        <contacts>
          <contact type="e-mail">osaline2@etapp.ee</contact>
        </contacts>
      </osaleja>
      <osaleja sugu="female" birthdate="1234-09-02" name="Osaline vikks">
        <club><![CDATA[Klubitu]]></club>
        <contacts>
          <contact type="phone">+37258446</contact>
          <contact type="e-mail">osalinevikks@etapp.ee</contact>
        </contacts>
      </osaleja>
      <osaleja sugu="female" birthdate="1965-11-05" name="Osaline Kasssssks">
        <club><![CDATA[Parnu Elekter]]></club>
        <contacts>
          <contact type="e-mail">osalinekasssskss@etapp.ee</contact>
        </contacts>
      </osaleja>
    </osalejad>
  </võistlus>
  
  
  <võistlus id="3" date="2015-04-26" time="09:00:00" type="Karikavõistlus">
    <name><![CDATA[Rändkarikas jalgpallis]]></name>
    <location linn="Kärdla" tanav="Muhu" number="10b">Kärdla spordiväljak</location>
    <contacts>
      <contact type="phone">+37252</contact>
      <contact type="e-mail">Kärdla@voistlus.ee</contact>
    </contacts>
    <osalejad>
      <osaleja sugu="" birthdate="" name="Muhu kalamehed">
        <club>Muhu kalamehed</club>
        <contacts>
          <contact type="phone">+3725234567456</contact>
          <contact type="e-mail">kalamehed@muhu.ee</contact>
        </contacts>
      </osaleja>
      <osaleja sugu="" birthdate="" name="Hiiumaa viiuldajad">
        <club>Hiiumaa viiuldajad</club>
        <contacts>
          <contact type="e-mail">viiuldajad@hiiumaa.ee</contact>
        </contacts>
      </osaleja>
    </osalejad>
  </võistlus>
  
  
  <võistlus id="4" date="2016-11-26" time="10:00:00" type="Lahtised juhused">
    <name><![CDATA[Rändamisseiklus algajatele]]></name>
    <location linn="" tanav="" number="">Saaremaa tuulikud</location>
    <contacts>
      <contact type="phone"></contact>
      <contact type="e-mail"></contact>
    </contacts>
    <osalejad>
      <osaleja sugu="male" birthdate="1995-09-02" name="Osaline Yks">
        <club></club>
        <contacts>
          <contact type="phone">+37258446</contact>
          <contact type="e-mail">osaline1@etapp.ee</contact>
        </contacts>
      </osaleja>
      <osaleja sugu="male" birthdate="1993-10-05" name="Osaline Kaks">
        <club></club>
        <contacts>
          <contact type="e-mail">osaline2@etapp.ee</contact>
        </contacts>
      </osaleja>
    </osalejad>
  </võistlus>
  
  <võistlus id="5" date="2017-01-05" time="10:00:00" type="Seeriavõistlus">
    <name><![CDATA[Rahvapinks 3. etapp]]></name>
    <location linn="Tallinn" tanav="forelli" number="11">Kristiine Spordikeskus</location>
    <contacts>
      <contact type="phone">+3725845845146</contact>
      <contact type="e-mail">Rahvapinks3@etapp.ee</contact>
    </contacts>
    <osalejad>
      <osaleja sugu="male" birthdate="1995-09-02" name="Osaline Yks">
        <club><![CDATA[Klubitu]]></club>
        <contacts>
          <contact type="phone">+37258446</contact>
          <contact type="e-mail">osaline1@etapp.ee</contact>
        </contacts>
      </osaleja>
      <osaleja sugu="male" birthdate="1993-10-05" name="Osaline Kaks">
        <club><![CDATA[Tallinna vesi]]></club>
        <contacts>
          <contact type="e-mail">osaline2@etapp.ee</contact>
        </contacts>
      </osaleja>
    </osalejad>
  </võistlus>
  
</võistlused>

skeem

<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="Võistlused">
    <xs:complexType>
      <xs:sequence>
        <xs:element maxOccurs="unbounded" name="võistlus">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="name" type="xs:string" />
              <xs:element name="location">
                <xs:complexType>
                  <xs:simpleContent>
                    <xs:extension base="xs:string">
                      <xs:attribute name="linn" type="xs:string" use="optional" />
                      <xs:attribute name="tanav" type="xs:string" use="optional" />
                      <xs:attribute name="number" type="xs:string" use="optional" />
                    </xs:extension>
                  </xs:simpleContent>
                </xs:complexType>
              </xs:element>
              <xs:element name="contacts">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element maxOccurs="unbounded" name="contact">
                      <xs:complexType>
                        <xs:simpleContent>
                          <xs:extension base="xs:string">
                            <xs:attribute name="type" type="xs:string" use="optional" />
                          </xs:extension>
                        </xs:simpleContent>
                      </xs:complexType>
                    </xs:element>
                  </xs:sequence>
                </xs:complexType>
              </xs:element>
              <xs:element name="Osalejad">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element maxOccurs="unbounded" name="osaleja">
                      <xs:complexType>
                        <xs:sequence>
                          <xs:element name="club" type="xs:string" />
                          <xs:element name="contacts">
                            <xs:complexType>
                              <xs:sequence>
                                <xs:element maxOccurs="unbounded" name="contact">
                                  <xs:complexType>
                                    <xs:simpleContent>
                                      <xs:extension base="xs:string">
                                        <xs:attribute name="type" type="xs:string" use="optional" />
                                      </xs:extension>
                                    </xs:simpleContent>
                                  </xs:complexType>
                                </xs:element>
                              </xs:sequence>
                            </xs:complexType>
                          </xs:element>
                        </xs:sequence>
                        <xs:attribute name="sugu" type="xs:string" use="optional" />
                        <xs:attribute name="birthdate" type="xs:date" use="optional" />
                        <xs:attribute name="name" type="xs:string" use="required" />
                      </xs:complexType>
                    </xs:element>
                  </xs:sequence>
                </xs:complexType>
              </xs:element>
            </xs:sequence>
            <xs:attribute name="id" type="xs:long" use="required" />
            <xs:attribute name="date" type="xs:date" use="optional" />
            <xs:attribute name="time" type="xs:time" use="optional" />
            <xs:attribute name="type" type="xs:string" use="optional" />
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

xslt HTML

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  
  <xsl:template match="/">
    <html>
      <head>
        
        <title>XSLT Võistlused</title>
      </head>
      <body>
        <ul style="list-style-type:none">
          <xsl:for-each select="võistlused/võistlus">
            <li>
              <h1>
                <xsl:value-of select="name"/>
              </h1>
            </li>
            <li>
              <xsl:text>
              Kuupäev: </xsl:text>
              <xsl:value-of select="@date"/>
             
             </li>
             <li>
               <b>
                 <xsl:text>
              Asukoht
              </xsl:text>
               </b>
                <xsl:value-of select="location"/>
              <xsl:text>;
              </xsl:text>
              <xsl:value-of select="location/@linn"/>
              <xsl:text> , </xsl:text>
              <xsl:value-of select="location/@tanav"/>
              <xsl:text> </xsl:text>
              <xsl:value-of select="location/@number"/>
             </li>
              <xsl:for-each select="contacts/contact">
                  <li>
                    <xsl:value-of select="@type"/>
                    <xsl:text> </xsl:text>
                    <xsl:value-of select="."/>
                  </li>
              </xsl:for-each>
              <h2>
                <xsl:text>Osalejad
                </xsl:text>
              </h2>
              <ul style="list-style-type:none">
                <xsl:for-each select="osalejad/osaleja">
                  <li>
                      <b>
                        <xsl:value-of select="@name"/>
                      </b>
                  </li>
                  <xsl:if test="@birthdate != ''">
                    <li>
                      <xsl:value-of select="@birthdate"/>
                    </li>
                  </xsl:if>
                  <li>
                    <xsl:text>Klubi: </xsl:text>
                    <b>
                      <xsl:value-of select="club"/>
                    </b>
                  </li>
                  <li>                    
                    <xsl:if test="contacts/contact != '' ">
                      <xsl:text>Kontakt:
                      </xsl:text>
                      <xsl:value-of select="contacts/contact"/>
                    </xsl:if>
                  </li>
                </xsl:for-each>
              </ul>
          </xsl:for-each>
        </ul>
      </body>
    </html>
  </xsl:template>
</xsl:stylesheet>

xslt xml

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <xsl:template match="/">
    <Võistlused>
      <xsl:for-each select="võistlused/võistlus">
        <võistlus>
          <xsl:attribute name="date">
            <xsl:value-of select="@date"/>  
          </xsl:attribute>
          <xsl:attribute name="time">
            <xsl:value-of select="@time"/>  
          </xsl:attribute>
          <xsl:attribute name="type">
            <xsl:value-of select="@type"/>  
          </xsl:attribute>
          <name>
            <xsl:value-of select="name"/>
          </name>
          <contacts>         
            <xsl:for-each select="contacts/contact">
              <contact>
                <xsl:attribute name="type">
                  <xsl:value-of select="@type"/>
                </xsl:attribute>
                <xsl:value-of select="."/>
              </contact>
            </xsl:for-each>
          </contacts>
          <xsl:for-each select="osalejad/osaleja">
          <participantsNames>
            <xsl:attribute name="Klubi">
              <xsl:value-of select="club"/>
            </xsl:attribute>
            <xsl:value-of select="@name"/>
          </participantsNames>
          </xsl:for-each>
        </võistlus>
      </xsl:for-each>
    </Võistlused>
  </xsl:template>
</xsl:stylesheet>