Team SPOT: Difference between revisions

From ICO wiki
Jump to navigationJump to search
Otiks (talk | contribs)
Otiks (talk | contribs)
Line 533: Line 533:


=== XSLT (xml) ===
=== XSLT (xml) ===
<nowiki>
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
>
  <xsl:output method="xml" indent="yes" cdata-section-elements="Name Style Comment"/>
  <xsl:template match="/">
    <Schedule>
      <xsl:for-each select="/Trainings/Training">
        <xsl:sort select="Name"/>
        <xsl:variable name="SelectedTraining" select="." />
        <xsl:for-each select="Schedule/ScheduleItem">
          <xsl:sort select="Time"/>
          <ScheduleItem>
            <xsl:variable name="VenueId" select="@VenueId" />
            <xsl:variable name="SelectedVenue" select="/Trainings/Venues/Venue[@Id=$VenueId]" />
            <xsl:attribute name="Id">
              <xsl:value-of select="@Id"/>
            </xsl:attribute>
            <xsl:attribute name="GroupSize">
              <xsl:choose>
                <xsl:when test="@GroupSize">
                  <xsl:value-of select="@GroupSize"/>
                </xsl:when>
                <xsl:otherwise>
                  <xsl:value-of select="$SelectedVenue/@GroupSize"/>
                </xsl:otherwise>
              </xsl:choose>
            </xsl:attribute>
            <Venue>
              <xsl:attribute name="Id">
                <xsl:value-of select="$VenueId"/>
              </xsl:attribute>
              <xsl:value-of select="$SelectedVenue"/>
            </Venue>
            <Training>
              <xsl:attribute name="Id">
                <xsl:value-of select="$SelectedTraining/@Id"/>
              </xsl:attribute>
              <xsl:if test="$SelectedTraining/@Licence">
                <xsl:attribute name="Licence">
                  <xsl:value-of select="$SelectedTraining/@Licence"/>
                </xsl:attribute>
              </xsl:if>
              <Name>
                <xsl:value-of select="$SelectedTraining/Name"/>
              </Name>
              <Styles>
                <xsl:for-each select="$SelectedTraining/Styles/Style">
                  <xsl:variable name="StyleId" select="@Id" />
                  <Style>
                    <xsl:attribute name="StyleId">
                      <xsl:value-of select="$StyleId"/>
                    </xsl:attribute>
                    <xsl:value-of select="/Trainings/Styles/Style[@Id=$StyleId]"/>
                  </Style>
                </xsl:for-each>
              </Styles>
            </Training>
            <Time>
              <xsl:attribute name="Duration">
                <xsl:value-of select="Time/@Duration"/>
              </xsl:attribute>
              <xsl:value-of select ="Time"/>
            </Time>
            <Instructors>
              <xsl:for-each select="Instructors/Instructor">
                <xsl:variable name="InstructorId" select="@Id"/>
                <xsl:variable name="SelectedInstructor" select="/Trainings/Instructors/Instructor[@Id=$InstructorId]"/>
                <Instructor>
                  <xsl:attribute name="Id">
                    <xsl:value-of select="$InstructorId"/>
                  </xsl:attribute>
                  <xsl:attribute name="Rating">
                    <xsl:value-of select="$SelectedInstructor/@Rating"/>
                  </xsl:attribute>
                  <Name>
                    <xsl:value-of select="$SelectedInstructor/Name"/>
                  </Name>
                </Instructor>
              </xsl:for-each>
            </Instructors>
            <xsl:if test="Comment">
              <Comment>
                <xsl:value-of select="Comment"/>
              </Comment>
            </xsl:if>
          </ScheduleItem>
        </xsl:for-each>
      </xsl:for-each>
    </Schedule>
  </xsl:template>
</xsl:stylesheet>
</nowiki>


== Log ==
== Log ==

Revision as of 13:34, 20 March 2017

Kodutöö aines "Võrgurakendused II: hajussüsteemide ehitamine"

Projekti kodu

Liikmed

  • Sigrid Pachel
  • Oliver Tiks

Idee

XML / XSD / XSLT

XML

<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="trainingsToHtml.xslt"?>

