You are on page 1of 32

Programiranje za internet

zimski semestar 2013/2014

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>

Čije je stablo izgleda:

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 "&#160;">
<?xml version="1.0" encoding="utf-8"?> <!ENTITY copy "&#169;">
<vizit_karte> ... (ovaj dio je isti kao u sljedećem zadatku)
<vizit_karta> <!ENTITY pound "&#163;">
<ime_i_prezime>Dzon Fante</ime_i_prezime> <!ENTITY yen "&#165;">
<telefon tip="posao">+387 62 345 543</telefon> <!ENTITY euro "&#8364;">
<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>

<table border="1" cellpadding="15">


<tr>
<td style="font-size:2em">Ime i prezime</td><td style="font-
size:2em; padding:15px">Kućni broj telefona i faks</td>
</tr>

<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 "&#160;">
<?xml version="1.0" encoding="utf-8"?> <!ENTITY copy "&#169;">
<vizit_karte> <!ENTITY reg "&#174;">
<vizit_karta> <!ENTITY trade "&#8482;">
<ime_i_prezime>Dzon Fante</ime_i_prezime> <!ENTITY mdash "&#8212;">
<telefon tip="posao">+387 62 345 543</telefon> <!ENTITY ldquo "&#8220;">
<telefon tip="kuca" vrsta="glavni">+387 32 345 <!ENTITY rdquo "&#8221;">
543</telefon> <!ENTITY pound "&#163;">
<telefon tip="faks">+387 70 345 543</telefon> <!ENTITY yen "&#165;">
<e-mail>dzonze@gmail.com</e-mail> <!ENTITY euro "&#8364;">
</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>

• Prepravljeni XML dokument


<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="sviBrojevi.xsl"?>
<vizit_karte>
...

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>

Čije je stablo izgleda:

6
Primjer 4 • Rješenje: stil1.xsl
<?xml version="1.0" encoding="utf-8"?><!DOCTYPE xsl:stylesheet [
• Dobijeni dokument: cdcatalog_v3.xml <!ENTITY nbsp "&#160;">
<?xml version="1.0" encoding="ISO-8859-1"?> <!ENTITY copy "&#169;">
<katalog> <!ENTITY reg "&#174;">
<cd> <!ENTITY trade "&#8482;">
<album>Live And Feelin' Good (The Blues Collection <!ENTITY mdash "&#8212;">
Vol.68)</album> <!ENTITY ldquo "&#8220;">
<izvodjac>Piano Red</izvodjac> <!ENTITY rdquo "&#8221;">
<zemlja>USA</zemlja> <!ENTITY pound "&#163;">
<izdavac>?</izdavac> <!ENTITY yen "&#165;">
<cijena>4.99</cijena> <!ENTITY euro "&#8364;">
<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 "&#160;">
<?xml version="1.0" encoding="ISO-8859-1"?> <!ENTITY copy "&#169;">
<katalog> …
<cd> <!ENTITY yen "&#165;">
<album>Live And Feelin' Good (The Blues Collection <!ENTITY euro "&#8364;">
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>

<div style="width:250px; background:#99FFFF; padding:10px">


<font size="+3">Album, Zemlja i Godina izdanja</font><br /><br />
<xsl:apply-templates select="katalog/cd"/>
</div>

<div style="width:250px; background:#99CC66; padding:10px;


position:absolute; top:10px; left:310px">
<font size="+3">Album, Zemlja i Godina izdanja</font><br /><br />
<xsl:apply-templates select="katalog/cd"/>
</div>

<div style="width:250px; background:#CCCCFF; padding:10px;


position:absolute; top:10px; left:610px">
<font size="+3">Album, Zemlja i Godina izdanja</font><br /><br />
<xsl:apply-templates select="katalog/cd"/>
</div>

</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 "&#8220;">
Primjer 6 <!ENTITY rdquo "&#8221;">
• Dobijeni dokument: cdcatalog_v3.xml <!ENTITY pound "&#163;">
<?xml version="1.0" encoding="ISO-8859-1"?> <!ENTITY yen "&#165;">
<katalog> <!ENTITY euro "&#8364;">
<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>

<h1>Albumi čija je godina izdanja između 2007-2010</h1>

<table width="700" border="1">


