[xslt] cartesian product of lists



I'm trying to create the cartesian product of lists / list-elements with XSLT:

 <colors name="list1">
   <alternative name="redish"><color name="red"/></alternative>
   <alternative name="greenish"><color name="green1"/></alternative>
 </colors>

 <colors name="list2">
   <alternative name="blueish"><color name="blue1"/></alternative>
   <alternative name="dark"><color name="black"/><color name="grey"/></alternative>
 </colors>

 <palette name="palette1">
   <color-alternatives name="list1"/>
   <color-alternatives name="list2"/>
   <color name="white"/>
 </palette>

should be transformed to

<palette name="palette1_list1_redish_list2_blueish">
<color name="red"/><color name="blue1"><color name="white"/>
</palette>
..
<palette name="palette1_list1_greenish_list2_dark">
<color name="green1"/><color name="black"><color name="grey"><color name="white"/>
</palette>

The idea is to to resolve this is to copy a node "palette", add an element from the first list, add the other lists and colors and apply the resolver recursively. The generated tree (one resolved list) looks good in debug output:

<palette name="palette1_list1_redish">
 <color name="white"/>
 <color name="red"/>
 <color-alternatives name="list2"/>
</palette>

But the resolver can't access its attribute "name" or find the "color-alternatives" (these are descendant but no children).

Did this occur before to anyone? Can I post more code?

Thanks,
Boris


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]