I use the following query to find all classes with the parent class PUMP:
PREFIX dm: <http://dm.rdlfacade.org/data#>
PREFIX rdl: <http://rds.posccaesar.org/2008/06/OWL/RDL#>
SELECT
?supclDesig ?supclIdPCA
?subclDesig ?subclDef
?subclIdPCA ?subcl
WHERE
{
?x dm:hasSuperclass ?supcl .
?x dm:hasSubclass ?subcl .
?subcl rdl:hasIdPCA ?subclIdPCA ;
rdl:hasDefinition ?subclDef ;
rdl:hasDesignation ?subclDesig .
?supcl rdl:hasIdPCA ?supclIdPCA ;
rdl:hasDesignation ?supclDesig ;
rdl:hasDesignation "PUMP"
}
LIMIT 2000
Now, I know that I can duplocate the expression above, change PUMP to VALUE and put a UNION between the two expressions to get a list of classes where the parent class is either PUMP or VALVE. However, it just itches all over my body having to duplicate code like that. An alternative way to do it, is this:
PREFIX dm: <http://dm.rdlfacade.org/data#>
PREFIX rdl: <http://rds.posccaesar.org/2008/06/OWL/RDL#>
SELECT
?supclDesig ?supclIdPCA
?subclDesig ?subclDef
?subclIdPCA ?subcl
WHERE
{
?muu dm:hasSuperclass ?supcl .
?muu dm:hasSubclass ?subcl .
?subcl rdl:hasIdPCA ?subclIdPCA ;
rdl:hasDefinition ?subclDef ;
rdl:hasDesignation ?subclDesig .
?supcl rdl:hasIdPCA ?supclIdPCA .
?supcl rdl:hasDesignation ?supclDesig .
FILTER (regex(?supclDesig, "^VALVE$") || regex(?supclDesig, "^PUMP$"))
}
LIMIT 2000
That however have the drawback that a lot more data is gone through and is then filtered according to the regexps, so it is much slower. Isn't there a way to write something like this:
PREFIX dm: <http://dm.rdlfacade.org/data#>
PREFIX rdl: <http://rds.posccaesar.org/2008/06/OWL/RDL#>
SELECT
?supclDesig ?supclIdPCA
?subclDesig ?subclDef
?subclIdPCA ?subcl
WHERE
{
?x dm:hasSuperclass ?supcl .
?x dm:hasSubclass ?subcl .
?subcl rdl:hasIdPCA ?subclIdPCA ;
rdl:hasDefinition ?subclDef ;
rdl:hasDesignation ?subclDesig .
?supcl rdl:hasIdPCA ?supclIdPCA ;
rdl:hasDesignation ?supclDesig ;
rdl:hasDesignation ("PUMP", "VALVE")
}
LIMIT 2000
("PUMP", "VALVE") above is just an example of how it could look like.