Minions

From ICO wiki
Revision as of 10:26, 1 April 2014 by Kkund (talk | contribs) (Created page with "== XML kodutöö == === XML fail === <?xml version="1.0"?> <kasutajad> <kasutaja id="0"> <name>superroot</name> <services> <service id="0" option="0"> <comment>R…")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

XML kodutöö

XML fail

<?xml version="1.0"?> <kasutajad> <kasutaja id="0"> <name>superroot</name> <services> <service id="0" option="0"> <comment>Root-level user w/ most superior access</comment> </service> <service id="1" option="0"> <comment>Premium subscription until end of service</comment> </service> </services> </kasutaja> <kasutaja id="1"> <name>root</name> <services> <service id="0" option="0"> <comment>Root-level user w/o premium service</comment> </service> </services> </kasutaja> <kasutaja id="2"> <name>admin</name> <services> <service id="0" option="1"> <comment>Admin-level user w/o premium service</comment> </service> </services> </kasutaja> <kasutaja id="3"> <name>Kaspar</name> <services> <service id="0" option="1"> <comment>Admin-level user</comment> </service> <service id="1" option="0"> <comment>Premium subscription until end of service</comment> </service> </services> </kasutaja> <kasutaja id="4"> <name>Tõnis</name> <services> <service id="0" option="0"> <comment>Admin-level user</comment> </service> <service id="1" option="0"> <comment>Premium subsciption until end of service</comment> </service> </services> </kasutaja> <kasutaja id="5"> <name>Lasse</name> <services> <service id="0" option="1"> <comment>Admin-level user</comment> </service> <service id="1" option="0"> <comment>Premium subsciption until end of service</comment> </service> </services> </kasutaja> <kasutaja id="6"> <name>mod</name> <services> <service id="0" option="2"> <comment>Moderator-level user</comment> </service> </services> </kasutaja> <kasutaja id="7"> <name>supermod</name> <services> <service id="0" option="2"> <comment>Moderator-level user</comment> </service> <service id="1" option="0"> <comment>Premium subsciption until end of service</comment> </service> </services> </kasutaja> <kasutaja id="8"> <name>promod</name> <services> <service id="0" option="2"> <comment>Moderator-level user</comment> </service> <service id="1" option="1" date="2015-02-01"> <comment>Finite period premium user</comment> </service> </services> </kasutaja> <kasutaja id="9"> <name>Pro User</name> <services> <service id="0" option="3"> <comment>Consumer-level user</comment> </service> <service id="1" option="1" date="2015-01-01"> <comment>Finite period premium user</comment> </service> </services> </kasutaja> <kasutaja id="10"> <name>User</name> <services> <service id="0" option="3"> <comment>Consumer-level user</comment> </service> </services> </kasutaja> </kasutajad>

Skeemifail

<?xml version="1.0"?> <xs:schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

 attributeFormDefault="unqualified"
 elementFormDefault="qualified"
 targetNamespace="http://www.w3schools.com"
 xmlns:xs="http://www.w3.org/2001/XMLSchema">
 <xs:element name="kasutajad">
   <xs:complexType>
     <xs:sequence>
       <xs:element name="kasutaja" minOccurs="0" maxOccurs="unbounded">
         <xs:complexType>
           <xs:sequence>
             <xs:element name="name2" type="xs:token" minOccurs="1" maxOccurs="1"/>
             <xs:element name="services">
               <xs:complexType>
                 <xs:sequence>
                   <xs:element name="service" maxOccurs="unbounded">
                     <xs:complexType>
                       <xs:sequence>
                         <xs:element name="comment" type="xs:string" minOccurs="0" maxOccurs="1"/>
                       </xs:sequence>
                       <xs:attribute name="id" type="xs:long" use="required"/>
                       <xs:attribute name="option" type="xs:integer" />
                       <xs:attribute name="date" type="xs:date" />
                     </xs:complexType>
                   </xs:element>
                 </xs:sequence>
               </xs:complexType>
             </xs:element>
           </xs:sequence>
           <xs:attribute name="id" type="xs:long" use="required" />
         </xs:complexType>
       </xs:element>
     </xs:sequence>
   </xs:complexType>
 </xs:element>

</xs:schema>

1. XSL

<?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>
         <title>Kasutajad</title>
       </head>
       <body>
    <xsl:for-each select="kasutajad/kasutaja">
  • <xsl:value-of select="name"/>
      <xsl:for-each select="services/service">
    • <xsl:value-of select="comment"/>
    • </xsl:for-each>
  • </xsl:for-each>
       </body>
     </html>
   </xsl:template>

</xsl:stylesheet>

2. XSL