title: SPARQL Blank node skolemization with incremental Variable
body: <p>I am trying to execute Blank node skolemization on a graph using an incremental variable for the identifier, however, the urn:count object is not being updated.</p>
  <p>I have the following code so far.</p>
  <pre><code>PREFIX :    &lt;http://example.com/&gt;
  PREFIX owl: &lt;http://www.w3.org/2002/07/owl#&gt;
  
  
  ####################
  # Create Counter Graph #
  ####################
  
  INSERT DATA {
      graph &lt;urn:counters&gt; {&lt;urn:Example&gt; &lt;urn:count&gt; 1 }
  }
  ;
  
  
  ####################
  # Rewrite objects #
  ####################
  
  DELETE {
      #remove the old value of the counter
      graph &lt;urn:counters&gt; {&lt;urn:Example&gt; &lt;urn:count&gt; ?old}
    ?s ?p ?bnode .
  }
  INSERT {
      #update the new value of the counter
      graph &lt;urn:counters&gt; {&lt;urn:Example&gt; &lt;urn:count&gt; ?new}
    
    ?s ?p ?iri .
    GRAPH :aliases {
      ?bnode owl:sameAs ?iri .
    }
  }
  WHERE {
    {
      SELECT ?bnode ?iri ?new ?old
      WHERE {
  
        {        
          SELECT DISTINCT ?bnode
          WHERE {
            [] ?p ?bnode .
            FILTER isBlank(?bnode)
          }
        } 
                  # retrieve the counter
      graph &lt;urn:counters&gt; {&lt;urn:Example&gt; &lt;urn:count&gt; ?old}
      
      
      # compute the new value
      bind(?old+1 as ?new)  
      
      
      #construct the IRI
      bind(IRI(concat(&quot;http://example.org/item/&quot;, str(?old))) as ?iri) 
      }
    }
      ?s ?p ?bnode .
  }
  ;
  </code></pre>
  <p>Which produces the following output.</p>
  <pre><code>&lt;#TripleMap1&gt;
          rr:logicalTable        &lt;http://example.org/item/1&gt; ;
          rr:predicateObjectMap  &lt;http://example.org/item/1&gt; ;
          rr:subjectMap          &lt;http://example.org/item/1&gt; .
  </code></pre>
  <p>However I would like the output as follows.</p>
  <pre><code>&lt;#TripleMap1&gt;
          rr:logicalTable        &lt;http://example.org/item/1&gt; ;
          rr:predicateObjectMap  &lt;http://example.org/item/2&gt; ;
          rr:subjectMap          &lt;http://example.org/item/3&gt; .
  </code></pre>
  <p>And the input graph is as follows.</p>
  <pre><code>@prefix rr:    &lt;http://www.w3.org/ns/r2rml#&gt; .
  &lt;#TripleMap1&gt;
          rr:logicalTable        [] ;
          rr:predicateObjectMap  [];
          rr:subjectMap []; 
  </code></pre>
  <p>Any help would be appreciated.</p>