473,785 Members | 2,414 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Sorting the element with in the sorting element

19 New Member
Hi all,

If u know the solution please suggest me. I need these urgent.

production.xml
Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <?xml-stylesheet type="text/xsl" href="xsl/vinoth-new.xsl"?>
  3. <report>
  4.     <production>
  5.         <etype>Break</etype>
  6.         <user>thiyagu</user>
  7.         <date>3/5/2008</date>
  8.         <book>Traning</book>
  9.         <file>Programming</file>
  10.         <status>WIP</status>
  11.         <task>RND</task>
  12.         <starttime>11:24:23 PM</starttime>
  13.         <endtime>11:46:21 PM</endtime>
  14.         <totaltime> 22</totaltime>
  15.         <updateto/>
  16.         <comment>Tea Break</comment>
  17.     </production>
  18.     <production>
  19.         <etype>Break</etype>
  20.         <user>saravanan</user>
  21.         <date>3/5/2008</date>
  22.         <book>Traning</book>
  23.         <file>Programming</file>
  24.         <status>WIP</status>
  25.         <task>RND</task>
  26.         <starttime>11:24:23 PM</starttime>
  27.         <endtime>11:46:21 PM</endtime>
  28.         <totaltime>5</totaltime>
  29.         <updateto/>
  30.         <comment>Tea Break</comment>
  31.     </production>
  32.     <production>
  33.         <etype>Job</etype>
  34.         <user>sai</user>
  35.         <date>3/6/2008</date>
  36.         <book>aw</book>
  37.         <file>`af</file>
  38.         <status>ar </status>
  39.         <task>Template</task>
  40.         <starttime>2:23:58 PM</starttime>
  41.         <endtime>2:24:05 PM</endtime>
  42.         <totaltime> 1</totaltime>
  43.         <updateto>awd </updateto>
  44.         <comment>ef</comment>
  45.     </production>
  46.     <production>
  47.         <etype>job</etype>
  48.         <user>saravanan</user>
  49.         <date>3/5/2008</date>
  50.         <book>Traning</book>
  51.         <file>Programming</file>
  52.         <status>WIP</status>
  53.         <task>RND</task>
  54.         <starttime>01:46:21 PM</starttime>
  55.         <endtime>02:46:21 PM</endtime>
  56.         <totaltime>2</totaltime>
  57.         <updateto/>
  58.         <comment>QC pending</comment>
  59.     </production>
  60.     <production>
  61.         <etype>Job</etype>
  62.         <user>kapil</user>
  63.         <date>3/6/2008</date>
  64.         <book>dcadcad</book>
  65.         <file>adcadc</file>
  66.         <status>OVER</status>
  67.         <task>XML</task>
  68.         <starttime>2:19:02 AM</starttime>
  69.         <endtime>2:19:19 PM</endtime>
  70.         <totaltime> 0</totaltime>
  71.         <updateto>adcadcac</updateto>
  72.         <comment>adcadca</comment>
  73.     </production>
  74.     <production>
  75.         <etype>Job</etype>
  76.         <user>ksaravanan</user>
  77.         <date>3/6/2008</date>
  78.         <book>aw</book>
  79.         <file>`af</file>
  80.         <status>ar</status>
  81.         <task>Template</task>
  82.         <starttime>2:23:58 PM</starttime>
  83.         <endtime>2:24:05 PM</endtime>
  84.         <totaltime> 1</totaltime>
  85.         <updateto>awd</updateto>
  86.         <comment>ef</comment>
  87.     </production>
  88.     <production>
  89.         <etype>Job</etype>
  90.         <user>vinoth</user>
  91.         <date>3/6/2008</date>
  92.         <book>meiners</book>
  93.         <file>chapter4</file>
  94.         <status>qc</status>
  95.         <task>XML</task>
  96.         <starttime>6:52:44 PM</starttime>
  97.         <endtime>6:53:36 PM</endtime>
  98.         <totaltime> 1</totaltime>
  99.         <updateto>add</updateto>
  100.         <comment>xfb </comment>
  101.     </production>
  102.     <production>
  103.         <etype>Break</etype>
  104.         <user>vinoth</user>
  105.         <date>3/6/2008</date>
  106.         <book>meiners</book>
  107.         <file>chapter4</file>
  108.         <status>qc</status>
  109.         <task>XML</task>
  110.         <starttime>6:52:44 PM</starttime>
  111.         <endtime>6:53:36 PM</endtime>
  112.         <totaltime> 1</totaltime>
  113.         <updateto>add</updateto>
  114.         <comment>xfb </comment>
  115.     </production>
  116. </report>
  117.  
