Wrox Programmer Forums
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 24th, 2008, 04:21 AM
Authorized User
 
Join Date: Jul 2008
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default compare

My xml contains the reords of an employee shift and it's task. so it might be possible that one employee in one has to do many task. so my xml contains the reords as:
 <Detail>
    <idShiftNo>72</idShiftNo>
    <idEmployee>221265</idEmployee>
    <NameEmployee>Biswal, Antje</NameEmployee>
    <Date>2007-01-05T00:00:00+05:30</Date>
    <Department>1</Department>
    <ShiftName>F11</ShiftName>
    <ShiftStart>2007-01-05T02:30:00+05:30</ShiftStart>
    <ShiftEnd>2007-01-05T11:00:00+05:30</ShiftEnd>
    <idTaskNo>324</idTaskNo>
    <strNameJob>C-DE</strNameJob>
    <idTaskNo1>324</idTaskNo1>
    <TaskStart>2007-01-05T02:30:00+05:30</TaskStart>
    <TaskEnd>2007-01-05T04:15:00+05:30</TaskEnd>
    <TaskName>C-DE5824</TaskName>
    #000000
    <backColorHTML>#C0C0C0</backColorHTML>
    <ToolTip>Flight: Job: C-DE Task:C-DE5824 STA: STD: 03:45 AcOP: DE AcType: 320 Dest: TFS

PaxMax: 174 PaxBkd: 176</ToolTip>
  </Detail>
  <Detail>
    <idShiftNo>72</idShiftNo>
    <idEmployee>221265</idEmployee>
    <NameEmployee>Biswal, Antje</NameEmployee>
    <Date>2007-01-05T00:00:00+05:30</Date>
    <Department>1</Department>
    <ShiftName>F11</ShiftName>
    <ShiftStart>2007-01-05T02:30:00+05:30</ShiftStart>
    <ShiftEnd>2007-01-05T11:00:00+05:30</ShiftEnd>
    <idTaskNo>292</idTaskNo>
    <strNameJob>BO</strNameJob>
    <idTaskNo1>292</idTaskNo1>
    <TaskStart>2007-01-05T04:15:00+05:30</TaskStart>
    <TaskEnd>2007-01-05T04:55:00+05:30</TaskEnd>
    <TaskName>DE5824</TaskName>
    #000000
    <backColorHTML>#C0C0C0</backColorHTML>
    <ToolTip>Flight: Job: BO Task:DE5824 STA: STD: 03:45 AcOP: DE AcType: 320 Dest: TFS PaxMax:

174 PaxBkd: 176</ToolTip>
  </Detail>
 <Detail>
    <idShiftNo>72</idShiftNo>
    <idEmployee>221265</idEmployee>
    <NameEmployee>Biswal, Antje</NameEmployee>
    <Date>2007-01-05T00:00:00+05:30</Date>
    <Department>1</Department>
    <ShiftName>F11</ShiftName>
    <ShiftStart>2007-01-05T02:30:00+05:30</ShiftStart>
    <ShiftEnd>2007-01-05T11:00:00+05:30</ShiftEnd>
    <idTaskNo>296</idTaskNo>
    <strNameJob>BO</strNameJob>
    <idTaskNo1>296</idTaskNo1>
    <TaskStart>2007-01-05T06:25:00+05:30</TaskStart>
    <TaskEnd>2007-01-05T06:55:00+05:30</TaskEnd>
    <TaskName>C91680</TaskName>
    #000000
    <backColorHTML>#C0C0C0</backColorHTML>
    <ToolTip>Flight: Job: BO Task:C91680 STA: STD: 05:55 AcOP: C9 AcType: D38 Dest: ZRH PaxMax: 33 PaxBkd: 20</ToolTip>
  </Detail>
  <Detail>
    <idShiftNo>72</idShiftNo>
    <idEmployee>221265</idEmployee>
    <NameEmployee>Biswal, Antje</NameEmployee>
    <Date>2007-01-05T00:00:00+05:30</Date>
    <Department>1</Department>
    <ShiftName>F11</ShiftName>
    <ShiftStart>2007-01-05T02:30:00+05:30</ShiftStart>
    <ShiftEnd>2007-01-05T11:00:00+05:30</ShiftEnd>
    <idTaskNo>428</idTaskNo>
    <strNameJob>CKI-F</strNameJob>
    <idTaskNo1>428</idTaskNo1>
    <TaskStart>2007-01-05T07:00:00+05:30</TaskStart>
    <TaskEnd>2007-01-05T08:15:00+05:30</TaskEnd>
    <TaskName>CKI-F</TaskName>
    #000000
    <backColorHTML>#C0C0C0</backColorHTML>
    <ToolTip>RoutineJob:CKI-F Task:CKI-F Start: 07:00 End: 08:15</ToolTip>
  </Detail>