<Trainings>
  <Styles>
    <Style Id="1"><![CDATA[Cardio]]></Style>
    <Style Id="2"><![CDATA[Body&Mind]]></Style>
    <Style Id="3"><![CDATA[Strength]]></Style>
    <Style Id="4"><![CDATA[Dance&Fun]]></Style>
  </Styles>

  <Instructors>
    <Instructor Id="1" Rating="5">
      <Name><![CDATA[Minnie Yogafier]]></Name>
    </Instructor>
    <Instructor Id="2" Rating="4.7">
      <Name><![CDATA[Mickey Mouse]]></Name>
    </Instructor>
    <Instructor Id="3" Rating="4.6">
      <Name><![CDATA[Minnie Mouse]]></Name>
    </Instructor>
    <Instructor Id="4" Rating="4.2">
      <Name><![CDATA[Donald Duck]]></Name>
    </Instructor>
    <Instructor Id="5" Rating="3.9">
      <Name><![CDATA[Goofy]]></Name>
    </Instructor>
    <Instructor Id="6" Rating="5">
      <Name><![CDATA[Arnold Schwarzenegger]]></Name>
    </Instructor>
    <Instructor Id="7" Rating="4.2">
      <Name><![CDATA[Arnold Zumbaschnegger]]></Name>
    </Instructor>
    <Instructor Id="8" Rating="4.8">
      <Name><![CDATA[Kayla Weightlifter]]></Name>
    </Instructor>
    <Instructor Id="9" Rating="5">
      <Name><![CDATA[Margaret Strengthener]]></Name>
    </Instructor>
  </Instructors>

  <Venues>
    <Venue Id="1" GroupSize="45"><![CDATA[Main Hall]]></Venue>
    <Venue Id="2" GroupSize="30"><![CDATA[Hall 2]]></Venue>
    <Venue Id="3" GroupSize="30"><![CDATA[Hall 3]]></Venue>
    <Venue Id="4" GroupSize="20"><![CDATA[Hall 4]]></Venue>
    <Venue Id="5" GroupSize="20"><![CDATA[Hall 5]]></Venue>
    <Venue Id="6" GroupSize="15"><![CDATA[Area 6]]></Venue>
    <Venue Id="7" GroupSize="30"><![CDATA[Yoga Hall]]></Venue>
  </Venues>

  <Training Id="1">
    <Name><![CDATA[Yoga]]></Name>
    <Description>
      <![CDATA[Yoga is a group of physical, mental, and spiritual practices or disciplines which originated in ancient India. ]]>
    </Description>
    <Styles>
      <Style Id="2" />
    </Styles>
    <Schedule>
      <ScheduleItem Id="1" VenueId="7">
        <Time Duration="PT60M">2017-03-25T14:00:00</Time>
        <Instructors>
          <Instructor Id="1"/>
        </Instructors>
      </ScheduleItem>
      <ScheduleItem Id="14" VenueId="7" GroupSize="15">
        <Time Duration="PT1H20M">2017-03-28T14:00:00</Time>
        <Instructors>
          <Instructor Id="1"/>
        </Instructors>
        <Comment>
          <![CDATA[Special class!]]>
        </Comment> 
      </ScheduleItem>
    </Schedule>
    <VideoUrl>https://www.youtube.com/embed/Nvlxn0EnmbM</VideoUrl>
  </Training>
  
  <Training Id="2" Licence="LesMills">
    <Name><![CDATA[BodyBalance™]]></Name>
    <Styles>
      <Style Id="2" />
    </Styles>
    <Description>
      <![CDATA[BODYBALANCE™ is the Yoga, Tai Chi, Pilates workout that builds flexibility and strength and leaves you feeling centered and calm. Based on a carefully structured series of stretches, moves and poses to music it creates a holistic workout that brings the body into a state of harmony and balance. This class will heighten your flexibility and inner strength creating a strong supple body from the inside out. Burn on average 390cals per hour.]]>
    </Description>
    <Schedule>
      <ScheduleItem Id="2" VenueId="3">
        <Instructors>
          <Instructor Id="2"/>
        </Instructors>
        <Time Duration="PT1H15M">2017-03-31T12:15:00</Time>
      </ScheduleItem>
      <ScheduleItem Id="3" VenueId="2" >
        <Time Duration="PT1H15M">2017-03-30T13:30:00</Time>
        <Instructors>
          <Instructor Id="3"/>
        </Instructors>
      </ScheduleItem>
    </Schedule>
    <VideoUrl>https://www.youtube.com/embed/jJxA6vBjUqY</VideoUrl>
  </Training>

  <Training Id="3" Licence="LesMills">
    <Name><![CDATA[BodyJam™]]></Name>
    <Styles>
      <Style Id="4" />
      <Style Id="1" />
    </Styles>
    <Description>
      <![CDATA[The Body Jam program is an addictive fusion of the latest dance styles to the hottest new sounds. This class isn’t just for dancers, it’s for everyone because the emphasis is put on not only having fun but also breaking a sweat. So grab a friend, get front and centre … you bring the attitude and we’ll bring the moves!]]>
    </Description>
    <Schedule>
      <ScheduleItem Id="4"  VenueId="3" >
        <Time Duration="PT60M">2017-03-30T16:10:00</Time>
        <Instructors>
          <Instructor Id="4"/>
        </Instructors>
      </ScheduleItem>
      <ScheduleItem Id="5" VenueId="5" >
        <Time Duration="PT45M">2017-04-01T12:00:00</Time>
        <Instructors>
          <Instructor Id="5"/>
        </Instructors>
      </ScheduleItem>
    </Schedule>
    <VideoUrl>https://www.youtube.com/embed/8PTXyg9si_4</VideoUrl>
  </Training>

  <Training Id="4" Licence="LesMills">
    <Name><![CDATA[BodyPump™]]></Name>
    <Description>
      <![CDATA[BodyPump classes are 59 minutes long and contain eight separate muscle-group specific songs or "tracks" along with an opening warm up track and closing cool-down track. There are also 45-minute and 30-minute class formats. The classes are performed to music using free weights-plates, barbells and an aerobic step. Participants choose their weights based on the exercise and their personal goals. Major muscle groups are worked via series of compound and isolation-based exercises including squats, presses, dead lifts. The focus is towards muscle endurance by moving light weights at high repetitions, what Les Mills calls the Rep Effect.]]>
    </Description>
    <Styles>
      <Style Id="3" />
    </Styles>
    <Schedule>
      <ScheduleItem Id="6" VenueId="1">
        <Time Duration="PT60M">2017-03-30T13:00:00</Time>
        <Instructors>
          <Instructor Id="6"/>
        </Instructors>
      </ScheduleItem>
      <ScheduleItem Id="7" VenueId="1">
        <Time Duration="PT60M">2017-03-23T13:00:00</Time>
        <Instructors>
          <Instructor Id="6"/>
        </Instructors>
      </ScheduleItem>
    </Schedule>
    <VideoUrl>https://www.youtube.com/embed/zU_0XrdO3wo</VideoUrl>
  </Training>

  <Training Id="5">
    <Name><![CDATA[CoreStrength]]></Name>
    <Description>
      <![CDATA[CoreStrenght is a very hard workout! Not for beginners.]]>
    </Description>
    <Styles>
      <Style Id="3" />
    </Styles>
    <Schedule>
      <ScheduleItem Id="8" VenueId="6" GroupSize="10">
        <Time Duration="PT2H">2017-03-23T12:00:00</Time>
        <Instructors>
          <Instructor Id="9"/>
        </Instructors>
        <Comment>
          <![CDATA[Special challenge!]]>
        </Comment>
      </ScheduleItem>
      <ScheduleItem Id="9" VenueId="6">
        <Time Duration="PT60M">2017-03-30T12:00:00</Time>
        <Instructors>
          <Instructor Id="8"/>
        </Instructors>
      </ScheduleItem>
      <ScheduleItem Id="10" VenueId="6">
        <Time Duration="PT60M">2017-04-05T12:00:00</Time>
        <Instructors>
          <Instructor Id="8"/>
          <Instructor Id="9"/>
        </Instructors>
      </ScheduleItem>
    </Schedule>
    <VideoUrl>https://www.youtube.com/embed/ZxTVmpvyUt8</VideoUrl>
  </Training>

  <Training Id="6">
    <Name><![CDATA[Zumba®]]></Name>
    <Description>
      <![CDATA[Zumba involves dance and aerobic movements performed to energetic music. The choreography incorporates hip-hop, soca, samba, salsa, merengue and mambo. Squats and lunges are also included.]]>
    </Description>
    <Styles>
      <Style Id="4" />
    </Styles>
    <Schedule>
      <ScheduleItem Id="11" VenueId="2">
        <Time Duration="PT55M">2017-03-26T15:00:00</Time>
        <Instructors>
          <Instructor Id="7"/>
        </Instructors>
      </ScheduleItem>
      <ScheduleItem Id="12" VenueId="4">
        <Instructors>
          <Instructor Id="7"/>
        </Instructors>
        <Time Duration="PT60M">2017-03-28T12:00:00</Time>
      </ScheduleItem>
      <ScheduleItem Id="13" VenueId="2">
        <Time Duration="PT60M">2017-03-30T12:00:00</Time>
        <Instructors>
          <Instructor Id="7"/>
        </Instructors>
      </ScheduleItem>
    </Schedule>
    <VideoUrl>https://www.youtube.com/embed/-ZB6XIkfxnQ</VideoUrl>
  </Training>
