raven ioctl

A discussion of the design and implementation of an RDF API.

ioctl.org : RDF : discussion : anonymous resources

anonymous resources

three tactics for dealing with anonymous resources

Three approaches:

generation of anonymous resources

An anonymous node can be created on its own, in which case it has no model-specific identity. Alternatively, we can call

	RDFResource a = model.newAnonymousResource();

in which case the resource comes into being with an identity with respect to the model already.

equality testing

semantics of identity lifetime. Does anything bizarre happen when we have three models?

desirable properties

This ...

	RDFModel m;
	RDFModel n = new RDFModel();
	for (TripleIterator i = m.confirmAndReturn(null, null, null); ! i.eof(); i.next()) {
		n.assert(i.getSubject(), i.getPredicate(), i.getObject());

... should work as you'd expect. in other words, anonymous nodes retain their identity for the duration of a serialisation (which is what *AndReturn really is).

The implication is that an Iterator has to carry with it the set of anonymous resources that it has come across so far, and return those resource objects again when they crop up, instead of just creating a new object. Those anonymous resources may then themselves collect model-specific 'identity' should they be asserted anywhere else.

other complications

This requirement has other complications. For example, if I have an anonymous node "a", then the call

	model.confirm(a, p, o);

may or may not succeed. If a has acquired an identity with respect to model already, then this will succeed or fail depending on the existence of the appropriate triple in model. If a has no such identity, then it will (by requirement) compare false with every resource in model; consequently this call _must_ return false in that case.

Example of things that _might_ be expected to work.

Example of how intuitive operation might be "broken":

	RDFModel m = new RDFModel();
			// This isn't how they're created (factories!) but you get the idea...

	m.assert(new AnonymousRDFResource(), "http://property", "value");
			// again, coercion here to simplify things. We'd really write:
			// ... , new RDFProperty("http://property"), new RDFLiteral("value")
			// or maybe even...
			// ... , new RDFProperty(new URI("http://property")), ...
			// (need to fix this!)

	TripleIterator i1 = m.confirmAndReturn(null, null, null);	// Return our (only) Triple
	TripleIterator i2 = m.confirmAndReturn(null, null, null);	// Return it again

	RDFModel n = new RDFModel();

	n.assert(i1.getSubject(), i1.getPredicate(), i1.getObject());
	n.assert(i2.getSubject(), i2.getPredicate(), i2.getObject());


At this stage, n MAY (probably will) contain twice as many triples (with subjects that are anonymous nodes that will NOT compare equal) as m.

I think this breakage is legitimate. Consider *AndReturn to be equivalent to serialisation; if m were serialised twice, its anonymous resource would get two differing temporary URIs. If those serialisations were streamed into another RDFModel, then without a resolution step there would be no way to identify those two resources.

I'm absolutely prepared to arm-wrestle into submission anyone who's got a different idea of how resources can be 'anonymous' and yet consider this example to be "really broken", as opposed to "non truly broken, but not completely intuitive".