473,396 Members | 1,966 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,396 software developers and data experts.

Sorting the element with in the sorting element

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 1560
MarkoKlacar
296 Expert 100+
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 Expert 2GB
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="ascending"/>
</xsl:for-each>

do absolutely nothing, and shouldn't be in the code.
Mar 7 '08 #3
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>Programming</file>
<status>WIP</status>
<task>QC</task>
<starttime>11:24: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>Programming</file>
<status>WIP</status>
<task>RND</task>
<starttime>11:24: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
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="ascending"/>
</xsl:for-each>

do absolutely nothing, and shouldn't be in the code.
Mar 10 '08 #5
jkmyoung
2,057 Expert 2GB
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
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...
20
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: ...
2
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...
18
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...
27
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...
7
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...
6
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...
7
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...
6
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...
7
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...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: 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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...

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.