Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 413443
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T18:11:05+00:00 2026-05-12T18:11:05+00:00

I am trying to write a SPARQL query which should give me all foaf:Agents

  • 0

I am trying to write a SPARQL query which should give me all foaf:Agents which aren’t foaf:Persons.

I can’t see a way to apply this OPTIONAL/BOUND construct to this problem, because all the properties like rdfs:subClassOf and rdf:type are transitive and reflexive.

I tried this:

SELECT * WHERE { 
?x rdf:type foaf:Agent 
OPTIONAL { ?y rdf:type foaf:Person } 
FILTER ( !BOUND(?y) ) }

But rdf:type seems to be transitive, at least with JENA/ARQ/SDB.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T18:11:05+00:00Added an answer on May 12, 2026 at 6:11 pm

    The reason this isn’t working is because you have two separate variable bindings (?x and ?y) which are unrelated in your query. So ?x must be bound to appear in the result set (which is what you want), but if ?y is unbound, you have not learned anything new about ?x.

    Update: In an ideal query, there would be no need for ?y at all; you could test the incoming/outgoing edegs of ?x directly. This is difficult (impossible?) to do in SPARQL 1.0 when you want to check if an edge does not exist on a given variable binding. However, SPARQL 1.1 will provide support for negation:

    PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> 
    PREFIX foaf: <http://xmlns.com/foaf/0.1/> 
    
    SELECT ?agent
    WHERE 
    {
        ?agent rdf:type foaf:Agent .
        FILTER NOT EXISTS { ?agent rdf:type foaf:Person . }
    }
    

    @Kingsley Idehen’s approach (using third-party SPARQL extensions) should help you solve the problem in the short run.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying write a query to find records which don't have a matching record
im trying to write a script , that can rewrites urls in slug way
Trying to write a function to see how often an object exists and give
I'm trying to write a blog post which includes a code segment inside a
Im trying to write a recursive function which returns the factorial of a number.
Im trying to write a batch file which scans several files and looks for
Trying to write a regex that can parse a full name and split it
Trying to write a byte[] to a file, which i think is working correctly
I've been trying write an application which will be able to connect to a
I've had problem when trying write a function which has a default value when

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.