Lab 2: Transform the Juicers


In this folder is the same juicers.xml as the last lab.

You are to add to the pipeline created in the last lab.

You are to create a pipeline that:

1. Deletes the empty elements in juicers.xml

2. Transforms the result from (1) using XSLT. The XSLT document
   creates an HTML document containing a list of all the
   juicer names.


There is a built-in XProc step called p:xslt that is
used to transform an XML document. Here's its skeletal structure:


<p:xslt name="give the step a name">
    -- input port="source" --
    -- input port="stylesheet" --
    -- input port="parameters" --
</p:xslt>


The p:xslt built-in step has 3 input ports:

1. The source port - supply this port with the XML 
   document from the previous (p:delete) step.


2. The stylesheet port - supply this port with the
   XSLT document. At the bottom of this document is
   the XSLT document. Please simply inline it.


3. The parameters port - we aren't going to send any
   parameters into the stylesheet, so bind this port
   to an empty element.


See lab2-pipeline.gif for an image of the pipeline you are to create.
(open the gif image in a browser)


Notes: 

A. The p:xslt step must get the XML from the p:delete step. What's the
   name of p:delete's output port? Answer: result 


B. The output of p:xslt is automatically routed to the next step (in this case,
the next step is the p:output of the pipeline), so don't connect the pipeline's 
output to p:delete.


Summary:

You need to connect the input of the pipeline to juicers.xml, and
the input of p:delete to the pipeline's input and p:xslt's source
input port to p:delete's result output port. p:xslt's stylesheet input
port is to be inlined. p:xslt's parameters input port is to be empty. 


Name your pipeline file: transform.xpl


When you've implemented your pipeline, open a DOS window, change
directory to this folder, and type this at the command prompt: 

   run > results.html

Open results.html in WordPad, and strip the stuff at the top, so that you
just have an HTML document; save it; open it in a browser. If you 
implemented your pipeline correctly, you should see a list of juicer
names.


Be sure to give the pipeline a meaningful name, and the p:delete step and
the p:xslt step a meaningful name.

Here's the stylesheet document that you are to use:

                <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                                version="1.0" >

                    <xsl:output method="html" indent="yes"/>

                    <xsl:template match="/">
                        <html>
                            <head>
                                <title>Juicer Names</title>
                            </head>
                            <body>
                               <h1>Juicer Names</h1>
                               <ul>
                                   <xsl:apply-templates select="//name" />
                               </ul>
                           </body>
                       </html>
                   </xsl:template>

                   <xsl:template match="name">
                       <li>
                           <xsl:value-of select="." />
                       </li>
                   </xsl:template>

               </xsl:stylesheet>