xsl-list
[Top] [All Lists]

Re: grouping probs

2002-09-16 09:09:20

Jeni.. I never realized i have ended myself in a serious situation :)
The reason why i want to generalize is because i have around 100 elements in my source XML , which have to be unique..as i described. so i cant actually go around naming each and every element.so i thot i shud have a generalized way of doing this. Ok.. taking your advice, I want to try the XSLT2 way..as i agree that the two pass method is quite tedious.. I however have got no clue about XSLT2.. How do i start it? what jar files do i need? I am using XALAN right now. and editor is XSelerator.
So if u can lead me towards it, i shall be happy doing that
Thank you very much jeni


From: Jeni Tennison <jeni(_at_)jenitennison(_dot_)com>
Reply-To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
To: "Laura Jenkins" <xsl_list(_at_)hotmail(_dot_)com>
CC: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: Re: [xsl] grouping probs
Date: Mon, 16 Sep 2002 16:43:17 +0100

Hello Laura,

> I do not know what the attribute would be called like in my example
> , for one set , its called 'type', and for the other set, its called
> 'catagory'.. so what i want to do is..
>
> go through each element, and if it has the same attribute value and
> same set of children..( children with same attribute value and same
> set of their children), then eliminate the duplicate.

Hmm... I think that the kind of generic grouping solution for every
possible grouping problem that you describe is likely to be complex,
inefficient and hard to maintain. You would need to create a
stylesheet that checked every previous instance of elements with the
same name and did a deep comparison of their children and attributes.

I think that overall you will find it easier to write, use and
understand code written specifically for the particular duplication
problems that you need to solve. Once you get used to the Muenchian
pattern, I honestly don't think it's that hard to do.

If for some reason you have to create something this general purpose
(for example, if you're writing a stylesheet for displaying any XML
document that it's passed), what I suggest is that you use a two-pass
method, where the first pass over your data (or preferably a schema)
creates a stylesheet that can make a second pass over your data that
will remove the duplicates.

Alternatively, if you're looking for a generic solution because
writing the code for the individual solutions is too tedious, I
suggest that you either use extension/XSLT 2.0 grouping elements (e.g.
saxon:group/xsl2:for-each-group), or that you use a literate
programming approach, where you write a "stylesheet" that contains
elements (which you make up yourself) that describe the duplicate
removal that you want to do, and then write another stylesheet that
transforms that stylesheet into proper XSLT.

I'm sure that we'll all be happy to assist with any of these paths,
but I wanted you to be aware of the range of possible routes you could
take to achieve the duplicate removal that you're after. If you're not
sure which to choose, perhaps you can describe the problem that you're
actually trying to solve and we can advise you on that basis.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list




_________________________________________________________________
Send and receive Hotmail on your mobile device: http://mobile.msn.com


XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>