Transforming XML with XSLT
happens because your Web browser read the XML file. Learned that it needed an XSLT file for transformation. Retrieved the XSLT file. Combined the XSLT file with the raw XML, and dis- played the results.
Exercise - Transform MODS into XHTML
MODS is an XML bibliographic vocabulary; it is very similar to MARC. In this exercise you will trans- form a set of MODS data into individual XHTML files.
Open xml-data/mods/single/catalog.xml in your favorite text editor. Examine the element names and take notice how they are similar to the fields of standard bibliographic data sets.
Open xslt/mods2xhtml.xsl in your favorite text editor or Web browser. Notice how the stylesheet declaration imports a namespace called mods. Notice how the namespace prefixes all of the MODS element names. Notice how the parameter named filename is assigned a value from the MODS re- cord. Notice the use of xsl:document element/command. It is used to define where output files will be saved. Finally, notice how the XSLT tries create rich and valid XHTML.
Open a command prompt and change to the root of the workbook's distribution.
Transform a set of MODS records into a set of XHTML files with the following command: xsltproc
Lastly, open the folder/directory named xml-data/xhtml/mods2xhtml. You should see sets of numbered files, and each file is a valid XHTML file containing bibliographic information from the catalog.xml.
As an extra exercise, use xmllint to validate the structure and syntax of one or more of the XHTML files.