RE: [xsl] How to test if a value itn't in a nodeset

Subject: RE: [xsl] How to test if a value itn't in a nodeset
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Thu, 7 Apr 2005 16:28:42 +0100
<xsl:apply-templates select="current_values/ROW[COB =
//valid_combination[CAD = 'a']/COB] | current_values/ROW[COB !=
//valid_combination/COB]" />

But it didn't work. I interpret that union as:
"show elements of 'current_values' where their COB is present in
'valid_combination' under CAD = 'a' category (to include 'b' and 'c'), plus
the elements where COB isn't in 'valid_combination' (to include only 'e' and
'f', not 'c')."


Your interpretation is wrong.

S1 != S2 is true if there is a pair of nodes from S1, S2 that are not-equal.

To test whether there is no pair that are equal, use not(S1 = S2).

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

 

> -----Original Message-----
> From: Jaime Stuardo [mailto:jstuardo@xxxxxxxxxxx] 
> Sent: 07 April 2005 15:31
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] How to test if a value itn't in a nodeset
> 
> 
> Hi all...
> 
> If I have this xml
> 
> <doc>
>   <valid_combination>
>     <ROW>
>       <CAD>a</CAD>
>       <COB>b</COB>
>     </ROW>
>     <ROW>
>       <CAD>a</CAD>
>       <COB>c</COB>
>     </ROW>
>     <ROW>
>       <CAD>b</CAD>
>       <COB>d</COB>
>     </ROW>
>   </valid_combination>
>   <current_values>
>     <ROW>
>       <COB>b</COB>
> 	<DESC>d1</DESC>
>     </ROW>
>     <ROW>
>       <COB>e</COB>
> 	<DESC>d2</DESC>
>     </ROW>
>     <ROW>
>       <COB>f</COB>
> 	<DESC>d3</DESC>
>     </ROW>
>     <ROW>
>       <COB>c</COB>
> 	<DESC>d4</DESC>
>     </ROW>
>     <ROW>
>       <COB>d</COB>
> 	<DESC>d5</DESC>
>     </ROW>
>   </current_values>
> </doc>
> 
> where CAD field is used to group mutually exclusive elements 
> of current_value set, for instance, that means that I have to 
> show 2 listings of elements of the current_values group. The 
> first listing has to show these COB's: b, e, f, c ("d" is 
> missing because "d" is mutually exclusive with "b" and "c" 
> according to valid_combination configuration). The second 
> listing has to show these COB's: e, f, d.
> 
> If I use this XSLT:
> 
> <xsl:apply-templates select="current_values/ROW[COB = 
> //valid_combination[CAD = 'a']/COB]" />
> <xsl:apply-templates select="current_values/ROW[COB = 
> //valid_combination[CAD = 'b']/COB]" />
> 
> It show:s
> 1 list.- "b" and "c"
> 2 list.- "d"
> 
> But I need to do the union with the other elements, not 
> present in valid_combination group. I tried, for example for 
> the first listing:
> 
> <xsl:apply-templates select="current_values/ROW[COB = 
> //valid_combination[CAD = 'a']/COB] | current_values/ROW[COB 
> != //valid_combination/COB]" />
> 
> But it didn't work. I interpret that union as:
> "show elements of 'current_values' where their COB is present 
> in 'valid_combination' under CAD = 'a' category (to include 
> 'b' and 'c'), plus the elements where COB isn't in 
> 'valid_combination' (to include only 'e' and 'f', not 'c')."
> 
> That is the simplified scenario what I'm trying to achieve.
> 
> Any help would be greatly appreciated.
> 
> Thanks in advance
> Jaime

Current Thread