XML technologies / XSLT / XSLT 3.0 / XSLT streaming / Solutions / Exercise 8: Yellow Pages
Below are the solution files for Exercise 8, described under Yellow Pages.
Code example: solution XSLT for Exercise 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>
<head>
<title>Gelbe Seiten</title>
<meta charset="utf-8"/>
<link rel="stylesheet" type="text/css" href="../styling/dataTables/bootstrap.min.css" />
<link rel="stylesheet" type="text/css" href="../styling/dataTables/dataTables.bootstrap.css" />
<link rel="stylesheet" type="text/css" href="../styling/dataTables/dataTables.colVis.css" />
<link rel="stylesheet" type="text/css" href="../styling/styles.css" />
<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/dataTables/dataTables.fixedHeader.js" />
<script type="text/javascript" src="../styling/script.js" />
</head>
<body>
<h1>Gelbe Seiten</h1>
<table id="liste" class="table table-striped table-hover">
<thead>
<tr>
<th>Typ</th>
<th>Shop</th>
<th>Adresse</th>
<th>Telefon</th>
<th>Website</th>
</tr>
</thead>
<tbody>
<xsl:merge>
<xsl:merge-source for-each-source="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:template match="tag[matches(@k, 'addr:(street|postcode|city)')]" mode="no-Streaming">
<xsl:value-of select="@v" />
<xsl:text> </xsl:text>
</xsl:template>
<xsl:template match="tag[matches(@k, 'addr:(housenumber)')]" mode="no-Streaming">
<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>
Note from the data2type editors:
Since the following code example would exceed the scope of this page (about 9000 lines of code), only an excerpt from the solution file is shown here in HTML.
CCode example: HTML output for Exercise 8 (excerpt).
<?xml version="1.0" encoding="UTF-8"?>
<html>
<head>
<title>Gelbe Seiten</title>
<a target="type="text/css"" class="href="../styling/dataTables/bootstrap.min.css"" href="t3://page?alias=rel="stylesheet""></a>
<a target="type="text/css"" class="href="../styling/dataTables/dataTables.bootstrap.css"" href="t3://page?alias=rel="stylesheet""></a>
<a target="type="text/css"" class="href="../styling/dataTables/dataTables.colVis.css"" href="t3://page?alias=rel="stylesheet""></a>
<a target="type="text/css"" class="href="../styling/styles.css"" href="t3://page?alias=rel="stylesheet""></a>
<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/dataTables/dataTables.fixedHeader.js"></script>
<script type="text/javascript" src="../styling/script.js"></script>
</head>
<body>
<h1>Gelbe Seiten</h1>
<table id="liste" class="table table-striped table-hover">
<thead>
<tr>
<th>Typ</th>
<th>Shop</th>
<th>Adresse</th>
<th>Telefon</th>
<th>Website</th>
</tr>
</thead>
<tbody>
<tr>
<td>gift</td>
<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 & 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>