RE: [xsl] how to do set operations (intersection, unify, relative compelent) on sequences (or any other possible structure); runtime dynamical structures?

Subject: RE: [xsl] how to do set operations (intersection, unify, relative compelent) on sequences (or any other possible structure); runtime dynamical structures?
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Sun, 10 May 2009 19:48:17 +0100
If the two sequences of strings are $s1 and $s2,

$s1[not(. = $s2)]

returns all strings that are in $s1 and not in $s2.

Regards,

Michael Kay
http://www.saxonica.com/
http://twitter.com/michaelhkay  

> -----Original Message-----
> From: Mtekel [mailto:thx@xxxxxxxxx] 
> Sent: 10 May 2009 19:16
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] how to do set operations (intersection, unify, 
> relative compelent) on sequences (or any other possible 
> structure); runtime dynamical structures?
> 
> Hello,
> 
> I have a another question:
> I have one sequence. In runtime I generate another one.
> Now I need a relative complement of the first to the second 
> (all the items that are in 1st sequence, but are not in the second).
> The first sequence for me is tags that I need to generate in 
> the output. The second sequence is tags that I have found 
> data for in input, have processed them and have generated 
> tags to output. The relative complement is then the set of 
> tags of which data I did not encounter while processing 
> input, thus I need to generate them with some default values.
> 
> Is there some good way to do so? Should I be using some other 
> structure instead of sequences? (now I have a sequence of 
> strings that represent XML
> tags)
> 
> Or other way, is it possible to extract items from the 
> sequence in runtime?
> E.g. in a for-each loop? So that in the end that sequence 
> will contain only those tags that I did not find data for. 
> The problem I have now is if I use remove($list,index), then 
> it returns a new list without that item. I cannot change the 
> original list itself, the only thing I can do now to remember 
> this newly generated list is to recursively call the same 
> function again and give it this new list as the parameter. 
> However I see this as very uneffective, since then the 
> function will start the for-each loop again from the first 
> node and go through all the already processed data again...
> 
> The only way I have found to dynamically preserve in-loop 
> generated data is to <xsl:variable>
> 	<xsl:for each>
> 		<xsl:sequence>    <--here I dynamically add data to that
> variable
> 	</for each>
>    </variable>
> 
> Thanks again for any advice,
> 
> Michael

Current Thread