473,402 Members | 2,064 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

Logic Problem in xsl

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

May 25 '06 #1
3 1292
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.)
May 26 '06 #2
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:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxml="urn:schemas-microsoft-com:xslt">
<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


May 26 '06 #3
Thanks, got it to work

May 28 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: A.V.C. | last post by:
Hello, I stuck in a delimma. Where to put the business logic that involves only one update but N number of selects from N tables........with N where conditions
4
by: Simon Harvey | last post by:
Hello Chaps, Me and a collegue have been talking about where the best place to put business logic is. I think that the best place is where Microsoft suggest - in a seperate business logic...
0
by: Al Fatykhov | last post by:
Using MABLE logic engine with existing .NET applications. MABLE web services provide an interface to MABLE business objects and logic. Let us review some technical details of the MABLE web...
0
by: Wim Vanhoof | last post by:
----------------------------------------------------------- WLPE' 06 - CALL FOR PAPERS Workshop on Logic-based Methods in Programming Environments (satellite workshop of ICLP’06) August...
16
by: MS newsgroup | last post by:
I don't have clear reasons why we need business logic layer and data logic layer instead of having only data logic layer. Are there any good reasons for that?
0
by: fiona | last post by:
FOR IMMEDIATE RELEASE Catalyst release low cost logic processing tool 87% of defects in software are errors in logic Yucca Valley, CA, September 2006 - Catalyst Development Corporation,...
14
by: rabbitrun | last post by:
Hi Everyone, I work for a financial company. I am planning to give a presentation to rest of the development team (15 people) here on moving server side logic to client-side javascript for an...
2
by: Chris Zopers | last post by:
Hello, I would like to know what's the best way to implement a business logic layer between my user interface and my database. I would say I'd make a dll-project for the business logic layer...
9
by: SAL | last post by:
Hello, I have a Dataset that I have table adapters in I designed using the designer (DataLayer). I have a business logic layer that immulates the DataLayer which may/may not have additional logic...
15
by: bruno.desthuilliers | last post by:
On 27 juin, 18:09, "John Salerno" <johnj...@NOSPAMgmail.comwrote: For which definitions of "content" and "logic" ??? The point of mvc is to keep domain logic separated from presentation logic,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.