Play-Auflistung

Übung 5

Schreiben Sie eine XSLT-Transformation, welche die Datei plays.xml einliest und eine Auflistung aller Shakespeare-Stücke inklusive Haupt-Titel, Untertitel, Szenenbeschreibung, Anzahl der Akte, Anzahl der Szenen sowie eine Auflistung aller Akt- und Szenen-Titel ausgibt.

Code-Beispiel: Output-Vorgabe zu Übung 5 (Auszug).

<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>

Transformiertes Ergebnis aller Plays mit Ausgabe des Haupt-Titels, Untertitel, Szenenbeschreibung, Anzahl der Akte, Anzahl der Szenen und eine Zusammenfassung aller Akt- und Szenen-Titel.

Verwenden Sie das Transformationsszenario [Übung 5] Burst-Mode - Play Auflistung (XML >> XML) (siehe die Erläuterungen zu den Übungen) und die folgende XSLT-Datei:

Code-Beispiel: Stylesheet für Übung 5: Play-Auflistung.

<?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>

Lösung

Das vollständige Output-XML und das Lösungsstylesheet finden Sie unter Lösungen zu Übung 5: Play-Auflistung.

   

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