[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
[xsl] rendering a treeview *hairy problem*
Subject: [xsl] rendering a treeview *hairy problem* From: "Mattias Konradsson" <preacher@xxxxxxxxxxx> Date: Thu, 1 Feb 2001 06:48:28 +0100 |
weee, this problem has been on my mind the last couple of days... So roll up your sleeves and get your gray ones going, hopefully they work better than mine :) I have an forum with xml structure something like this <forum> <thread> <post postID="1" Subject="First Post"> <post postID="2" Subject="Reply to first Post"/> <post postID="3" Subject="Second Reply to first Post"> <post postID="4" Subject="First Reply to Second Reply to first Post"/> </post> </post> <post postID="5" Subject="Second Post"/> </thread> <thread> ... </thread> </forum> and I want to make an xslt stylesheet that outputs a graphical hierarchial tree based on this, this is what I got sofar <xsl:template match="/"> <xsl:apply-templates/> </xsl:template> <xsl:template match="forum"> <div> <xsl:for-each select="thread"> <xsl:apply-templates /> </xsl:for-each> </div> </xsl:template> <xsl:template match="post"> <div style="padding-left:12px"> <xsl:choose> <xsl:when test="position() = last()"> <img align="middle" src="/community/images/thread.gif" alt="" border="0"/> </xsl:when> <xsl:otherwise > <img align="middle" src="/community/images/branch.gif" alt="" border="0"/> </xsl:otherwise> </xsl:choose> <xsl:value-of select="@subject" />   <xsl:value-of select="@nickname" /> <xsl:if test="position() = last()">last</xsl:if> <xsl:value-of select="count(child::post)"/> <xsl:apply-templates /> </div> </xsl:template> branch.gif is a a image where the the tree branches but has more nodes after it and thread.gif is a L-shaped image for the last node in a branch . This is what's produced (here we go with the ascii) I- First Post L Reply to First Post L Second Reply to First Post L First Reply to Second Reply to first post L Second Post Sofar so good, the padding takes care of the indenting and we check to see if a node is last to select image. The *problem is that there should be Lines connecting the First and Second Post and any Siblings (if there were any) So I want it to look like this: I- First Post I L Reply to First Post I L Second Reply to First Post I I L First Reply to Second Reply to first post I L Third Reply to first post L Second Post But I haven't been able to figure out a good solution.. the current solution is recursive but for this to work you'd have to keep track on which siblings line graphics should be before replies. Anyway, I hope I've explained it well, if anyone can solve this hairy problem I'd be forever grateful :) Best Regards --- Mattias Konradsson XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] XML to PDF ????, cutlass | Thread | Re: [xsl] rendering a treeview *hai, Mattias Konradsson |
[xsl] XML to PDF ????, manisha | Date | [xsl] how to insert a section of ht, Rosa I-Ting Cheng |
Month |