如何在RDF类的所有实例上选择all?

时间:2017-06-16 23:01:18

标签: sparql rdf semantic-web

我正在尝试在朋友的数据集上执行选择所有查询。我对他的RDF数据集的设计有些担忧,因为每个客户端的URI都不同。在这种情况下,如何选择所有查询?这是我第一次使用RDF,所以也许我猜错了。

以下是数据:

<rdf:RDF
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:owl="http://www.w3.org/2002/07/owl#"
    xmlns:ontoex="http://www.semanticweb.org/home/ontologies/2016/10/ex#"
    xmlns:ex="http://example.com/"
    xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema#">
  <ontoex:DataRecipient rdf:about="http://www.semanticweb.org/home/ontologies/2016/10/ex#unrelated">
    <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
  </ontoex:DataRecipient>
  <ex:Client rdf:about="http://www.semanticweb.org/home/ontologies/2016/10/ex#ergergghbjk,">
    <ex:hasBdDate>
      <ex:BdDate rdf:about="http://www.semanticweb.org/home/ontologies/2016/10/ex#ergergghbjk,BdDate">
        <ex:hasValue>31/12/2011</ex:hasValue>
        <ex:hasRetention rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#no-retention"/>
        <ex:hasRecipient rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#ours"/>
        <ex:hasPurpose rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#current"/>
      </ex:BdDate>
    </ex:hasBdDate>
    <ex:hasAge>
      <ex:Age rdf:about="http://www.semanticweb.org/home/ontologies/2016/10/ex#ergergghbjk,Age">
        <ex:hasValue>4</ex:hasValue>
        <ex:hasRetention rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#no-retention"/>
        <ex:hasRecipient rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#ours"/>
        <ex:hasPurpose rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#current"/>
      </ex:Age>
    </ex:hasAge>
    <ex:hasAdress>
      <ex:Adress rdf:about="http://www.semanticweb.org/home/ontologies/2016/10/ex#ergergghbjk,Adress">
        <ex:hasValue>ergdrg</ex:hasValue>
        <ex:hasRetention rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#no-retention"/>
        <ex:hasRecipient rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#ours"/>
        <ex:hasPurpose rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#current"/>
      </ex:Adress>
    </ex:hasAdress>
    <ex:hasIdentityCard>
      <ex:IdentityCard rdf:about="http://www.semanticweb.org/home/ontologies/2016/10/ex#ergergghbjk,IdentityCard">
        <ex:hasNumber>
          <ex:IdentityCardNumber rdf:about="http://www.semanticweb.org/home/ontologies/2016/10/ex#ergergghbjk,IdentityCardNumber">
            <ex:hasValue>10521</ex:hasValue>
            <ex:hasRetention rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#no-retention"/>
            <ex:hasRecipient rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#ours"/>
            <ex:hasPurpose rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#current"/>
          </ex:IdentityCardNumber>
        </ex:hasNumber>
        <ex:hasExpirationDate>
          <ex:IdentityCardExpirationDate rdf:about="http://www.semanticweb.org/home/ontologies/2016/10/ex#ergergghbjk,IdentityCardExpirationDate">
            <ex:hasValue>14/12/2018</ex:hasValue>
            <ex:hasRetention rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#no-retention"/>
            <ex:hasRecipient rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#ours"/>
            <ex:hasPurpose rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#current"/>
          </ex:IdentityCardExpirationDate>
        </ex:hasExpirationDate>
        <ex:hasDeliveryDate>
          <ex:IdentityCardDeliveryDate rdf:about="http://www.semanticweb.org/home/ontologies/2016/10/ex#ergergghbjk,IdentityCardDeliveryDate">
            <ex:hasValue>12/12/2014</ex:hasValue>
            <ex:hasRetention rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#no-retention"/>
            <ex:hasRecipient rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#ours"/>
            <ex:hasPurpose rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#current"/>
          </ex:IdentityCardDeliveryDate>
        </ex:hasDeliveryDate>
      </ex:IdentityCard>
    </ex:hasIdentityCard>
    <ex:hasPassPort>
      <ex:PassPort rdf:about="http://www.semanticweb.org/home/ontologies/2016/10/ex#ergergghbjk,PassPort">
        <ex:hasNumber>
          <ex:PassPortNumber rdf:about="http://www.semanticweb.org/home/ontologies/2016/10/ex#ergergghbjk,PassPortNumber">
            <ex:hasValue></ex:hasValue>
            <ex:hasRetention rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#no-retention"/>
            <ex:hasRecipient rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#ours"/>
            <ex:hasPurpose rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#current"/>
          </ex:PassPortNumber>
        </ex:hasNumber>
        <ex:hasExpirationDate>
          <ex:PassPortExpirationDate rdf:about="http://www.semanticweb.org/home/ontologies/2016/10/ex#ergergghbjk,PassPortExpirationDate">
            <ex:hasValue></ex:hasValue>
            <ex:hasRetention rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#no-retention"/>
            <ex:hasRecipient rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#ours"/>
            <ex:hasPurpose rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#current"/>
          </ex:PassPortExpirationDate>
        </ex:hasExpirationDate>
        <ex:hasDeliveryDate>
          <ex:PassPortDeliveryDate rdf:about="http://www.semanticweb.org/home/ontologies/2016/10/ex#ergergghbjk,PassPortDeliveryDate">
            <ex:hasValue></ex:hasValue>
            <ex:hasRetention rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#no-retention"/>
            <ex:hasRecipient rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#ours"/>
            <ex:hasPurpose rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#current"/>
          </ex:PassPortDeliveryDate>
        </ex:hasDeliveryDate>
      </ex:PassPort>
    </ex:hasPassPort>
    <ex:hasService>
      <ontoex:LandTransportationService rdf:about="http://www.semanticweb.org/home/ontologies/2016/10/ex#BuyBusTicket">
        <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
      </ontoex:LandTransportationService>
    </ex:hasService>
  </ex:Client>
  <ex:Client rdf:about="http://www.semanticweb.org/home/ontologies/2016/10/ex#Taleb">
    <ex:hasPassPort>
      <ex:PassPort rdf:about="http://www.semanticweb.org/home/ontologies/2016/10/ex#TalebPassPort">
        <ex:hasDeliveryDate>
          <ex:PassPortDeliveryDate rdf:about="http://www.semanticweb.org/home/ontologies/2016/10/ex#TalebPassPortDeliveryDate">
            <ex:hasPurpose rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#current"/>
            <ex:hasRecipient rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#ours"/>
            <ex:hasRetention rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#no-retention"/>
            <ex:hasValue></ex:hasValue>
          </ex:PassPortDeliveryDate>
        </ex:hasDeliveryDate>
        <ex:hasExpirationDate>
          <ex:PassPortExpirationDate rdf:about="http://www.semanticweb.org/home/ontologies/2016/10/ex#TalebPassPortExpirationDate">
            <ex:hasPurpose rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#current"/>
            <ex:hasRecipient rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#ours"/>
            <ex:hasRetention rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#no-retention"/>
            <ex:hasValue></ex:hasValue>
          </ex:PassPortExpirationDate>
        </ex:hasExpirationDate>
        <ex:hasNumber>
          <ex:PassPortNumber rdf:about="http://www.semanticweb.org/home/ontologies/2016/10/ex#TalebPassPortNumber">
            <ex:hasPurpose rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#current"/>
            <ex:hasRecipient rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#ours"/>
            <ex:hasRetention rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#no-retention"/>
            <ex:hasValue></ex:hasValue>
          </ex:PassPortNumber>
        </ex:hasNumber>
      </ex:PassPort>
    </ex:hasPassPort>
    <ex:hasIdentityCard>
      <ex:IdentityCard rdf:about="http://www.semanticweb.org/home/ontologies/2016/10/ex#TalebIdentityCard">
        <ex:hasDeliveryDate>
          <ex:IdentityCardDeliveryDate rdf:about="http://www.semanticweb.org/home/ontologies/2016/10/ex#TalebIdentityCardDeliveryDate">
            <ex:hasPurpose rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#current"/>
            <ex:hasRecipient rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#ours"/>
            <ex:hasRetention rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#no-retention"/>
            <ex:hasValue>20/12/2013</ex:hasValue>
          </ex:IdentityCardDeliveryDate>
        </ex:hasDeliveryDate>
        <ex:hasExpirationDate>
          <ex:IdentityCardExpirationDate rdf:about="http://www.semanticweb.org/home/ontologies/2016/10/ex#TalebIdentityCardExpirationDate">
            <ex:hasPurpose rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#current"/>
            <ex:hasRecipient rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#ours"/>
            <ex:hasRetention rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#no-retention"/>
            <ex:hasValue>18/12/2020</ex:hasValue>
          </ex:IdentityCardExpirationDate>
        </ex:hasExpirationDate>
        <ex:hasNumber>
          <ex:IdentityCardNumber rdf:about="http://www.semanticweb.org/home/ontologies/2016/10/ex#TalebIdentityCardNumber">
            <ex:hasPurpose rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#current"/>
            <ex:hasRecipient rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#ours"/>
            <ex:hasRetention rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#no-retention"/>
            <ex:hasValue>561</ex:hasValue>
          </ex:IdentityCardNumber>
        </ex:hasNumber>
      </ex:IdentityCard>
    </ex:hasIdentityCard>
    <ex:hasAdress>
      <ex:Adress rdf:about="http://www.semanticweb.org/home/ontologies/2016/10/ex#TalebAdress">
        <ex:hasPurpose rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#current"/>
        <ex:hasRecipient rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#ours"/>
        <ex:hasRetention rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#no-retention"/>
        <ex:hasValue>binjk,l</ex:hasValue>
      </ex:Adress>
    </ex:hasAdress>
    <ex:hasAge>
      <ex:Age rdf:about="http://www.semanticweb.org/home/ontologies/2016/10/ex#TalebAge">
        <ex:hasPurpose rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#current"/>
        <ex:hasRecipient rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#ours"/>
        <ex:hasRetention rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#no-retention"/>
        <ex:hasValue>2</ex:hasValue>
      </ex:Age>
    </ex:hasAge>
    <ex:hasBdDate>
      <ex:BdDate rdf:about="http://www.semanticweb.org/home/ontologies/2016/10/ex#TalebBdDate">
        <ex:hasPurpose rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#current"/>
        <ex:hasRecipient rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#ours"/>
        <ex:hasRetention rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#no-retention"/>
        <ex:hasValue>20/12/2013</ex:hasValue>
      </ex:BdDate>
    </ex:hasBdDate>
  </ex:Client>
  <ontoex:DataPurpose rdf:about="http://www.semanticweb.org/home/ontologies/2016/10/ex#contact">
    <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
  </ontoex:DataPurpose>
  <ex:Client rdf:about="http://www.semanticweb.org/home/ontologies/2016/10/ex#Djamel">
    <ex:hasFirstName>
      <ex:FirstName rdf:about="http://www.semanticweb.org/home/ontologies/2016/10/ex#DjamelFirstName">
        <ex:hasValue>Nom</ex:hasValue>
        <ex:hasRetention rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#no-retention"/>
        <ex:hasRecipient rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#ours"/>
        <ex:hasPurpose rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#current"/>
      </ex:FirstName>
    </ex:hasFirstName>
    <ex:hasLastName>
      <ex:LastName rdf:about="http://www.semanticweb.org/home/ontologies/2016/10/ex#DjamelLastName">
        <ex:hasValue>Prenom</ex:hasValue>
        <ex:hasRetention rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#no-retention"/>
        <ex:hasRecipient rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#ours"/>
        <ex:hasPurpose rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#current"/>
      </ex:LastName>
    </ex:hasLastName>
    <ex:hasIdentityCard>
      <ex:IdentityCard rdf:about="http://www.semanticweb.org/home/ontologies/2016/10/ex#DjamelIdentityCard">
        <ex:hasNumber>
          <ex:IdentityCardNumber rdf:about="http://www.semanticweb.org/home/ontologies/2016/10/ex#DjamelIdentityCardNumber">
            <ex:hasValue>95175364</ex:hasValue>
            <ex:hasRetention rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#no-retention"/>
            <ex:hasRecipient rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#ours"/>
            <ex:hasPurpose rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#current"/>
          </ex:IdentityCardNumber>
        </ex:hasNumber>
        <ex:hasExpirationDate>
          <ex:IdentityCardExpirationDate rdf:about="http://www.semanticweb.org/home/ontologies/2016/10/ex#DjamelIdentityCardExpirationDate">
            <ex:hasValue>11/06/2021</ex:hasValue>
            <ex:hasRetention rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#no-retention"/>
            <ex:hasRecipient rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#ours"/>
            <ex:hasPurpose rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#current"/>
          </ex:IdentityCardExpirationDate>
        </ex:hasExpirationDate>
        <ex:hasDeliveryDate>
          <ex:IdentityCardDeliveryDate rdf:about="http://www.semanticweb.org/home/ontologies/2016/10/ex#DjamelIdentityCardDeliveryDate">
            <ex:hasValue>10/06/2016</ex:hasValue>
            <ex:hasRetention rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#no-retention"/>
            <ex:hasRecipient rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#ours"/>
            <ex:hasPurpose rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#current"/>
          </ex:IdentityCardDeliveryDate>
        </ex:hasDeliveryDate>
      </ex:IdentityCard>
    </ex:hasIdentityCard>
    <ex:hasDriverLicense>
      <ex:DriverLicense rdf:about="http://www.semanticweb.org/home/ontologies/2016/10/ex#DjamelDriverLicense">
        <ex:hasNumber>
          <ex:DriverLicenseNumber rdf:about="http://www.semanticweb.org/home/ontologies/2016/10/ex#DjamelDriverLicenseNumber">
            <ex:hasValue>0123456789</ex:hasValue>
            <ex:hasRetention rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#no-retention"/>
            <ex:hasRecipient rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#ours"/>
            <ex:hasPurpose rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#current"/>
          </ex:DriverLicenseNumber>
        </ex:hasNumber>
        <ex:hasExpirationDate>
          <ex:DriverLicenseExpirationDate rdf:about="http://www.semanticweb.org/home/ontologies/2016/10/ex#DjamelDriverLicenseExpirationDate">
            <ex:hasValue>19/06/2024</ex:hasValue>
            <ex:hasRetention rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#no-retention"/>
            <ex:hasRecipient rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#ours"/>
            <ex:hasPurpose rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#current"/>
          </ex:DriverLicenseExpirationDate>
        </ex:hasExpirationDate>
        <ex:hasDeliveryDate>
          <ex:DriverLicenseDeliveryDate rdf:about="http://www.semanticweb.org/home/ontologies/2016/10/ex#DjamelDriverLicenseDeliveryDate">
            <ex:hasValue>13/06/2014</ex:hasValue>
            <ex:hasRetention rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#no-retention"/>
            <ex:hasRecipient rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#ours"/>
            <ex:hasPurpose rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#current"/>
          </ex:DriverLicenseDeliveryDate>
        </ex:hasDeliveryDate>
      </ex:DriverLicense>
    </ex:hasDriverLicense>
    <ex:hasPassPort>
      <ex:PassPort rdf:about="http://www.semanticweb.org/home/ontologies/2016/10/ex#DjamelPassPort">
        <ex:hasNumber>
          <ex:PassPortNumber rdf:about="http://www.semanticweb.org/home/ontologies/2016/10/ex#DjamelPassPortNumber">
            <ex:hasValue>987654321</ex:hasValue>
            <ex:hasRetention rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#no-retention"/>
            <ex:hasRecipient rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#ours"/>
            <ex:hasPurpose rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#current"/>
          </ex:PassPortNumber>
        </ex:hasNumber>
        <ex:hasExpirationDate>
          <ex:PassPortExpirationDate rdf:about="http://www.semanticweb.org/home/ontologies/2016/10/ex#DjamelPassPortExpirationDate">
            <ex:hasValue>11/06/2026</ex:hasValue>
            <ex:hasRetention rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#no-retention"/>
            <ex:hasRecipient rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#ours"/>
            <ex:hasPurpose rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#current"/>
          </ex:PassPortExpirationDate>
        </ex:hasExpirationDate>
        <ex:hasDeliveryDate>
          <ex:PassPortDeliveryDate rdf:about="http://www.semanticweb.org/home/ontologies/2016/10/ex#DjamelPassPortDeliveryDate">
            <ex:hasValue>25/06/2016</ex:hasValue>
            <ex:hasRetention rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#no-retention"/>
            <ex:hasRecipient rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#ours"/>
            <ex:hasPurpose rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#current"/>
          </ex:PassPortDeliveryDate>
        </ex:hasDeliveryDate>
      </ex:PassPort>
    </ex:hasPassPort>
    <ex:hasAdress>
      <ex:Adress rdf:about="http://www.semanticweb.org/home/ontologies/2016/10/ex#DjamelAdress">
        <ex:hasValue>Mon Adresse</ex:hasValue>
        <ex:hasRetention rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#no-retention"/>
        <ex:hasRecipient rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#ours"/>
        <ex:hasPurpose rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#current"/>
      </ex:Adress>
    </ex:hasAdress>
    <ex:hasCreditCard>
      <ex:CreditCard rdf:about="http://www.semanticweb.org/home/ontologies/2016/10/ex#DjamelCreditCard">
        <ex:hasNumber>
          <rdf:Description rdf:about="http://www.semanticweb.org/home/ontologies/2016/10/ex#DjamelCreditCardNumber">
            <ex:hasValue>123456789</ex:hasValue>
            <ex:hasRetention rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#no-retention"/>
            <ex:hasRecipient rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#ours"/>
            <ex:hasPurpose rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#current"/>
          </rdf:Description>
        </ex:hasNumber>
        <ex:hasCCType>
          <ex:CCType rdf:about="http://www.semanticweb.org/home/ontologies/2016/10/ex#DjamelCCType">
            <ex:hasValue>Visa</ex:hasValue>
            <ex:hasRetention rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#no-retention"/>
            <ex:hasRecipient rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#ours"/>
            <ex:hasPurpose rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#current"/>
          </ex:CCType>
        </ex:hasCCType>
      </ex:CreditCard>
    </ex:hasCreditCard>
    <ex:hasBdDate>
      <ex:BdDate rdf:about="http://www.semanticweb.org/home/ontologies/2016/10/ex#DjamelBdDate">
        <ex:hasValue>19/06/1991</ex:hasValue>
        <ex:hasRetention rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#no-retention"/>
        <ex:hasRecipient rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#ours"/>
        <ex:hasPurpose rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#current"/>
      </ex:BdDate>
    </ex:hasBdDate>
    <ex:hasAge>
      <ex:Age rdf:about="http://www.semanticweb.org/home/ontologies/2016/10/ex#DjamelAge">
        <ex:hasValue>25</ex:hasValue>
        <ex:hasRetention rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#no-retention"/>
        <ex:hasRecipient rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#ours"/>
        <ex:hasPurpose rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#current"/>
      </ex:Age>
    </ex:hasAge>
    <ex:hasService rdf:resource="http://www.semanticweb.org/home/ontologies/2016/10/ex#RentVehicle"/>
  </ex:Client>