<tr style="font-size:2em">
<td>R.b.</td>
<td style="background:#CCFF33">Album</td>
<td style="text-align:center;">Godina izdanja</td>
<td style="text-align:center;">Cijena</td>
</tr>

<xsl:for-each select="katalog/cd[godina>2006 and 2011>godina]">


<tr style="font-size:1.4em">
<td><xsl:value-of select="position()"/>.</td>
<td style="background:#CCFF33"><xsl:value-of
select="album"/></td>
<td style="text-align:center; width:100px"><xsl:value-of
select="godina"/></td>
<td style="text-align:center; width:100px"><xsl:value-of
select="cijena"/> KM</td>
• Prepravljeni XML dokument </tr>
<?xml version="1.0" encoding="ISO-8859-1"?> </xsl:for-each>
<?xml-stylesheet href="stil3.xsl" type="text/xsl"?> </table>

• Rješenje: stil3.xsl
<?xml version="1.0" encoding="utf-8"?><!DOCTYPE xsl:stylesheet [
<!ENTITY nbsp "&#160;"> </body>
<!ENTITY copy "&#169;"> </html>
<!ENTITY reg "&#174;">
<!ENTITY trade "&#8482;"> </xsl:template>
<!ENTITY mdash "&#8212;"> </xsl:stylesheet>

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">

Čije je stablo izgleda:

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 "&#160;">
<utakmice total-count="5" first="1" last="5"> <!ENTITY copy "&#169;">
<predmet sadrzaj="rom_l1" status="finished" timestamp- <!ENTITY reg "&#174;">
starts="1280156400"> <!ENTITY trade "&#8482;">
<timovi> <!ENTITY mdash "&#8212;">
<domacini id="tarmfcm_rom"> <!ENTITY ldquo "&#8220;">
<ime>Targu</ime> <!ENTITY rdquo "&#8221;">
<punoime>FCM Targu Mures</punoime> <!ENTITY pound "&#163;">
</domacini> <!ENTITY yen "&#165;">
<gosti id="brasfc_rom"> <!ENTITY euro "&#8364;">
<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>

<table width="600px" border="2">


<tr><th>R.b.</th><th>Domacini</th><th>Gosti</th><th>Rezultat</th></
tr>

<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>

Domaci igraci:<br />


<xsl:for-each select="dogadjaji/dogadjaj">
<xsl:if test="(.[contains(@type,'yellow_card') and
contains(@team,'domacini')]
)">
Igrač <b>
<xsl:value-of select="igrac"/>
</b> je dobio žuti karton u
<b>
<xsl:value-of select="minuta"/>
</b> minuti.<br />
</xsl:if>

</xsl:for-each>
</td></tr>
<tr><td>&nbsp;</td><td>&nbsp;</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 />

U datom dokumentu utakmice su iz sljedećih liga:<br />


<xsl:for-each select="utakmice/predmet/detalji/sadrzaj/takmicenje">
<xsl:value-of
select="naslov"/>,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</xsl:for-each>
<br /><br />
<br />

U datom dokumentu pojavljuju se sljedeći timovi:


<xsl:for-each select="utakmice/predmet/timovi"><br />
<xsl:value-of select="domacini/ime"/> čije je puno ime <font
size="+2"><xsl:value-of select="domacini/punoime"/></font><br />
<xsl:value-of select="gosti/ime"/> čije je puno ime <font
size="+2"><xsl:value-of select="gosti/punoime"/></font>
</xsl:for-each>

<br /><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 "&#160;">
<utakmice total-count="5" first="1" last="5"> <!ENTITY copy "&#169;">
<predmet sadrzaj="rom_l1" status="finished" timestamp- <!ENTITY reg "&#174;">
starts="1280156400"> <!ENTITY trade "&#8482;">
<timovi> <!ENTITY mdash "&#8212;">
<domacini id="tarmfcm_rom"> <!ENTITY ldquo "&#8220;">
<ime>Targu</ime> <!ENTITY rdquo "&#8221;">
<punoime>FCM Targu Mures</punoime> <!ENTITY pound "&#163;">
</domacini> <!ENTITY yen "&#165;">
<gosti id="brasfc_rom"> <!ENTITY euro "&#8364;">
<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>

<table width="600px" border="2">


