Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
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 23rd, 2008, 04:07 AM
Authorized User
 
Join Date: Jul 2008
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to store the previous node value

i want to store the previous node(TaskEnd) value to variable so that m able to compare it with current node(TaskEnd).please help m in this.
this is my xml:
<NewDataSet>
  <Detail>
    <idShiftNo>71</idShiftNo>
    <idEmployee>221364</idEmployee>
    <NameEmployee>Biswal, Katrin</NameEmployee>
    <Date>2007-01-05T00:00:00+05:30</Date>
    <Department>1</Department>
    <ShiftName>F25</ShiftName>
    <ShiftStart>2007-01-05T06:15:00+05:30</ShiftStart>
    <ShiftEnd>2007-01-05T14:00:00+05:30</ShiftEnd>
    <idTaskNo>337</idTaskNo>
    <strNameJob>C-4U</strNameJob>
    <idTaskNo1>337</idTaskNo1>
    <TaskStart>2007-01-05T06:15:00+05:30</TaskStart>
    <TaskEnd>2007-01-05T08:15:00+05:30</TaskEnd>
    <TaskName>C-4U</TaskName>
    #000000
    <backColorHTML>#C0C0C0</backColorHTML>
    <ToolTip>RoutineJob:C-4U Task:C-4U Start: 06:15 End: 08:15</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>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>
<NewDataSet>


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


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


  <xsl:variable name="timeendshow"></xsl:variable>
  <xsl:variable name="timeendshow2"></xsl:variable>
  <xsl:variable name="timeendshow1"></xsl:variable>
  <xsl:variable name="timestartshow"></xsl:variable>
  <xsl:variable name="taskname"></xsl:variable>
  <xsl:variable name="taskname1"></xsl:variable>
  <xsl:variable name="taskname2"></xsl:variable>
  <xsl:variable name="taskmincal"></xsl:variable>
  <xsl:variable name="timeendmin"></xsl:variable>
  <xsl:variable name ="taskmatch"></xsl:variable>

  <xsl:template match="NewDataSet/Detail[@type = 'idShiftNo']">
    <NewDataSet>
      <xsl:copy-of select="*" />
      <xsl:copy-of select="following-sibling::NewDataSet/Detail[1]
                           [@type = 'TaskName']/*"/>
    </NewDataSet>
  </xsl:template>
  <xsl:template match="/">
  <xsl:for-each select="NewDataSet/Detail[generate-id() = generate-id(key('distinctShift', ./idShiftNo)[1])]">
<xsl:value-of select="idShiftNo"/>
<xsl:value-of select="ShiftName"/>
<xsl:value-of select="NameEmployee"/>
<xsl:value-of select="substring(ShiftStart,12,5)"/>
<xsl:value-of select="substring(ShiftEnd,12,5)"/>
<xsl:for-each select="/NewDataSet/Detail[idShiftNo = current()/idShiftNo]">
<xsl:value-of select="$taskname"/>
</xsl:for-each>
</xsl:for-each>
 </xsl:template>

</xsl:stylesheet>


Inside the for-each loop for Task i want to store the previous value of the node(taskEnd)
Please help me :(

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

You can't update a global variable in the way you are describing. I don't however see a Task for-each loop in your code above so can't really tell what you are trying to achieve.

If you show us what you are trying to output, and what your input looks like we can probably suggest a way of doing what you are trying to do in an XSLT manner.

/- Sam Judson : Wrox Technical Editor -/
 
Old July 23rd, 2008, 05:23 AM
Authorized User
 
Join Date: Jul 2008
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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

I'm sorry, I don't have time to read all of that. Try distilling what you are trying to output to a few lines - this will often help you as much as it helps us.

/- Sam Judson : Wrox Technical Editor -/





Similar Threads
Thread Thread Starter Forum Replies Last Post
Compare current value with previous parent node ratjetoes XSLT 2 July 17th, 2008 06:15 AM
The reference node is not a child of this node.XSL XMLUser XSLT 2 February 25th, 2008 05:22 AM
how to append child node after an node in XML + C# vishnu108mishra XML 5 November 13th, 2007 05:30 AM
Copying Source Node attributes to output node pvsat XSLT 2 November 3rd, 2005 09:46 AM
How do I get Data from the previous node? runeteacher XSLT 5 October 13th, 2004 03:55 AM





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