![]() |
|
|
|
#1 |
|
Hi,
I want to convert the following xml file into html using xsl: <?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="projects.xsl"?> <Employees> <Employee> <Name>Aseem Sharma</Name> <EmployeeId>119370</EmployeeId> <Project>Metlife</Project> <Designation rank="d">Programmer Analyst</Designation> </Employee> <Employee> <Name>Aiman Ashraf</Name> <EmployeeId>119372</EmployeeId> <Project>Metlife</Project> <Designation rank="d">Programmer Analyst</Designation> </Employee> <Employee> <Name>S Krishnan</Name> <EmployeeId>143370</EmployeeId> <Project>Metlife</Project> <Designation rank="a">Project Manager</Designation> </Employee> <Employee> <Name>Aaditya Thakur</Name> <EmployeeId>118736</EmployeeId> <Project>Coors</Project> <Designation rank="d">Programmer Analyst</Designation> </Employee> <Employee> <Name>Ankur Srivastava</Name> <EmployeeId>129370</EmployeeId> <Project>Coors</Project> <Designation rank="d">Programmer Analyst</Designation> </Employee> <Employee> <Name>Rohan Taneja</Name> <EmployeeId>126660</EmployeeId> <Project>Coors</Project> <Designation rank="c">Associate</Designation> </Employee> <Employee> <Name>Purnima Raghunath</Name> <EmployeeId>113330</EmployeeId> <Project>Coors</Project> <Designation rank="a">Project Manager</Designation> </Employee> <Employee> <Name>Trisha Singh</Name> <EmployeeId>112340</EmployeeId> <Project>Wachovia</Project> <Designation rank="d">Programmer Analyst</Designation> </Employee> <Employee> <Name>Rakesh Menon</Name> <EmployeeId>103450</EmployeeId> <Project>Metlife</Project> <Designation rank="c">Associate</Designation> </Employee> <Employee> <Name>Sachin Doshi</Name> <EmployeeId>145670</EmployeeId> <Project>Metlife</Project> <Designation rank="b">Senior Associate</Designation> </Employee> </Employees> The html should show a table for each PROJECT with their respective employees. So, there'll be 3 tables (Metlife,Coors,Wachovia). The problem is that I cannot hard code the name of the project anywhere in xsl as more nodes with other project names can get added to the xml file. Could anyone give me a hint on how to go about this. Any help would be super appreciated. Thanks GeezerButler |
|
|
|
|
#2 |
|
Posts: n/a
|
Sounds like a standard grouping problem:
http://www.dpawson.co.uk/xsl/sect2/N4486.html (I believe XSLT 2.0 is supposed to make grouping a bit easier.) |
|
|
|
#3 |
|
Posts: n/a
|
Hi try this not exactly what your looking for but might give you an
idea: <?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet version="1.0" xmlns xmlns:msxml="urn:schemas-microsoft-com <xsl:template match="/"> <xsl:variable name="SortedRows"> <xsl:for-each select="/Root/Table/Row"> <xsl:sort select="Group"/> <xsl:copy-of select="."/> </xsl:for-each> </xsl:variable> <html> <table border="1"> <tr> <th>First Name</th> <th>Second Name</th> <th>Group</th> <th>Next</th> </tr> <xsl:for-each select="msxml:node-set($SortedRows)/*"> <tr> <td><xsl:value-of select="./FirstName"/></td> <td><xsl:value-of select="./SecondName"/></td> <td><xsl:value-of select="./Group"/></td> <td><xsl:value-of select="following-sibling::*/SecondName"/></td> </tr> </xsl:for-each> </table> </html> </xsl:template> </xsl:stylesheet> GeezerButler wrote: > Hi, > I want to convert the following xml file into html using xsl: > > <?xml version="1.0"?> > <?xml-stylesheet type="text/xsl" href="projects.xsl"?> > <Employees> > <Employee> > <Name>Aseem Sharma</Name> > <EmployeeId>119370</EmployeeId> > <Project>Metlife</Project> > <Designation rank="d">Programmer Analyst</Designation> > </Employee> > <Employee> > <Name>Aiman Ashraf</Name> > <EmployeeId>119372</EmployeeId> > <Project>Metlife</Project> > <Designation rank="d">Programmer Analyst</Designation> > </Employee> > <Employee> > <Name>S Krishnan</Name> > <EmployeeId>143370</EmployeeId> > <Project>Metlife</Project> > <Designation rank="a">Project Manager</Designation> > </Employee> > <Employee> > <Name>Aaditya Thakur</Name> > <EmployeeId>118736</EmployeeId> > <Project>Coors</Project> > <Designation rank="d">Programmer Analyst</Designation> > </Employee> > <Employee> > <Name>Ankur Srivastava</Name> > <EmployeeId>129370</EmployeeId> > <Project>Coors</Project> > <Designation rank="d">Programmer Analyst</Designation> > </Employee> > <Employee> > <Name>Rohan Taneja</Name> > <EmployeeId>126660</EmployeeId> > <Project>Coors</Project> > <Designation rank="c">Associate</Designation> > </Employee> > <Employee> > <Name>Purnima Raghunath</Name> > <EmployeeId>113330</EmployeeId> > <Project>Coors</Project> > <Designation rank="a">Project Manager</Designation> > </Employee> > <Employee> > <Name>Trisha Singh</Name> > <EmployeeId>112340</EmployeeId> > <Project>Wachovia</Project> > <Designation rank="d">Programmer Analyst</Designation> > </Employee> > <Employee> > <Name>Rakesh Menon</Name> > <EmployeeId>103450</EmployeeId> > <Project>Metlife</Project> > <Designation rank="c">Associate</Designation> > </Employee> > <Employee> > <Name>Sachin Doshi</Name> > <EmployeeId>145670</EmployeeId> > <Project>Metlife</Project> > <Designation rank="b">Senior Associate</Designation> > </Employee> > </Employees> > > The html should show a table for each PROJECT with their respective > employees. > So, there'll be 3 tables (Metlife,Coors,Wachovia). The problem is that > I cannot hard code the name of the project anywhere in xsl as more > nodes with other project names can get added to the xml file. > Could anyone give me a hint on how to go about this. > > Any help would be super appreciated. > > Thanks |
|
|
|
#4 |
|
Posts: n/a
|
Thanks, got it to work
|
|