X hits on this document

413 views

0 shares

1 downloads

0 comments

56 / 142

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.

  • 1.

    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.

  • 2.

    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.

  • 3.

    Open a command prompt and change to the root of the workbook's distribution.

  • 4.

    Transform a set of MODS records into a set of XHTML files with the following command: xsltproc

xslt/mods2xhtml.xsl xml-data/mods/single/catalog.xml.

  • 5.

    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.

  • 6.

    As an extra exercise, use xmllint to validate the structure and syntax of one or more of the XHTML files.

48

Document info
Document views413
Page views419
Page last viewedTue Dec 06 10:39:47 UTC 2016
Pages142
Paragraphs3126
Words34660

Comments