RAKK

From EIK wiki

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

Lehekülg loodud: 08.03.2014

Meeskonna nimi: RAKK

Liikmed:

  • Kert Kukk, D21
  • Roland Pukk, D21
  • Kristjan Adrat, D21
  • Anti Meos, D21


Kodutöö XML osa 8.märts

xml fail hoiab andmeid tegelaste kohta, kes võivad eksisteerida näiteks mõnes arvutimängus.

XML fail andmetega

<?xml version="1.0" encoding="utf-8" ?>

<Characters>

  <Character ID="1" Name="Skin_head">

    <Gender>Female</Gender>
    <Race>Vulcan</Race>
    <Class>Mage</Class>
    <Health Max="28000">14224</Health>
    <Mana Max="17000">8034</Mana>
    <Level Max="65">62</Level>
    <Experience>145647653</Experience>

    <Inventory MaxSlots="20">

      <Item ID="1" Name="Gold" Cost="1">
        <Count>23443</Count>
      </Item>

      <Item ID="2" Name="Paper_bag" Cost="789">
        <Count>1</Count>
        <Level>60</Level>
        <Durability>175</Durability>
        <Stat Skill="STR">3</Stat>
        <Stat Skill="INT">22</Stat>
        <Stat Skill="VIT">5</Stat>
      </Item>

      <Item ID="3" Name="Lollipop" Cost="112">
        <Count>1</Count>
        <Level>61</Level>
        <Durability>275</Durability>
        <Stat Skill="STR">3</Stat>
        <Stat Skill="INT">12</Stat>
        <Stat Skill="VIT">7</Stat>
      </Item>

    </Inventory>

  </Character>

  <Character ID="2" Name="Bat_Cat">

    <Gender>Female</Gender>
    <Race>Human</Race>
    <Class>Rogue</Class>
    <Health Max="21000">9324</Health>
    <Mana Max="14000">1234</Mana>
    <Level Max="65">42</Level>
    <Experience>2647653</Experience>

    <Inventory MaxSlots="20">

      <Item ID="1" Name="Gold" Cost="1">
        <Count>1437</Count>
      </Item>

      <Item ID="2" Name="Dirty_whip" Cost="359">
        <Count>1</Count>
        <Level>40</Level>
        <Durability>125</Durability>
        <Stat Skill="STR">12</Stat>
        <Stat Skill="INT">1</Stat>
        <Stat Skill="VIT">3</Stat>
      </Item>

      <Item ID="3" Name="Partyhat" Cost="112">
        <Count>1</Count>
        <Level>61</Level>
        <Durability>275</Durability>
        <Stat Skill="STR">15</Stat>
        <Stat Skill="INT">1</Stat>
        <Stat Skill="VIT">6</Stat>
      </Item>

    </Inventory>

  </Character>


  <Character ID="3" Name="Ultimate_Badass">

    <Gender>Male</Gender>
    <Race>Human</Race>
    <Class>Warrior</Class>
    <Health Max="23800">23800</Health>
    <Mana Max="18000">18000</Mana>
    <Level Max="65">65</Level>
    <Experience>136649823</Experience>

    <Inventory MaxSlots="20">

      <Item ID="1" Name="Gold" Cost="1">
        <Count>5000</Count>
      </Item>

      <Item ID="2" Name="Sword of Sharpness" Cost="1337">
        <Count>1</Count>
        <Level>60</Level>
        <Durability>200</Durability>
        <Stat Skill="STR">25</Stat>
        <Stat Skill="VIT">15</Stat>
      </Item>

      <Item ID="3" Name="Darth Vader's Helmet" Cost="3000">
        <Count>1</Count>
        <Level>65</Level>
        <Durability>300</Durability>
        <Stat Skill="DEX">25</Stat>
        <Stat Skill="VIT">45</Stat>
        <Stat Skill="Armor">250</Stat>
      </Item>

      <Item ID="4" Name="Useless Junk" Cost="1">
        <Count>22</Count>
      </Item>

    </Inventory>

  </Character>

  <Character ID="4" Name="Princess_Kenny">

    <Gender>Female</Gender>
    <Race>Human</Race>
    <Class>Archer</Class>
    <Health Max="100">8</Health>
    <Mana Max="100">0</Mana>
    <Level Max="65">1</Level>
    <Experience>8532435</Experience>

    <Inventory MaxSlots="10">

      <Item ID="1" Name="Gold" Cost="1">
        <Count>7</Count>
      </Item>

      <Item ID="2" Name="Bow of Sucking" Cost="480">
        <Count>1</Count>
        <Level>50</Level>
        <Durability>200</Durability>
        <Stat Skill="DEX">10</Stat>
      </Item>

      <Item ID="3" Name="Dress" Cost="5">
        <Count>1</Count>
        <Level>1</Level>
        <Durability>20</Durability>
        <Stat Skill="Armor">1</Stat>
      </Item>

    </Inventory>
    
  </Character>
  
