Search | Directories | Reference Tools
UW Home > UWIN > Computing and Networking > Software Guide 
-->
 
[Software Guide]
   
  UW Software Resources:
    Site Licenses 
 >   UW Tech Computers 
      A-Z Software List
      Computer List
      Software Category List
      Guidelines for Use
      Software Update Policy 
   
   
   
 

Xalan

Available on the computers: Ovid and Vergil

Xalan is a library that converts XML files to HTML or other XML files using XSL stylesheets

Using the Software
Xalan is usually accessed through an HTML/CGI combination in the Web environment, although it can also be accessed directly on the computer Ovid.

Let us say that you have an XML file named "my.xml" and an XSL stylesheet named "my.xsl" and you wish to convert your XML file to HTML format. Here are two ways to do it:

Execute Xalan directly on Ovid:
- Login to Ovid
- Invoke this command:

/usr/local/xalan/bin/Xalan my.xml my.xsl > my.html

This creates the file "my.html"

Apply the XSL stylesheet and directly display the resulting HTML file on the Web:
- Create an HTML file named "xalan.html" that looks like this:

    <html>
    <!-- A simple form that calls "xalan.cgi" to convert an XML file  -->
    <!-- to HTML via an XSL stylesheet                                -->
    <h2> Convert an XML file to HTML Using an XSL Stylesheet </h2>
    <form action="xalan.cgi" method="post">
    <table cellpadding="3" border="0">
      <tr><td>XML File: </td> <td> <input type="text" name="xml"> </td> </tr>
      <tr><td>XSL File: </td> <td> <input type="text" name="xsl"> </td> </tr>
      <tr><td> </td>    <td> <input type="submit"> </td> <td>     </td> </tr>
    </table>
    </form>
    </html>
	
- Create a CGI file named "xalan.cgi" that looks like this:

    #!/usr/local/bin/perl
    #
    # Accepts an XML and an XSL file as inputs, and converts the XML to
    # HTML using the XSL stylesheet.
    #
    use CGI;
    $query = new CGI;
    my $xml  = $query->param("xml");  chomp($xml);    # Get the XML file
    my $xsl  = $query->param("xsl");  chomp($xsl);    # Get the XSL file
    print "Content-type: text/html\n\n";
    system("/usr/local/xalan/bin/Xalan $xml $xsl") || print "oops! ";
    warn $@ if $@;
    exit(0);
	
- Then execute the HTML file on the Web and supply the "my.xml" and "my.xsl" files as arguments and it will display the resulting HTML file.

Technical Support
Help is available from UW Technology. Send a question to help@u.washington.edu if you need help with this software.

(software installed November 2005)