<tr><th>R.b.</th><th>Domacini</th><th>Gosti</th><th>Rezultat</th></
tr>

<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>

Domaci igraci:<br />


<xsl:for-each select="dogadjaji/dogadjaj">
<xsl:if test="(.[contains(@type,'yellow_card') and
contains(@team,'domacini')]
)">
Igrač <b>
<xsl:value-of select="igrac"/>
</b> je dobio žuti karton u
<b>
<xsl:value-of select="minuta"/>
</b> minuti.<br />
</xsl:if>
</xsl:for-each>
</td></tr>
<tr><td>&nbsp;</td><td>&nbsp;</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>

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>

<br /><br />


</xsl:for-each>
• Prepravljeni XML dokument
</body>
<?xml version="1.0" encoding="utf-8"?> </html>
<?xml-stylesheet type="text/xsl" href="stil3_zaUtakmice.xsl"?> </xsl:template>
... </xsl:stylesheet>
17
Zadatak broj 13 • Jedno od mogućih rješenja: stil1_zaUtakmice.xsl
<?xml version="1.0" encoding="utf-8"?><!DOCTYPE xsl:stylesheet [
• Dobijeni dokument: utakmice.xml <!ENTITY nbsp "&#160;">
<?xml version="1.0" encoding="utf-8"?> <!ENTITY copy "&#169;">
<utakmice total-count="5" first="1" last="5"> <!ENTITY reg "&#174;">
<!ENTITY trade "&#8482;">
<predmet sadrzaj="rom_l1" status="finished" timestamp- <!ENTITY mdash "&#8212;">
starts="1280156400"> <!ENTITY ldquo "&#8220;">
<timovi> <!ENTITY rdquo "&#8221;">
<domacini id="tarmfcm_rom"> <!ENTITY pound "&#163;">
<ime>Targu</ime> <!ENTITY yen "&#165;">
<punoime>FCM Targu Mures</punoime> <!ENTITY euro "&#8364;">
</domacini> ]>
<gosti id="brasfc_rom"> <xsl:stylesheet version="1.0"
<ime>Brasov</ime> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<punoime>FC Brasov</punoime> <xsl:output method="html" encoding="utf-8" doctype-public="-
</gosti> //W3C//DTD XHTML 1.0 Transitional//EN" doctype-
</timovi> system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>
...
• Traženi izgled u web browseru (prikaz svih rezultata odigranih utakmica <xsl:template match="/utakmice">
iz dokumenta u jednoj tabeli) <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>

<table width="600" border="2">

<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 "&#160;">
<timovi> <!ENTITY copy "&#169;">
<domacini id="tarmfcm_rom"> ...(ovaj dio je isti kao u prethodnom zadatku)
<ime>Targu</ime> <!ENTITY euro "&#8364;">
<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>

<table width="600" border="2">

<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 "&#165;">
Zadatak broj 15 <!ENTITY euro "&#8364;">
• 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:if test="detalji/sadrzaj/takmicenje[naslov = 'Romania - Liga


1']">

<table width="600" border="2">


<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>
• 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 "&#160;">
<!ENTITY copy "&#169;"> </xsl:if>
<!ENTITY reg "&#174;"> </body>
<!ENTITY trade "&#8482;"> </html>
<!ENTITY mdash "&#8212;">
<!ENTITY ldquo "&#8220;"> </xsl:template>
<!ENTITY rdquo "&#8221;"> </xsl:stylesheet>
<!ENTITY pound "&#163;">
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 "&#160;">
<utakmice total-count="5" first="1" last="5"> <!ENTITY copy "&#169;">
<predmet sadrzaj="rom_l1" status="finished" timestamp- …
starts="1280156400"> <!ENTITY rdquo "&#8221;">
<timovi> <!ENTITY pound "&#163;">
<domacini id="tarmfcm_rom"> <!ENTITY yen "&#165;">
<ime>Targu</ime> <!ENTITY euro "&#8364;">
<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 />

<font style="font-size:1.5em"> Golove dali:


<xsl:for-each select="dogadjaji/dogadjaj">
<xsl:if test="(.[contains(@type,'goal')])">
<xsl:value-of select="."/><br />
</xsl:if>
</xsl:for-each>
• Prepravljeni XML dokument </font>
<?xml version="1.0" encoding="utf-8"?> </div>
<?xml-stylesheet href="stil1_utakmice_12062013.xsl" </xsl:template>
type="text/xsl"?> </xsl:stylesheet>

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 "&#160;">
<utakmice total-count="5" first="1" last="5"> <!ENTITY copy "&#169;">
<predmet sadrzaj="rom_l1" status="finished" timestamp- <!ENTITY reg "&#174;">
starts="1280156400"> …
<timovi> <!ENTITY yen "&#165;">
<domacini id="tarmfcm_rom"> <!ENTITY euro "&#8364;">
<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>

<div style="width:250px; background:#99FFFF; padding:10px">


<font size="+3">Timovi, rezultati i detalji</font><br /><br />
<xsl:apply-templates select="utakmice/predmet"/>
</div>

<div style="width:250px; background:#99CC66; padding:10px;


position:absolute; top:10px; left:310px">
<font size="+3">Timovi, rezultati i detalji</font><br /><br />
<xsl:apply-templates select="utakmice/predmet"/>
</div>

<div style="width:250px; background:#CCCCFF; padding:10px;


position:absolute; top:10px; left:610px">
<font size="+3">Timovi, rezultati i detalji</font><br /><br />
<xsl:apply-templates select="utakmice/predmet"/>
</div>

</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 "&#160;">
Primjer 18 <!ENTITY copy "&#169;">
• Dobijeni dokument: utakmice2012.xml …
<?xml version="1.0" encoding="utf-8"?> <!ENTITY euro "&#8364;">
<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>

<table width="700" border="1">


<tr style="font-size:2em">
<td>R.b.</td>
<td style="background:#CCFF33">Utakmica</td>
<td style="text-align:center;">Rezultat</td>
<td style="text-align:center;">Žuti kartoni</td>
</tr>

<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 "&#160;">
<?xml version="1.0" encoding="ISO-8859-1"?> ...(ovaj dio je isti kao u sljedećem zadatku)
<!-- Programiranje za internet --> <!ENTITY yen "&#165;">
<KATALOG> <!ENTITY euro "&#8364;">]>
<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"/>,&nbsp;
<?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 "&#160;">
<?xml version="1.0" encoding="ISO-8859-1"?> <!ENTITY copy "&#169;">
<!-- Programiranje za internet --> <!ENTITY reg "&#174;">
<KATALOG> <!ENTITY trade "&#8482;">
<BILJKA> <!ENTITY mdash "&#8212;">
<NAZIV>Bloodroot</NAZIV> <!ENTITY ldquo "&#8220;">
<BOTANICKI>Sanguinaria canadensis</BOTANICKI> <!ENTITY rdquo "&#8221;">
<ZONA>4</ZONA> <!ENTITY pound "&#163;">
<OSVJETLJENJE>Mostly Shady</OSVJETLJENJE> <!ENTITY yen "&#165;">
<CIJENA>$2.44</CIJENA> <!ENTITY euro "&#8364;">]>
<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()"/>
&nbsp; <xsl:value-of select="."/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

<xsl:if test="position() mod 9 = 0">


<br /><br />
</xsl:if>

<xsl:if test="position() mod 3 = 0">


<br />
</xsl:if>

</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">

<h2>Biljke koje preporučujemo su</h2>


<xsl:for-each select="KATALOG/BILJKA">

<xsl:if test="5 > position()">

<div style="color:blue; padding:4px">


<span style="font-weight:bold">
<xsl:value-of select="NAZIV"/>
</span>
- <xsl:value-of select="CIJENA"/>
</div>

<div style="color:blue; padding:4px; background:#99FFFF">


<span style="font-style:italic">
Dostupnost <xsl:value-of select="DOSTUPNOST"/>
</span>
</div>

<br />

</xsl:if>

</xsl:for-each>
</div>

• Prepravljeni XML dokument </body>


</html>
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" </xsl:template>
href="stil3_za_Katalog_biljaka.xsl"?> </xsl:stylesheet>
27
Primjer 22 • 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">&#160;&#160;&#160;&#160;&#160;</xsl:if>
<xsl:value-of select="."/><br/>
</xsl:template>

• Prepravljeni XML dokument </xsl:stylesheet>