</Trainings>

XSD

<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="Trainings">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="Styles">
          <xs:complexType>
            <xs:sequence>
              <xs:element maxOccurs="unbounded" name="Style">
                <xs:complexType>
                  <xs:simpleContent>
                    <xs:extension base="xs:string">
                      <xs:attribute name="Id" type="xs:int" use="required" />
                    </xs:extension>
                  </xs:simpleContent>
                </xs:complexType>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
          <xs:unique name="UniqueStyleId">
            <xs:selector xpath="Style"/>
            <xs:field xpath="@Id"/>
          </xs:unique>
        </xs:element>
        <xs:element name="Instructors">
          <xs:complexType>
            <xs:sequence>
              <xs:element maxOccurs="unbounded" name="Instructor">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element name="Name" type="xs:string"/>
                  </xs:sequence>
                  <xs:attribute name="Id" type="xs:int" use="required" />
                  <xs:attribute name="Rating" type="xs:decimal" use="required" />
                </xs:complexType>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
          <xs:unique name="UniqueInstructorId">
            <xs:selector xpath="Instructor"/>
            <xs:field xpath="@Id"/>
          </xs:unique>
        </xs:element>
        <xs:element name="Venues">
          <xs:complexType>
            <xs:sequence>
              <xs:element maxOccurs="unbounded" name="Venue">
                <xs:complexType>
                  <xs:simpleContent>
                    <xs:extension base="xs:string">
                      <xs:attribute name="Id" type="xs:int" use="required" />
                      <xs:attribute name="GroupSize" type="xs:int" use="required" />
                    </xs:extension>
                  </xs:simpleContent>
                </xs:complexType>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
          <xs:unique name="UniqueVenueId">
            <xs:selector xpath="Venue"/>
            <xs:field xpath="@Id"/>
          </xs:unique>
        </xs:element>
        <xs:element maxOccurs="unbounded" name="Training">
          <xs:complexType>
            <xs:all>
              <xs:element name="Name" type="xs:string" />
              <xs:element name="Description" type="xs:string" />
              <xs:element name="Styles">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element maxOccurs="unbounded" name="Style">
                      <xs:complexType>
                        <xs:simpleContent>
                          <xs:extension base="xs:string">
                            <xs:attribute name="Id" type="xs:int" use="required" />
                          </xs:extension>
                        </xs:simpleContent>
                      </xs:complexType>
                    </xs:element>
                  </xs:sequence>
                </xs:complexType>
              </xs:element>
              <xs:element name="Schedule">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element maxOccurs="unbounded" name="ScheduleItem">
                      <xs:complexType>
                        <xs:all>
                          <xs:element  maxOccurs="1" name="Time">
                            <xs:complexType>
                              <xs:simpleContent>
                                <xs:extension base="xs:dateTime">
                                  <xs:attribute name="Duration" type="xs:duration" use="required" />
                                </xs:extension>
                              </xs:simpleContent>
                            </xs:complexType>
                          </xs:element>
                          <xs:element name="Instructors">
                            <xs:complexType>
                              <xs:sequence>
                                <xs:element maxOccurs="unbounded" name="Instructor">
                                  <xs:complexType>
                                    <xs:simpleContent>
                                      <xs:extension base="xs:string">
                                        <xs:attribute name="Id" type="xs:int" use="required" />
                                      </xs:extension>
                                    </xs:simpleContent>
                                  </xs:complexType>
                                </xs:element>
                              </xs:sequence>
                            </xs:complexType>
                          </xs:element>
                          <xs:element minOccurs="0" maxOccurs="1" name="Comment" type="xs:string" />
                        </xs:all>
                        <xs:attribute name="Id" type="xs:int" use="required" />
                        <xs:attribute name="VenueId" type="xs:int" use="required" />
                        <xs:attribute name="GroupSize" type="xs:int" use="optional" />
                      </xs:complexType>
                    </xs:element>
                  </xs:sequence>
                </xs:complexType>
              </xs:element>
              <xs:element name="VideoUrl" type="xs:string" />
            </xs:all>
            <xs:attribute name="Id" type="xs:int" use="required" />
            <xs:attribute name="Licence" type="xs:string" use="optional" />
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
    <xs:unique name="UniqueTrainingId">
      <xs:selector xpath="Training"/>
      <xs:field xpath="@Id"/>
    </xs:unique>
    <xs:unique name="UniqueScheduleItemId">
      <xs:selector xpath="Training/Schedule/ScheduleItem"/>
      <xs:field xpath="@Id"/>
    </xs:unique>
  </xs:element>