</NewDataSet>

xslt is:

<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">


<xsl:key name="distinctShift" match="NewDataSet/Detail" use="./idShiftNo"/>

<xsl:template match="/">

<table>

<xsl:for-each select="NewDataSet/Detail[generate-id() = generate-id(key('distinctShift', ./idShiftNo)[1])]">
  <tr>
    <td>
      <xsl:value-of select="idShiftNo"/>
    </td>
    <td>
      <xsl:value-of select="ShiftName"/>
    </td>
    <td>
      <xsl:for-each select="/NewDataSet/Detail[idShiftNo = current()/idShiftNo]">
        <xsl:if test="position() != 1">,</xsl:if>
        <xsl:value-of select="idTaskNo"/>
      </xsl:for-each>
    </td>
  </tr>
</xsl:for-each>
</table>
</xsl:template>

</xsl:stylesheet>


The problem is that as i have to show this on a chart then there it shows as


but i wan't to show it like
72 Biswal, Antje shiftstarttime shiftendtime task1 task2

 m able to show it like that one problem is there i wan't to compare the current TaskStart to the previous TaskStart.
How m able to do that???
Help m in this .





 
Old July 24th, 2008, 04:54 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Have you tried the links to grouping given in the first post in this forum?

--

Joe (Microsoft MVP - XML)
 
Old July 24th, 2008, 05:04 AM
Authorized User
 
Join Date: Jul 2008
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default

yup, but m not able to do that.
Help me


Thanx for ur reply.

 
Old July 24th, 2008, 05:50 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

You're grouping stuff looks fine - but you say you need to compare the current TaskStart to the 'previous' one.

Have you tried "preceding-sibling::Detail[1]/TaskStart"?

/- Sam Judson : Wrox Technical Editor -/
 
Old July 24th, 2008, 06:12 AM
Authorized User
 
Join Date: Jul 2008
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default

actually what i want to show the xml data to the browser in the form of a chart where i want to depict the employee shifts and their tasks.
it look like as:
                                              scale used to show task according to time
shift shiftname empName ShiftStart ShiftEnd -------------------------------------------------------------------------
                                            00:00 01:00 02:00 03:00-------------------------23:00
                                            --------------------------------------------------------------------------
72 F11 Biswal, Antje 2:30 11:00 Task1 task2

so what i done is at time of task firstly a yellow line comes which is calculated on the basis of Shift start and end and then draw a yellow <td>
there and then in that i make another table which is used to show task. m able to show the first task and it shows accurately but in second task i have to find the gap between first task and second so can i get the previous values to find the Task.

 
Old July 24th, 2008, 07:27 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

Does my previous suggestion provide you access to the previous task start element? If so then you just have a load of calculations to work out - something I think you're going to have to do yourself.

/- Sam Judson : Wrox Technical Editor -/
 
Old July 24th, 2008, 08:11 AM
Authorized User
 
Join Date: Jul 2008
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanx samjudson as through your help m able to acheive the target, exatly the same output which i want.
Thanx a lot,i highly appreciate your spirit to help others.
:)






Similar Threads
Thread Thread Starter Forum Replies Last Post
compare a cell with nothing popaerou Excel VBA 2 October 26th, 2008 12:35 PM
How to compare the value elayaraja.s XSLT 3 July 28th, 2008 07:48 AM
compare nmnm XSLT 3 April 24th, 2007 08:13 AM
compare these date fields and compare and get the susanring Oracle 1 July 24th, 2006 04:58 PM
Compare 2 tables.... Seb_soum Classic ASP Databases 2 June 4th, 2004 05:47 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.