3-5 Liiget: Difference between revisions
From ICO wiki
				
				
				Jump to navigationJump to search
				
				
| No edit summary | No edit summary | ||
| (3 intermediate revisions by the same user not shown) | |||
| Line 14: | Line 14: | ||
| === XML fail === | === XML fail === | ||
| <source lang="xml"> | |||
| <?xml version="1.0" encoding="utf-8"?> | <?xml version="1.0" encoding="utf-8"?> | ||
| <yritused> | <yritused> | ||
| Line 52: | Line 53: | ||
|    </yritus> |    </yritus> | ||
| </yritused> | </yritused> | ||
| </source> | |||
| == XSD (XML Schema) == | |||
| === XSD fail === | |||
| <source lang="xml"> | |||
| <?xml version="1.0" encoding="ISO-8859-1" ?> | |||
| <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> | |||
| <xs:element name="yritused"> | |||
|   <xs:complexType> | |||
|     <xs:sequence> | |||
|       <xs:element name="yritus"> | |||
|         <xs:complexType> | |||
|           <xs:sequence> | |||
|             <xs:element name="info"> | |||
|               <xs:complexType> | |||
|                 <xs:sequence> | |||
|                   <xs:element name="nimi" type="xs:string"/> | |||
|                   <xs:element name="kirjeldus" type="xs:string"/> | |||
|                   <xs:element name="asukoht" type="xs:string"/> | |||
|                   <xs:element name="maakond" type="xs:string"/> | |||
|                   <xs:element name="asula" type="xs:string"/> | |||
|                   <xs:element name="aeg" type="xs:string"/> | |||
|                   <xs:element name="hind"> | |||
|                     <xs:complexType> | |||
|                       <xs:simpleContent> | |||
|                         <xs:extension base="xs:int"> | |||
|                           <xs:attribute name="yhik" type="xs:string" /> | |||
|                         </xs:extension> | |||
|                       </xs:simpleContent> | |||
|                     </xs:complexType> | |||
|                   </xs:element> | |||
|                 </xs:sequence> | |||
|               </xs:complexType> | |||
|             </xs:element> | |||
|             <xs:element name="fotod" maxOccurs="unbounded" minOccurs="0"> | |||
|               <xs:complexType> | |||
|                 <xs:sequence> | |||
|                   <xs:element name="foto" maxOccurs="unbounded" minOccurs="0"> | |||
|                     <xs:complexType> | |||
|                       <xs:sequence> | |||
|                         <xs:element name="nimi" type="xs:string"/> | |||
|                         <xs:element name="kirjeldus" type="xs:string"/> | |||
|                         <xs:element name="lisatud" type="xs:string"/> | |||
|                         <xs:element name="fail"> | |||
|                           <xs:complexType> | |||
|                             <xs:sequence> | |||
|                               <xs:element name="suurus" maxOccurs="unbounded" minOccurs="0"> | |||
|                                 <xs:complexType> | |||
|                                   <xs:simpleContent> | |||
|                                     <xs:extension base="xs:string"> | |||
|                                       <xs:attribute name="vaade" type="xs:string" /> | |||
|                                     </xs:extension> | |||
|                                   </xs:simpleContent> | |||
|                                 </xs:complexType> | |||
|                               </xs:element> | |||
|                             </xs:sequence> | |||
|                           </xs:complexType> | |||
|                         </xs:element> | |||
|                       </xs:sequence> | |||
|                       <xs:attribute name="id" type="xs:int"/> | |||
|                       <xs:attribute name="avapilt" type="xs:string"/> | |||
|                     </xs:complexType> | |||
|                   </xs:element> | |||
|                 </xs:sequence> | |||
|               </xs:complexType> | |||
|             </xs:element> | |||
|           </xs:sequence> | |||
|           <xs:attribute name="id" type="xs:int"/> | |||
|           <xs:attribute name="kategooria" type="xs:string"/> | |||
|           <xs:attribute name="marksonad" type="xs:string"/> | |||
|         </xs:complexType> | |||
|       </xs:element> | |||
|     </xs:sequence> | |||
|   </xs:complexType> | |||
| </xs:element> | |||
| </xs:schema> | |||
| </source> | |||
| == XSLT == | |||
| === XSLT fail === | |||
| <source lang="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="html" indent="yes"/> | |||
| <xsl:template match="/"> | |||
| <html> | |||
| <head></head> | |||
| <body> | |||
| <table border="1" cellpadding="3"> | |||
|   <tr bgcolor="#abcdef"> | |||
|     <td>Liik/Märksõnad</td> | |||
|     <td colspan="2">Info</td> | |||
|     <td>Pildid</td> | |||
|   </tr> | |||
|   <xsl:for-each select="yritused/yritus"> | |||
|   <tr> | |||
|     <td align="center" rowspan="7"> | |||
|       <xsl:value-of select ="@kategooria"/> | |||
|       <br/> | |||
|       (<xsl:value-of select ="@marksonad"/>) | |||
|     </td> | |||
|     <td rowsapan="7"> | |||
|       <strong>Nimi</strong> | |||
|     </td> | |||
|       <td rowsapan="7"> | |||
|       <strong><xsl:value-of select="info/nimi"/></strong>     	  | |||
|     </td> | |||
|     <td rowspan="7"> | |||
|       <xsl:for-each select="fotod/foto"> | |||
|         <div> | |||
|           <xsl:choose> | |||
|             <xsl:when test="@avapilt='jah'"> | |||
|               <strong title="avapilt"> | |||
|                 <xsl:value-of select="nimi"/> | |||
|               </strong> | |||
|             </xsl:when> | |||
|             <xsl:otherwise> | |||
|               <xsl:value-of select="nimi"/> | |||
|             </xsl:otherwise> | |||
|           </xsl:choose> | |||
|           <ul> | |||
|             <xsl:for-each select ="fail/suurus"> | |||
|               <li> | |||
|                 <xsl:value-of select="."></xsl:value-of> | |||
|               </li> | |||
|             </xsl:for-each> | |||
|           </ul> | |||
|         </div> | |||
|       </xsl:for-each> | |||
|     </td> | |||
|   </tr> | |||
|   <tr> | |||
|     <td> | |||
|       <strong>Kirjeldus:</strong> | |||
|     </td> | |||
|     <td><xsl:value-of select ="info/kirjeldus"/></td> | |||
|   </tr> | |||
|   <tr> | |||
|     <td> | |||
|       <strong>Asukoht:</strong> | |||
|     </td> | |||
|     <td><xsl:value-of select ="info/asukoht"/></td> | |||
|   </tr> | |||
|   <tr> | |||
|     <td> | |||
|       <strong>Maakond:</strong> | |||
|     </td> | |||
|     <td><xsl:value-of select ="info/maakond"/></td> | |||
|   </tr> | |||
|   <tr> | |||
|     <td> | |||
|       <strong>Asula:</strong> | |||
|     </td> | |||
|     <td><xsl:value-of select ="info/asula"/></td> | |||
|   </tr> | |||
|   <tr> | |||
|     <td> | |||
|       <strong>Aeg</strong> | |||
|     </td> | |||
|     <td><xsl:value-of select ="info/aeg"/></td> | |||
|     </tr> | |||
|     <tr> | |||
|       <td> | |||
|         <strong>Hind:</strong> | |||
|       </td> | |||
|       <td><xsl:value-of select ="info/hind"/></td> | |||
|     </tr> | |||
|   </xsl:for-each>           	  | |||
| </table> | |||
| </body> | |||
| </html> | |||
|  </xsl:template> | |||
| </xsl:stylesheet> | |||
| </source> | |||
Latest revision as of 12:12, 8 June 2013
Meeskond "Seekord 3 liiget"
- Liikmed
- Tarvo Rohiväli
- Indrek Vallsalu
- Ragnar Vutt
 