</rdf:RDF>

总之,我们有

<ex:Client rdf:about="http://www.semanticweb.org/home/ontologies/2016/10/ex#Taleb"> 
<ex:Client rdf:about="http://www.semanticweb.org/home/ontologies/2016/10/ex#Djamel">

我们希望获得有关Taleb和Djamel的所有数据。除此之外,当有两个以上的客户端时,如何编写类似的查询?

1 个答案:

答案 0 :(得分:3)

分享您的数据真是太棒了。我做了一些编辑,因为它没有完成RDF的发布:

  • 未定义ex:前缀
  • 它没有打开和关闭<rdf:RDF>标签

此外

  • 很多人会发现您的数据更易于以TURTLE格式阅读,而不是您发布的RDF / XML格式
  • 您还应该考虑为所有实体提供人类可读的rdfs:label,例如<http://www.semanticweb.org/home/ontologies/2016/10/ex#Djamel>
  • 我觉得hasValue的{​​{1}}对象DjamelFirstName而不是Nom有点奇怪。这是标签/价值混淆的情况吗?

这是您可以尝试的SO answer listing some training materials

这里是您的数据片段,采用Turtle格式,并带有标签:

Djamel

你问题的最后两行提供了答案的提示:如果你想找到关于RDF同一类(@prefix ex: <http://www.semanticweb.org/home/ontologies/2016/10/ex#> . @prefix owl: <http://www.w3.org/2002/07/owl#> . @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . @prefix xsd: <http://www.w3.org/2001/XMLSchema#> . @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . ex:DjamelFirstName a ex:FirstName ; rdfs:label "Djamel's first name" ; ex:hasPurpose ex:current ; ex:hasRecipient ex:ours ; ex:hasRetention ex:no-retention ; ex:hasValue "Nom" . ex:Djamel a ex:Client ; rdfs:label "Client 'Djamel'" ; ex:hasAdress ex:DjamelAdress ; ex:hasAge ex:DjamelAge ; ex:hasBdDate ex:DjamelBdDate ; ex:hasCreditCard ex:DjamelCreditCard ; ex:hasDriverLicense ex:DjamelDriverLicense ; ex:hasFirstName ex:DjamelFirstName ; ex:hasIdentityCard ex:DjamelIdentityCard ; ex:hasLastName ex:DjamelLastName ; ex:hasPassPort ex:DjamelPassPort ; ex:hasService ex:RentVehicle . )的两个实例的信息,你应该要求该类的所有成员。

ex:Client

查询的<ex:Client rdf:about="http://www.semanticweb.org/home/ontologies/2016/10/ex#Taleb"> <ex:Client rdf:about="http://www.semanticweb.org/home/ontologies/2016/10/ex#Djamel"> 部分来自的地方。

您的数据模型对我来说通常是合理的,但是您必须处理它嵌套的事实。例如,?s a ex:Client与表示其(?)名称的字符串文字没有直接关系。

我编写了一个查询级别的嵌套查询。如果您的数据实际使用更深层次的嵌套,则您需要修改查询。

ex:Djamel

给出

PREFIX  ex:   <http://www.semanticweb.org/home/ontologies/2016/10/ex#>
SELECT  *
WHERE
  { ?s  a    ex:Client .
    ?s  ?p1  ?o1 .
    OPTIONAL
      { ?o1  ?p2  ?o2 } .
  }