W3C home > Mailing lists > Public > www-rdf-interest@w3.org > August 2002

RE: xml DOM as rdf

From: Danny Ayers <danny666@virgilio.it>
Date: Fri, 16 Aug 2002 20:44:31 +0200
To: "RDF-Interest" <www-rdf-interest@w3.org>, "Seth Russell" <seth@robustai.net>
Message-ID: <EBEPLGMHCDOJJJPCFHEFGENMHHAA.danny666@virgilio.it>

>Yes, I was going to suggest this schema too.  But to convert any
>kind of XML
>into RDF, don't you still need a mapping from each element and attribute
>name in the XML document to the set of things defined by the RDF model?
>I've used translatesTo in the following example:
>    type infoset:Element;
>    translatesTo sru:Node.
>    type infoset:Attribute;
>    sru:translatesTo sru:Arrow;
>    sru:content rdfs:Resource.
>So that the following XML:
>     <bar>http://robustai.net/sailor/</bar>
>Would end up being the following RDF:
>    <bar resource="http://robustai.net/sailor/" />
>This needs a lot more work, but perhaps you get the drift.  The point being
>that we can extract RDF from any given XML but just describing the XML
>schema in this manner.  Alternatively you could just assume that Elements
>alternate between nodes and arrows as they nest and that all attributes are
>arrows ... but making this explicit should give us better results.

I've been attacking this general problem on a few levels, in different
ways - one of which is very like your translatesTo (I have a mapSource and a
mapTarget instead). In all of them is the use of an internal representation
that in itself has virtually no constraints, just a decorated digraph. For
straight XML with arbitrary/unknown semantics, so far I've been taking it in
with vertices corresponding to elements, with these vertices carrying the
set of attributes from the element as a hashtable. The nesting of the tree
is interpreted as edges/arcs. It would be straightforward to include the
attributes as arc+nodes dangling off the element, but with the formats I've
played with so far this hasn't been needed. The options are fairly wide open
for taking the internal graph and making RDF from it (probably with dangling
nodes), and you can see what I wanted the vocabulary for - something like :

source xml -
	<b x="4"/>

internal graph -
[a] -[parent]-> [b {x=4}]

output rdf -

(I wasted half an hour trying to manually work this out, then realised it'd
be quicker to hack the code - there are undoubtedly many mistakes. Anyone
happen to know how to prettyprint away the RDFNsIds in Jena, btw?)


     <RDFNsId1:Node rdf:about='vertex1'

     <RDFNsId1:Node rdf:about='vertex2'

     <RDFNsId1:Edge rdf:ID='e1'>
         <RDFNsId1:source rdf:resource='#vertex1'/>
         <RDFNsId1:target rdf:resource='#vertex2'/>


The IDs are just local for now - imagine a http://behind
RGML is a minimal graph vocabulary.

Hmm - that is a little more verbose than
<a><b x="4"/></a>
Maybe it isn't such a good idea after all...

At the smartest (and least implemented) level, I've been putting together a
subsystem for taking a graph (or tree) with any semantics and mapping it to
the generalised internal graph using transformations specified in an RDF
file. This is rather like the RDFPath idea, but I think by allowing
processing instructions as well the system should be able to handle a wider
variety of input/output. Once the data is in the internal graph, it can be
mapped out again in the same declarative fashion.

This stuff very quickly flies off into the deep end, so I've spent quite a
lot of time hard-coding the transformations for various languages and trying
to get the core model in the application in a form that would be a good
compromise between versatility & easiness.

Incidentally, Manos mentioned redundancy, and my app is becoming a big
friend of that - below is the SVG generated at the same time from the input


<?xml version="1.0"?>
<?xml-stylesheet href="null" type="text/css"?>
<svg contentScriptType="text/ecmascript" zoomAndPan="magnify"
     contentStyleType="text/css" viewBox="0 0 800 600"
     preserveAspectRatio="xMidYMid meet" xmlns="http://www.w3.org/2000/svg"
        <marker refX="0" markerUnits="strokeWidth" refY="5" orient="auto"
                class="triangle" markerHeight="9" id="triangle"
                viewBox="0 0 10 10" preserveAspectRatio="xMidYMid meet"
            <path d="M 0 0 L 10 5 L 0 10 z"/>
    <g uri="edges">
            <line x1="120" x2="120" y1="121" y2="186" class=""
            <line x1="120" x2="120" y1="121" y2="186" class=""
            <text class="" transform="translate(120,151)">
    <g uri="vertices">
        <g transform="translate(120,91)            scale(2,2)">
            <rect x="-50" width="100" y="-15" height="30" class="vertex"/>
            <text class="H2">
        <g transform="translate(120,216)              scale(2,2)">
            <ellipse rx="50" ry="15" class="vertex"/>
            <text class="H2">
    <g uri="adjuncts"/>
Received on Friday, 16 August 2002 14:53:16 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 22:44:37 UTC