The purpose of this laboratory session is to help you learn about
XSLT. To do so, you will be given a source of
information in the form of an XML file, and will be asked to use XSLT
stylesheets to transform certain parts of the information into HTML.
This can be done either by using a standalone XSLT processor, such
as Saxon
or xt
, or
by including an appropriate stylesheet processing instruction in
the XML file and viewing it using a browser.
The source file contains bibliographic information about papers
presented at the ACM Principles of Database Systems (PODS) conference
in 1998. Use a browser to view the XML file pods98.xml
. Take particular note
of the names and structure of the elements in the file, since you will
need to know these in order to express the following retrieval
requests as XSLT programs. Save a copy of the file pods98.xml
(by right-clicking on the link above) in the directory (folder) in which
you plan to work.
Below you will be asked to write four stylesheet programs. It is easiest
if you write each in a separate file (with the extension (type) .xsl
),
all in the directory you chose above.
To use Saxon
or xt
, open a Windows Command Prompt
window and change to the directory you chose above. To use xt
,
type the following in the command prompt window:
n:\xmltools\xt pods98.xml your-xslt-file.xsl output-file.html
where your-xslt-file.xsl
is the name of the file you have created
containing the particular XSLT
stylesheet you want to be applied to the file pods98.xml
.
The output of the transformation will be written to output-file.html
.
You can view this file using a browser, or a text editor if you want to see
the HTML source produced by the transformation.
To use Saxon
instead, type
n:\SaxonHE\saxon pods98.xml your-xslt-file.xsl output-file.html
You may get a warning about using a version 1 stylesheet with a version 2 processor.
You should use a standard text editor, such as Notepad
or Textpad
,
to create the contents of your stylesheet file. A starting
skeleton for the file (just the root xsl:stylesheet
element) is in skeleton.xsl
(right-click to save the file as is).
To use a stylesheet processing instruction in the XML file instead
of Saxon
or xt
, insert
<?xml-stylesheet href="your-xslt-file.xsl" type="text/xsl" ?>
between the XML declaration and the proceedings
root element in your
copy of pods98.xml
. Once again, your-xslt-file.xsl
is
the name of the file you have created containing the stylesheet you want to apply.
Now write a stylesheet for each of the following. Use one of the methods described above to check that each transforms the XML file as expected:
name
element which is a child of the proceedings
element in the
XML document. The output should be in HTML with the value of the
name
element being the contents of an h1
heading.
h1
heading.