RE: [xsl] processin each element not on a list

Subject: RE: [xsl] processin each element not on a list
From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx>
Date: Sun, 6 Oct 2002 18:02:59 +0100
> Thanks. Basically everyone is saying to use a key. How do
> you approach the problem if you have several sets of choices. 
> Lets say one set of choices is {A,B,C,D} and the other set is 
> {X,Y,Z}. Reformulating the source XML a bit, I would like to 
> process all <item>'s that did not match their respective set 
> of choices:

You can form a composite key:

<xsl:key name="c" match="choice" use="concat(../@id, '/', .)"/>

... select="item[not(key('c', concat(object/@id, '/', object))]"

Michael Kay
Software AG
home: Michael.H.Kay@xxxxxxxxxxxx
work: Michael.Kay@xxxxxxxxxxxxxx 

> <root>
>  <objects>
>   <object id="1">
>    <choices>
>     <choice>A</choice>
>     <choice>B</choice>
>     <choice>C</choice>
>     <choice>D</choice>
>    </choices>
>   </object>
>   <object id="2">
>    <choices>
>     <choice>X</choice>
>     <choice>Y</choice>
>     <choice>Z</choice>
>    </choices>
>   </object>
>  </objects>
>  <items>
>   <item id="1"><object id="1">A</object></item>
>   <item id="2"><object id="1">X</object></item>
>   <item id="3"><object id="2">W</object></item>
>   <item id="4"><object id="1">D</object></item>
>   <item id="5"><object id="2">B</object></item>
>   <item id="6"><object id="2">Y</object></item>
>  </item>
> </root>
> In other words, <item id="2"> should be processed
> because its text value "X" is not among the list
> of choices for <ojbect id="1">. Likewise, <item id="3"> 
> and <item id="5"> should be processed because thier 
> text values "W" and "B" are not among the list
> of allowed choices.
> Is it possible to do this in a generic fashion
> with a *fixed* key definition or do I have to have
> one key for each set of choices? What I am trying
> to do is come up with a key definition and processing
> that would accomodate *any* set of choices that
> might be found in the source XML file. 
> Thanks in advance.
>  XSL-List info and archive:

 XSL-List info and archive:

Current Thread