title: SPARQL: query for a complete list
body: <p>I have such a query:   </p>
  
  <pre><code> CONSTRUCT {
      ?p a :IndContainer .
      ?p :contains ?ind .
  } WHERE{
      :ClassContainer_1  :contains ?class .
      ?ind a ?class .
      BIND (IRI(...) AS ?p) .
  }
  </code></pre>
  
  <p>An individual <code>ClassContainer_1</code> relates to some classes. I get this classes and try to find individuals for these classes. Then I try to create an <code>IndContainer</code> that should store found individuals (dots are used only for simplification). So, I want to:</p>
  
  <ol>
  <li>Create individual of <code>IndContainer</code> only when individuals for all bindings of <code>?class</code> have been found;</li>
  <li>Create individuals of <code>IndContainer</code> for all possible sets of individuals from <code>?ind</code> (i.e. when some of <code>?class</code> has a nuber of individuals).</li>
  </ol>
  
  <p>Is it possible to create such a SPARQL query? Or it is necessary to use some rule engine?</p>
  
  <p>EDIT (add illustration):
  Positive example. Have:</p>
  
  <pre><code>test:ClassContainer_1
    rdf:type test:ClassContainer ;
    test:contains test:Type1 ;
    test:contains test:Type2 ;
  .
  test:Type1_1
    rdf:type test:Type1 ;
  .
  test:Type1_2
    rdf:type test:Type1 ;
  .
  test:Type2_1
    rdf:type test:Type2 ;
  .
  </code></pre>
  
  <p>Want to receive:</p>
  
  <pre><code>test:IndContainer_1
    rdf:type test:IndContainer ;
    test:contains test:Type1_1 ;
    test:contains test:Type2_1 ;
  .
  test:IndContainer_2
    rdf:type test:IndContainer ;
    test:contains test:Type1_2 ;
    test:contains test:Type2_1 ;
  .
  </code></pre>
  
  <p>Negative example: the same as positive except that there is no individuals of class <code>Type2</code> and so no individuals of <code>IndContainer</code> should be generated.</p>
  
  <p>EDIT 2 (problem essence):
  We may look at this problem from the perspective of combination composing. We have two positions (in my example) in each combination. The number of positions is determined by the number of classes each <code>ClassContainer</code> depends on. Each position must be filled in with one individual of a class that correspond to that position. So in my example first position must be filled with one individual of <code>Type1</code> class, the second - with <code>Type2</code> class (but the order does not matter). We have two individuals for the first class and one individual for the second class. To get the number of combinations we may use the rule of product from combinatorics - 2*1 = 2, i.e. {Type1_1,Type2_1} - is the first combination and {Type1_2,Type2_1} - is the second combination. For each combination it is necessary to generate <code>IndContainer</code> individual.</p>