A rendering language for RDF

Fabio Labella

Henry S. Thompson

Rendering

RDF

  • machine readable
  • graph-based data model
  • different serialisation formats

Synctactic variability

Same RDF graph
Same RDF graph

Goals

  • Declarative
  • Syntax unaware
  • Graph data model

Result

Enhanced XSLT processor using just-in-time reflection

RDF and XSLT

Problems

  • Limited to RDF/XML
  • Still very hard

Tree vs Graph

  • Rooted
  • Connected
  • Acyclic
  • Non-reentrant

Tree vs Graph

Mismatch = Syntactic variability

Static reflection

Reflection (1)

alice:me a foaf:Person
<foaf:Person rdf:about="alice/me"/>
<rdf:Description rdf:about="alice/me">
  <rdf:type rdf:resource="http://xmlns.com/foaf/0.1/Person"/>
</rdf:Description >

Reflection (2)

Reflection (3)

<alice:me>
  <rdf:type>
    <foaf:Person >
      .....

Solves one half of the problem

XSLT becomes syntax unaware but... you need a suitable normal form (good luck with that)

Just-in-time reflection

A JIT reflection is...

  • In-memory representation of a reflection
  • Processable by XSLT
  • Generated on-the-fly at each step of a path expression

Cyclic graph

Alice knows Bob and Bob knows Alice

Infinitely deep tree

<alice:me>
 <foaf:knows>
  <bob:me>
   <foaf:knows>
    <alice:me>
     <foaf:knows>
      <bob:me>
       <foaf:knows>
         ...
       </foaf:knows>
      </bob:me>
     </foaf:knows>
    </alice:me>
   </foaf:knows>
  </bob:me>
 </foaf:knows>
</alice:me>

Not a problem!

<xsl:template name="main">
    <xsl:apply-templates select="reflect()/Alice:me"/>
</xsl:template >
<xsl:template match="foaf:knows/*">

returns Bob:me

XSLT 3.0

<xsl:template match="reflect()/Alice:me/foaf:knows/*">

But...

  • Descendant axis + cycle = non-termination
  • Descendant axis + reentrancy = duplicate nodes

So...

Graph depth first search to the rescue!

Normal form highlights

In a nutshell

  • Xml nodes wrap RDF resources
  • Multiple roots to choose from
  • subject/predicate/object/predicate/object/...

The descendant axis

Graph-based depth first search prevents non-termination and duplicate nodes

The parent axis

Conclusion

crc:A a foaf:Person ;
        foaf:name "Alice" ;
        foaf:knows crc:D .

crc:B a foaf:Person ;
        foaf:name "Bob" ;
        foaf:knows crc:C , crc:A .

crc:C a foaf:Person ;
        foaf:name "Charlie" ;
        foaf:knows crc:A , crc:B .

crc:D a foaf:Person ;
        foaf:name "Dave" ;
        foaf:knows crc:C .

<xsl:variable name="Node" select="enf:reflect()"/>
<xsl:template name="main">
 <html>
   ...
   <xsl:for-each select="$Node/*">
     ...
      <xsl:for-each select=".//*[parent::foaf:knows]">
       <tr>
        <td>
         <xsl:value-of select="@foaf:name"/>
        </td>
       </tr>
      </xsl:for-each>
    ...
  </xsl:for-each>
 </html>
</xsl:template>

Questions?