私の問題は、 ID が何であれ、cim:ACLineSegment を含むすべてのサブジェクトを取得したいということです。
<cim:ACLineSegment rdf:ID="_05b8">
<!-- some code... -->
</cim:ACLineSegment>
あなたの主題は「含まない」cim:ACLineSegment
. サブジェクトにはRDFには何も含まれていません。リソース (トリプルのサブジェクトを含む) は URI によって識別されます。RDF は、{主語、述語、目的語} という形式のトリプルに基づいています。表示しているスニペットは、トリプルの特定のシリアル化である RDF/XML です。あなたが示したスニペットには、フォームのトリプルがいくつかあります{<.../_05b8>, rdf:type, cim:ACLineSegment}
。つまり、サブジェクトはプロパティの値cim:ACLineSegment
として値を持っていrdf:type
ます。
もう少し説明するために、次のデータがあるとします。(ちなみに、将来的には、最小限ではあるが完全なサンプル データを提供していただけると、より便利になります。提供されたデータは完全ではなく、それに対してクエリを実行することも、実行することもできません。文脈でそれが何であるかを確認してください。)
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:ex="http://stackoverflow.com/q/23432445/1281433/ex#"
xml:base="http://stackoverflow.com/q/23432445/1281433/ex#">
<ex:Person rdf:ID="Mary">
<ex:hasName>Mary</ex:hasName>
</ex:Person>
<ex:Person rdf:ID="Jim">
<ex:hasName>James</ex:hasName>
<ex:hasAge rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">34</ex:hasAge>
</ex:Person>
<ex:Person rdf:ID="John">
<ex:hasName>John</ex:hasName>
</ex:Person>
</rdf:RDF>
このデータを N-Triples シリアライゼーション (1 行に 1 つのトリプルしかありません) で見ると、次のトリプルが表示されます。
<http://stackoverflow.com/q/23432445/1281433/ex#Mary> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://stackoverflow.com/q/23432445/1281433/ex#Person> .
<http://stackoverflow.com/q/23432445/1281433/ex#Mary> <http://stackoverflow.com/q/23432445/1281433/ex#hasName> "Mary" .
<http://stackoverflow.com/q/23432445/1281433/ex#John> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://stackoverflow.com/q/23432445/1281433/ex#Person> .
<http://stackoverflow.com/q/23432445/1281433/ex#John> <http://stackoverflow.com/q/23432445/1281433/ex#hasName> "John" .
<http://stackoverflow.com/q/23432445/1281433/ex#Jim> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://stackoverflow.com/q/23432445/1281433/ex#Person> .
<http://stackoverflow.com/q/23432445/1281433/ex#Jim> <http://stackoverflow.com/q/23432445/1281433/ex#hasName> "James" .
<http://stackoverflow.com/q/23432445/1281433/ex#Jim> <http://stackoverflow.com/q/23432445/1281433/ex#hasAge> "34"^^<http://www.w3.org/2001/XMLSchema#integer> .
これらすべてのrdf:type
トリプルに注意してください。これは、RDF/XML 構文 ( §2.13 Typed Node Elements ) では、リソースに対応する要素が の値として要素名を持っているためrdf:type
です。したがって、上記の RDF/XML は、実際にはこのデータの省略形です。
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:ex="http://stackoverflow.com/q/23432445/1281433/ex#" >
<rdf:Description rdf:about="http://stackoverflow.com/q/23432445/1281433/ex#Mary">
<rdf:type rdf:resource="http://stackoverflow.com/q/23432445/1281433/ex#Person"/>
<ex:hasName>Mary</ex:hasName>
</rdf:Description>
<rdf:Description rdf:about="http://stackoverflow.com/q/23432445/1281433/ex#Jim">
<rdf:type rdf:resource="http://stackoverflow.com/q/23432445/1281433/ex#Person"/>
<ex:hasName>James</ex:hasName>
<ex:hasAge rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">34</ex:hasAge>
</rdf:Description>
<rdf:Description rdf:about="http://stackoverflow.com/q/23432445/1281433/ex#John">
<rdf:type rdf:resource="http://stackoverflow.com/q/23432445/1281433/ex#Person"/>
<ex:hasName>John</ex:hasName>
</rdf:Description>
</rdf:RDF>
SPARQL クエリ構文に非常に近いため、N3 または Turtle 構文でデータを表示することも役立ちます。
@prefix ex: <http://stackoverflow.com/q/23432445/1281433/ex#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
ex:Mary a ex:Person ;
ex:hasName "Mary" .
ex:John a ex:Person ;
ex:hasName "John" .
ex:Jim a ex:Person ;
ex:hasAge 34 ;
ex:hasName "James" .
これが意味することは、指定されたタイプのものを単に要求したいということです。クエリは次のようになります。
select ?predicate ?object where {
?subject rdf:type cim:ACLineSegment ; # You can use `a` instead of rdf:type.
?predicate ?object
}