Mjart: Difference between revisions

From ICO wiki
Jump to navigationJump to search
Mhakkine (talk | contribs)
No edit summary
Mhakkine (talk | contribs)
No edit summary
Line 1: Line 1:
== Sissejuhatus ==
Sellel lehel saab olema meeskonna Mjart projekt ja sellega seonduvad failid,dokumendid.


== Meeskond ==
== Meeskond ==

Revision as of 01:22, 21 March 2017

Sissejuhatus

Sellel lehel saab olema meeskonna Mjart projekt ja sellega seonduvad failid,dokumendid.

Meeskond

Märt Häkkinen - Arendaja, testija ja projektijuht

XML

<?xml version="1.0" encoding="utf-8" ?>
<ArmedForces>
  <Vehicles type="MotorVehicles" name="Motor Vehicles" description="contains trucks,cars">
    <Vehicle id="1" type="multipurpose wheeled vehicle" cost="220000" currency="$" active="true">
      <Name><![CDATA[HMMWV M1025]]></Name>
      <ImageUrl type="absolute">
        <![CDATA[http://www.cgsociety.org/cgsarchive/newgallerycrits/g20/198120/198120_1269734620_large.jpg]]>
      </ImageUrl>
    </Vehicle>
    <Vehicle id="2" type="truck" cost="170000" currency="$" active="true">
      <Name><![CDATA[M939]]></Name>
      <ImageUrl type="absolute">
        <![CDATA[https://upload.wikimedia.org/wikipedia/commons/6/67/US_Marine_Corps_030224-M-XT622-034_USMC_M923_(6X6)_5-ton_cargo_truck_heads_a_convoy_departing_Camp_Matilda,_Kuwait_crop.jpg]]>
      </ImageUrl>
    </Vehicle>
  </Vehicles>
  <Vehicles type="Armoured" name="Armoured Vehicles" description="contains armoured vehicles, such as tanks, anti aircraft weapons systems, AFVs">
    <Vehicle id="3" type="tank" name="M1A2 ABRAMS" cost="6200000" currency="$" active="true">
      <Name><![CDATA[M1A1 ABRAMS]]></Name>
      <ImageUrl type="absolute">
        <![CDATA[http://www.military-today.com/tanks/m1a2_abrams.jpg]]>
      </ImageUrl>
    </Vehicle>
    <Vehicle id="4" type="armoured fighting vehicle" cost="4900000" currency="$" active="true">
      <Name><![CDATA[Stryker]]></Name>
      <ImageUrl type="absolute">
        <![CDATA[https://upload.wikimedia.org/wikipedia/commons/5/51/Stryker_ICV_front_q.jpg]]>
      </ImageUrl>
    </Vehicle>
    <Vehicle id="5" type="self-propelled anti-aircraft weapon system" cost="3500000" currency="$" active="false">
      <Name><![CDATA[M163 VADS]]></Name>
      <ImageUrl type="absolute">
        <![CDATA[http://afvdb.50megs.com/usa/pics/vadsside.jpg]]>
      </ImageUrl>
    </Vehicle>
  </Vehicles>
  <Vehicles type="Watercraft" name="Watercrafts" description="contains ships,boats and submarines">
    <Vehicle id="6" type="destroyer" cost="1200000000" currency="£" active="true">
      <Name><![CDATA[HMS Daring]]></Name>
      <ImageUrl type="relative">
        <![CDATA[/commons/thumb/c/c9/Royal_Navy_Type_45_Destroyer_HMS_Daring_MOD_45153705.jpg/1280px-Royal_Navy_Type_45_Destroyer_HMS_Daring_MOD_45153705.jpg]]>
      </ImageUrl>
    </Vehicle>
    <Vehicle id="7" type="submarine" cost="1000000000" currency="£" active="true">
      <Name><![CDATA[HMS Artful]]></Name>
      <ImageUrl type="absolute">
        <![CDATA[http://blogs.plymouth.ac.uk/dcss/wp-content/uploads/sites/50/2016/03/HMS-Artful-S121.jpg]]>
      </ImageUrl>
    </Vehicle>
  </Vehicles>
</ArmedForces>


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="ArmedForces">
    <xs:complexType>
      <xs:sequence>
        <xs:element maxOccurs="5" name="Vehicles">
          <xs:complexType>
            <xs:sequence>
              <xs:element maxOccurs="4096" name="Vehicle">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element name="Name" type="xs:string" />
                    <xs:element name="ImageUrl">
                      <xs:complexType>
                        <xs:simpleContent>
                          <xs:extension base="xs:string">
                            <xs:attribute name="type" type="xs:string" use="required" />
                          </xs:extension>
                        </xs:simpleContent>
                      </xs:complexType>
                    </xs:element>
                  </xs:sequence>
                  <xs:attribute name="id" type="xs:unsignedInt" use="required" />
                  <xs:attribute name="type" type="xs:string" use="required" />
                  <xs:attribute name="cost" type="xs:unsignedInt" use="required" />
                  <xs:attribute name="currency" type="xs:string" use="required" />
                  <xs:attribute name="active" type="xs:boolean" use="required" />
                  <xs:attribute name="name" type="xs:string" use="optional" />
                </xs:complexType>
              </xs:element>
            </xs:sequence>
            <xs:attribute name="type" type="xs:string" use="required" />
            <xs:attribute name="name" type="xs:string" use="required" />
            <xs:attribute name="description" type="xs:string" use="required" />
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

XSLT I

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

  <xsl:template match="/">
    <html>
      <head></head>
      <body>
        <h1>Vehicles</h1>
        <ul>
          <xsl:for-each select="/ArmedForces/Vehicles">
            <h1>
              <xsl:value-of select="@type"/>
            </h1>
            <xsl:for-each select="Vehicle">
            <h2>
              Type of vehicle : <xsl:value-of select="@type"/>
            </h2>
            <h3>
              Name of vehicle : <xsl:value-of select="Name/."/>
            </h3>
            <xsl:variable name="url" select="ImageUrl"/>
            <xsl:variable name="urlType" select="ImageUrl/@type"/>
            <xsl:if test=" $urlType = 'absolute'">
              <img>
                <xsl:attribute name="height">
                  200px
                </xsl:attribute>
                <xsl:attribute name="src">
                  <xsl:value-of select="$url"/>
                </xsl:attribute>
              </img>
            </xsl:if>
            <xsl:if test=" $urlType != 'absolute'">
              search for img in local dir
            </xsl:if>
          </xsl:for-each>
          </xsl:for-each>
        </ul>
      </body>
    </html>
  </xsl:template>
</xsl:stylesheet>

XSLT II

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

  <xsl:template match="/">
    <html>
      <head></head>
      <body>
        <h1>Vehicles</h1>
        <ul>
          <xsl:for-each select="/ArmedForces/Vehicles">
            <h1>
              <xsl:value-of select="@name"/>
            </h1>
            Total vehicles : <xsl:value-of select="count(Vehicle)" />
            <br></br>
            <xsl:variable name="inactiveCount" select="count(Vehicle[@active='true'])"></xsl:variable>
            Total active vehicles : <xsl:value-of select="$inactiveCount" />
            <br></br>
            Total inactive vehicles : <xsl:value-of select="count(Vehicle[@active!='true'])" />
            <xsl:if test="$inactiveCount>0">
              <xsl:for-each select="Vehicle">
                <xsl:if test="@active!='true'">
                  <br></br>
                   Inactive unit ID:
                  <xsl:value-of select="@id"/>
                  <br></br>
                  Inactive unit Name:
                  <xsl:value-of select="Name"/>
                </xsl:if>
              </xsl:for-each>
            </xsl:if>
            <br></br>            
            <xsl:for-each select="Vehicle">
          </xsl:for-each>
          </xsl:for-each>
        </ul>
      </body>
    </html>
  </xsl:template>
</xsl:stylesheet>