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:

CDs
DVDs
Games
Ipods

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:
//department/cd
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.

Structure.xml
Code:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="style.xsl"?>
<SHOP>
	<Department type="CDs">
			<CD>
				<title>Metal</title>
				<description>Metal Music</description>
				<section>CDs</section>
			</CD>
	</Department>

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

  <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">
  <html>
  <title>Online Catalogue</title>
  <body>
  <h2>All Worlds Store</h2>
	
      <xsl:for-each select="//Department">
		  <a href="{@type}.html">
		  <xsl:value-of select="@type" />
		  </a>
      <br />
      </xsl:for-each>

  </body>
  </html>
  </xsl:result-document>
<!-- 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">
  
  <html>
  <title>Current Section:</title>
  <body>
 
  <h2>Choose Sub Navigation</h2>
      <xsl:for-each select="//Department/CD">
		  <a href="{title}.html">
		  <xsl:value-of select="title" />
		  </a>
      <br />
      </xsl:for-each>
      
	</body>
  </html>

</xsl:result-document>
</xsl:for-each>
<!-- SUB Department Menu -->

</xsl:template>
</xsl:stylesheet>