I want to display these element as

sort with date
sort with task with in date
sort user with in task
sort etype with in user






now my xsl

Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <xsl:stylesheet version="1.0" 
  3.  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  4.  <xsl:output method="html" encoding="ISO-8859-1" doctype-public="-//W3C//DTD HTML 4.0 Transitional//EN"/>
  5. <xsl:variable name="report" select="//production"/>
  6. <!-- Define keys used to group elements -->
  7. <xsl:key name="keyDate" match="production" use="date" />
  8. <xsl:key name="keyUser" match="production" use="user" />
  9. <xsl:key name="keyTask" match="production" use="task" />
  10. <xsl:key name="keyEtype" match="production" use="etype" />
  11.  
  12. <xsl:template match="/">
  13.  <html>
  14.   <head>
  15.    <title>Cengage Production Report</title>
  16.   </head>
  17.   <body>
  18. <center>****************************************</center>
  19.   <center><font size="6" color="brown">PreMedia Global P. Ltd.</font>
  20.   </center>
  21. <center>****************************************</center>
  22.  
  23. <center><font size="4" color="blue">Cengage Production Report</font></center><br/>
  24.  
  25.  
  26.  
  27.     <table width="80%" frame="box" border="2" align="center">
  28.     <tbody>
  29. <xsl:apply-templates/>
  30.     </tbody>
  31.     </table>
  32.  
  33.   </body>
  34.  </html>
  35. </xsl:template>
  36.  
  37.  
  38. <xsl:template match="report" name="ShowproductionsInTeam">
  39.  
  40. <xsl:for-each select="$report">
  41.  
  42.  
  43. <xsl:sort select="date" order="ascending"/>
  44.  
  45.  
  46. <xsl:for-each select="$report[generate-id(.) = generate-id(key('keyTask', task)[1])]">
  47. <xsl:sort select="task" order="ascending"/>
  48. </xsl:for-each>
  49.  
  50.  
  51.  
  52. <xsl:variable name="date" select="date"/>
  53.  
  54. <xsl:if test="generate-id(.)=generate-id($report[date=$date])">
  55.  
  56. <tr>
  57.     <td width="10%" colspan="8" align="center"><font size="5" color="Green">Date: <xsl:value-of select="date"/></font></td>
  58. </tr>
  59. </xsl:if>
  60.  
  61. <xsl:for-each select="$report[generate-id(.) = generate-id(key('keyDate', date)[1])]">
  62. <xsl:sort select="task" order="ascending"/>
  63. </xsl:for-each>
  64.  
  65. <xsl:variable name="task" select="task"/>
  66. <xsl:if test="generate-id(.)=generate-id($report[task=$task]) or generate-id(.)=generate-id($report[date=$date])">
  67. <tr  bgcolor="#9e7bff">
  68.     <td width="10%" colspan="8"><h3><xsl:value-of select="task"/></h3></td>
  69. </tr>
  70. </xsl:if>
  71.  
  72.  <xsl:for-each select="$report[generate-id(.) = generate-id(key('keyDate', date)[1])]">
  73. <xsl:sort select="user" order="ascending"/>
  74. </xsl:for-each>
  75.  
  76. <xsl:variable name="user" select="user"/>
  77. <xsl:if test="generate-id(.)=generate-id($report[user=$user]) or generate-id(.)=generate-id($report[date=$date])">
  78. <tr  bgcolor="#dddddd">
  79.     <td width="10%" colspan="8"><font color="blue" size="4"><xsl:value-of select="user"/></font></td>
  80. </tr>
  81. </xsl:if>
  82.  
  83.  <xsl:for-each select="$report[generate-id(.) = generate-id(key('keyUser', user)[1])]">
  84. <xsl:sort select="etype" order="ascending"/>
  85. </xsl:for-each>
  86.  
  87. <xsl:variable name="etype" select="etype"/>
  88. <xsl:if test="generate-id(.)=generate-id($report[etype=$etype]) or generate-id(.)=generate-id($report[user=$user])">
  89.  <tr>
  90.             <th width="10%">Book</th>
  91.             <th width="10%">File</th>
  92.             <th width="10%">Status</th>
  93.             <th width="10%">Start Time</th>
  94.             <th width="10%">End Time</th>
  95.             <th width="10%">Total time</th>
  96.             <th width="10%">Updated To</th>
  97.             <th width="10%">Comment</th>
  98. </tr> 
  99. </xsl:if>            
  100.  
  101. <tr>
  102.             <td width="10%" bgcolor="#dddddd"><xsl:value-of select="book" /></td>
  103.             <td width="10%" bgcolor="#dddddd"><xsl:value-of select="file" /></td>
  104.             <td width="10%" bgcolor="#dddddd"><xsl:value-of select="status" /></td>
  105.             <td width="10%" bgcolor="#dddddd"><xsl:value-of select="starttime" /></td>
  106.             <td width="10%" bgcolor="#dddddd"><xsl:value-of select="endtime" /></td>
  107.             <td width="10%" bgcolor="#dddddd"><xsl:value-of select="totaltime" /></td>
  108.             <td width="10%" bgcolor="#dddddd"><xsl:value-of select="updateto" /></td>
  109.             <td width="10%" bgcolor="#dddddd"><xsl:value-of select="comment" /></td>            
  110. </tr>
  111.  
  112.  
  113. <xsl:variable name="totaltime" select="totaltime"/>
  114. <xsl:if test="generate-id(.)=generate-id($report[user=$user]) ">
  115. <tr>
  116.     <th colspan="8" align="right"><font color="blue">Total time:   <xsl:value-of select="sum($report[user=$user]/totaltime)" /> minutes</font></th>
  117. </tr>
  118. </xsl:if>
  119.  
  120.  
  121.  
  122. </xsl:for-each>
  123.  
  124. </xsl:template>
  125.  
  126. </xsl:stylesheet>
  127.  

