XML technologies / XSLT / XSLT 3.0 / XSLT streaming / First steps with XSLT streaming / Burst-Mode / Play listing

Exercise 5

Write an XSLT transformation that reads the file plays.xml and outputs a list of all Shakespeare plays, including the main title, subtitle, scene description, number of acts, number of scenes and a list of all act and scene titles.

Code example: required output for exercise 5 (excerpt).

<plays>
  ...
  <play>
    <title>A Midsummer Night's Dream</title>
    <scndescr>SCENE Athens, and a wood near it.</scndescr>
    <playsubt>A MIDSUMMER NIGHT'S DREAM</playsubt>
    <acts>5</acts>
    <scenes>9</scenes>
    <titles>
      <title>ACT I</title>
      <title>SCENE I. Athens. The palace of THESEUS.</title>
      <title>SCENE II. Athens. QUINCE'S house.</title>
      <title>ACT II</title>
      <title>SCENE I. A wood near Athens.</title>
      <title>SCENE II. Another part of the wood.</title>
      <title>ACT III</title>
      <title>SCENE I. The wood. TITANIA lying asleep.</title>
      <title>SCENE II. Another part of the wood.</title>
      <title>ACT IV</title>
      <title>SCENE I. The same. LYSANDER, DEMETRIUS, HELENA</title>
      <title>SCENE II. Athens. QUINCE'S house.</title>
      <title>ACT V</title>
      <title>SCENE I. Athens. The palace of THESEUS.</title>
    </titles>
  </play>
  ...
</plays>

Transformed result for all plays, showing the main title, subtitle, scene description, number of acts, number of scenes and a summary of all act and scene titles.

Use the transformation scenario [Übung 5] Burst-Mode - Play Auflistung (XML >> XML) (see the notes on the exercises) and the following XSLT file:

Code example: stylesheet for exercise 5: play listing.

<?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" xmlns:hdm="http://www.hdm-stuttgart.de" exclude-result-prefixes="xs hdm" version="3.0">
  <!-- Output-Vorlage:
    <plays>
      <play>
        <title>A Midsummer Night's Dream</title>
        <scndescr>SCENE Athens, and a wood near it.</scndescr>
        <playsubt>A MIDSUMMER NIGHT'S DREAM</playsubt>
        <acts>5</acts>
        <scenes>9</scenes>
        <titles>
          <title>ACT I</title>
          <title>SCENE I. Athens. The palace of THESEUS.</title>
          <title>SCENE II. Athens. QUINCE'S house.</title>
          ...
        </titles>
      </play>
      ...
    </plays>
  -->
  <xsl:output method="xml" indent="yes" />
  <xsl:strip-space elements="*" />
  <xsl:mode streamable="yes" on-no-match="shallow-copy" />
  <xsl:mode streamable="no" on-no-match="shallow-copy" name="no-Streaming" />
</xsl:stylesheet>

Solution

The complete output XML and the solution stylesheet can be found under Solutions to Exercise 5: Play listing.

   

back to top