# Lösungen zu Übung 8: Gelbe Seiten (xsl:merge)

Im Folgenden finden Sie die Lösungsdateien zu Übung 8 unter Gelbe Seiten.

Code-Beispiel: Lösungs-XSLT zu Übung 8.

``````<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs" version="3.0">
<xsl:output indent="yes" method="xhtml" />
<xsl:mode streamable="yes" />
<xsl:mode streamable="no" name="no-Streaming" />
<xsl:template match="/">
<html>
<title>Gelbe Seiten</title>
<meta charset="utf-8"/>
<script type="text/javascript" src="../styling/dataTables/jquery-1.11.1.min.js" />
<script type="text/javascript" src="../styling/dataTables/jquery.dataTables.min.js" />
<script type="text/javascript" src="../styling/dataTables/dataTables.bootstrap.js" />
<script type="text/javascript" src="../styling/dataTables/dataTables.colVis.js" />
<script type="text/javascript" src="../styling/script.js" />
<body>
<h1>Gelbe Seiten</h1>
<table id="liste" class="table table-striped table-hover">
<tr>
<th>Typ</th>
<th>Shop</th>
<th>Telefon</th>
<th>Website</th>
</tr>
<tbody>
<xsl:merge>
<xsl:merge-source for-each-stream="uri-collection('../in?select=*.xml')" streamable="yes" select="osm/node">
<xsl:merge-key select="spieltHierKeineRolle" />
</xsl:merge-source>
<xsl:merge-action>
<xsl:apply-templates select="current-merge-group()" mode="no-Streaming" />
</xsl:merge-action>
</xsl:merge>
</tbody>
</table>
</body>
</html>
</xsl:template>
<xsl:template match="node[tag/@k = 'shop']" mode="no-Streaming">
<tr>
<td>
<xsl:apply-templates select="tag[@k = 'shop']" mode="#current" />
</td>
<td>
<xsl:apply-templates select="tag[@k = 'name']" mode="#current" />
</td>
<td>
<xsl:apply-templates select="tag[@k = 'addr:street']" mode="#current" />
<xsl:apply-templates select="tag[@k = 'addr:housenumber']" mode="#current" />
<xsl:apply-templates select="tag[@k = 'addr:postcode']" mode="#current" />
<xsl:apply-templates select="tag[@k = 'addr:city']" mode="#current" />
</td>
<td>
<xsl:apply-templates select="tag[@k = 'contact:phone']" mode="#current" />
</td>
<td>
<xsl:apply-templates select="tag[@k = 'website']" mode="#current" />
</td>
</tr>
</xsl:template>
<xsl:template match="node[not(tag/@k = 'shop')]" mode="no-Streaming" />
<xsl:template match="tag[matches(@k, '(name|contact:phone|opening_hours|shop)')]" mode="no-Streaming">
<xsl:value-of select="@v" />
</xsl:template>
<xsl:value-of select="@v" />
<xsl:text> </xsl:text>
</xsl:template>
<xsl:value-of select="@v" />
<xsl:text>, </xsl:text>
</xsl:template>
<xsl:template match="tag[matches(@k, '(website)')]" mode="no-Streaming">
<a href="{@v}">Website</a>
</xsl:template>
</xsl:stylesheet>
``````

Anmerkung der data2type-Redaktion:
Da das folgende Code-Beispiel den Rahmen sprengen würde (ca. 9000 Zeilen Code), folgt hier nur ein Auszug aus der Lösungs-HTML-Datei.

Code-Beispiel: Output-HTML zu Übung 8 (Auszug).

``````<?xml version="1.0" encoding="UTF-8"?>
<html>
<title>Gelbe Seiten</title>
<script type="text/javascript" src="../styling/dataTables/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="../styling/dataTables/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="../styling/dataTables/dataTables.bootstrap.js"></script>
<script type="text/javascript" src="../styling/dataTables/dataTables.colVis.js"></script>
<script type="text/javascript" src="../styling/script.js"></script>
<body>
<h1>Gelbe Seiten</h1>
<table id="liste" class="table table-striped table-hover">
<tr>
<th>Typ</th>
<th>Shop</th>
<th>Telefon</th>
<th>Website</th>
</tr>
<tbody>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>books</td>
<td>Berlin Story</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>kiosk</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>mall</td>
<td>Galeries Lafayette</td>
<td>Friedrichstraße 76-78, 10117 Berlin </td>
<td></td>
<td><a href="http://www.galerieslafayette.de/">Website</a></td>
</tr>
<tr>
<td>rc_models</td>
<td>Staufenbiel</td>
<td></td>
<td></td>
<td><a href="modellhobby.de">Website</a></td>
</tr>
<tr>
<td>massage</td>
<td>Wang Spa</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>supermarket</td>
<td>Edeka</td>
<td>Friedrichstraße 142, 10117 Berlin </td>
<td></td>
<td><a href="http://www.edeka-bahnhof.de">Website</a></td>
</tr>
<tr>
<td>car</td>
<td>Automobil Forum</td>
<td>Friedrichstraße 84, 10117 Berlin </td>
<td></td>
<td><a href="http://www.volkswagenag.com/content/afb/content/de/homepage.html">Website</a></td>
</tr>
<tr>
<td>confectionery</td>
<td>Bunte Schokowelt</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>confectionery</td>
<td>Fassbender &amp; Rausch Chocolatiers am Gendarmenmarkt</td>
<td>Charlottenstraße 60, 10117 Berlin </td>
<td></td>
<td><a href="http://www.fassbender-rausch.de">Website</a></td>
</tr>
...
</tbody>
</table>
</body>
</html>
``````

 Tipp der data2type-Redaktion: Zum Thema XSLT bieten wir auch folgende Schulungen zur Vertiefung und professionellen Fortbildung an: