i have an xml file 'structure', and an xsl file 'style'. I put the files together with saxon-b to generate an output html file.
basically, what is being output at the moment on the HTML file is:


These two categories have generated html links to cds.html and dvds.html, etc (for displaying sub-categories)

The problem is that cds.html displays 'Metal' (which is corrent), but also dvds.html , games.html and ipods.html displays the same subcategories from the cds.html page

in the code for generating the menus, i use:
so im guessing this is the problem? (as im bypassing dvd, games, ipods elements) but Im assuming i need to assign a variable or something.
maybe department/$variable or another variable somewhere else to check where the current page is and to gather the right data depending on what the user clicked. eg if i clicked games, i want the games sub-category to show. so the department link would need to be //department/games instead.

Any help apprechiated.
Im new to XML.

Ive posted the code so you can have a closer look, its pretty simple to understand i hope.

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="style.xsl"?>
	<Department type="CDs">
				<description>Metal Music</description>

	<Department type="DVDs">
				<description>List of action movies</description>
	<Department type="Games">
				<title>Xbox 360</title>
				<description>Xbox 360 games</description>
	<Department type="iPods">
				<description>iPod shuffle</description>
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

  <xsl:output method="text" />
  <xsl:output method="html" indent="yes" name="html" />
  <xsl:template match="/">

<!-- MAIN Navigation Categories -->
<xsl:result-document href="html/index.html" format="html">
  <title>Online Catalogue</title>
  <h2>All Worlds Store</h2>
      <xsl:for-each select="//Department">
		  <a href="{@type}.html">
		  <xsl:value-of select="@type" />
      <br />

<!-- MAIN Navigation Categories -->

<!-- sub navigation-->
<xsl:for-each select="//Department">
<xsl:variable name="file" select="concat('html/',@type,'.html')"/>
<xsl:value-of select="$file" /> 
<xsl:result-document href="{$file}" format="html">
  <title>Current Section:</title>
  <h2>Choose Sub Navigation</h2>
      <xsl:for-each select="//Department/CD">
		  <a href="{title}.html">
		  <xsl:value-of select="title" />
      <br />

<!-- SUB Department Menu -->