Poème
Soit l'extrait de poème suivant écrit en XML :
CTRL+C pour copier, CTRL+V pour coller
1
<poeme titre="The Stone Troll" auteur="JRR Tolkien">
2
<strophe>
3
<vers>Troll sat alone on his seat of stone,</vers>
4
<vers>And munched and mumbled a bare old bone;</vers>
5
<vers>For many a year he had gnawed it near,</vers>
6
<vers>For meat was hard to come by.</vers>
7
<vers>Done by! Gum by!</vers>
8
<vers>In a cave in the hills he dwelt alone,</vers>
9
<vers>And meat was hard to come by.</vers>
10
</strophe>
11
<strophe>
12
<vers>Up came Tom with his big boots on.</vers>
13
<vers>Said he to Troll: 'Pray, what is yon?</vers>
14
<vers>For it looks like the shin o' my nuncle Tim.</vers>
15
<vers>As should be a-lyin' in the graveyard.</vers>
16
<vers>Caveyard! Paveyard!</vers>
17
<vers>This many a year has Tim been gone,</vers>
18
<vers>And I thought he were lyin' in the graveyard.</vers>
19
</strophe>
20
</poeme>
<poeme titre="The Stone Troll" auteur="JRR Tolkien"> <strophe> <vers>Troll sat alone on his seat of stone,</vers> <vers>And munched and mumbled a bare old bone;</vers> <vers>For many a year he had gnawed it near,</vers> <vers>For meat was hard to come by.</vers> <vers>Done by! Gum by!</vers> <vers>In a cave in the hills he dwelt alone,</vers> <vers>And meat was hard to come by.</vers> </strophe> <strophe> <vers>Up came Tom with his big boots on.</vers> <vers>Said he to Troll: 'Pray, what is yon?</vers> <vers>For it looks like the shin o' my nuncle Tim.</vers> <vers>As should be a-lyin' in the graveyard.</vers> <vers>Caveyard! Paveyard!</vers> <vers>This many a year has Tim been gone,</vers> <vers>And I thought he were lyin' in the graveyard.</vers> </strophe> </poeme>
Question
Écrire un programme XSL-XSLT permettant de le transformer selon le format HTML suivant :
CTRL+C pour copier, CTRL+V pour coller
1
<html>
2
<head>
3
<title>The Stone Troll (JRR Tolkien)</title>
4
</head>
5
<body>
6
<p>Troll sat alone on his seat of stone,</p>
7
<p>And munched and mumbled a bare old bone;</p>
8
<p>For many a year he had gnawed it near,</p>
9
<p>For meat was hard to come by.</p>
10
<p>Done by! Gum by!</p>
11
<p>In a cave in the hills he dwelt alone,</p>
12
<p>And meat was hard to come by.</p>
13
<hr/>
14
<p>Up came Tom with his big boots on.</p>
15
<p>Said he to Troll: 'Pray, what is yon?</p>
16
<p>For it looks like the shin o' my nuncle Tim.</p>
17
<p>As should be a-lyin' in the graveyard.</p>
18
<p>Caveyard! Paveyard!</p>
19
<p>This many a year has Tim been gone,</p>
20
<p>And I thought he were lyin' in the graveyard.</p>
21
</body>
22
</html>
<html> <head> <title>The Stone Troll (JRR Tolkien)</title> </head> <body> <p>Troll sat alone on his seat of stone,</p> <p>And munched and mumbled a bare old bone;</p> <p>For many a year he had gnawed it near,</p> <p>For meat was hard to come by.</p> <p>Done by! Gum by!</p> <p>In a cave in the hills he dwelt alone,</p> <p>And meat was hard to come by.</p> <hr/> <p>Up came Tom with his big boots on.</p> <p>Said he to Troll: 'Pray, what is yon?</p> <p>For it looks like the shin o' my nuncle Tim.</p> <p>As should be a-lyin' in the graveyard.</p> <p>Caveyard! Paveyard!</p> <p>This many a year has Tim been gone,</p> <p>And I thought he were lyin' in the graveyard.</p> </body> </html>
Question
Après avoir rappelé que l'ordre des règles n'est pas signifiant en XSLT, expliquer pourquoi, d'après les règles de priorité implicite, strophe[last()]
sera toujours prioritaire sur strophe
.
Question
En utilisant la fonction XPath position(), proposer une transformation qui affiche une strophe sur deux en italique.
Vous mettrez en place des règles de priorité explicite.