</xs:schema>

XSLT (html)

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">
  <xsl:output method="html" />
  <xsl:template match="/">
    <html>
      <head>
        <title>SuperSportsClub - Trainings</title>
        <style>
          body {
          background:BurlyWood;
          text-align: center;
          }
          .section {
          text-align:left;
          width:1000px;
          padding:20px;
          background:Chocolate;
          margin: auto;
          }
          table, th, td, .section {
          border: 1px solid black;
          }
          th {
          text-align:left;
          padding-left: 10px;
          padding-right: 10px;
          }
          td {
          text-align:center;
          }
          p {
          text-align:justify;
          }
          .description {
          vertical-align:top; 
          padding:10px;
          }
        </style>
      </head>
      <body>
        <h1>Trainings at SuperSportsClub</h1>
        <xsl:for-each select="/Trainings/Styles/Style">
          <xsl:sort select="."/>
          <xsl:variable select="." name="SelectedStyle" />
          <div class="section" >
            <h2>
              <xsl:value-of select="$SelectedStyle" />
            </h2>
            <ul>
              <xsl:for-each select="/Trainings/Training">
                <xsl:sort select="."/>
                <xsl:variable name="Training" select="." />
                <xsl:if test="Styles/Style/@Id = $SelectedStyle/@Id">
                  <li>
                    <h3>
                      <xsl:value-of select="$Training/Name" />
                      <xsl:if test="$Training/@Licence">
                        <xsl:text> (</xsl:text>
                        <xsl:value-of select="$Training/@Licence" />
                        <xsl:text>)</xsl:text>
                      </xsl:if>
                    </h3>
                    <table>
                      <tr>
                        <th>When:</th>
                        <th>Duration:</th>
                        <th>Where:</th>
                        <th>Instructors:</th>
                      </tr>
                      <xsl:for-each select="$Training/Schedule/ScheduleItem">
                        <xsl:sort select="Time"/>
                        <xsl:variable name="StartTime" select="Time"/>
                        <xsl:variable name="Duration" select="$StartTime/@Duration"/>
                        <tr>
                          <td width="150" >
                            <xsl:value-of select="concat(
                                            substring($StartTime, 9, 2), 
                                            '.', 
                                            substring($StartTime, 6, 2), 
                                            '.', 
                                            substring($StartTime, 1, 4),
                                            ' ',
                                            substring($StartTime, 12, 2),
                                            ':',
                                            substring($StartTime, 15, 2))
                                            " />
                            <xsl:if test="Comment">
                              <br/>
                              <div style="color:Green">
                                <xsl:value-of select="Comment"/>
                              </div>
                            </xsl:if>
                          </td>
                          <td width="100">
                            <xsl:value-of select="substring($Duration, 3, 6)" />
                          </td>
                          <td width="150">
                            <xsl:variable name="VenueId" select="@VenueId"/>
                            <xsl:value-of select="/Trainings/Venues/Venue[@Id=$VenueId]" />
                          </td>
                          <td width="250">
                            <xsl:for-each select="Instructors/Instructor">
                              <xsl:variable name="InstructorId" select="@Id"></xsl:variable>
                              <xsl:variable name="SelectedInstructor" select="/Trainings/Instructors/Instructor[@Id=$InstructorId]" />
                              <xsl:value-of select="$SelectedInstructor/Name"/>
                              <xsl:text> (</xsl:text>
                              <xsl:value-of select="$SelectedInstructor/@Rating" />
                              <xsl:text>)</xsl:text>
                              <br/>
                            </xsl:for-each>
                          </td>
                        </tr>
                      </xsl:for-each>
                    </table>
                    <br/>
                    <table>
                      <tr>
                        <td>
                          <xsl:variable name="VideoUrl" select="$Training/VideoUrl" />
                          <iframe width="420" height="315" src="{$VideoUrl}"></iframe>
                        </td>
                        <td class="description" width="420">
                          <p>
                            <b>Description:</b>
                          </p>
                          <p>
                            <xsl:value-of select="$Training/Description" />
                          </p>
                        </td>
                      </tr>
                    </table>
                  </li>
                </xsl:if>
              </xsl:for-each>
            </ul>
          </div>
          <br/>
        </xsl:for-each>
      </body>
    </html>
  </xsl:template>
