XML technologies / XSLT / XSLT 3.0 / XSLT streaming / First steps with XSLT streaming / Burst-Mode / Address list
Exercise 4
Write an XSLT transformation to use the employee data from all companies (see the XML file companies.xml) to create a CSV file for Word’s mail merge feature.
Code example: required output for exercise 4 (excerpt).
Anrede;Nachname;Vorname;PLZ;Stadt;Strasse;Land;
Ms.;Ackermann;Laura;45699;Herten;Friedrichstrasse 55;Germany;
Ms.;Bar;Lena;08142;Crossen;Oldesloer Strasse 10;Germany;Excerpt from the transformation result.
Use the transformation scenario [Übung 4] Burst-Mode - Adressliste (XML >> CSV) (see the notes on the exercises) and the following XSLT file:
Code example: stylesheet for exercise 4: address list.
<?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">
<!-- Output-Vorlage: Anrede;Nachname;Vorname;PLZ;Stadt;Strasse;Land;
Ms.;Ackermann;Laura;45699;Herten;Friedrichstrasse 55;Germany; -->
<xsl:output method="text" />
<xsl:mode streamable="yes" on-no-match="shallow-skip" />
<xsl:mode streamable="no" name="no-streaming" />
<xsl:template match="Name/* | Address/*" mode="no-streaming">
<xsl:apply-templates select="node() | @*" mode="no-streaming" />
<xsl:text>;</xsl:text>
</xsl:template>
</xsl:stylesheet>
Tips
View the result in Excel.
Excel can be used to check the result.
Line breaks
A line break can be inserted with the entity 
.
Extension
Extend the result to include the company name. It should be read from the surrounding Company element.
Code example: required output for exercise 4 – extension (excerpt).
Anrede;Nachname;Vorname;PLZ;Stadt;Strasse;Land;Firma;
Ms.;Ackermann;Laura;45699;Herten;Friedrichstrasse 55;Germany;Flexus;
Ms.;Bar;Lena;08142;Crossen;Oldesloer Strasse 10;Germany;Matrix Architectural Service;Excerpt from the transformation result of the extension.
Solution
The complete output CSV and the solution stylesheet can be found under Solutions to Exercise 4: address list.