[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] simple recursion
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: <html> <body> <ol> <li> <a href="Default.aspx" title="This is where it all began">Homepage</a> <ol> <li> <a href="SubSubpage.aspx" title="Now there is so much more">SubSubpage</a> </li> <li> <a href="SubSubpage2.aspx" title="Now there is so much more,too">SubSubpage2</a> <ol> </ol> </li> <li> <a href="Beautiful.jpeg" title="It shows pure beauty">A beautiful Picture</a> </li> </ol> </li> </ol> </body> </html> 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|