简体   繁体   中英

Apache Jena - get all resources with property

I'm currently facing a problem and can't seem to find a solution in the net. In my project I have a RDF model with various smartphones, described like this:

<rdf:Description rdf:about="https://lukasgorny.pro/devices#GooglePixelXL2">
    <device-name>Google Pixel XL2</device-name>
    <screen-size>big</screen-size>
    <primary-camera-resolution>13</primary-camera-resolution>
</rdf:Description>

Is there a way I'm able to find all devices in Apache Jena with, fe "screen-size" property set as "big"? Regards, Lukas.

Model m = RDFDataMgr.loadModel("phones.rdf", Lang.RDFXML);
m.listResourcesWithProperty(m.createProperty("screen-size"), m.createLiteral("big"))
        .forEachRemaining(System.out::println);

prints them to console

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM