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

Grouping, Relating or is it Merging Data ?

Help! This is probably easy but I just don't get it. I am trying to
relate and merge 2 datasets. My XML file has 2 datasets (1st level
nodes) TimeDetail and TimeSummary. The report is supposed to show the
TimeDetail rows then the TimeSummary row. Like this:
Task1 9:20 9:30 0:10 <-- from TimeDetail
Task2 9:30 10:00 0:30
TOTAL 0:40 <-- from TimeSummary

(The reason I am using 2 datasets is because I figured it was easier
doing the minutes to time conversion in .net but I could review that)

So the question is: How do I merge the 2 datasets? i.e. how do I
relate the data in TimeDetail to the data in TimeSummary? I have
things like
<xsl:for-each select = "/DS/TimeSummary">
<xsl:for-each select = "/DS/TimeDetail[Date=/DS/SummaryData/Date]">
... output the task, times etc
</xsl:for-each>
... output the TOTAL
</xsl:for-each>

So the filter [Date=/DS/SummaryData/Date] is not working as I want it
because it is not filtering... but I hope you can see the intention!
Jul 20 '05 #1
6 1765
So what is the contents of the two xml files?

=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL
"Jon Bosker" <Go*******@VisualBasic.net> wrote in message
news:b1**************************@posting.google.c om...
Help! This is probably easy but I just don't get it. I am trying to
relate and merge 2 datasets. My XML file has 2 datasets (1st level
nodes) TimeDetail and TimeSummary. The report is supposed to show the
TimeDetail rows then the TimeSummary row. Like this:
Task1 9:20 9:30 0:10 <-- from TimeDetail
Task2 9:30 10:00 0:30
TOTAL 0:40 <-- from TimeSummary

(The reason I am using 2 datasets is because I figured it was easier
doing the minutes to time conversion in .net but I could review that)

So the question is: How do I merge the 2 datasets? i.e. how do I
relate the data in TimeDetail to the data in TimeSummary? I have
things like
<xsl:for-each select = "/DS/TimeSummary">
<xsl:for-each select = "/DS/TimeDetail[Date=/DS/SummaryData/Date]">
... output the task, times etc
</xsl:for-each>
... output the TOTAL
</xsl:for-each>

So the filter [Date=/DS/SummaryData/Date] is not working as I want it
because it is not filtering... but I hope you can see the intention!

Jul 20 '05 #2
Here is a cut down version:

<?xml version="1.0" standalone="yes"?>
<NewDataSet>

<timeDataDetails>
<Date>8/08/2003</Date>
<Minutes>34</Minutes>
</timeDataDetails>
<timeDataDetails>
<Date>8/08/2003</Date>
<Minutes>28</Minutes>
</timeDataDetails>
<timeDataDetails>
<Date>9/08/2003</Date>
<Minutes>7</Minutes>
</timeDataDetails>

<summaryData>
<Date>8/08/2003</Date>
<TotalMinutes>1:01</TotalMinutes>
</summaryData>
<summaryData>
<Date>9/08/2003</Date>
<TotalMinutes>0:07</TotalMinutes>
</summaryData>

</NewDataSet>

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #3
I don't see:
Task1 9:20 9:30 0:10 <-- from TimeDetail
Task2 9:30 10:00 0:30
any such data in your source xml...

Based on the source.xml you provided, what transformation do you want to be
performed and what exactly should the output be?
=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL
"Jon Bosker" <de***********@visualbasic.net> wrote in message
news:3f***********************@news.frii.net... Here is a cut down version:

<?xml version="1.0" standalone="yes"?>
<NewDataSet>

<timeDataDetails>
<Date>8/08/2003</Date>
<Minutes>34</Minutes>
</timeDataDetails>
<timeDataDetails>
<Date>8/08/2003</Date>
<Minutes>28</Minutes>
</timeDataDetails>
<timeDataDetails>
<Date>9/08/2003</Date>
<Minutes>7</Minutes>
</timeDataDetails>

<summaryData>
<Date>8/08/2003</Date>
<TotalMinutes>1:01</TotalMinutes>
</summaryData>
<summaryData>
<Date>9/08/2003</Date>
<TotalMinutes>0:07</TotalMinutes>
</summaryData>

</NewDataSet>

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Jul 20 '05 #4
Sorry about that - the first posting I was explaining the concept but in
the second I cut it down to the essential data. Of course there are
tags for the start and end times but I felt that they were not relevant
here as I am only having problems with the grouping/summing aspect.

Based on the source I have sent I want the output to be:

Date Minutes
--------- --------
8/08/2003 34
8/08/2003 28
Total 1:02

9/8/2003 7
Total 0:07

Thanks for being so patient with me :)

Regards, Jon

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #5
This is straightforward:

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="text"/>

<xsl:template match="/">
<xsl:value-of select="'Date Minutes&#xA;---- -------'"/>
<xsl:apply-templates select="*/summaryData"/>
</xsl:template>

<xsl:template match="summaryData">
<xsl:apply-templates select="../timeDataDetails[Date =
current()/Date]"/>
<xsl:value-of select="concat('&#xA;','Total ', TotalMinutes,
'&#xA;')"/>
</xsl:template>

<xsl:template match="timeDataDetails">
<xsl:value-of select="concat('&#xA;', Date, ' ', Minutes)"/>
</xsl:template>
</xsl:stylesheet>

When this transformation is applied on your source.xml:

<NewDataSet>
<timeDataDetails>
<Date>8/08/2003</Date>
<Minutes>34</Minutes>
</timeDataDetails>
<timeDataDetails>
<Date>8/08/2003</Date>
<Minutes>28</Minutes>
</timeDataDetails>
<timeDataDetails>
<Date>9/08/2003</Date>
<Minutes>7</Minutes>
</timeDataDetails>
<summaryData>
<Date>8/08/2003</Date>
<TotalMinutes>1:01</TotalMinutes>
</summaryData>
<summaryData>
<Date>9/08/2003</Date>
<TotalMinutes>0:07</TotalMinutes>
</summaryData>
</NewDataSet>

the wanted result is produced:

Date Minutes
---- -------
8/08/2003 34
8/08/2003 28
Total 1:01

9/08/2003 7
Total 0:07

=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL

"Jon Bosker" <de***********@visualbasic.net> wrote in message
news:3f***********************@news.frii.net...
Sorry about that - the first posting I was explaining the concept but in
the second I cut it down to the essential data. Of course there are
tags for the start and end times but I felt that they were not relevant
here as I am only having problems with the grouping/summing aspect.

Based on the source I have sent I want the output to be:

Date Minutes
--------- --------
8/08/2003 34
8/08/2003 28
Total 1:02

9/8/2003 7
Total 0:07

Thanks for being so patient with me :)

Regards, Jon

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Jul 20 '05 #6
Many thanks Dimitre - that worked a treat! :)
Regards, Jon

PS my final XSL looks something like this:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<table>
<tr>
<th>Date</th>
<th>Project</th>
<th>Task</th>
<th>Start Time</th>
<th>End Time</th>
<th>Hours</th>
</tr>
<xsl:for-each select="/NewDataSet/SummaryData">
<xsl:for-each select="/NewDataSet/timeDataDetails[Date = current()/Date]">
<tr>
<td><xsl:value-of select="Date"/></td>
<td><xsl:value-of select="Project"/></td>
<td><xsl:value-of select="Task"/></td>
<td><xsl:value-of select="StartTime"/></td>
<td><xsl:value-of select="EndTime"/></td>
<td><xsl:value-of select="Time"/></td>
</tr>
</xsl:for-each>
<tr>
<td><xsl:value-of select="Date"/></td>
<td>=== </td>
<td></td>
<td></td>
<td>Total</td>
<td><xsl:value-of select="TotalTime"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Jul 20 '05 #7

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

Similar topics

1
by: amber | last post by:
Hello, I have a report in VB.NET/Crystal Reports. I have a criteria form that users select between 2 different types of grouping (group by category or group by year). Can I programmatically...
2
by: Klatuu | last post by:
Whew, I've struggled my way through figuring out how to use XML to transport data..now I can imagine what having a baby is like :) But, I'm stuck now. I generate the XML (single table, no...
3
by: Patrick | last post by:
I have got 2 XML documents, both of which conform to the same XSD Schema, which define possible optional elements. The 2 XML documents contain 2 disjoint set of XML elements. What is the best,...
1
by: Brian Coy | last post by:
I am creating a database to track scrap on a daily basis at my plant. I have to provide a weekly scrap report with the amount of each part scrapped per day. I have the basic database set up, and...
2
by: Emmett Power | last post by:
Hi, I have an Access table with a number of records which refer to the same person but with data in different fields. So for example the table would look like this: Name..............Field...
3
by: ahaque38 | last post by:
Hello. Using A2K SP3, I am having the following problem with a report using "Sorting and Grouping". I have recently added a grouping in the reports for "Category2<>'CONTRACTS'". I have...
8
by: Mike MacSween | last post by:
tblCourses one to many to tblEvents. A course may have an intro workshop (a type of event), a mid course workshop, a final exam. Or any combination. Or something different in the future. At...
1
by: svdh | last post by:
I have posed a question last saturday and have advanced alot in the meantime. But I am still not there Problem is that I try to merging various fields from various tables in one document in Word...
6
by: jkoufala | last post by:
Hi I am new to XSLT and i have a problem with grouping. What im trying to do is group using two elements as a unique identifier. This is output from another program which outputs the same element...
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
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
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
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
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,...

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.