Idee
Ürituste otsimise teenus.
XML
XML fail
<?xml version="1.0" encoding="utf-8"?>
<yritused>
  <yritus id="1" kategooria="jaanituli" marksonad="jaan, tuli, lõke">
    <info>
      <nimi>Lutike jaanituli</nimi>
      <kirjeldus>Tahad tunda rõõmu heast seltskonnast? Astu aga läbi. Rumm on tasuta!</kirjeldus>
      <asukoht>Lutike Peomaja (meie teame, kus pidu tegelikult käib)</asukoht>
      <maakond>Valgamaa</maakond>
      <asula>Lutike</asula>
      <aeg>2013-06-27 21:00:00</aeg>
      <hind yhik="euro">0</hind>
    </info>
    <fotod>
      <foto id="1" avapilt="jah">
        <nimi>Poster</nimi>
        <kirjeldus>Lõkke ääres...</kirjeldus>
        <lisatud>2013-04-29</lisatud>
        <fail>
          <suurus vaade="ico">poster_jaanituli_ico.jpg</suurus>
          <suurus vaade="s">poster_jaanituli_150.jpg</suurus>
          <suurus vaade="m">poster_jaanituli_800.jpg</suurus>
          <suurus vaade="l">poster_jaanituli.jpg</suurus>
        </fail>
      </foto>
      <foto id="2" avapilt="ei">
        <nimi>Opossum</nimi>
        <kirjeldus>Opossumionu hüppab üle lõkke</kirjeldus>
        <lisatud>2013-04-29</lisatud>
        <fail>
          <suurus vaade="ico">opossum_ico.jpg</suurus>
          <suurus vaade="s">opossum_150.jpg</suurus>
          <suurus vaade="m">opossum_800.jpg</suurus>
          <suurus vaade="l">opossum.jpg</suurus>
        </fail>
      </foto>
    </fotod>
  </yritus>
