[15 minutes]

L'instance XML ci-après permet d'intégrer les contenus des deux maps précédentes en une seule, en vue d'une publication unifiée.

1
<?xml version="1.0" encoding="utf-8"?>
2
<!-- tasksAndConcepts.ditamap -->
3
<map title="Garage tasks and concepts">
4
<topichead navtitle="Tasks">
5
  <topicref href="tasks/changingtheoil.xml" type="task"/>
6
  <topicref href="tasks/washingthecar.xml" type="task"/>
7
  <topicref href="tasks/spraypainting.xml" type="task"/>
8
  <topicref href="tasks/shovellingsnow.xml" type="task"/>
9
  <topicref href="tasks/takinggarbage.xml" type="task"/>
10
</topichead>
11
<topichead navtitle="Concepts">
12
  <topicref href="concepts/lawnmower.xml" type="concept"/>
13
  <topicref href="concepts/oil.xml" type="concept"/>
14
  <topicref href="concepts/paint.xml" type="concept"/>
15
  <topicref href="concepts/shelving.xml" type="concept"/>
16
  <topicref href="concepts/snowshovel.xml" type="concept"/>
17
  <topicref href="concepts/toolbox.xml" type="concept"/>
18
  <topicref href="concepts/tools.xml" type="concept"/>
19
  <topicref href="concepts/waterhose.xml" type="concept"/>
20
  <topicref href="concepts/wheelbarrow.xml" type="concept"/>
21
  <topicref href="concepts/workbench.xml" type="concept"/>
22
  <topicref href="concepts/wwfluid.xml" type="concept"/>
23
</topichead>
24
</map>
Publication HTML "Garage tasks and concepts" (table des matières)

Question

Proposer une expression XPath permettant de renvoyer les topicrefs, petits-fils du nœud courant, qui ont comme père un topichead avec pour titre "Tasks" ; proposer une seconde expression pour "Concepts".

Solution

1
topichead[@navtitle='Tasks']/topicref
2
topichead[@navtitle='Concepts']/topicref

Question

Proposer deux programmes XSLT, chacun permettant de transformer le fichier tasksAndConcepts.ditamap en une map ne contenant que les tasks ou que les concepts, pour retrouver les maps du premier exercice.

Solution

1
<?xml version="1.0" encoding="UTF-8"?>
2
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
3
<xsl:template match="map">
4
  <map title="Garage tasks">
5
    <xsl:copy-of select="topichead[@navtitle='Tasks']/topicref"/>
6
  </map>
7
</xsl:template>
8
</xsl:stylesheet>