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: "Mtekel" <thx@xxxxxxxxx>
Date: Sun, 10 May 2009 21:43:10 +0200
OK, so I have:

<xsl:variable name="DocRefINFO" select="( 'Project Name', 'Project ID', 'Sub
Project ID', 'tester' )"/>

<xsl:variable name="Lst" >
	<xsl:for-each select="$root/html:tbody/html:tr[position()>1]">
	<xsl:sequence
select="string(normalize-space(current()/html:td[1]/uci:par))" />
	</xsl:for-each>
</xsl:variable>

then

<xsl:copy-of select="$DocRefINFO[not(.=$Lst)]"/>

returns whole $DocRefINFO

...when I debug, I have noticed Lst is sequence of Text types, whereas
DocRefINFO is sequence of string types;

I was trying to declare <xsl:variable name="Lst" as="xs:string"> but I get
error:

XTTE0570: Error in XPath 2.0 expression
Type error, value does not match a required type as specified by the
matching rules in 2.5.4 SequenceType Matching. - 'xs:string'

Which I guess is due to even though Lst would be declared as sequence of
strings, the way I assign values to it would make it rather a sequence of
Texts, which are incompatible to Strings?

m.


-----Original Message-----
From: Michael Kay [mailto:mike@xxxxxxxxxxxx]
Sent: 10. maja 2009 20:48
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE: [xsl] how to do set operations (intersection, unify, relative
compelent) on sequences (or any other possible structure); runtime dynamical
structures?


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