PB138/07 - Modern Markup Languages and Their Applications Lab 03 [09.03.2020] EXtensible Stylesheet Language Transformations (XSLT) Bruno Rossi Department of Computer Systems and Communications, Lasaris (Lab of Software Architectures and Information Systems) Masaryk University, Brno 2/8 ● XSL (EXtensible Stylesheet Language) : styling language for XML ● XSLT stands for XSL Transformations ● XSLT uses XPath for matching one or more predefined templates and transforming the matching part in the resulting document ● “Navigational style” (e.g., using ) vs “Rulebased style” (using ) Introduction 3/8 XSLT Reminder ● Definition of a template ... (in a for-each) (note that you can also use xpath filtering conditions) ... ... 4/8 Example - “navigational” style ● Using the continent.xml file used previously Continents

Cities and Continents

background: LightCyan;
Pos Name Population
5/8 Example - “rule-based” style ● Using the continent.xml file used previously Continents

Cities and Continents

Pos Name Population
background: LightCyan;
6/8 XSL Transformation continents.xml + continents.xsl → continents.html ● Some ways to run the transformation for the next tasks ● Netbeans: right click on the xml file → XSL transformation... ● Java: using javax.xml.transform.* classes ● xsltproc - xsltproc continents.xsl continents.xml > continents.html ● Online converters, like: – https://xslttest.appspot.com – https://www.freeformatter.com/xsl-transformer.html 7/8 Task 01 (week03) ● Download the project seminars/xslt2-zadani.zip and uncompress locally in a directory ● The goal of the task is to complete file transf.xsl so that the transformations run on data.xml give as output the file data.html (that you can use as example of the expected result) Using the command line (or the implementation in the project or methods mentioned in the previous slide): xsltproc transf.xsl data.xml > out.html (out.html can then be compared with data.html) ● Upload the final XSL file to homework vault sem07/task01-week03/ 8/8 References Suggested material: ● XSLT Specifications →https://www.w3.org/TR/xslt ● W3C School XSLT pages: →https://www.w3schools.com/xml/xsl_intro.asp ● XSLT Tutorial → http://zvon.org/comp/r/tut-XSLT_1.html ● XSLT Elements → https://www.w3schools.com/xml/xsl_elementref.asp ● Online XSLT Quick Card →https://www.cheatography.com/univer/cheat-sheets/xslt-2-0-cheat-sheet/pdf/