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

XML Grouping problem

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 but if there are mulitple drawings it will repeat it several times each time with the next drawing number.

e.g.

child parent DrawingNo
x y z
x y z1
x1 y1 z2

to

x y z,z1
x1 y1 z2

merging the two

here is some of the XML to help


- <row idx="1">
<Child>105394</Child>
<Description>Element 1</Description>
<Parent>105388</Parent>
<Drawing>102553</Drawing>
</row>
- <row idx="2">
<Child>105394</Child>
<Description>Element 1</Description>
<Parent>105388</Parent>
<Drawing>102554</Drawing>
</row>
- <row idx="3">
<Child>105379</Child>
<Description>Element 2</Description>
<Parent>105381</Parent>
<Drawing>102554</Drawing>
</row>


I have another xsl file that uses the parent child relationship to create a tree structure (indenture level e.g. 0 is highest level parent, 1 is next child, 2 is 1's child etc) This is why combining the same elements into one is so important otherwise i will have the same element having duplicate records of the same children.
Mar 5 '07 #1
6 1590
dorinbogdan
839 Expert 512MB
For grouping try to use xsl:sort. See this sample, which is part of an easy tutorial.
Mar 5 '07 #2
For grouping try to use xsl:sort. See this sample, which is part of an easy tutorial.

This is not what i am doing. I have two identifiers.

e.g.
child parent DrawingNo
x y z
x y z1
x w z5
d y z2
s f z3

From this the two entries with child x AND parent y are the exact same element except the drawingNo. I need to combine these two

x y z1, z2

and the others need to remain the same

x w z5
d y z2
s f z3

see
x w z5
is a different element because it is related to a different parent, so it not the same and shouldnt be combined with
x y z1,z2

i need to group by child and parent combined

HOW????
Mar 5 '07 #3
dorinbogdan
839 Expert 512MB
One solution could be to concatenate the parent & child, so that it results as a single element, then the grouping is easy.
It would require to build an XSL "concatenator" which will generate the intermediar XML (haing the parent&child element), and finally build the main XSL to be applied on the intermediar XML.
Mar 6 '07 #4
i found the solution and wasn't as complicated as that.

The output from the previous program was sorted by part then parent. This could be done the same way in xslt by using sort.

The next step was to use the preceding-sibling to locate the previous row
preceding-sibling::row[position() = 1]/Part
and
preceding-sibling::row[position() = 1]/Parent
to access the previous rows part and parent respectively.

It was then a simple matter of testing if the previous row to see if had the same parent and part and if so only concatenate the drawing.
Mar 9 '07 #5
dorinbogdan
839 Expert 512MB
Good finding.
I'm glad to hear that you solved it.
Thanks for information...
God bless you.
Mar 9 '07 #6
dorinbogdan
839 Expert 512MB
Since the problem was solved I will close the thread.
Mar 21 '07 #7

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

Similar topics

2
by: Debbie Davis | last post by:
Hi there, SQL 2000 I have the following query: SELECT sponsor, COUNT(sponsor) * 2 AS total FROM Referrals GROUP BY sponsor Works great, returns the sponsor and the total * 2 of their...
5
by: Jody Greening | last post by:
Transforming with XSLT, Grouping elements until difference found. I am seeking some help with the following problem, I am fairly new at XSLT transformations, and my problem may lie in looking at...
2
by: Andreas Håkansson | last post by:
Seeing how my previous post seem to have fallen between the cracks, I thought I would have a second, more direct, go at it. So my question is "Is it possible to group (Muenchian method) over...
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...
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...
0
by: virendra | last post by:
hi, I am working on crystal report 9 in asp.net. I created multilevel dynamic grouping in CR. if page is load firsttime. and i am giving firstlevel of grouping or whatever it's working fine. but...
0
by: Corey | last post by:
hello, I’m trying to run a query and I’m getting error messages Can anyone help me get though this problem? 1: Tried this and got this error message ORA-00923 , decode...
4
by: Chris | last post by:
I tried to retrieve the digit grouping symbol in MSAccess but unfortunately 3;0 is retrieved instead of comma which is my symbol. Function retrieves decimal symbol and list separator without any...
6
patjones
by: patjones | last post by:
Good afternoon: This seems like it shouldn't be hard, and then again this is how so many problems seem at the outset. My situation is this: I have a report called rptMain319, which is based...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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: 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
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.