问题
I'm reading the RDF Schema 1.1 recommendation, which includes the following (emphasis added):
5.1.2 rdf:Bag
The rdf:Bag class is the class of RDF 'Bag' containers. It is a subclass of rdfs:Container. Whilst formally it is no different from an rdf:Seq or an rdf:Alt, the rdf:Bag class is used conventionally to indicate to a human reader that the container is intended to be unordered.
5.1.3 rdf:Seq
The rdf:Seq class is the class of RDF 'Sequence' containers. It is a subclass of rdfs:Container. Whilst formally it is no different from an rdf:Bag or an rdf:Alt, the rdf:Seq class is used conventionally to indicate to a human reader that the numerical ordering of the container membership properties of the container is intended to be significant.
5.1.4 rdf:Alt
The rdf:Alt class is the class of RDF 'Alternative' containers. It is a subclass of rdfs:Container. Whilst formally it is no different from an rdf:Seq or an rdf:Bag, the rdf:Alt class is used conventionally to indicate to a human reader that typical processing will be to select one of the members of the container. The first member of the container, i.e. the value of the rdf:_1 property, is the default choice.
I tried understanding last line of each of them (Shown in BOLD). Also googled to understand it well. But couldn't get how they want to differentiate all 3 Containers on human/logical level. Also how the order is maintained in rdf:Seq.
For understanding Ordering I also tried reading them using rdf parser from rdf file like below:
<rdf:Alt rdf:about="http://eresources.nlb.gov.sg/ID/NLBDM/entity/XYZContainer">
<rdf:li>http://eresources.nlb.gov.sg/ID/NLBDM/resource/c85a5e82-b357-4168-a31e-1c8fd7f46101</rdf:li>
<rdf:li>http://eresources.nlb.gov.sg/ID/NLBDM/vocab/tqS1cM1h</rdf:li>
<rdf:li>http://eresources.nlb.gov.sg/ID/NLBDM/vocab/rQhlIgDw</rdf:li>
<rdf:li>http://eresources.nlb.gov.sg/ID/NLBDM/vocab/AaNRoEP6</rdf:li>
</rdf:Alt>
Using either rdf:Bag or rdf:Seq or rdf:Alt, all are giving same ordered Uris for rdf:li
eg. www.w3.org/1999/02/22-rdf-syntax-ns#_1,www.w3.org/1999/02/22-rdf-syntax-ns#_2,www.w3.org/1999/02/22-rdf-syntax-ns#_3 and so on...
I want to understand it with clear example that how to use these Containers differently in different scenarios, and what is special to maintain order for rdf:Seq.
回答1:
The spec also says this:
D.2 RDF containers
There are no special semantic conditions on the container vocabulary: the only structure which RDF presumes its containers to have is what can be inferred from the use of this vocabulary and the general RDF semantic conditions. This amounts to knowing the type of a container, and having a partial enumeration of the items in the container. The intended mode of use is that things of type rdf:Bag are considered to be unordered but to allow duplicates; things of type rdf:Seq are considered to be ordered, and things of type rdf:Alt are considered to represent a collection of alternatives, possibly with a preference ordering. If the container is of an ordered type, then the ordering of items in the container is intended to be indicated by the numerical ordering of the container membership properties, which are assumed to be single-valued. However, these informal conditions are not reflected in any formal RDF entailments.
Using either rdf:Bag or rdf:Seq or rdf:Alt, all are giving same ordered Uris for rdf:li
eg. www.w3.org/1999/02/22-rdf-syntax-ns#_1,www.w3.org/1999/02/22-rdf-syntax-ns#_2,www.w3.org/1999/02/22-rdf-syntax-ns#_3 and so on...
Yes, there's no formal difference between these containers. Note that rdf:li is not an RDF property. It's a special URI that gets used in the RDF/XML serialization, and when the triples are extracted from the RDF/XML document, they actually use the rdf:_n properties, which are RDF properties. You get the same sequence of rdf:_n properties because that's the order that they appeared in the RDF/XML document.
With Bag, the fact that order doesn't matter means that you ignore the particular values of i in rdf:_i, and just treat them all as members. With Seq, the order does matter, and so you should pay attention to the value of i in rdf:_i. Order might matter in Alt; it would depend on the application.
I want to understand it with clear example that how to use these Containers differently in different scenarios, and what is special to maintain order for rdf:Seq.
The difference is in what the consumer is intended to do with the data. The actual data doesn't really change, but the intent is that:
- if you see a Bag, then you treat it like a mathematical set. It has a bunch of elements, and no special order. Of course, when it's written down in a RDF/XML file, the elements have to be written in some order, but it's just incidental.
- If you see an Alt, then the intent is that it's a collection of items, but you only really need one of them, and there may or may not be an ordering. For instance, if someone is likes the colors red and blue, but doesn't like yellow or orange, and you need to know what color shirt to get for them, you could pick an arbitrary color out of an alt containing just red and blue.
- If you see a seq, then the ordering is important.
Now imagine that we're not using RDF, but a programming language with arrays. I can use an array to represent all of these structures. The difference is in what the consumer does with the array. Formally, though, they're all just arrays.
All that said, people don't really seem to use these collections all that much. They don't have a definite semantics, and so there's not really a definite use case for them. If you need them, you can use them, but tools won't usually do anything special with them; you might want to consider other alternatives.
Related
These aren't duplicate questions, but they're related and may be useful or interesting reading:
- What is the difference between rdf:_1....rdf_n and rdf:_li?
- Difference between RDF Containers and Collections?
The sections D.2 RDF containers and D.3 RDF collections of the RDF Semantics W3C Recommendation are also good resources.
来源:https://stackoverflow.com/questions/29001433/how-rdfbag-rdfseq-and-rdfalt-is-different-while-using-them