Results 1 to 2 of 2

Thread: [RESOLVED] XML: Output HTML Menu

Hybrid View

  1. #1
    Join Date
    Mar 2009

    resolved [RESOLVED] XML: Output HTML Menu

    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 -->

  2. #2
    Join Date
    May 2007
    <xsl:for-each select="//Department/*">

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center