<?xml version="1.0" encoding="iso-8859-1"?>
<?xml-stylesheet type="text/xsl" href="stil_za_pjesmu.xsl"?>
...
28
Primjer 23 • Rješenje: stil_fja_position.xsl
<?xml version="1.0" encoding="utf-8"?><!DOCTYPE xsl:stylesheet [
• Dobijeni dokument: poem.xml <!ENTITY nbsp "&#160;">
<?xml version="1.0" encoding="iso-8859-1"?> <!ENTITY copy "&#169;">
<poem> <!ENTITY reg "&#174;">
<author>Rupert Brooke</author> <!ENTITY trade "&#8482;">
<date>1912</date> <!ENTITY mdash "&#8212;">
<title>Hladnoca</title> <!ENTITY ldquo "&#8220;">
<stanza> <!ENTITY rdquo "&#8221;">
<line>I iznenada vjetar dolazi mekan,</line> <!ENTITY pound "&#163;">
<line>I proljece je ovjde ponovo</line> <!ENTITY yen "&#165;">
<line>I glog pospjeva sa pupoljkom zelenim</line> <!ENTITY euro "&#8364;">
<line>I moje srce sa pupoljkom bola.</line> ]>
</stanza> <xsl:stylesheet version="1.0"
<stanza> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<line>My heart all Winter lay so numb,</line> <xsl:output method="html" encoding="utf-8" doctype-public="-
<line>The earth so dead and frore,</line> //W3C//DTD XHTML 1.0 Transitional//EN" doctype-
<line>That I never thought the Spring would come again</line> system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>
<line>Or my heart wake any more.</line>
</stanza> <xsl:template match="poem">
<stanza> <html xmlns="http://www.w3.org/1999/xhtml">
<line>But Winter's broken and earth has woken,</line> <head>
<line>And the small birds cry again;</line> <meta http-equiv="Content-Type" content="text/html; charset=utf-
<line>And the hawthorn hedge puts forth its buds,</line> 8"/>
<line>And my heart puts forth its pain.</line> <title>Stil sa funkcijom positionn</title>
</stanza> </head>
</poem> <body>
• Traženi izgled u web browseru (ispisati broj ispred svakog stiha u strofi) <xsl:apply-templates select="title"/>
<xsl:apply-templates select="author"/>
<xsl:apply-templates select="stanza"/>
</body>
</html>
</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()"/>&nbsp;
<?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 "&#160;">
<author>Rupert Brooke</author> <!ENTITY copy "&#169;">
<date>1912</date> <!ENTITY reg "&#174;">
<title>Hladnoca</title> <!ENTITY trade "&#8482;">
<stanza> <!ENTITY mdash "&#8212;">
<line>I iznenada vjetar dolazi mekan,</line> <!ENTITY ldquo "&#8220;">
<line>I proljece je ovjde ponovo</line> <!ENTITY rdquo "&#8221;">
<line>I glog pospjeva sa pupoljkom zelenim</line> <!ENTITY pound "&#163;">
<line>I moje srce sa pupoljkom bola.</line> <!ENTITY yen "&#165;">
</stanza>
<stanza> <!ENTITY euro "&#8364;">
<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()"/>&nbsp;
<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 "&#160;">
<cd> <!ENTITY copy "&#169;">
<title>Live And Feelin' Good (The Blues Collection <!ENTITY reg "&#174;">
Vol.68)</title> <!ENTITY trade "&#8482;">
<artist>Piano Red</artist> <!ENTITY mdash "&#8212;">
<country>USA</country> <!ENTITY ldquo "&#8220;">
<company>?</company> <!ENTITY rdquo "&#8221;">
<price>4.99</price> <!ENTITY pound "&#163;">
<year>2007</year> <!ENTITY yen "&#165;">
</cd>
<cd> <!ENTITY euro "&#8364;">
<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">&#160;&#160;&#160;&#160;&#160;</xsl:if>
<xsl:value-of select="."/><br/>
</xsl:template>

• Prepravljeni XML dokument </xsl:stylesheet>


<?xml version="1.0" encoding="iso-8859-1"?>
<?xml-stylesheet type="text/xsl" href="stil_za_pjesmu.xsl"?>
...
32

You might also like