Professional Documents
Culture Documents
XML i XSLT
(26 detaljno urađenih zadataka)
1
U prva tri zadatka dat je isti dokument
• Dobijeni dokument: vizit_karte.xml
<?xml version="1.0" encoding="utf-8"?>
<vizit_karte>
<vizit_karta>
<ime_i_prezime>Dzon Fante</ime_i_prezime>
<telefon tip="posao">+387 62 345 543</telefon>
<telefon tip="kuca" vrsta="glavni">+387 32 345 543</telefon>
<telefon tip="faks">+387 70 345 543</telefon>
<e-mail>dzonze@gmail.com</e-mail>
</vizit_karta>
<vizit_karta>
<ime_i_prezime>Robert Grevs</ime_i_prezime>
<telefon tip="posao" vrsta="glavni">+387 64 221 324</telefon>
<telefon tip="kuca">+387 32 221 324</telefon>
<telefon tip="faks">+387 70 221 324</telefon>
<e-mail>robertart@gmail.com</e-mail>
</vizit_karta>
<vizit_karta>
<ime_i_prezime>Reinhart Diestel</ime_i_prezime>
<telefon tip="posao">+387 65 998 667</telefon>
<telefon tip="kuca" vrsta="glavni">+387 32 998 667</telefon>
<telefon tip="faks">+387 70 998 667</telefon>
<e-mail>reinhartpro@gmail.com</e-mail>
</vizit_karta>
<vizit_karta>
<ime_i_prezime>Julia Kristeva</ime_i_prezime>
<telefon tip="posao">+387 61 765 793</telefon>
<telefon tip="kuca" vrsta="glavni">+387 32 765 793</telefon>
<telefon tip="faks">+387 70 765 793</telefon>
<e-mail>juliamat@gmail.com</e-mail>
</vizit_karta>
</vizit_karte>
2
Zadatak broj 1 • Prepravljeni XML dokument
<?xml version="1.0" encoding="utf-8"?>
• Dobijeni dokument: vizit_karte.xml <?xml-stylesheet type="text/css" href="prikaz.css"?>
<?xml version="1.0" encoding="utf-8"?> <vizit_karte>...
<vizit_karte>
<vizit_karta> • Jedno od mogućih rješenja: prikaz.css
<ime_i_prezime>Dzon Fante</ime_i_prezime> @charset "utf-8";
<telefon tip="posao">+387 62 345 543</telefon> /* CSS Document */
<telefon tip="kuca" vrsta="glavni">+387 32 345
543</telefon> vizit_karta
<telefon tip="faks">+387 70 345 543</telefon> {
<e-mail>dzonze@gmail.com</e-mail> display:block;
</vizit_karta> width:300px;
... border:thick solid #000066;
float:inherit;
• Traženi izgled u web browseru (prikaz vizit karti) background:#CCFF33;
padding:10px;
margin: 25px;
}
ime_i_prezime
{
font-size:1.3em;
font-family:Arial, Helvetica, sans-serif;
font-size:2em;
text-align:center;
}
telefon
{
display:block;
}
e-mail
{
display:none;
}
telefon:before
{
content:attr(tip) ": ";
}
vizit_karta:hover
{
display:block;
width:300px;
border:thick solid #000066;
float:inherit;
background:#999900;
padding:10px;
margin: 25px;
}
3
Zadatak broj 2 • Jedno od mogućih rješenja: kucniBrojTelefona.xsl
<?xml version="1.0" encoding="utf-8"?><!DOCTYPE xsl:stylesheet [
• Dobijeni dokument: vizit_karte.xml <!ENTITY nbsp " ">
<?xml version="1.0" encoding="utf-8"?> <!ENTITY copy "©">
<vizit_karte> ... (ovaj dio je isti kao u sljedećem zadatku)
<vizit_karta> <!ENTITY pound "£">
<ime_i_prezime>Dzon Fante</ime_i_prezime> <!ENTITY yen "¥">
<telefon tip="posao">+387 62 345 543</telefon> <!ENTITY euro "€">
<telefon tip="kuca" vrsta="glavni">+387 32 345 ]>
543</telefon> <xsl:stylesheet version="1.0"
<telefon tip="faks">+387 70 345 543</telefon> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<e-mail>dzonze@gmail.com</e-mail> <xsl:output method="html" encoding="utf-8" doctype-public="-
</vizit_karta> //W3C//DTD XHTML 1.0 Transitional//EN" doctype-
... system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>
<xsl:template match="/">
• Traženi izgled u web browseru (kućni brojevi telefona i faks)
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-
8"/>
<title>Kucni broj telefona</title>
</head>
<body>
<xsl:for-each select="vizit_karte/vizit_karta">
<tr>
<td style="font-size:1.5em"><xsl:value-of
select="ime_i_prezime"/></td>
<td>
<xsl:for-each select="telefon">
<xsl:if test="(.[contains(@tip,'kuca')])">
<xsl:value-of select="."/><br />
</xsl:if>
</xsl:for-each>
<xsl:for-each select="telefon">
<xsl:if test="(.[contains(@tip,'faks')])">
Faks: <xsl:value-of select="."/><br /><br />
</xsl:if>
</xsl:for-each>
</td>
</tr>
</xsl:for-each>
</table>
• Prepravljeni XML dokument </body>
<?xml version="1.0" encoding="utf-8"?> </html>
<?xml-stylesheet type="text/xsl" href="kucniBrojTelefona.xsl"?> </xsl:template>
<vizit_karte>... </xsl:stylesheet>
4
Zadatak broj 3 • Jedno od mogućih rješenja: sviBrojevi.xsl
<?xml version="1.0" encoding="utf-8"?><!DOCTYPE xsl:stylesheet [
• Dobijeni dokument: vizit_karte.xml <!ENTITY nbsp " ">
<?xml version="1.0" encoding="utf-8"?> <!ENTITY copy "©">
<vizit_karte> <!ENTITY reg "®">
<vizit_karta> <!ENTITY trade "™">
<ime_i_prezime>Dzon Fante</ime_i_prezime> <!ENTITY mdash "—">
<telefon tip="posao">+387 62 345 543</telefon> <!ENTITY ldquo "“">
<telefon tip="kuca" vrsta="glavni">+387 32 345 <!ENTITY rdquo "”">
543</telefon> <!ENTITY pound "£">
<telefon tip="faks">+387 70 345 543</telefon> <!ENTITY yen "¥">
<e-mail>dzonze@gmail.com</e-mail> <!ENTITY euro "€">
</vizit_karta> ]>
... <xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
• Traženi izgled u web browseru (svi brojevi telefona iz dokumenta) <xsl:output method="html" encoding="utf-8" doctype-public="-
//W3C//DTD XHTML 1.0 Transitional//EN" doctype-
system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>
<xsl:template match="/">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-
8"/>
<title>Vjezba broj 3 Svi brojevi telefona</title>
</head>
<body>
<h1>Svi brojevi telefona koji se pojavljuju u dokumentu su</h1>
<font size="+2">
<xsl:for-each select="vizit_karte/vizit_karta/telefon">
<xsl:value-of select="."/><br />
</xsl:for-each>
</font>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
5
U četvrtom, petom i šestom zadatku dat je isti dokument
Dobijeni dokument: cdcatalog_v3.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<katalog>
<cd>
<album>Live And Feelin' Good (The Blues Collection
Vol.68)</album>
<izvodjac>Piano Red</izvodjac>
<zemlja>USA</zemlja>
<izdavac>?</izdavac>
<cijena>4.99</cijena>
<godina>2007</godina>
</cd>
<cd>
<album>The Definitive Collection, Volume II: The Best
Of Brian (Disc 1)</album>
<izvodjac>AC/DC</izvodjac>
<zemlja>USA</zemlja>
<izdavac>?</izdavac>
<cijena>11.99</cijena>
<godina>2010</godina>
</cd>
…
</katalog>
6
Primjer 4 • Rješenje: stil1.xsl
<?xml version="1.0" encoding="utf-8"?><!DOCTYPE xsl:stylesheet [
• Dobijeni dokument: cdcatalog_v3.xml <!ENTITY nbsp " ">
<?xml version="1.0" encoding="ISO-8859-1"?> <!ENTITY copy "©">
<katalog> <!ENTITY reg "®">
<cd> <!ENTITY trade "™">
<album>Live And Feelin' Good (The Blues Collection <!ENTITY mdash "—">
Vol.68)</album> <!ENTITY ldquo "“">
<izvodjac>Piano Red</izvodjac> <!ENTITY rdquo "”">
<zemlja>USA</zemlja> <!ENTITY pound "£">
<izdavac>?</izdavac> <!ENTITY yen "¥">
<cijena>4.99</cijena> <!ENTITY euro "€">
<godina>2007</godina> ]>
</cd> <xsl:stylesheet version="1.0"
... xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
</katalog> <xsl:output method="html" encoding="utf-8" doctype-public="-
• Traženi izgled u web browseru //W3C//DTD XHTML 1.0 Transitional//EN" doctype-
system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>
<xsl:template match="/">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-
8"/>
<title>Vježba broj 1 - upotreba templata i CSS</title>
</head>
<body>
<xsl:apply-templates select="katalog"/>
</body>
</html>
</xsl:template>
<xsl:template match="katalog">
<xsl:apply-templates select="cd"/><br />
</xsl:template>
<xsl:template match="cd">
<div style="background:#99FFCC; width:400px; border:thick solid
#000000; padding:10px; margin:20px; text-align:center">
<font style="font-size:2em; color:#FF0000"><xsl:value-of
select="izvodjac"/></font><br />
<xsl:value-of select="album"/><br />
Godina izdanja: <xsl:value-of select="godina"/><br />
<font style="font-size:1.5em"> Cijena: <xsl:value-of
select="cijena"/> KM </font><br />
• Prepravljeni XML dokument </div>
<?xml version="1.0" encoding="ISO-8859-1"?> </xsl:template>
<?xml-stylesheet href="stil1.xsl" type="text/xsl"?>
… </xsl:stylesheet>
7
Primjer 5 • Rješenje: stil2.xsl
<?xml version="1.0" encoding="utf-8"?><!DOCTYPE xsl:stylesheet [
• Dobijeni dokument: cdcatalog_v3.xml <!ENTITY nbsp " ">
<?xml version="1.0" encoding="ISO-8859-1"?> <!ENTITY copy "©">
<katalog> …
<cd> <!ENTITY yen "¥">
<album>Live And Feelin' Good (The Blues Collection <!ENTITY euro "€">
Vol.68)</album> ]>
<izvodjac>Piano Red</izvodjac> <xsl:stylesheet version="1.0"
<zemlja>USA</zemlja> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<izdavac>?</izdavac> <xsl:output method="html" encoding="utf-8" doctype-public="-
<cijena>4.99</cijena> //W3C//DTD XHTML 1.0 Transitional//EN" doctype-
<godina>2007</godina> system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>
</cd> <xsl:template match="/">
...
</katalog> <html xmlns="http://www.w3.org/1999/xhtml">
• Traženi izgled u web browseru <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-
8"/>
<title>Tri kolone ili tri div-a???</title>
</head>
<body>
</body>
</html>
</xsl:template>
• Prepravljeni XML dokument <xsl:template match="cd">
<?xml version="1.0" encoding="ISO-8859-1"?> <xsl:value-of select="album"/>,
<xsl:value-of select="zemlja"/>,
<?xml-stylesheet href="stil2.xsl" type="text/xsl"?> <xsl:value-of select="godina"/><br />
</xsl:template>
<katalog>
<cd>
… </xsl:stylesheet>
8
<!ENTITY ldquo "“">
Primjer 6 <!ENTITY rdquo "”">
• Dobijeni dokument: cdcatalog_v3.xml <!ENTITY pound "£">
<?xml version="1.0" encoding="ISO-8859-1"?> <!ENTITY yen "¥">
<katalog> <!ENTITY euro "€">
<cd> ]>
<album>Live And Feelin' Good (The Blues Collection <xsl:stylesheet version="1.0"
Vol.68)</album> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<izvodjac>Piano Red</izvodjac> <xsl:output method="html" encoding="utf-8" doctype-public="-
<zemlja>USA</zemlja> //W3C//DTD XHTML 1.0 Transitional//EN" doctype-
<izdavac>?</izdavac> system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>
<cijena>4.99</cijena> <xsl:template match="/">
<godina>2007</godina>
</cd> <html xmlns="http://www.w3.org/1999/xhtml">
... <head>
</katalog> <meta http-equiv="Content-Type" content="text/html; charset=utf-
8"/>
• Traženi izgled u web browseru <title>Vježba broj 3 - tabela</title>
</head>
<body>
9
U sljedećih dvanaest zadataka dat je isti dokument </dogadjaj>
<dogadjaj type="yellow_card" team="domacini">
• Dobijeni dokument: utakmice2012.xml <igrac>Stere</igrac>
<minuta>46</minuta>
</dogadjaj>
<?xml version="1.0" encoding="utf-8"?>
<dogadjaj type="yellow_card" team="gosti">
<utakmice total-count="5" first="1" last="5"> <igrac>Chipciu</igrac>
<minuta>52</minuta>
<predmet sadrzaj="rom_l1" status="finished" timestamp- </dogadjaj>
starts="1280156400"> <dogadjaj type="yellow_card" team="domacini">
<igrac>Balau</igrac>
<timovi> <minuta>60</minuta>
<domacini id="tarmfcm_rom">
<ime>Targu</ime> </dogadjaj>
<punoime>FCM Targu Mures</punoime> <dogadjaj type="yellow_card" team="domacini">
</domacini> <igrac>Stanga</igrac>
<minuta>65</minuta>
<gosti id="brasfc_rom"> </dogadjaj>
<ime>Brasov</ime> <dogadjaj type="goal" team="gosti">
<punoime>FC Brasov</punoime> <igrac>Badea</igrac>
</gosti>
</timovi> <rezultat>0 - 1</rezultat>
<minuta>68</minuta>
<rezultat>0 - 1</rezultat> </dogadjaj>
<dogadjaj type="red_card" team="gosti">
<detalji> <igrac>Majernik</igrac>
<sadrzaj> <minuta>76</minuta>
<takmicenje id="rom_l1"> </dogadjaj>
<naslov>Romania - Liga 1</naslov> </dogadjaji>
</takmicenje> </predmet>
<sezona>2010/2011</sezona>
</sadrzaj> <predmet sadrzaj="swe_fd" status="active" timestamp-
<oprema-info>1</oprema-info> starts="1280163600">
</detalji> <timovi>
<domacini id="hif_swe">
<dogadjaji> <ime>Helsingborg</ime>
<dogadjaj type="yellow_card" team="domacini"> <punoime>Helsingborgs IF</punoime>
<igrac>Onicas</igrac> </domacini>
<minuta>22</minuta>
</dogadjaj> <gosti id="bkh_swe">
<dogadjaj type="yellow_card" team="domacini"> <ime>Hacken</ime>
<igrac>Vancea</igrac> <punoime>BK Hacken</punoime>
<minuta>27</minuta> </gosti>
</dogadjaj> </timovi>
<dogadjaj type="yellow_card" team="gosti"> <rezultat>0 - 1</rezultat>
<igrac>Hadnagy</igrac> <trenutno-stanje>
<minuta>29</minuta>
</dogadjaj> <poluvrijeme>first_half</poluvrijeme>
<dogadjaj type="yellow_card" team="gosti"> <minuta>23</minuta>
</trenutno-stanje>
<igrac>Voicu</igrac>
<minuta>34</minuta> <detalji>
10
<sadrzaj> <igrac>Sellman</igrac>
<takmicenje id="swe_fd"> <minuta>3</minuta>
<naslov>Sweden - First Division</naslov> </dogadjaj>
</takmicenje>
<sezona>2010</sezona> <dogadjaj type="yellow_card" team="gosti">
</sadrzaj> <igrac>Robert</igrac>
<oprema-info>16</oprema-info> <minuta>6</minuta>
</detalji> </dogadjaj>
<dogadjaji> </dogadjaji>
<dogadjaj type="goal" team="gosti"> </predmet>
<igrac>Ostberg</igrac>
<rezultat>0 - 1</rezultat>
<minuta>12</minuta>
</dogadjaj> ...
</dogadjaji>
<dogadjaji> </utakmice>
<dogadjaj type="yellow_card" team="domacini">
11
<utakmice total-count="5" first="1" last="5">...
Zadatak broj 7
• Jedno od mogućih rješenja: stil1_zaUtakmice.xsl
• Dobijeni dokument: utakmice2012.xml <?xml version="1.0" encoding="utf-8"?><!DOCTYPE xsl:stylesheet [
<?xml version="1.0" encoding="utf-8"?> <!ENTITY nbsp " ">
<utakmice total-count="5" first="1" last="5"> <!ENTITY copy "©">
<predmet sadrzaj="rom_l1" status="finished" timestamp- <!ENTITY reg "®">
starts="1280156400"> <!ENTITY trade "™">
<timovi> <!ENTITY mdash "—">
<domacini id="tarmfcm_rom"> <!ENTITY ldquo "“">
<ime>Targu</ime> <!ENTITY rdquo "”">
<punoime>FCM Targu Mures</punoime> <!ENTITY pound "£">
</domacini> <!ENTITY yen "¥">
<gosti id="brasfc_rom"> <!ENTITY euro "€">
<ime>Brasov</ime> ]>
<punoime>FC Brasov</punoime> <xsl:stylesheet version="1.0"
</gosti> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
</timovi> <xsl:output method="html" encoding="utf-8" doctype-public="-
... //W3C//DTD XHTML 1.0 Transitional//EN" doctype-
• Traženi izgled u web browseru (rezultati utakmica, redni broj utakmice, system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>
veći font, obojene ćelije) <xsl:template match="/">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-
8"/>
<title>Vjezba broj 1</title>
</head>
<body>
<h1>Rezultati utakmica</h1>
<xsl:for-each select="utakmice/predmet">
<tr>
<td><font size="+3"><xsl:value-of
select="position()"/>.</font></td>
<td><xsl:value-of select="timovi/domacini/punoime"/></td>
<td><xsl:value-of select="timovi/gosti/punoime"/></td>
<td><xsl:value-of select="rezultat"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
• Prepravljeni XML dokument
</xsl:template>
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="stil1_zaUtakmice.xsl"?> </xsl:stylesheet>
12
<?xml-stylesheet type="text/xsl" href="stil2_zaUtakmice.xsl"?>
Zadatak broj 8 <utakmice total-count="5" first="1" last="5">...
• Dobijeni dokument: utakmice2012.xml • Jedno od mogućih rješenja: stil2_zaUtakmice.xsl
<?xml version="1.0" encoding="utf-8"?> ... Početak je isti kao u prethodnom zadatku ...
<utakmice total-count="5" first="1" last="5">
<predmet sadrzaj="rom_l1" status="finished" timestamp- <xsl:template match="/">
starts="1280156400"> <html xmlns="http://www.w3.org/1999/xhtml">
<timovi> <head>
<domacini id="tarmfcm_rom"> <meta http-equiv="Content-Type" content="text/html; charset=utf-
... 8"/>
<title>Vjezba broj 2</title>
• Traženi izgled u web browseru (žuti kartoni svih igrača iz svih utakmica) </head>
<body>
<h1>Žuti kartoni domacih igraca</h1>
<table width="600" border="2">
<xsl:for-each select="utakmice/predmet">
<tr><td bgcolor="#CCFFFF"><font size="+3">Utakmica</font></td><td>
<xsl:value-of select="timovi/domacini/punoime"/>
-
<xsl:value-of select="timovi/gosti/punoime"/><br />
</td></tr>
<tr><td>Kartoni</td><td>
</xsl:for-each>
</td></tr>
<tr><td> </td><td> </td></tr>
</xsl:for-each>
</table>
<tr>
<td></td>
<td></td>
<td><xsl:value-of select="rezultat"/></td>
</tr>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
• Prepravljeni XML dokument </xsl:template>
<?xml version="1.0" encoding="utf-8"?> </xsl:stylesheet>
13
Zadatak broj 9 • Jedno od mogućih rješenja: stil3_zaUtakmice.xsl
• Dobijeni dokument: utakmice2012.xml ... Početak je isti kao u prethodnom zadatku ...
<?xml version="1.0" encoding="utf-8"?>
<utakmice total-count="5" first="1" last="5"> <xsl:stylesheet version="1.0"
<predmet sadrzaj="rom_l1" status="finished" timestamp- xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
starts="1280156400"> <xsl:output method="html" encoding="utf-8" doctype-public="-
<timovi> //W3C//DTD XHTML 1.0 Transitional//EN" doctype-
<domacini id="tarmfcm_rom"> system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>
...
• Traženi izgled u web browseru (imena liga, timovi i njihovi puni nazivi,
broj utakmica u dokumentu) <xsl:template match="/">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-
8"/>
<title>Vježba broj 3</title>
</head>
<body>
<h1>Neke zanimljive informacije:</h1><br />
Ukupno ima
<xsl:for-each select="utakmice/predmet/detalji/sadrzaj/takmicenje">
<xsl:if test="position()=1">
<font size="+3"><xsl:value-of select="last()"/></font>
</xsl:if>
</xsl:for-each> utkmica.
• Prepravljeni XML dokument
</body>
<?xml version="1.0" encoding="utf-8"?> </html>
<?xml-stylesheet type="text/xsl" href="stil3_zaUtakmice.xsl"?>
<utakmice total-count="5" first="1" last="5">... </xsl:template>
</xsl:stylesheet>
14
...
Zadatak broj 10 • Jedno od mogućih rješenja: stil1_zaUtakmice.xsl
• Dobijeni dokument: utakmice2012.xml <?xml version="1.0" encoding="utf-8"?><!DOCTYPE xsl:stylesheet [
<?xml version="1.0" encoding="utf-8"?> <!ENTITY nbsp " ">
<utakmice total-count="5" first="1" last="5"> <!ENTITY copy "©">
<predmet sadrzaj="rom_l1" status="finished" timestamp- <!ENTITY reg "®">
starts="1280156400"> <!ENTITY trade "™">
<timovi> <!ENTITY mdash "—">
<domacini id="tarmfcm_rom"> <!ENTITY ldquo "“">
<ime>Targu</ime> <!ENTITY rdquo "”">
<punoime>FCM Targu Mures</punoime> <!ENTITY pound "£">
</domacini> <!ENTITY yen "¥">
<gosti id="brasfc_rom"> <!ENTITY euro "€">
<ime>Brasov</ime> ]>
<punoime>FC Brasov</punoime> <xsl:stylesheet version="1.0"
</gosti> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
</timovi> <xsl:output method="html" encoding="utf-8" doctype-public="-
... //W3C//DTD XHTML 1.0 Transitional//EN" doctype-
system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>
• Traženi izgled u web browseru (rezultati utakmica i redni brojevi)
<xsl:template match="/">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-
8"/>
<title>Vjezba broj 1</title>
</head>
<body>
<h1>Rezultati utakmica</h1>
<xsl:for-each select="utakmice/predmet">
<tr>
<td><font size="+3"><xsl:value-of
select="position()"/>.</font></td>
<td><xsl:value-of select="timovi/domacini/punoime"/></td>
<td><xsl:value-of select="timovi/gosti/punoime"/></td>
<td><xsl:value-of select="rezultat"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
• Prepravljeni XML dokument
<?xml version="1.0" encoding="utf-8"?> </xsl:template>
<?xml-stylesheet type="text/xsl" href="stil1_zaUtakmice.xsl"?>
<utakmice total-count="5" first="1" last="5"> </xsl:stylesheet>
15
Zadatak broj 11 • Prepravljeni XML dokument
<?xml version="1.0" encoding="utf-8"?>
• Dobijeni dokument: utakmice2012.xml <?xml-stylesheet type="text/xsl" href="stil2_zaUtakmice.xsl"?>
<?xml version="1.0" encoding="utf-8"?> ...
<utakmice total-count="5" first="1" last="5"> • Jedno od mogućih rješenja: stil2_zaUtakmice.xsl
<predmet sadrzaj="rom_l1" status="finished" timestamp- ...čitav početak je isti kao u prethodnom zadatku...
starts="1280156400">
<timovi> <html xmlns="http://www.w3.org/1999/xhtml">
<domacini id="tarmfcm_rom"> <head>
<ime>Targu</ime> <meta http-equiv="Content-Type" content="text/html; charset=utf-
<punoime>FCM Targu Mures</punoime> 8"/>
... <title>Vjezba broj 2</title>
• Traženi izgled u web browseru (žuti kartoni domaćih igrača iz svih </head>
utakmica) <body>
<h1>Žuti kartoni domacih igraca</h1>
<table width="600" border="2">
<xsl:for-each select="utakmice/predmet">
<tr><td bgcolor="#CCFFFF"><font size="+3">Utakmica</font></td><td>
<xsl:value-of select="timovi/domacini/punoime"/>
-
<xsl:value-of select="timovi/gosti/punoime"/><br />
</td></tr>
<tr><td>Kartoni</td><td>
</table>
<tr>
<td></td>
<td></td>
<td><xsl:value-of select="rezultat"/></td>
</tr>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
16
Zadatak broj 12 • Jedno od mogućih rješenja: stil3_zaUtakmice.xsl
...početak je isti kao u svim zadacima...
• Dobijeni dokument: utakmice2012.xml <xsl:stylesheet version="1.0"
<?xml version="1.0" encoding="utf-8"?> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<utakmice total-count="5" first="1" last="5"> <xsl:output method="html" encoding="utf-8" doctype-public="-
//W3C//DTD XHTML 1.0 Transitional//EN" doctype-
<predmet sadrzaj="rom_l1" status="finished" timestamp- system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>
starts="1280156400"> <xsl:template match="/">
<timovi>
<domacini id="tarmfcm_rom"> <html xmlns="http://www.w3.org/1999/xhtml">
<ime>Targu</ime> <head>
<punoime>FCM Targu Mures</punoime> <meta http-equiv="Content-Type" content="text/html; charset=utf-
... 8"/>
<title>Vjezba broj 3</title>
• Traženi izgled u web browseru (koja utakmica je iz koje lige i status </head>
utakmice)
<body>
<h1>Neke zanimljive informacije</h1>
<xsl:for-each select="utakmice/predmet">
Utakmica
<font size="+2">
<xsl:value-of select="timovi/domacini/punoime"/> - <xsl:value-of
select="timovi/gosti/punoime"/>
</font>
je iz
<font size="+2">
<xsl:value-of select="detalji/sadrzaj/takmicenje/naslov"/>
</font>
lige.<br />
Utakmica
<xsl:if test="(.[contains(@status,'finished')])">
<font size="+2">je završena.</font>
</xsl:if>
<xsl:if test="(.[contains(@status,'active')])">
<font size="+2">je u toku.</font>
</xsl:if>
<xsl:if test="(.[contains(@status,'not_started')])">
<font size="+2">još nije započela.</font>
</xsl:if>
<body>
<tr>
<th width="200">Domacin</th><th width="200">Gost</th><th
width="200">Rezultat</th>
</tr>
<xsl:for-each select="predmet">
<tr>
<td><xsl:value-of select="timovi/domacini/punoime"/></td>
<td><xsl:value-of select="timovi/gosti/punoime"/></td>
<td><xsl:value-of select="rezultat"/></td>
• Prepravljeni XML dokument </tr>
<?xml version="1.0" encoding="utf-8"?> </xsl:for-each>
<?xml-stylesheet type="text/xsl" href="stil1_zaUtakmice.xsl"?>
<utakmice total-count="5" first="1" last="5"> </table>
<predmet sadrzaj="rom_l1" status="finished" timestamp-
starts="1280156400"> </body>
<timovi> </html>
<domacini id="tarmfcm_rom">
<ime>Targu</ime> </xsl:template>
... </xsl:stylesheet>
18
Zadatak broj 14 • Prepravljeni XML dokument
<?xml version="1.0" encoding="utf-8"?>
• Dobijeni dokument: utakmice.xml <?xml-stylesheet type="text/xsl" href="stil2_zaUtakmice.xsl"?>
<?xml version="1.0" encoding="utf-8"?> ...
<utakmice total-count="5" first="1" last="5">
• Jedno od mogućih rješenja: stil2_zaUtakmice.xsl
<predmet sadrzaj="rom_l1" status="finished" timestamp- <?xml version="1.0" encoding="utf-8"?><!DOCTYPE xsl:stylesheet [
starts="1280156400"> <!ENTITY nbsp " ">
<timovi> <!ENTITY copy "©">
<domacini id="tarmfcm_rom"> ...(ovaj dio je isti kao u prethodnom zadatku)
<ime>Targu</ime> <!ENTITY euro "€">
<punoime>FCM Targu Mures</punoime> ]>
... <xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
• Traženi izgled u web browseru (prikaz imena lige i svih odigranih <xsl:output method="html" encoding="utf-8" doctype-public="-
utakmica u posebnim tabelama (bez rezultata ili sa)) //W3C//DTD XHTML 1.0 Transitional//EN" doctype-
system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>
<xsl:template match="/utakmice/predmet">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-
8"/>
<title>Vjezba broj 2</title>
</head>
<body>
<h1>
<xsl:value-of select="detalji/sadrzaj/takmicenje/naslov"/>
</h1>
<tr>
<th width="200">Domacin</th><th width="200">Gost</th><th
width="200">Rezultat</th>
</tr>
<xsl:for-each select="timovi">
<tr>
<td><xsl:value-of select="domacini/punoime"/></td>
<td><xsl:value-of select="gosti/punoime"/></td>
<td>.</td>
</tr>
</xsl:for-each>
</table>
<br />
</body>
</html>
</xsl:template>
</xsl:stylesheet>
19
<!ENTITY yen "¥">
Zadatak broj 15 <!ENTITY euro "€">
• Dobijeni dokument: utakmice.xml ]>
<?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0"
<utakmice total-count="5" first="1" last="5"> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="utf-8" doctype-public="-
<predmet sadrzaj="rom_l1" status="finished" timestamp- //W3C//DTD XHTML 1.0 Transitional//EN" doctype-
starts="1280156400"> system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>
<timovi>
<domacini id="tarmfcm_rom"> <xsl:template match="/">
<ime>Targu</ime> <h1>
<punoime>FCM Targu Mures</punoime> Romania - Liga 1
... </h1>
• Traženi izgled u web browseru (prikaz rezultat odigranih utakmica samo <xsl:apply-templates select="/utakmice/predmet"/>
iz Rumunske lige) </xsl:template>
<xsl:template match="/utakmice/predmet">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-
8"/>
<title>Vjezba broj 3</title>
</head>
<body>
<xsl:for-each select="timovi">
<tr>
<td><xsl:value-of select="domacini/punoime"/></td>
• Prepravljeni XML dokument <td><xsl:value-of select="gosti/punoime"/></td>
<?xml version="1.0" encoding="utf-8"?> <td><xsl:value-of select="../rezultat"/></td>
<?xml-stylesheet type="text/xsl" href="stil3_zaUtakmice.xsl"?> </tr>
... </xsl:for-each>
• Jedno od mogućih rješenja: stil3_zaUtakmice.xsl </table>
<?xml version="1.0" encoding="utf-8"?><!DOCTYPE xsl:stylesheet [ <br />
<!ENTITY nbsp " ">
<!ENTITY copy "©"> </xsl:if>
<!ENTITY reg "®"> </body>
<!ENTITY trade "™"> </html>
<!ENTITY mdash "—">
<!ENTITY ldquo "“"> </xsl:template>
<!ENTITY rdquo "”"> </xsl:stylesheet>
<!ENTITY pound "£">
20
Primjer 16 • Rješenje: stil1_utakmice_12062013.xsl
<?xml version="1.0" encoding="utf-8"?>
• Dobijeni dokument: utakmice2012.xml <!DOCTYPE xsl:stylesheet [
<?xml version="1.0" encoding="utf-8"?> <!ENTITY nbsp " ">
<utakmice total-count="5" first="1" last="5"> <!ENTITY copy "©">
<predmet sadrzaj="rom_l1" status="finished" timestamp- …
starts="1280156400"> <!ENTITY rdquo "”">
<timovi> <!ENTITY pound "£">
<domacini id="tarmfcm_rom"> <!ENTITY yen "¥">
<ime>Targu</ime> <!ENTITY euro "€">
<punoime>FCM Targu Mures</punoime> ]>
</domacini> <xsl:stylesheet version="1.0"
... xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
• Traženi izgled u web browseru <xsl:output method="html" encoding="utf-8" doctype-public="-
//W3C//DTD XHTML 1.0 Transitional//EN" doctype-
system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>
<xsl:template match="/">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-
8"/>
<title>Vjezba broj 1</title>
</head>
<body>
<xsl:apply-templates select="utakmice"/>
</body>
</html>
</xsl:template>
<xsl:template match="utakmice">
<xsl:apply-templates select="predmet"/><br />
</xsl:template>
<xsl:template match="predmet">
<div style="background:#99FFCC; width:400px; border:thick solid
#000000; padding:10px; margin:20px; text-align:center">
<font style="font-size:2em; color:#FF0000"><xsl:value-of
select="rezultat"/></font><br />
<xsl:value-of select="timovi/domacini/punoime"/> -
<xsl:value-of select="timovi/gosti/punoime"/><br />
21
Primjer 17 • Rješenje: stil2_utakmice_12062013.xsl
<?xml version="1.0" encoding="utf-8"?>
• Dobijeni dokument: utakmice2012.xml <!DOCTYPE xsl:stylesheet [
<?xml version="1.0" encoding="utf-8"?> <!ENTITY nbsp " ">
<utakmice total-count="5" first="1" last="5"> <!ENTITY copy "©">
<predmet sadrzaj="rom_l1" status="finished" timestamp- <!ENTITY reg "®">
starts="1280156400"> …
<timovi> <!ENTITY yen "¥">
<domacini id="tarmfcm_rom"> <!ENTITY euro "€">
<ime>Targu</ime> ]>
<punoime>FCM Targu Mures</punoime> <xsl:stylesheet version="1.0"
</domacini> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<gosti id="brasfc_rom"> <xsl:output method="html" encoding="utf-8" doctype-public="-
... //W3C//DTD XHTML 1.0 Transitional//EN" doctype-
• Traženi izgled u web browseru (tri div-a) system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>
<xsl:template match="/">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-
8"/>
<title>Vjezba 2</title>
</head>
<body>
</body>
</html>
</xsl:template>
<xsl:template match="utakmice/predmet">
<xsl:value-of select="timovi"/>,<br />
• Prepravljeni XML dokument <xsl:value-of select="rezultat"/>,<br />
<?xml version="1.0" encoding="utf-8"?> <xsl:value-of select="detalji"/><br /><br /><br />
<?xml-stylesheet href="stil2_utakmice_12062013.xsl" </xsl:template>
type="text/xsl"?> …
</xsl:stylesheet>
22
<!ENTITY nbsp " ">
Primjer 18 <!ENTITY copy "©">
• Dobijeni dokument: utakmice2012.xml …
<?xml version="1.0" encoding="utf-8"?> <!ENTITY euro "€">
<utakmice total-count="5" first="1" last="5"> ]>
<predmet sadrzaj="rom_l1" status="finished" timestamp- <xsl:stylesheet version="1.0"
starts="1280156400"> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<timovi> <xsl:output method="html" encoding="utf-8" doctype-public="-
<domacini id="tarmfcm_rom"> //W3C//DTD XHTML 1.0 Transitional//EN" doctype-
<ime>Targu</ime> system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>
<punoime>FCM Targu Mures</punoime> <xsl:template match="/">
</domacini>
<gosti id="brasfc_rom"> <html xmlns="http://www.w3.org/1999/xhtml">
... <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-
• Traženi izgled u web browseru 8"/>
<title>Vjezba 3</title>
</head>
<body>
<h1>Utakmice</h1>
<xsl:for-each select="utakmice/predmet">
<tr style="font-size:1.4em">
<td><xsl:value-of select="position()"/>.</td>
<td style="background:#CCFF33"><xsl:value-of
select="timovi/domacini/ime"/> -
<xsl:value-of select="timovi/gosti/ime"/></td>
<td style="text-align:center; width:100px">
<xsl:value-of select="rezultat"/>
</td>
<td style="text-align:center; width:200px">
<xsl:for-each select="dogadjaji/dogadjaj">
<xsl:if test="(.[contains(@type,'yellow_card')])">
<xsl:value-of select="."/><br />
</xsl:if>
• Prepravljeni XML dokument </xsl:for-each>
<?xml version="1.0" encoding="utf-8"?> </td>
</tr>
<?xml-stylesheet href="stil3_utakmice_12062013.xsl" </xsl:for-each>
type="text/xsl"?> </table>
…
</body>
• Rješenje: stil3_utakmice_12062013.xsl </html>
<?xml version="1.0" encoding="utf-8"?> </xsl:template>
<!DOCTYPE xsl:stylesheet [ </xsl:stylesheet>
23
U sva tri sljedeća zadatka dobijen je isti dokument <BILJKA>
<NAZIV>Hepatica</NAZIV>
• Dobijeni dokument: katalog_biljaka.xml <BOTANICKI>Hepatica americana</BOTANICKI>
<?xml version="1.0" encoding="ISO-8859-1"?> <ZONA>4</ZONA>
<!-- Programiranje za internet --> <OSVJETLJENJE>Mostly Shady</OSVJETLJENJE>
<KATALOG> <CIJENA>$4.45</CIJENA>
<BILJKA> <DOSTUPNOST>012699</DOSTUPNOST>
<NAZIV>Bloodroot</NAZIV> </BILJKA>
<BOTANICKI>Sanguinaria canadensis</BOTANICKI> <BILJKA>
<ZONA>4</ZONA> <NAZIV>Liverleaf</NAZIV>
<OSVJETLJENJE>Mostly Shady</OSVJETLJENJE> <BOTANICKI>Hepatica americana</BOTANICKI>
<CIJENA>$2.44</CIJENA> <ZONA>4</ZONA>
<DOSTUPNOST>031599</DOSTUPNOST> <OSVJETLJENJE>Mostly Shady</OSVJETLJENJE>
</BILJKA> <CIJENA>$3.99</CIJENA>
<BILJKA> <DOSTUPNOST>010299</DOSTUPNOST>
<NAZIV>Columbine</NAZIV> </BILJKA>
<BOTANICKI>Aquilegia canadensis</BOTANICKI> <BILJKA>
<ZONA>3</ZONA> <NAZIV>Jack-In-The-Pulpit</NAZIV>
<OSVJETLJENJE>Mostly Shady</OSVJETLJENJE> <BOTANICKI>Arisaema triphyllum</BOTANICKI>
<CIJENA>$9.37</CIJENA> <ZONA>4</ZONA>
<DOSTUPNOST>030699</DOSTUPNOST> <OSVJETLJENJE>Mostly Shady</OSVJETLJENJE>
</BILJKA> <CIJENA>$3.23</CIJENA>
<BILJKA> <DOSTUPNOST>020199</DOSTUPNOST>
<NAZIV>Marsh Marigold</NAZIV> </BILJKA>
<BOTANICKI>Caltha palustris</BOTANICKI> <BILJKA>
<ZONA>4</ZONA> <NAZIV>Mayapple</NAZIV>
<OSVJETLJENJE>Mostly Sunny</OSVJETLJENJE> <BOTANICKI>Podophyllum peltatum</BOTANICKI>
<CIJENA>$6.81</CIJENA> <ZONA>3</ZONA>
<DOSTUPNOST>051799</DOSTUPNOST> <OSVJETLJENJE>Mostly Shady</OSVJETLJENJE>
</BILJKA> <CIJENA>$2.98</CIJENA>
<BILJKA> <DOSTUPNOST>060599</DOSTUPNOST>
<NAZIV>Cowslip</NAZIV> </BILJKA>
<BOTANICKI>Caltha palustris</BOTANICKI> <BILJKA>
<ZONA>4</ZONA> <NAZIV>Phlox, Woodland</NAZIV>
<OSVJETLJENJE>Mostly Shady</OSVJETLJENJE> <BOTANICKI>Phlox divaricata</BOTANICKI>
<CIJENA>$9.90</CIJENA> <ZONA>3</ZONA>
<DOSTUPNOST>030699</DOSTUPNOST> <OSVJETLJENJE>Sun or Shade</OSVJETLJENJE>
</BILJKA> <CIJENA>$2.80</CIJENA>
<BILJKA> <DOSTUPNOST>012299</DOSTUPNOST>
<NAZIV>Dutchman's-Breeches</NAZIV> </BILJKA>
<BOTANICKI>Dicentra cucullaria</BOTANICKI> <BILJKA>
<ZONA>3</ZONA> <NAZIV>Phlox, Blue</NAZIV>
<OSVJETLJENJE>Mostly Shady</OSVJETLJENJE> <BOTANICKI>Phlox divaricata</BOTANICKI>
<CIJENA>$6.44</CIJENA> <ZONA>3</ZONA>
<DOSTUPNOST>012099</DOSTUPNOST> <OSVJETLJENJE>Sun or Shade</OSVJETLJENJE>
</BILJKA> <CIJENA>$5.59</CIJENA>
<BILJKA> <DOSTUPNOST>021699</DOSTUPNOST>
<NAZIV>Ginger, Wild</NAZIV> </BILJKA>
<BOTANICKI>Asarum canadense</BOTANICKI> ...
<ZONA>3</ZONA> <BILJKA>
<OSVJETLJENJE>Mostly Shady</OSVJETLJENJE> <NAZIV>Cardinal Flower</NAZIV>
<CIJENA>$9.03</CIJENA> <BOTANICKI>Lobelia cardinalis</BOTANICKI>
<DOSTUPNOST>041899</DOSTUPNOST> ...
</BILJKA> </BILJKA>
</KATALOG>
24
Zadatak broj 19 • Rješenje: stil1_za_Katalog_biljaka.xsl
<?xml version="1.0" encoding="utf-8"?><!DOCTYPE xsl:stylesheet [
• Dobijeni dokument: katalog_biljaka.xml <!ENTITY nbsp " ">
<?xml version="1.0" encoding="ISO-8859-1"?> ...(ovaj dio je isti kao u sljedećem zadatku)
<!-- Programiranje za internet --> <!ENTITY yen "¥">
<KATALOG> <!ENTITY euro "€">]>
<BILJKA> <xsl:stylesheet version="1.0"
<NAZIV>Bloodroot</NAZIV> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<BOTANICKI>Sanguinaria canadensis</BOTANICKI> <xsl:output method="html" encoding="utf-8" doctype-public="-
<ZONA>4</ZONA> //W3C//DTD XHTML 1.0 Transitional//EN" doctype-
<OSVJETLJENJE>Mostly Shady</OSVJETLJENJE> system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>
<CIJENA>$2.44</CIJENA>
<DOSTUPNOST>031599</DOSTUPNOST> <xsl:template match="/">
</BILJKA>
... <html xmlns="http://www.w3.org/1999/xhtml">
</KATALOG> <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-
• Traženi izgled u web browseru (biljke u tabeli sa osvjetljenjem Sunny, i 8"/>
biljke sa osvjetljenjem Shade) <title>Katalog biljaka - Vjezba sa ispita broj 1</title>
</head>
<body>
<h2>
Biljke iz našeg kataloga koje trebaju dosta sunce su sljedeće
</h2>
<table border="1">
<tr>
<th bgcolor="#99FFFF">Naziv biljke</th>
<th bgcolor="#99FFFF">Potrebna osvjetljenost</th>
</tr>
<xsl:for-each select="KATALOG/BILJKA">
<xsl:if test="OSVJETLJENJE = 'Sunny'">
<tr>
<td><xsl:value-of select="NAZIV"/></td>
<td><xsl:value-of select="OSVJETLJENJE"/></td>
</tr>
</xsl:if>
</xsl:for-each>
</table>
<h2>
Biljke iz našeg kataloga koje mogu rasti i u hladu su:</h2>
<xsl:for-each select="KATALOG/BILJKA">
• Prepravljeni XML dokument <xsl:if test="OSVJETLJENJE = 'Shade'">
<?xml version="1.0" encoding="ISO-8859-1"?> <xsl:value-of select="NAZIV"/>,
<?xml-stylesheet type="text/xsl" </xsl:if>
href="stil1_za_Katalog_biljaka.xsl"?> </xsl:for-each>
<!-- Programiranje za internet --> </body>
<KATALOG> </html>
...
</xsl:template>
</xsl:stylesheet>
25
Zadatak broj 20 • Rješenje: stil2_za_Katalog_biljaka.xsl
<?xml version="1.0" encoding="utf-8"?><!DOCTYPE xsl:stylesheet [
• Dobijeni dokument: katalog_biljaka.xml <!ENTITY nbsp " ">
<?xml version="1.0" encoding="ISO-8859-1"?> <!ENTITY copy "©">
<!-- Programiranje za internet --> <!ENTITY reg "®">
<KATALOG> <!ENTITY trade "™">
<BILJKA> <!ENTITY mdash "—">
<NAZIV>Bloodroot</NAZIV> <!ENTITY ldquo "“">
<BOTANICKI>Sanguinaria canadensis</BOTANICKI> <!ENTITY rdquo "”">
<ZONA>4</ZONA> <!ENTITY pound "£">
<OSVJETLJENJE>Mostly Shady</OSVJETLJENJE> <!ENTITY yen "¥">
<CIJENA>$2.44</CIJENA> <!ENTITY euro "€">]>
<DOSTUPNOST>031599</DOSTUPNOST> <xsl:stylesheet version="1.0"
</BILJKA> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
... <xsl:output method="html" encoding="utf-8" doctype-public="-
</KATALOG> //W3C//DTD XHTML 1.0 Transitional//EN" doctype-
system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>
• Traženi izgled u web browseru (imena biljaka sa rednim brojem u tri
kolone) <xsl:template match="/KATALOG">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-
8"/>
<title>Vjezba sa ispita broj 2</title>
</head>
<body>
<h2>U nasoj radnji mozete kupiti sljedeće biljke</h2>
<xsl:for-each select="BILJKA/NAZIV">
<xsl:value-of select="position()"/>
<xsl:value-of select="."/>
&
nbsp;
</xsl:for-each>
</body>
</html>
• Prepravljeni XML dokument
<?xml version="1.0" encoding="ISO-8859-1"?> </xsl:template>
<?xml-stylesheet type="text/xsl" </xsl:stylesheet>
href="stil2_za_Katalog_biljaka.xsl"?>
...
26
...
Zadatak broj 21
• Rješenje: stil3_za_Katalog_biljaka.xsl
• Dobijeni dokument: katalog_biljaka.xml <?xml version="1.0" encoding="utf-8"?><!DOCTYPE xsl:stylesheet [
<?xml version="1.0" encoding="ISO-8859-1"?> ...(ovaj dio je isti kao u prethodnom zadatku)
<!-- Programiranje za internet --> ]>
<KATALOG> <xsl:stylesheet version="1.0"
<BILJKA> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<NAZIV>Bloodroot</NAZIV> <xsl:output method="html" encoding="utf-8" doctype-public="-
<BOTANICKI>Sanguinaria canadensis</BOTANICKI> //W3C//DTD XHTML 1.0 Transitional//EN" doctype-
<ZONA>4</ZONA> system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>
<OSVJETLJENJE>Mostly Shady</OSVJETLJENJE>
<CIJENA>$2.44</CIJENA> <xsl:template match="/">
<DOSTUPNOST>031599</DOSTUPNOST>
</BILJKA> <html xmlns="http://www.w3.org/1999/xhtml">
... <head>
</KATALOG> <meta http-equiv="Content-Type" content="text/html; charset=utf-
8"/>
• Traženi izgled u web browseru (prve četiri biljke iz kataloga) <title>Katalog biljaka - Vjezba sa ispita broj 3</title>
</head>
<body>
<div style="width:800px">
<br />
</xsl:if>
</xsl:for-each>
</div>
<xsl:template match="author">
<div align="center"><h2>Od <xsl:value-of
select="."/></h2></div>
</xsl:template>
<xsl:template match="date">
<p><i><xsl:value-of select="."/></i></p>
</xsl:template>
<xsl:template match="stanza">
<p><xsl:apply-templates select="line"/></p>
</xsl:template>
<xsl:template match="line">
<xsl:if test="position() mod 2 =
0">     </xsl:if>
<xsl:value-of select="."/><br/>
</xsl:template>
<xsl:template match="title">
<div align="center">
<h1><xsl:value-of select="."/></h1></div>
</xsl:template>
<xsl:template match="author">
<div align="center">
<h2>Od <xsl:value-of select="."/></h2></div>
</xsl:template>
<xsl:template match="stanza">
<p><xsl:apply-templates select="line"/></p>
</xsl:template>
<xsl:template match="line">
• Prepravljeni XML dokument <xsl:value-of select="position()"/>
<?xml version="1.0" encoding="iso-8859-1"?> <xsl:value-of select="."/><br/>
</xsl:template>
<?xml-stylesheet type="text/xsl" href="stil_fja_position.xsl"?>
... </xsl:stylesheet>
29
Primjer 24 • Rješenje: stil_fja_position_v2.xsl
• Dobijeni dokument: poem.xml <?xml version="1.0" encoding="utf-8"?><!DOCTYPE
<?xml version="1.0" encoding="iso-8859-1"?>
xsl:stylesheet [
<poem> <!ENTITY nbsp " ">
<author>Rupert Brooke</author> <!ENTITY copy "©">
<date>1912</date> <!ENTITY reg "®">
<title>Hladnoca</title> <!ENTITY trade "™">
<stanza> <!ENTITY mdash "—">
<line>I iznenada vjetar dolazi mekan,</line> <!ENTITY ldquo "“">
<line>I proljece je ovjde ponovo</line> <!ENTITY rdquo "”">
<line>I glog pospjeva sa pupoljkom zelenim</line> <!ENTITY pound "£">
<line>I moje srce sa pupoljkom bola.</line> <!ENTITY yen "¥">
</stanza>
<stanza> <!ENTITY euro "€">
<line>My heart all Winter lay so numb,</line> ]>
<line>The earth so dead and frore,</line> <xsl:stylesheet version="1.0"
<line>That I never thought the Spring would come again</line> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<line>Or my heart wake any more.</line> <xsl:output method="html" encoding="utf-8" doctype-public="-
</stanza> //W3C//DTD XHTML 1.0 Transitional//EN" doctype-
<stanza> system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-
<line>But Winter's broken and earth has woken,</line> transitional.dtd"/>
<line>And the small birds cry again;</line>
<line>And the hawthorn hedge puts forth its buds,</line>
<line>And my heart puts forth its pain.</line> <xsl:template match="poem">
</stanza>
</poem> <html xmlns="http://www.w3.org/1999/xhtml">
• Traženi izgled u web browseru (ispisati broj stiha ne razdvajajući strofe) <head>
<meta http-equiv="Content-Type" content="text/html;
charset=utf-8"/>
<title>Stil sa funkcijom position v2</title>
</head>
<body>
<xsl:apply-templates select="title"/>
<xsl:for-each select="stanza/line">
<xsl:value-of select="position()"/>
<xsl:value-of select="."/><br/>
</xsl:for-each>
</body>
</html>
</xsl:template>
<xsl:template match="title">
• Prepravljeni XML dokument <div align="center">
<?xml version="1.0" encoding="iso-8859-1"?> <h1><xsl:value-of select="."/></h1></div>
<?xml-stylesheet type="text/xsl" href="stil_fja_position_v2.xsl"?> </xsl:template>
<poem>
<author>Rupert Brooke</author> </xsl:stylesheet>
...
30
Primjer 25 • Rješenje: Stil_za_if.xsl
• Dobijeni dokument: cdcatalogv2.xml <?xml version="1.0" encoding="utf-8"?><!DOCTYPE
<?xml version="1.0" encoding="ISO-8859-1"?>
xsl:stylesheet [
<catalog> <!ENTITY nbsp " ">
<cd> <!ENTITY copy "©">
<title>Live And Feelin' Good (The Blues Collection <!ENTITY reg "®">
Vol.68)</title> <!ENTITY trade "™">
<artist>Piano Red</artist> <!ENTITY mdash "—">
<country>USA</country> <!ENTITY ldquo "“">
<company>?</company> <!ENTITY rdquo "”">
<price>4.99</price> <!ENTITY pound "£">
<year>2007</year> <!ENTITY yen "¥">
</cd>
<cd> <!ENTITY euro "€">
<title>2cellos</title> ]>
<artist>2cellos</artist> <xsl:stylesheet version="1.0"
<country>HR</country> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<company>?</company> <xsl:output method="html" encoding="utf-8" doctype-public="-
<price>10.99</price> //W3C//DTD XHTML 1.0 Transitional//EN" doctype-
<year>2011</year> system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-
</cd> transitional.dtd"/>
...
</catalog>
<xsl:template match="/">
• Traženi izgled u web browseru (svi albumi koji su skuplji od 10 KM) <html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=utf-8"/>
<title>Naredba if</title>
</head>
<body>
<h2>Moja CD kolekcija</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th>Ime albuma</th>
<th>Izvođaća</th>
</tr>
<xsl:for-each select="catalog/cd">
<xsl:if test="price > 10">
<tr>
<td><xsl:value-of select="title"/></td>
<td><xsl:value-of select="artist"/></td>
</tr>
</xsl:if>
</xsl:for-each>
• Prepravljeni XML dokument </table>
<?xml version="1.0" encoding="ISO-8859-1"?> </body>
<?xml-stylesheet type="text/xsl" href="Stil_za_if.xsl"?> </html>
<catalog> </xsl:template>
<cd>
... </xsl:stylesheet>
31
Primjer 26 • Rješenje: stil_za_pjesmu.xsl
• Dobijeni dokument: poem.xml <?xml version="1.0" encoding="iso-8859-1"?>
<?xml version="1.0" encoding="iso-8859-1"?>
<poem> <xsl:stylesheet
<author>Rupert Brooke</author> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
<date>1912</date> version="1.0">
<title>Hladnoca</title>
<stanza> <xsl:template match="poem">
<line>I iznenada vjetar dolazi mekan,</line> <html>
<line>I proljece je ovjde ponovo</line> <head>
<line>I glog pospjeva sa pupoljkom zelenim</line> <title><xsl:value-of select="title"/></title>
<line>I moje srce sa pupoljkom bola.</line> </head>
</stanza>
<stanza> <body>
<line>My heart all Winter lay so numb,</line> <xsl:apply-templates select="title"/>
<line>The earth so dead and frore,</line> <xsl:apply-templates select="author"/>
<line>That I never thought the Spring would come again</line> <xsl:apply-templates select="stanza"/>
<line>Or my heart wake any more.</line> <xsl:apply-templates select="date"/>
</stanza> </body>
... </html>
</poem> </xsl:template>
• Traženi izgled u web browseru (svaki drugi stih uvući pet milimetara)
<xsl:template match="title">
<div align="center"><h1><xsl:value-of
select="."/></h1></div>
</xsl:template>
<xsl:template match="author">
<div align="center"><h2>Od <xsl:value-of
select="."/></h2></div>
</xsl:template>
<xsl:template match="date">
<p><i><xsl:value-of select="."/></i></p>
</xsl:template>
<xsl:template match="stanza">
<p><xsl:apply-templates select="line"/></p>
</xsl:template>
<xsl:template match="line">
<xsl:if test="position() mod 2 =
0">     </xsl:if>
<xsl:value-of select="."/><br/>
</xsl:template>