Helping ordinary people create extraordinary websites!
HOME TUTORIALS SCRIPTS WEB HOSTING BLOG FORUM
Get Our Newsletter
Email:

Tip: Create Multiple Files in XSLT 2.0

By Jack Herrington
2005-05-16


Create an index

To finish, I need to add an index file that points to all the output test results. To do that, I use another xsl:result-document tag and hard-code the output to go to an index file (see Listing 6).

Listing 6. Code to build the index file


<!-- Creating the index -->
<xsl:result-document href="output3/index.html"
format="html">
<html><head><title>Test Index</title></head>
<body>
<xsl:for-each select="//testrun">
<a href="{@run}.html"><xsl:value-of select="@run" />
</a><br/>
</xsl:for-each>
</body>
</html>
</xsl:result-document>

This section goes right after the xsl:for-each loop that builds the HTML files for each test case. Listing 7 shows the index file for the example data set.

Listing 7. The index file


<html>
<head>
<meta http-equiv="Content-Type"
content="text/html; charset=UTF-8">

<title>Test Index</title>
</head>
<body><a href="test1.html">test1</a><br>
<a href="test2.html">test2</a><br>
<a href="test3.html">test3</a><br></body>
</html>


Tutorial Pages:
» Use a single XSLT template to create multiple files
» Create a file for each test
» Get better output
» Create an index
» Summary
» Resources


First published by IBM DeveloperWorks


 | Bookmark
Related Tutorials:
» Starting with XML
» Performing Client-Side XSL Transformations
» Create a Google Sitemap for your Web Site
» XML and Scripting Languages
» Parsing Comma-Separated Values
» XML Security Suite: Increasing the Security of E-Business