</xsl:stylesheet>

XSLT (xml)

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
>
  <xsl:output method="xml" indent="yes" cdata-section-elements="Name Style Comment"/>

  <xsl:template match="/">
    <Schedule>
      <xsl:for-each select="/Trainings/Training">
        <xsl:sort select="Name"/>
        <xsl:variable name="SelectedTraining" select="." />
        <xsl:for-each select="Schedule/ScheduleItem">
          <xsl:sort select="Time"/>
          <ScheduleItem>
            <xsl:variable name="VenueId" select="@VenueId" />
            <xsl:variable name="SelectedVenue" select="/Trainings/Venues/Venue[@Id=$VenueId]" />
            <xsl:attribute name="Id">
              <xsl:value-of select="@Id"/>
            </xsl:attribute>
            <xsl:attribute name="GroupSize">
              <xsl:choose>
                <xsl:when test="@GroupSize">
                  <xsl:value-of select="@GroupSize"/>
                </xsl:when>
                <xsl:otherwise>
                  <xsl:value-of select="$SelectedVenue/@GroupSize"/>
                </xsl:otherwise>
              </xsl:choose>
            </xsl:attribute>
            <Venue>
              <xsl:attribute name="Id">
                <xsl:value-of select="$VenueId"/>
              </xsl:attribute>
              <xsl:value-of select="$SelectedVenue"/>
            </Venue>
            <Training>
              <xsl:attribute name="Id">
                <xsl:value-of select="$SelectedTraining/@Id"/>
              </xsl:attribute>
              <xsl:if test="$SelectedTraining/@Licence">
                <xsl:attribute name="Licence">
                  <xsl:value-of select="$SelectedTraining/@Licence"/>
                </xsl:attribute>
              </xsl:if>
              <Name>
                <xsl:value-of select="$SelectedTraining/Name"/>
              </Name>
              <Styles>
                <xsl:for-each select="$SelectedTraining/Styles/Style">
                  <xsl:variable name="StyleId" select="@Id" />
                  <Style>
                    <xsl:attribute name="StyleId">
                      <xsl:value-of select="$StyleId"/>
                    </xsl:attribute>
                    <xsl:value-of select="/Trainings/Styles/Style[@Id=$StyleId]"/>
                  </Style>
                </xsl:for-each>
              </Styles>
            </Training>
            <Time>
              <xsl:attribute name="Duration">
                <xsl:value-of select="Time/@Duration"/>
              </xsl:attribute>
              <xsl:value-of select ="Time"/>
            </Time>
            <Instructors>
              <xsl:for-each select="Instructors/Instructor">
                <xsl:variable name="InstructorId" select="@Id"/>
                <xsl:variable name="SelectedInstructor" select="/Trainings/Instructors/Instructor[@Id=$InstructorId]"/>
                <Instructor>
                  <xsl:attribute name="Id">
                    <xsl:value-of select="$InstructorId"/>
                  </xsl:attribute>
                  <xsl:attribute name="Rating">
                    <xsl:value-of select="$SelectedInstructor/@Rating"/>
                  </xsl:attribute>
                  <Name>
                    <xsl:value-of select="$SelectedInstructor/Name"/>
                  </Name>
                </Instructor>
              </xsl:for-each>
            </Instructors>
            <xsl:if test="Comment">
              <Comment>
                <xsl:value-of select="Comment"/>
              </Comment>
            </xsl:if>
          </ScheduleItem>
        </xsl:for-each>
      </xsl:for-each>
    </Schedule>
  </xsl:template>
</xsl:stylesheet>

Log

  • 03.03.17 Esimene kohtumine. Idee.
  • 17.03.17 Osa XMList valmis, osa XSLT-st valmis
  • 18.03.17 Teine kohtumine. XMLi täiendamine, esimene ülekäimine XSD-s.
  • 19.03.17 XML/XSLT/XSD täiendamine ja lõpetamine.