</Characters>

XML skeemifail

<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="Characters">
    <xs:complexType>
      <xs:sequence>
        <xs:element maxOccurs="unbounded" name="Character">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="Gender" type="xs:string" />
              <xs:element name="Race" type="xs:string" />
              <xs:element name="Class" type="xs:string" />
              <xs:element name="Health">
                <xs:complexType>
                  <xs:simpleContent>
                    <xs:extension base="xs:unsignedShort">
                      <xs:attribute name="Max" type="xs:unsignedShort" use="required" />
                    </xs:extension>
                  </xs:simpleContent>
                </xs:complexType>
              </xs:element>
              <xs:element name="Mana">
                <xs:complexType>
                  <xs:simpleContent>
                    <xs:extension base="xs:unsignedShort">
                      <xs:attribute name="Max" type="xs:unsignedShort" use="required" />
                    </xs:extension>
                  </xs:simpleContent>
                </xs:complexType>
              </xs:element>
              <xs:element name="Level">
                <xs:complexType>
                  <xs:simpleContent>
                    <xs:extension base="xs:unsignedByte">
                      <xs:attribute name="Max" type="xs:unsignedByte" use="required" />
                    </xs:extension>
                  </xs:simpleContent>
                </xs:complexType>
              </xs:element>
              <xs:element name="Experience" type="xs:unsignedInt" />
              <xs:element name="Inventory">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element maxOccurs="unbounded" name="Item">
                      <xs:complexType>
                        <xs:sequence>
                          <xs:element name="Count" type="xs:unsignedShort" />
                          <xs:element minOccurs="0" name="Level" type="xs:unsignedByte" />
                          <xs:element minOccurs="0" name="Durability" type="xs:unsignedShort" />
                          <xs:element minOccurs="0" maxOccurs="unbounded" name="Stat">
                            <xs:complexType>
                              <xs:simpleContent>
                                <xs:extension base="xs:unsignedByte">
                                  <xs:attribute name="Skill" type="xs:string" use="required" />
                                </xs:extension>
                              </xs:simpleContent>
                            </xs:complexType>
                          </xs:element>
                        </xs:sequence>
                        <xs:attribute name="ID" type="xs:unsignedByte" use="required" />
                        <xs:attribute name="Name" type="xs:string" use="required" />
                        <xs:attribute name="Cost" type="xs:unsignedShort" use="required" />
                      </xs:complexType>
                    </xs:element>
                  </xs:sequence>
                  <xs:attribute name="MaxSlots" type="xs:unsignedByte" use="required" />
                </xs:complexType>
              </xs:element>
            </xs:sequence>
            <xs:attribute name="ID" type="xs:unsignedByte" use="required" />
            <xs:attribute name="Name" type="xs:string" use="required" />
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

XSL fail 1 - Kõikide tegelaste nimekiri

