Subject: Re: [xsl] simple recursion From: Jurn Ho <jurn@xxxxxxxxxxxxxxxx> Date: Tue, 24 Aug 2004 14:32:57 +1000 |
cya, Jurn
hi,
I am quite beginner when it comes to XML and related technologies, and I hope someone will give me an explaination on how to solve the following problem.
I use an XML file to organize a website:
<?xml version="1.0" encoding="utf-8" ?>
<Site Title="My Site">
<Document MIMEType="text/html" Filename="Default.aspx"
Title="Homepage" Description="This is where it all began">
<Document MIMEType="text/html" Filename="Subpage.aspx"
Title="Subpage" Description="This is where it continued">
<Document MIMEType="text/html" Filename="SubSubpage.aspx"
Title="SubSubpage" Description="Now there is so much more" />
<Document MIMEType="text/html" Filename="SubSubpage2.aspx"
Title="SubSubpage2" Description="Now there is so much more,too">
<Document MIMEType="text/html" Filename="SubSubSubpage.aspx"
Title="SubSubpage2" Description="Now there is so much more,too" />
</Document>
<Document MIMEType="image/jpeg" Filename="Beautiful.jpeg" Title="A
beautiful Picture" Description="It shows pure beauty" />
</Document>
<Document MIMEType="text/html" Filename="Subpage2.aspx"
Title="Subpage2" Description="This is where it continued" />
<Document MIMEType="text/html" Filename="AnotherPage.htm"
Title="Another Page" Description="" />
</Document>
</Site>
then I use this xsl stylesheet to convert it to html
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<ol>
<xsl:apply-templates />
</ol>
</body>
</html>
</xsl:template>
<xsl:template match="Document">
<li>
<a href="{@Filename}" title="{@Description}">
<xsl:value-of select="@Title" />
</a>
<xsl:if test="node()">
<ol>
<xsl:for-each select="Document">
<xsl:apply-templates />
</xsl:for-each>
</ol>
</xsl:if>
</li>
</xsl:template>
</xsl:stylesheet>
Somehow the recursion stops somewhere unexpected (for me). It shows like:
* <Default.htm>Homepage * <SubSubpage.htm>SubSubpage * <SubSubpage2.htm>SubSubpage2 * <Beautiful.htm>A beautiful Picture
So obviously it does not actually recurse, it seems, whenever it enters a deeper level, the parent's following silblings are left out. But I can not find why this is so. Help?
-- Jan Limpens http://www.limpens.com
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] simple recursion, Jan Limpens | Thread | Re: [xsl] simple recursion, Jan Limpens |
[xsl] Printing a value if an attrib, michael . s . eberha | Date | Re: [xsl] Printing a value if an at, Jurn Ho |
Month |