Visions of Aestia

06 Sep 2005

Exploring RDF with XPath

Filed under: PlanetRDF, XML — JBowtie @ 9:15 pm

If I keep up this string of posts I risk turning into Danny Ayers (not necessarily a bad thing). Most I’ve written in ages.

It’s been my observation that XPath is one of the things keeping people chained to XML. It’s familiar, easy to explore with, and heavily supported. So why not co-opt it for exploring RDF? If we do that, we might be able to show people some of the virtues of the semantic model.

This is a thought experiment, not a concrete, fully-thought out proposal. In fact, it’s probably not even cohesive. I just wanted to get it down in writing while I thought of it.

So here’s a bit of RDF in abbreviated XML format:

<rpg:skill rdf:about="https://nzlinux.org.nz/srd#acrobatics">
<rpg:name>Acrobatics</rpg:name>
<rpg:keyAbility>DEX</rpg:keyAbility>
<rpg:blurb>You can flip, dive, roll, tumble, and perform other acrobatic maneuvers.</rpg:blurb>
</rpg:skill>

Assume we have namespace definitions for rpg and srd and that we’re positioned on the srd:acrobatics node. What kind of XPath expressions could we write?

“rpg:name” would follow the arc and return the value “Acrobatics”.
“rdf:type” would follow the arc and return the “rpg:skill” node. “rdf:type/rdf:label[@xml:lang=’en’]” would return the value “Skill”. Without the qualifier it wound return all the labels.

Assuming owl:instanceOf is the inverse of rdf:type -
“rdf:type/owl:instanceOf” would return all nodes with the “rpg:skill” type.
“rdf:type/owl:instanceOf[rpg:name=’Acrobatics’]” would return the “srd:acrobatics” node.

A couple of XPath constructs would need special interpretation.
There’s no root as such, so “/” would not be a node of itself, but rather simply indicate that the next part of the path should be interpreted as a subject. So, “/srd:acrobatics” positions us on the “srd:acrobatics” node.
“/srd:acrobatics/rpg:name” is therefore the same as the triple “srd:acrobatics rpg:name ?”, whereas “/rpg:name/rdf:type” would presumably return the “rdf:Literal” node.

There’s no parent node as such, so “..” would best be interpreted as following the arc back to the original node. If there is no arc to follow back, it doesn’t do anything.
“/srd:acrobatics/rpg:name/../rpg:keyAbility” would return the value “DEX”.

I think this would be a fruitful area for research. XPath is implicitly graph-oriented and a reasonably well-understood. By using it to explore RDF graphs, it opens up new opportunities to bring people on board and exposes some of the power of the underlying model.

Finally figured it out

Filed under: General, PlanetRDF — JBowtie @ 8:44 pm

So, I finally figured out the problem with file URI parsing on Redland/Windows.

Basically, the problem boiled down to this - the Windows-specific raptor code was assuming a leading slash, but that was blowing up when there wasn’t one (as in the shipped examples). I misdiagnosed the problem and removed the attempt to skip that character. This however blew up in other circumstances. I couldn’t reproduce it because all my test cases left off the leading slash.

So, after taking a nice break from the code, the problem was immediately obvious. Now the code looks at the first character; if it’s a leading slash it skips it. Everything works again.

New packages are being generated - I should be able to sign and upload them tomorrow.

Autotools are bad, m’kay?

Filed under: Aestia, PlanetRDF — JBowtie @ 1:06 pm

I finally mucked in and added autotool support to my character generator (which now has a name: Lorax-RPG). It’s ugly as sin but at least it’s done. Required a massive code re-org to get things into the “right” places; I probably will end up doing another one once I actually understand why I needed to make some of those changes.

It’s really skeletal support in the sense that most of the files don’t get deployed yet, but I have convinced myself that things are going to the right places, and the whole configure/make/make install triune works. Now I’m fixing up all the paths to wipe out assumptions about file layout.

In another rev or two XML support will be finally dropped completely in favour of the new Redland-based RDF loader. All my rules will be expressed entirely in RDF, which allows me to stop maintaining serialization code. It also allows me to start seeing the benefits of distributed data, though I still need to work out a strategy for handling conflicting assertions.

Condolences to Dave Beckett

Filed under: PlanetRDF — JBowtie @ 12:52 pm

Dave announced he is leaving the UK for the USA.

California is probably the least of evils given the circumstances, but this refugee from the old country find it hard to believe that anyone would voluntarily immerse themselves in the culture there when they don’t have to. And they don’t have Doctor Who over there.

Ah well. I should probably start a pool on how long Dave will last before returning to civilization. [smiley face - yes, I’m avoiding UTF8 art]

In the meantime perhaps I should get my act together and finish fixing that showstopper in the Windows port. I’ve been trying to avoid that platform in principle, but even Windows users need the Semantic Web.

Powered by WordPress