<?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="no"/>

  <xsl:template match="/">
    <html>
      <head>
        <title>Characters</title>
      </head>
      <body>
        <ul>
          <xsl:for-each select="/Characters/Character">
            <li>
              Character ID: <xsl:value-of select="@ID"/>
              <br />
              Name: <xsl:value-of select="@Name"/>
              <br />
              Gender: <xsl:value-of select="Gender"/>
              <br />
              Race: <xsl:value-of select="Race"/>
              <br />
              Class: <xsl:value-of select="Class"/>
              <br />
              Health: <xsl:value-of select="Health"/>/<xsl:value-of select="Health/@Max"/>
              <br />
              Mana: <xsl:value-of select="Mana"/>/<xsl:value-of select="Mana/@Max"/>
              <br />
              Level: <xsl:value-of select="Level"/> Max: <xsl:value-of select="Level/@Max"/>
              <br />
              Experience: <xsl:value-of select="Experience"/>
              <br />
              <br />
              Inventory (max slots: <xsl:value-of select="Inventory/@MaxSlots"/>):
              <ul>
              <xsl:for-each select="Inventory/Item">
                <li>
                  Item ID: <xsl:value-of select="@ID"/>
                  <br />
                  Name: <xsl:value-of select="@Name"/>
                  <br />
                  Cost: <xsl:value-of select="@Cost"/>
                  <br />

                  <xsl:choose>
                    <xsl:when test="Count">
                      Count: <xsl:value-of select="Count"/>
                      <br />
                    </xsl:when>
                  </xsl:choose>

                  <xsl:choose>
                    <xsl:when test="Level">
                      Level: <xsl:value-of select="Level"/>
                      <br />
                    </xsl:when>
                  </xsl:choose>

                  <xsl:choose>
                    <xsl:when test="Durability">
                      Durability: <xsl:value-of select="Durability"/>
                      <br />
                    </xsl:when>
                  </xsl:choose>

                  <xsl:choose>
                    <xsl:when test="count(Stat) > 0">
                      Stat modifiers:
                      <ul>
                        <xsl:for-each select="Stat">
                          <li>
                            <xsl:value-of select="@Skill"/>: <xsl:value-of select="."/>
                          </li>
                        </xsl:for-each>
                      </ul>
                    </xsl:when>
                  </xsl:choose>
                  <br />
                </li>
               </xsl:for-each>
              </ul>
            </li>
          </xsl:for-each>
        </ul>
      </body>
    </html>
  </xsl:template>
</xsl:stylesheet>

XSL fail 2 - Tegelaste itemite maksumus

<?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" xmlns:exsl="http://exslt.org/common"
    exclude-result-prefixes="msxsl">

    <xsl:output method="html" indent="yes"/>

    <xsl:template match="/">
      <html>
        <head><title>xsl file 2</title></head>
        <body>

          <h2>Items costs</h2>
          
          <xsl:for-each select="/Characters/Character">
          <ul>
            <b>
              <xsl:text>Character name: </xsl:text><xsl:value-of select="@Name"/>
            </b>
            <br/>
            <xsl:for-each select="Inventory/Item">
              <xsl:variable name="cost" select="@Cost"/>
              <xsl:variable name="count" select="Count"/>
              <xsl:variable name="multiplic" select="$cost*$count"/>

              <xsl:value-of select="$count"/>
              <xsl:text> </xsl:text>
              <xsl:value-of select="@Name"/>
              <xsl:text> costs: </xsl:text>
              <xsl:value-of select="$multiplic"/>            
              <br/>
            </xsl:for-each>

            <xsl:variable name="nodes">
              <xsl:for-each select="Inventory/Item">
                <cost>
                  <xsl:value-of select="Count*@Cost"/>
                </cost>
              </xsl:for-each>
            </xsl:variable>
            <xsl:text>All </xsl:text>
            <xsl:value-of select="@Name"/>
            <xsl:text> items together costs: </xsl:text>
            <xsl:value-of select="sum(exsl:node-set($nodes)/cost)"/>
          </ul>
          </xsl:for-each>
                    
        </body>
      </html>
    </xsl:template>
</xsl:stylesheet>

Veebiteenus

Klientrakendus

Logi

  • 08.03.2014 - Wiki lehe loomine
  • 08.03.2014 - XML fail, XML skeemifail, XSL failid