Advance thanks for ur help
Mar 7 '08 #1
5 1582
MarkoKlacar
296 Recognized Expert Contributor
Hi,

Could you re-post using code tags, otherwise it's difficult to say what row needs attention.

Thanks
Mar 7 '08 #2
jkmyoung
2,057 Recognized Expert Top Contributor
I think the word for it is subsort.

In this case you simply need an additional <xsl:sort/> element

But to be honest, I'm really not sure what you're trying to do.. the xsl is quite messy. things like
<xsl:for-each select="$report[generate-id(.) = generate-id(key('keyTask ', task)[1])]">
<xsl:sort select="task" order="ascendin g"/>
</xsl:for-each>

do absolutely nothing, and shouldn't be in the code.
Mar 7 '08 #3
saran3b2
19 New Member
Hi MarkoKlacar,

Thanks 4 ur reply. As per previous mail. I have the (etype, user, book, file, status, task, starttime, endtime, totaltime, updateto, comment) elements. Here i want display these elements in stylesheet by

Date wise then task wise (All are must be ascending order in sub sorting) then user wise like as below mentioned:

Date: 2/5/2008

Task: RND

User: Thiyagu

Then display Book, file, status,........ .........
------------------------------------------------------------------------------------------

Date: 3/5/2008

Task: QC

User: Thiyagu

Then display Book, file, status,........ .........
------------------------------------------------------------------------------------------

And finally i want total time for each user by date wise.

I think this may be clear to u. Further any doubt i will like to explain details manner. (My E-mail id: kuberan.vinoth@ gmail.com)


<report>
<production>
<etype>Break</etype>
<user>thiyagu </user>
<date>2/5/2008</date>
<book>Traning </book>
<file>Programmi ng</file>
<status>WIP</status>
<task>QC</task>
<starttime>11:2 4:23 PM</starttime>
<endtime>11:46: 21 PM</endtime>
<totaltime> 22</totaltime>
<updateto/>
<comment>Tea Break</comment>
</production>
<production>
<etype>Break</etype>
<user>thiyagu </user>
<date>3/5/2008</date>
<book>Traning </book>
<file>Programmi ng</file>
<status>WIP</status>
<task>RND</task>
<starttime>11:2 4:23 PM</starttime>
<endtime>11:46: 21 PM</endtime>
<totaltime> 22</totaltime>
<updateto/>
<comment>Tea Break</comment>
</production>
------ and so on
</report




