user4233758
user4233758

Reputation:

How to put multiple elements in a rdf:bag

So I have the following problem. I would like to put multiple elements in a rdf:li element. There will always be a fixed amount of this elements. For now it looks like it will be a tuple, a resource and an integer.

For now I tried

<rdf:bag>
    <rdf:li rdf:resource="http://www.example.com/example#1">1</rdf:li>
</rdf:bag>

and also

<rdf:bag>
    <rdf:li>
        <test:x rdf:resource="http://www.example.com/example#1"/>
        <test:t>5</test:t>
    </rdf:li>
<rdf:bag>

Both do not work. So is this even possible, or should I restructure my data?

Upvotes: 0

Views: 301

Answers (1)

Jeen Broekstra
Jeen Broekstra

Reputation: 22052

This is not possible. The RDF/XML syntax spec does not allow this - and I don't understand why you would want to do this either, as the whole point of the rdf:li element is that it denotes a single list member. You normally put multiple values in a bag by using a separate rdf:li in for each value.

So yes, if your goal is to have multiple values captured as a "single item" in the bag, you will have to restructure your data.

Presumably, and I'm just guessing here, you are trying to make some combination of values into a single object that can become a member of the bag. You will need to actually structure that object itself: create an object that represents the combination of values, and have each value linked to it as a property of the object. Then you can add an rdf:li to your bag that refers to that object.

On a more general note: can I recommend that you stop focusing on the XML syntax and actually take some time to learn how the RDF data model works? It's a bad idea to base your application on the XML surface syntax for RDF (for one thing, the exact same RDF model can be written down in multiple ways in XML). You should really be structuring your data according to that model - the XML syntax then naturally follows.

Upvotes: 2

Related Questions