XML technologies / XSLT / XSLT 3.0 / XSLT streaming / First steps with XSLT streaming / xsl:mode on-no-match / on-no-match="shallow-skip"

Exercise 3

The XML file WetterdatenStuttgart.xml should be reduced. The output file should contain only the root element year and, for each month element, a child temperature element. See the following output file. All other elements must be omitted from the output file. For this, use on-no-match="shallow-skip".

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

<year value="2015">
  <month name="january">
    <temperature min="-2,1" max="3,2" unit="celsius"/>
  </month>
  <month name="february">
    <temperature min="-1,2" max="5,1" unit="celsius"/>
  </month>
  ...       
</year>

The result XML containing only the required information.

Use the transformation scenario [Übung 3] on-no-match="shallow-skip" (XML >> XML) (see the notes on the exercises) and the following XSLT file:

Code example: stylesheet for exercise 3 on xsl:mode on-no-match="shallow-skip".

<?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:math="http://www.w3.org/2005/xpath-functions/math" exclude-result-prefixes="xs math" version="3.0">
  <!--AUFGABE: Nutzen Sie on-no-match="shallow-skip", um nur die Elemente year, month und temperature der XML-Datei in den Output zu übernehmen.-->
  <!--TODO: Streaming-Modus und on-no-match definieren.-->
  <xsl:output indent="yes" />
  <!--TODO: Entsprechende Templates anlegen.-->
</xsl:stylesheet>

Extension

Replace shallow-skip with deep-skip.

How does this change the output? And why?

Solution

The complete output XML and the solution stylesheet can be found under Solutions to Exercise 3 — xsl:mode on-no-match="shallow-skip".

   

back to top