</yritused>
XSD (XML Schema)
XSD fail
<?xml version="1.0" encoding="ISO-8859-1" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="yritused">
  <xs:complexType>
    <xs:sequence>
      <xs:element name="yritus">
        <xs:complexType>
          <xs:sequence>
            <xs:element name="info">
              <xs:complexType>
                <xs:sequence>
                  <xs:element name="nimi" type="xs:string"/>
                  <xs:element name="kirjeldus" type="xs:string"/>
                  <xs:element name="asukoht" type="xs:string"/>
                  <xs:element name="maakond" type="xs:string"/>
                  <xs:element name="asula" type="xs:string"/>
                  <xs:element name="aeg" type="xs:string"/>
                  <xs:element name="hind">
                    <xs:complexType>
                      <xs:simpleContent>
                        <xs:extension base="xs:int">
                          <xs:attribute name="yhik" type="xs:string" />
                        </xs:extension>
                      </xs:simpleContent>
                    </xs:complexType>
                  </xs:element>
                </xs:sequence>
              </xs:complexType>
            </xs:element>
            <xs:element name="fotod" maxOccurs="unbounded" minOccurs="0">
              <xs:complexType>
                <xs:sequence>
                  <xs:element name="foto" maxOccurs="unbounded" minOccurs="0">
                    <xs:complexType>
                      <xs:sequence>
                        <xs:element name="nimi" type="xs:string"/>
                        <xs:element name="kirjeldus" type="xs:string"/>
                        <xs:element name="lisatud" type="xs:string"/>
                        <xs:element name="fail">
                          <xs:complexType>
                            <xs:sequence>
                              <xs:element name="suurus" maxOccurs="unbounded" minOccurs="0">
                                <xs:complexType>
                                  <xs:simpleContent>
                                    <xs:extension base="xs:string">
                                      <xs:attribute name="vaade" type="xs:string" />
                                    </xs:extension>
                                  </xs:simpleContent>
                                </xs:complexType>
                              </xs:element>
                            </xs:sequence>
                          </xs:complexType>
                        </xs:element>
                      </xs:sequence>
                      <xs:attribute name="id" type="xs:int"/>
                      <xs:attribute name="avapilt" type="xs:string"/>
                    </xs:complexType>
                  </xs:element>
                </xs:sequence>
              </xs:complexType>
            </xs:element>
          </xs:sequence>
          <xs:attribute name="id" type="xs:int"/>
          <xs:attribute name="kategooria" type="xs:string"/>
          <xs:attribute name="marksonad" type="xs:string"/>
        </xs:complexType>
      </xs:element>
    </xs:sequence>
  </xs:complexType>
</xs:element>
</xs:schema>
XSLT
XSLT fail
<?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>
<table border="1" cellpadding="3">
  <tr bgcolor="#abcdef">
    <td>Liik/Märksõnad</td>
    <td colspan="2">Info</td>
    <td>Pildid</td>
  </tr>
  <xsl:for-each select="yritused/yritus">
  <tr>
    <td align="center" rowspan="7">
      <xsl:value-of select ="@kategooria"/>
      <br/>
      (<xsl:value-of select ="@marksonad"/>)
    </td>
    <td rowsapan="7">
      <strong>Nimi</strong>
    </td>
      <td rowsapan="7">
      <strong><xsl:value-of select="info/nimi"/></strong>     	 
    </td>
    <td rowspan="7">
      <xsl:for-each select="fotod/foto">
        <div>
          <xsl:choose>
            <xsl:when test="@avapilt='jah'">
              <strong title="avapilt">
                <xsl:value-of select="nimi"/>
              </strong>
            </xsl:when>
            <xsl:otherwise>
              <xsl:value-of select="nimi"/>
            </xsl:otherwise>
          </xsl:choose>
          <ul>
            <xsl:for-each select ="fail/suurus">
              <li>
                <xsl:value-of select="."></xsl:value-of>
              </li>
            </xsl:for-each>
          </ul>
        </div>
      </xsl:for-each>
    </td>
  </tr>
  <tr>
    <td>
      <strong>Kirjeldus:</strong>
    </td>
    <td><xsl:value-of select ="info/kirjeldus"/></td>
  </tr>
  <tr>
    <td>
      <strong>Asukoht:</strong>
    </td>
    <td><xsl:value-of select ="info/asukoht"/></td>
  </tr>
  <tr>
    <td>
      <strong>Maakond:</strong>
    </td>
    <td><xsl:value-of select ="info/maakond"/></td>
  </tr>
  <tr>
    <td>
      <strong>Asula:</strong>
    </td>
    <td><xsl:value-of select ="info/asula"/></td>
  </tr>
  <tr>
    <td>
      <strong>Aeg</strong>
    </td>
    <td><xsl:value-of select ="info/aeg"/></td>
    </tr>
    <tr>
      <td>
        <strong>Hind:</strong>
      </td>
      <td><xsl:value-of select ="info/hind"/></td>
    </tr>
  </xsl:for-each>           	 
</table>
</body>
</html>
 </xsl:template>
</xsl:stylesheet>