Arc Selection Syntax Proposal

Adding arc selection to NodePaths has created some usability problems. Its not obvious from looking at a NodePath in isolation whether it expects nodes or arcs as its context. It's easy enough for the stylesheet author to work out but it might be a stumbling block for newcomers to RDF Templates. It's similar to the criticisms RDF/XML faces with the striping syntax - there's no easy way to identify whether you're looking at a node or an arc. RDF/XML has a convention of using an upper case first letter for nodes and lower case first letters for arcs but many schemas don't use this convention.

Here's an example of the kind of problem that I'm talking about:

<rt:root-template>
  <rt:for-each rt:select="~subject()">
    <rt:for-each rt:select="resource()/resource()">
      <rt:for-each rt:select="resource()/resource()">
        <rt:value-of rt:select="label()"/>
      </rt:for-each>
  </rt:for-each>
</rt:root-template>

Does the rt:value-of instruction emit the label of nodes or arcs? It's not immediately obvious, but tracing through the NodePaths reveals the answer to be node. The first for-each selects nodes that are subjects of a triple, the second for-each selects arcs of those nodes and the third for-each selects node values of those arcs

To clarify this situation I'm proposing a NodePath syntax change. My proposal is to prefix each ArcPattern with an @ symbol. The example above would become:

<rt:root-template>
  <rt:for-each rt:select="~subject()">
    <rt:for-each rt:select="resource()/@resource()">
      <rt:for-each rt:select="@resource()/resource()">
        <rt:value-of rt:select="label()"/>
      </rt:for-each>
  </rt:for-each>
</rt:root-template>

This would make it easier to match up arc-matching NodePaths with arc-selecting NodePaths. The compact syntax would also be clearer: */@*/*.

Is this a good idea or is it an unnecessary complication of the syntax?

Comments

No comments yet.

Leave a comment

Sorry, the comment form is closed at this time.