Tecnologías XML / XSLT / XSLT 3.0 / Streaming XSLT / Primeros pasos con el streaming XSLT / Burst-Mode / Listado de obras
Ejercicio 5
Escriba una transformación XSLT que lea el archivo plays.xml y genere un listado de todas las obras de Shakespeare que incluya el título principal, el subtítulo, la descripción de la escena, el número de actos, el número de escenas y una lista de todos los títulos de actos y escenas.
Ejemplo de código: salida requerida para el ejercicio 5 (extracto).
<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>Resultado transformado de todas las obras, con el título principal, el subtítulo, la descripción de la escena, el número de actos, el número de escenas y un resumen de todos los títulos de actos y escenas.
Utilice el escenario de transformación [Übung 5] Burst-Mode - Play Auflistung (XML >> XML) (véanse las explicaciones de los ejercicios) y el siguiente archivo XSLT:
Ejemplo de código: hoja de estilo para el ejercicio 5: listado de obras.
<?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>
Solución
El XML de salida completo y la hoja de estilo de solución se encuentran en Soluciones del ejercicio 5: listado Play.