Jump to content

newbie xsl:nested levels do not show.


Guest raghu1
 Share

Recommended Posts

Guest raghu1

I have the following XML and am trying to build an xsl to view this in a browser. My data has tree nodes nested upto 8 levels also. If I can get this working for 2 levels, I can build the final one. <?xml version="1.0" standalone="yes"?> <?xml-stylesheet href="test.xsl" type="text/xsl"?> <TREENODES> <treenode Text="1st level group" > <treenode Text="member1" /> <treenode Text="member2" /> <treenode Text="member3" /> <treenode Text="member" /> <treenode Text="admin member" /> <treenode Text="2nd level group"> <treenode Text="member1" /> <treenode Text="nested group in 2n level"> <treenode Text="member Admin member" /> <treenode Text="nested group in 2nd level"> <treenode Text="member new" /> <treenode Text="test1" /> <treenode Text="test2" /> <treenode Text="test3" /> </treenode> </treenode> </treenode> </treenode> </TREENODES> xsl: <?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">; <xsl:output method='html' version='1.0' encoding='UTF-8' indent='yes'/> <xsl:template match="/"> <html> <body> <xsl:for-each select="TREENODES/treenode"> <table border="1" cellpadding="2" cellspacing="0"> <!-- Group Name --> <tr><td nowrap="nowrap" bgcolor="gray"><font face="arial" size="2"> <b><xsl:value-of select="@Text"/></b></font> </td></tr> <!-- 1st level --> <xsl:for-each select="treenode" > <tr><td nowrap="nowrap" bgcolor="aqua"><font face="arial" size="1"> <xsl:value-of select="@Text"/></font></td></tr> <!-- 2nd level --> <xsl:for-each select="treenode/treenode"> <tr><td nowrap="nowrap" bgcolor="yellow"><font face="arial" size="1"> <xsl:value-of select="@Text"/></font></td></tr> </xsl:for-each> <!-- 2nd level --> </xsl:for-each> <!-- 1st level --> </table> </xsl:for-each> <!-- group Name --> </body> </html> </xsl:template> </xsl:stylesheet> The nested members do not appear, I am new to xml/xsl. My data is hierarchal so I assume that xml is the way to go for reporint on this. I was looking to import this to excel also: needs lots of re-formatting, HTML table looks better. Any advise on fixing the xsl ...

Link to comment
Share on other sites

Sounds like a work for the linear to tabular data code. That is, if you want this data to be properly "linearized". However, all of this talk about "nesting" confuses me. What is the final output you're after?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...