title: Query Sparql in Drupal
body: <p>In my website I have articles filled with rdf attributes.
  I Can't figure out what's the Sparql query to simply retrieve all the titles of the articles which author is admin.</p>
  
  <p><img src="https://i.stack.imgur.com/EFFcY.jpg" alt="enter image description here"></p>
  
  <p>I retrieved all the user names by:</p>
  
  <pre><code>PREFIX foaf:  &lt;http://xmlns.com/foaf/0.1/&gt;
  SELECT ?name
  WHERE {
      ?person foaf:name ?name .
  }
  </code></pre>
  
  <p>Then I try:</p>
  
  <pre><code>PREFIX dc:    &lt;http://purl.org/dc/elements/1.1/&gt;
  PREFIX foaf:  &lt;http://xmlns.com/foaf/0.1/&gt;
  SELECT ?dc:title
  WHERE {
      ?person sioc:has_creator 1 .
  }
  LIMIT 5
  </code></pre>
  
  <p>But the result is: </p>
  
  <pre><code>Could not properly handle &amp;quot;PREFIX foaf:  &amp;lt;http://xmlns.co&amp;quot; in ARC2_SPARQLPlusParser
  </code></pre>
  
  <p>if I remove foaf which is not used I get:</p>
  
  <pre><code>Could not properly handle &amp;quot;SELECT ?dc:title  WHERE {     &amp;quot; in ARC2_SPARQLPlusParser.
  </code></pre>
  
  <h2>UPDATE 01</h2>
  
  <p>Sample of data output from the query:</p>
  
  <pre><code>select ?s ?p ?o where { ?s ?p ?o } limit 300
  </code></pre>
  
  <p>Result:</p>
  
  <pre><code>[...]
  {
      "s": {
        "type": "uri",
        "value": "http://drupal.test/users/admin"
      },
  
      "p": {
        "type": "uri",
        "value": "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"
      },
  
      "o": {
        "type": "uri",
        "value": "http://rdfs.org/sioc/ns#UserAccount"
      }
    },
    {
      "s": {
        "type": "uri",
        "value": "http://drupal.test/users/admin"
      },
  
      "p": {
        "type": "uri",
        "value": "http://xmlns.com/foaf/0.1/name"
      },
  
      "o": {
        "type": "literal",
        "value": "admin"
      }
    },
  [...]
    {
      "s": {
        "type": "uri",
        "value": "http://drupal.test/content/consectetuer-dignissim-luptatum-tego"
      },
  
      "p": {
        "type": "uri",
        "value": "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"
      },
  
      "o": {
        "type": "uri",
        "value": "http://xmlns.com/foaf/0.1/Document"
      }
    },
    {
      "s": {
        "type": "uri",
        "value": "http://drupal.test/content/consectetuer-dignissim-luptatum-tego"
      },
  
      "p": {
        "type": "uri",
        "value": "http://purl.org/rss/1.0/modules/content/encoded"
      },
  
      "o": {
        "type": "literal",
        "value": "&lt;p&gt;Dignissim luptatum neo te. Damnum decet pala proprius quadrum sagaciter vel. Defui erat qui. Distineo esca macto nisl probo. Humo illum luctus nimis singularis sino sit valde wisi. Consequat eum iaceo paratus velit. Bene dolus esca eu fere mauris pala refero saepius suscipit.&lt;\/p&gt;\n&lt;p&gt;Camur dignissim facilisi genitus huic humo nimis. Ad conventio jumentum pala plaga praemitto premo quibus rusticus. Huic ibidem iriure macto nimis vel. Cui esca euismod sagaciter. Bene eros feugiat genitus jugis pagus quidem sudo valde vicis.&lt;\/p&gt;\n&lt;p&gt;Esca letalis odio tum. Abigo commodo probo quidne singularis. Eros iriure ullamcorper. Antehabeo aptent erat mauris molior oppeto validus verto wisi.&lt;\/p&gt;\n&lt;p&gt;Adipiscing aptent decet mos nostrud similis ullamcorper. Camur commoveo hendrerit jus odio uxor. Decet ea eum illum iriure natu os proprius ratis. Appellatio comis ibidem. Dolore molior neo pertineo. Autem consectetuer hendrerit patria.&lt;\/p&gt;\n&lt;p&gt;Blandit conventio eum te tego. Illum lobortis paratus wisi. Facilisi quibus singularis ulciscor. Illum in lucidus mos torqueo velit. Appellatio bene caecus hendrerit hos qui velit. Praemitto premo vereor. Acsi nulla ratis. Amet commodo consequat defui luctus vereor verto.&lt;\/p&gt;\n&lt;p&gt;Eligo ibidem illum iusto loquor neque oppeto utrum validus. At commodo eligo facilisi hos.&lt;\/p&gt;\n&lt;p&gt;Fere immitto pecus praemitto sino. Damnum hos jus laoreet letalis suscipere. Hos mauris nibh odio paulatim tation tego usitas.&lt;\/p&gt;\n&lt;p&gt;Abluo exputo iaceo volutpat. Abico duis et minim refoveo saluto validus vereor virtus voco. Ex minim vero. Commodo consequat interdico nobis singularis vel wisi. Ea fere hos quis saepius singularis torqueo virtus vulputate. Aliquip consectetuer defui ea ex quidem sudo usitas.&lt;\/p&gt;\n"
      }
    },
  </code></pre>
  
  <h2>UPDATE 02</h2>
  
  <p>Describe the article:</p>
  
  <pre><code>describe 
  &lt;http://drupal.test/content/consectetuer-dignissim-luptatum-tego&gt;
  </code></pre>
  
  <p>Result:</p>
  
  <pre><code>{
    "http://drupal.test/content/consectetuer-dignissim-luptatum-tego" : {
      "http://www.w3.org/1999/02/22-rdf-syntax-ns#type" : [
        { "value" : "http://xmlns.com/foaf/0.1/Document", "type" : "uri" }
      ],
      "http://purl.org/rss/1.0/modules/content/encoded" : [
        { "value" : "&lt;p&gt;Dignissim luptatum neo te. Damnum decet pala proprius quadrum sagaciter vel. Defui erat qui. Distineo esca macto nisl probo. Humo illum luctus nimis singularis sino sit valde wisi. Consequat eum iaceo paratus velit. Bene dolus esca eu fere mauris pala refero saepius suscipit.&lt;/p&gt;\n", "type" : "literal" }
      ],
      "http://purl.org/dc/terms/title" : [
        { "value" : "Consectetuer Dignissim Luptatum Tego", "type" : "literal" }
      ],
      "http://purl.org/dc/terms/date" : [
        { "value" : "2014-06-11T08:22:09-07:00", "type" : "literal", "datatype" : "xsd:dateTime" }
      ],
      "http://purl.org/dc/terms/created" : [
        { "value" : "2014-06-11T08:22:09-07:00", "type" : "literal", "datatype" : "xsd:dateTime" }
      ],
      "http://purl.org/dc/terms/modified" : [
        { "value" : "2014-06-11T08:22:09-07:00", "type" : "literal", "datatype" : "xsd:dateTime" }
      ]
    } 
  }
  </code></pre>
  
  <p>Give me all triples about an article:</p>
  
  <pre><code>select ?p ?o where { &lt;http://drupal.test/content/consectetuer-dignissim-luptatum-tego&gt; ?p ?o }
  </code></pre>
  
  <p>Result:</p>
  
  <pre><code>{
    "head": {
      "vars": [
        "p",
        "o"
      ]
    },
    "results": {
      "bindings": [
        {
          "p": {
            "type": "uri",
            "value": "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"
          },
  
          "o": {
            "type": "uri",
            "value": "http://xmlns.com/foaf/0.1/Document"
          }
        },
        {
          "p": {
            "type": "uri",
            "value": "http://purl.org/rss/1.0/modules/content/encoded"
          },
  
          "o": {
            "type": "literal",
            "value": "&lt;p&gt;Dignissim luptatum neo te. Damnum decet pala proprius quadrum sagaciter vel. Defui erat qui. Distineo esca macto nisl probo. Humo illum luctus nimis singularis sino sit valde wisi. Consequat eum iaceo paratus velit. Bene dolus esca eu fere mauris pala refero saepius suscipit.&lt;\/p&gt;\n"
          }
        },
        {
          "p": {
            "type": "uri",
            "value": "http://purl.org/dc/terms/title"
          },
  
          "o": {
            "type": "literal",
            "value": "Consectetuer Dignissim Luptatum Tego"
          }
        },
        {
          "p": {
            "type": "uri",
            "value": "http://purl.org/dc/terms/date"
          },
  
          "o": {
            "type": "typed-literal",
            "value": "2014-06-11T08:22:09-07:00",
            "datatype": "xsd:dateTime"
          }
        },
        {
          "p": {
            "type": "uri",
            "value": "http://purl.org/dc/terms/created"
          },
  
          "o": {
            "type": "typed-literal",
            "value": "2014-06-11T08:22:09-07:00",
            "datatype": "xsd:dateTime"
          }
        },
        {
          "p": {
            "type": "uri",
            "value": "http://purl.org/dc/terms/modified"
          },
  
          "o": {
            "type": "typed-literal",
            "value": "2014-06-11T08:22:09-07:00",
            "datatype": "xsd:dateTime"
          }
        }
      ]
    }
  }
  </code></pre>