我想要做的是从Individual1或类中获取属性列表, 获取“某物”的所有物业 结果应该是这样的(对于Secret_Data):
| Asset_has_Confidentiality_Importance | High |
| Asset_has_Availability_Importance....| Moderate |
| Asset_has_Integrity_Importance.......| Moderate |
| Asset_threatenedBy_ThreatEvent.......| Compromise_sensitive_information |
| Asset_threatenedBy_ThreatEvent.......| Disclosure_of_sensitive_information |
| Asset_threatenedBy_ThreatEvent.......| Exploit_exposed_unauthorized_information |
| Asset_threatenedBy_ThreatEvent.......| Integrity_loss_by_corrupting_critital_data |
<owl:NamedIndividual rdf:about="&securityOntology_ITESM_UC3M;Secret_Data">
<rdf:type rdf:resource="&securityOntology_ITESM_UC3M;Data"/>
<Asset_has_Confidentiality_Importance rdf:datatype="&xsd;string">High</Asset_has_Confidentiality_Importance>
<Asset_has_Availability_Importance rdf:datatype="&xsd;string">Moderate</Asset_has_Availability_Importance>
<Asset_has_Integrity_Importance rdf:datatype="&xsd;string">Moderate</Asset_has_Integrity_Importance>
<Asset_threatenedBy_ThreatEvent rdf:resource="&securityOntology_ITESM_UC3M;Compromise_sensitive_information"/>
<Asset_threatenedBy_ThreatEvent rdf:resource="&securityOntology_ITESM_UC3M;Disclosure_of_sensitive_information"/>
<Asset_threatenedBy_ThreatEvent rdf:resource="&securityOntology_ITESM_UC3M;Exploit_exposed_unauthorized_information"/>
<Asset_threatenedBy_ThreatEvent rdf:resource="&securityOntology_ITESM_UC3M;Integrity_loss_by_corrupting_critital_data"/>
<Asset_threatenedBy_ThreatEvent rdf:resource="&securityOntology_ITESM_UC3M;Obtain_unauthorized_access"/>
</owl:NamedIndividual>
我认为查询是这样的,(但是值没有很好地格式化,并且某些属性不像“type property”那样重要):
PREFIX css:<http://www.semanticweb.org/evalues/ontologies/2014/3/securityOntology_ITESM_UC3M#>
SELECT DISTINCT ?property ?value
WHERE {
css:Secret_Data ?property ?value.
}
答案 0 :(得分:1)
使用完整的示例数据回答问题要容易得多。如果我们将您给出的数据与适当的命名空间声明捆绑在一起,我们最终得到如下内容:
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:owl="http://www.w3.org/2002/07/owl#"
xmlns="http://stackoverflow.com/q/23223447/1281433/">
<owl:NamedIndividual rdf:about="http://stackoverflow.com/q/23223447/1281433/Secret_Data">
<Asset_has_Availability_Importance rdf:datatype="http://www.w3.org/2001/XMLSchema#string"
>Moderate</Asset_has_Availability_Importance>
<rdf:type rdf:resource="http://stackoverflow.com/q/23223447/1281433/Data"/>
<Asset_threatenedBy_ThreatEvent rdf:resource="http://stackoverflow.com/q/23223447/1281433/Integrity_loss_by_corrupting_critital_data"/>
<Asset_has_Integrity_Importance rdf:datatype="http://www.w3.org/2001/XMLSchema#string"
>Moderate</Asset_has_Integrity_Importance>
<Asset_threatenedBy_ThreatEvent rdf:resource="http://stackoverflow.com/q/23223447/1281433/Obtain_unauthorized_access"/>
<Asset_threatenedBy_ThreatEvent rdf:resource="http://stackoverflow.com/q/23223447/1281433/Disclosure_of_sensitive_information"/>
<Asset_threatenedBy_ThreatEvent rdf:resource="http://stackoverflow.com/q/23223447/1281433/Compromise_sensitive_information"/>
<Asset_has_Confidentiality_Importance rdf:datatype="http://www.w3.org/2001/XMLSchema#string"
>High</Asset_has_Confidentiality_Importance>
<Asset_threatenedBy_ThreatEvent rdf:resource="http://stackoverflow.com/q/23223447/1281433/Exploit_exposed_unauthorized_information"/>
</owl:NamedIndividual>
</rdf:RDF>
在Turtle序列化中查看它通常很有用,因为它看起来更像查询。但数据是相同的,当然,查询将针对序列化中的数据运行。
@prefix : <http://stackoverflow.com/q/23223447/1281433/> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
:Secret_Data a owl:NamedIndividual , :Data ;
:Asset_has_Availability_Importance
"Moderate"^^<http://www.w3.org/2001/XMLSchema#string> ;
:Asset_has_Confidentiality_Importance
"High"^^<http://www.w3.org/2001/XMLSchema#string> ;
:Asset_has_Integrity_Importance
"Moderate"^^<http://www.w3.org/2001/XMLSchema#string> ;
:Asset_threatenedBy_ThreatEvent
:Integrity_loss_by_corrupting_critital_data , :Obtain_unauthorized_access , :Disclosure_of_sensitive_information , :Compromise_sensitive_information , :Exploit_exposed_unauthorized_information .
您可以使用如下查询:
prefix : <http://stackoverflow.com/q/23223447/1281433/>
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix owl: <http://www.w3.org/2002/07/owl#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
select distinct ?property ?value where {
:Secret_Data ?property ?value .
}
---------------------------------------------------------------------------------------
| property | value |
=======================================================================================
| rdf:type | owl:NamedIndividual |
| :Asset_has_Availability_Importance | "Moderate"^^xsd:string |
| rdf:type | :Data |
| :Asset_threatenedBy_ThreatEvent | :Integrity_loss_by_corrupting_critital_data |
| :Asset_has_Integrity_Importance | "Moderate"^^xsd:string |
| :Asset_threatenedBy_ThreatEvent | :Obtain_unauthorized_access |
| :Asset_threatenedBy_ThreatEvent | :Disclosure_of_sensitive_information |
| :Asset_threatenedBy_ThreatEvent | :Compromise_sensitive_information |
| :Asset_has_Confidentiality_Importance | "High"^^xsd:string |
| :Asset_threatenedBy_ThreatEvent | :Exploit_exposed_unauthorized_information |
---------------------------------------------------------------------------------------
如果您不想要rdf:type
,可以使用filter ?property != rdf:type
,或者如果您要排除多个媒体资源,filter ( ?property NOT IN ( rdf:type … ) )
:
prefix : <http://stackoverflow.com/q/23223447/1281433/>
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix owl: <http://www.w3.org/2002/07/owl#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
select distinct ?property ?value where {
:Secret_Data ?property ?value .
filter ( ?property not in ( rdf:type ) )
}
---------------------------------------------------------------------------------------
| property | value |
=======================================================================================
| :Asset_has_Availability_Importance | "Moderate"^^xsd:string |
| :Asset_threatenedBy_ThreatEvent | :Integrity_loss_by_corrupting_critital_data |
| :Asset_has_Integrity_Importance | "Moderate"^^xsd:string |
| :Asset_threatenedBy_ThreatEvent | :Obtain_unauthorized_access |
| :Asset_threatenedBy_ThreatEvent | :Disclosure_of_sensitive_information |
| :Asset_threatenedBy_ThreatEvent | :Compromise_sensitive_information |
| :Asset_has_Confidentiality_Importance | "High"^^xsd:string |
| :Asset_threatenedBy_ThreatEvent | :Exploit_exposed_unauthorized_information |
---------------------------------------------------------------------------------------
在问题的原始版本中,您提供了本体的图像,并询问其后的结果:
| numberChapters | 1 |
| numberPages | 5 |
在该本体的RDF / XML序列化中(自从问题中删除),Psicology类的描述如下:
<owl:Class rdf:about="http://webprotege.stanford.edu/RiMIUJzVuVHCr4Ke4TkFwX">
<rdfs:label>Psicology</rdfs:label>
<rdfs:subClassOf rdf:resource="http://webprotege.stanford.edu/RDHbMG5sh4tyJ6ZoHwxLBHk"/>
<rdfs:subClassOf>
<owl:Restriction>
<owl:onProperty rdf:resource="http://webprotege.stanford.edu/R9DdxIZDrtXApiHoBJ6NmAy"/>
<owl:hasValue rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">5</owl:hasValue>
</owl:Restriction>
</rdfs:subClassOf>
<rdfs:subClassOf>
<owl:Restriction>
<owl:onProperty rdf:resource="http://webprotege.stanford.edu/R8WDOefPWzIoTChbjV31ela"/>
<owl:hasValue rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">1</owl:hasValue>
</owl:Restriction>
</rdfs:subClassOf>
</owl:Class>
或更人性化的海龟符号:
<http://webprotege.stanford.edu/RiMIUJzVuVHCr4Ke4TkFwX>
a owl:Class ;
rdfs:label "Psicology" ;
rdfs:subClassOf <http://webprotege.stanford.edu/RDHbMG5sh4tyJ6ZoHwxLBHk> ;
rdfs:subClassOf [ a owl:Restriction ;
owl:hasValue 5 ;
owl:onProperty <http://webprotege.stanford.edu/R9DdxIZDrtXApiHoBJ6NmAy>
] ;
rdfs:subClassOf [ a owl:Restriction ;
owl:hasValue 1 ;
owl:onProperty <http://webprotege.stanford.edu/R8WDOefPWzIoTChbjV31ela>
说Psicology(顺便说一下,通常用英语拼写心理学)是属性numPages的值为5的事物的子类,以及属性numChapters的值为1的事物。 Psicology也是Libray的子类。 (这应该是图书馆吗?)
这对我来说似乎是奇怪的公理,我想知道是否会出现某种建模错误。我不确定Psicology是什么,但你说的是,对于任何Psicology p,它是numPages(p,5)和numChapters(p,1)的情况。这真的是你想要做的吗?
无论如何,根据您的数据,我们可以检索您想要的结果。查看Turtle序列化非常有用,因为它与SPARQL查询语法非常相似。您想要的查询是:
prefix owl: <http://www.w3.org/2002/07/owl#>
prefix : <http://webprotege.stanford.edu/project/Bnag2Z5E4j78tB27NnLq1L#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
select ?property ?value where {
?class rdfs:label "Psicology" ;
rdfs:subClassOf [ owl:hasValue ?value ;
owl:onProperty [ rdfs:label ?property ] ] .
}
-------------------------
| property | value |
=========================
| "numChapters" | 1 |
| "numPages" | 5 |
-------------------------