Hi,

Could you re-post using code tags, otherwise it's difficult to say what row needs attention.

Thanks
Mar 10 '08 #4
saran3b2
19 New Member
hi,

please ignore that watch the my reply to MarkoKlacar for clear doubt

I think the word for it is subsort.

In this case you simply need an additional <xsl:sort/> element

But to be honest, I'm really not sure what you're trying to do.. the xsl is quite messy. things like
<xsl:for-each select="$report[generate-id(.) = generate-id(key('keyTask ', task)[1])]">
<xsl:sort select="task" order="ascendin g"/>
</xsl:for-each>

do absolutely nothing, and shouldn't be in the code.
Mar 10 '08 #5
jkmyoung
2,057 Recognized Expert Top Contributor
This took awhile:
Expand|Select|Wrap|Line Numbers
  1. <xsl:template match="report" name="ShowproductionsInTeam">
  2.     <xsl:for-each select="$report[generate-id(.) = generate-id(key('keyDate', date)[1])]"><!-- Get unique dates -->
  3.     <xsl:sort select="date" order="ascending"/>
  4.         <xsl:variable name="date" select="date"/>
  5.         <!-- output date information -->
  6.         <tr>
  7.             <td width="10%" colspan="8" align="center"><font size="5" color="Green">Date: <xsl:value-of select="date"/></font></td>
  8.         </tr>
  9.         <xsl:for-each select="key('keyDate')[generate-id(.) = generate-id(key('keyTask', concat(date,task))[1])]"> <!-- Get unique tasks within a date -->
  10.         <xsl:sort select="task" order="ascending"/>
  11.             <!-- output task information -->
  12.             <tr  bgcolor="#9e7bff">
  13.                 <td width="10%" colspan="8"><h3><xsl:value-of select="task"/></h3></td>
  14.             </tr>
  15.  
  16.             <xsl:for-each select="key('keyTask', concat(date,task))[count(. | key('keyDateTaskUser', concat(date, task,user))[1]) = 1]"><!-- get unique users within a dateTask -->
  17.             <xsl:sort select="user" order="ascending"/>
  18.                 <!-- output user information -->
  19.                 <tr  bgcolor="#dddddd">
  20.                     <td width="10%" colspan="8"><font color="blue" size="4"><xsl:value-of select="user"/></font></td>
  21.                 </tr>
  22.                 <xsl:for-each select="key('keyDateTaskUser', concat(date, task,user))[count (. | key('keyDateTaskUserEtype',concat(date, task,user,etype))[1]) = 1]">
  23.                 <xsl:sort select="etype" order="ascending"/> <!-- get unique etypes within a date task user. -->
  24.                      <tr>
  25.                         <th width="10%">Book</th>
  26.                         <th width="10%">File</th>
  27.                         <th width="10%">Status</th>
  28.                         <th width="10%">Start Time</th>
  29.                         <th width="10%">End Time</th>
  30.                         <th width="10%">Total time</th>
  31.                         <th width="10%">Updated To</th>
  32.                         <th width="10%">Comment</th>
  33.                     </tr>
  34.                 </xsl:for-each>
  35.                 <xsl:for-each select="key('keyDateTaskUserEtype',concat(date, task,user,etype))">
  36.                     <tr>
  37.                         <td width="10%" bgcolor="#dddddd"><xsl:value-of select="book" /></td>
  38.                         <td width="10%" bgcolor="#dddddd"><xsl:value-of select="file" /></td>
  39.                         <td width="10%" bgcolor="#dddddd"><xsl:value-of select="status" /></td>
  40.                         <td width="10%" bgcolor="#dddddd"><xsl:value-of select="starttime" /></td>
  41.                         <td width="10%" bgcolor="#dddddd"><xsl:value-of select="endtime" /></td>
  42.                         <td width="10%" bgcolor="#dddddd"><xsl:value-of select="totaltime" /></td>
  43.                         <td width="10%" bgcolor="#dddddd"><xsl:value-of select="updateto" /></td>
  44.                         <td width="10%" bgcolor="#dddddd"><xsl:value-of select="comment" /></td>            
  45.                     </tr>
  46.                 </xsl:for-each><!-- etype -->
  47.             <tr><!-- This doesn't work, if a user is in multiple days--> 
  48.                 <th colspan="8" align="right"><font color="blue">Total time:   <xsl:value-of select="sum($report[user=$user]/totaltime)" /> minutes</font></th>
  49.             </tr>
  50.             </xsl:for-each><!-- user -->
  51.         </xsl:for-each><!-- task -->
  52.     </xsl:for-each><!-- date -->        
  53. </xsl:template>
  54.  
Mar 11 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

4
293
by: James P | last post by:
Hi All, I have an xml file as listed below. This is a list of scripts. Some of the scripts depend on the output of other scripts. I want to sort this xml in such a way that the scripts are listed in the correct order of execution. I created an IComparer class and implememted the Compare method. I am calling Array.Sort on an XmlNode array. The sorting is not correct. Can anyone suggest a correct algorithm for a compare method to sort this...
20
4081
by: Xah Lee | last post by:
Sort a List Xah Lee, 200510 In this page, we show how to sort a list in Python & Perl and also discuss some math of sort. To sort a list in Python, use the “sort” method. For example: li=;
2
1901
by: Alan Searle | last post by:
I find that I can display structured data very nicely using XML with an XSL template. As an extra 'goodie', I would like to give users the ability to sort that data (for example with a button above a particular column). What I need to know now is whether this is possible with XML/XSL? Or do I need to resort to a programming language (maybe JScript?). So far I have worked with the XML and XSL split into separate documents. However, I...
18
5752
by: Scott | last post by:
I have a collection where the items in the collection are dates. I want to iterate over the collection and build a value list string for the rowsource of a listbox. The dates in the collection are not in chronological order. Is there a way to first sort the collection and put the dates in chronological order before creating the value list string? Or, how would I iterate over the collection pulling out the dates in chronological order? ...
27
2354
by: ruel loehr | last post by:
Hey guys, I am looking for some insight: Given two sorted arrays of integers A and B, where array B has enough extra room in it to hold the contents of both A and B. Merge array A and B together such that the result is the sorted combination of the two (do not remove duplicates) and the result resides in the B array. I cannot perform any memory allocations to solve the problem.
7
10085
by: Foodbank | last post by:
Hi everyone. I'm having trouble with this radix sorting program. I've gotten some of it coded except for the actual sorting :( The book I'm teaching myself with (Data Structures Using C and C++) just doesn't explain things good at all and the tutorials I've viewed don't really explain least significant digit first sorting or show examples, which would be most helpful. I've commented the section where I know that the iteration of the...
6
7832
by: Fred Morrison | last post by:
Do you know of a way to load a hash table with random key/value pairs (e.g., 2/"Two",1/"One",3/"Three") and then iterate through the entries in "sorted" (key sequence) order (1/"One",2/"Two",3/"Three")? The following just returns them in the order they were loaded: Dim hshPrimaryKeyInfo as New Hashtable <snip code to Add entries to hash table> For Each hshEntry As DictionaryEntry In hshPrimaryKeyInfo
7
1781
by: Cerebrus99 | last post by:
Hi all, I am confused about how to sort an XML file. I mean how to *actually* sort the data in the physical file, not how to display sorted data. I am using a large XML file as a back-end database, and am making many inserts and updates using the XmlDocument class. But I need to make the XML file human readable too, and want to physically sort the data in the file, every time an insert is made. At present I'm having to use a tool like...
6
2495
by: bcochofel | last post by:
I'm using xsl to list an xml file that contains something like: sites, tag and weight. I'm listing this in a table with the following titles: | URL | TAG | WEIGHT (each title his a link) What I want is when someone clicks a title chooses the sorting option, if this is the actual sorting option then reverses the order. Can I do this? How?
7
4827
by: Kamal | last post by:
Hello all, I have a very simple html table with collapsible rows and sorting capabilities. The collapsible row is hidden with css rule (display:none). When one clicks in the left of the expandable row, the hidden row is made visible with css. The problem is when i sort the rows, the hidden rows get sorted as well which i don't want and want to be moved (while sorting) relative to their parent rows. The following is my complete html code...
0
9646
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
9483
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10157
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9956
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8982
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 projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7504
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
4055
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3658
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2887
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.