XML and XSLT help!

admin

Administrator
Staff member
Hi I am using XML Spy 2005. I have been given the task of creating an XML source, and then generating HTML pages from it using XSLT.

The subject is a general store that sells PCs, games and Phones.

I am currently trying to get the basic naviagation working.

Below is some of the XML:


<catalogue>

<catagory>
<title>Hardware</title>
<link>Hardware.html</link>
<subcatagory>Desktops</subcatagory>
<subcatagoryURL>Desktops.html</subcatagoryURL>
<subcatagory>Laptops</subcatagory>
<subcatagoryURL>Laptops.html</subcatagoryURL>
<subcatagory>Workstations</subcatagory>
<subcatagoryURL>Workstations.html</subcatagoryURL>
<subcatagory>Servers</subcatagory>
<subcatagoryURL>servers.html</subcatagoryURL>
</catagory>

</catalogue>



What I would like it to do is generate a page for each subcatagory with the subcatagory as the URL.
E.g. address/hardware/desktops.html.


On each page however I would like links to the other subcatagories. So if you were on desktops you could click on laptops, servers etc...

I have been working on the XSLT file for a while but get the same problem! All of the hyperlinks show up, but when i mouse over them I can see that the link says
<!-- m --><a class="postlink" href="http://address/desktop.html">http://address/desktop.html</a><!-- m --> laptop.html workstaion.html and so on.... all on one line. So im guessing I need to put another loop somewhere! So it will pick out these urls and put them on the appropriate place!

Anyway here is the section of XSLT code ive been using:


<xsl:for-each select="catalogue/catagory">
<xsl:result-document href=http://www.webdeveloper.com/forum/archive/index.php/"{title}{'.html'}">
<a>
<xsl:attribute name="href">
<xsl:value-of select="subcatagoryURL"></xsl:value-of>
</xsl:attribute>
<xsl:value-of select="subcatagory"></xsl:value-of>
</a>
</xsl:result-document>
</xsl:for-each>


Any help on this would be awesome!!
I can send the full XML and XSL file if needed!

Thanks

James!!
 
Back
Top