W3C home > Mailing lists > Public > public-grddl-wg@w3.org > October 2006

Re: spec#issue-output-formats formal specification in terms of graphs

From: Chimezie Ogbuji <ogbujic@bio.ri.ccf.org>
Date: Thu, 19 Oct 2006 22:51:01 -0400 (EDT)
To: Dan Connolly <connolly@w3.org>
cc: GRDDL Working Group <public-grddl-wg@w3.org>
Message-ID: <Pine.GSO.4.60.0610192206180.14480@joplin.bio.ri.ccf.org>

I've had a chance to ponder this issue.  In the end I think the 
language is fine as it is.  In particular, a GRDDL result has to be 
handled by the same user agent which invokes the GRDDL mechanism and will 
include actions such as merging graphs, interpreting / querying graphs and possibly serializing them.

It has to be able to interpret GRDDL result graphs in order to glean transformation links expressed in RDF.

So, the agent would need to be (or have access to) an RDF processor which 
could parse an RDF serialization safely, perhaps even in the absence of an associated mime-type from the output of the 

A sample implementation appendix can demonstrate some failsafe ways to 
parse transformation output (XML w/ XSLT 1.0).

In particular, for XSLT results w/out mime-types or output types, the RDF 
could be parsed in a particular order (http://esw.w3.org/topic/DereferenceURI has some suggestions on 
prospective RDF parsing).

I can write up some 4Suite [1] / RDFLib snippets for this as well as some 
XSLT transforms that use a 'default' base-uri throughout and this ends up 
when parsed as RDF.

For example, this bit below is how 4Suite's content management repository 
synchronizes XML documents with a corresponding RDF graph:

from Ft.Xml.Xslt import Processor
from Ft.Rdf import Util as RdfUtil

p = Processor.Processor()
.. snip ..
.. snip ..
rt = p.run(isrc, ignorePis=1, topLevelParams=params)

#So we got a result.  Cool, parse it and add it.
model, db = RdfUtil.DeserializeFromXSLT(
   p.outputParams.method[-1], rt, create=1, scope=srcUri

Where model is an instance of an API for a named RDF graph and db is the 
persistence mechanism.  In this case, the URI of the 
source document (srcUri) is used as the name of the graph into 
which the output of the transformation is parsed.  DeserializeFromXSLT is 
currently [2] defined as:

def DeserializeFromXSLT(outputMethod,st, driver=Memory, dbName='', create=False, scope=None):
     Parse RDF syntax from an XSLT transform based on the output method used

     if XML:
         - Try RDF/XML
         - Try TriX?
         - raise Exception
     elif text:
         - Try N3
         - raise Exception
     elif HTML:
         - *should perhaps follow GRDDL rules?*
     if outputMethod == 'xml':
         from Ft.Rdf.Serializers.Dom  import Serializer
         from Ft.Xml.Domlette import NonvalidatingReader
         doc = NonvalidatingReader.parseString(st,scope)
         if create:
             db = driver.CreateDb(dbName, 'default')
             db = driver.GetDb(dbName, 'default')
         model = Model.Model(db)
         serializer = Serializer()
         serializer.deserialize(model, doc, scope)
         return model, db

     elif outputMethod == 'text':
         #The most widely deployed text syntax for RDF is N3 and it's derivatives (Turtle & NTriples)
         from Ft.Rdf.Serializers.N3 import Serializer
         if create:
             db = driver.CreateDb(dbName, 'default')
             db = driver.GetDb(dbName, 'default')
         model = Model.Model(db)
         serializer = Serializer()
         serializer.deserialize(model, cStringIO.StringIO(st), scope)
         return model, db

         raise Exception("Unsupported RDF Serialization: %s"%(repr(processor.outputParams.method)))

Additional observations for current spec draft:

I would move 'Using GRDDL with an RDF Namespace document' to the primer as 

- [1] http://4suite.org/docs/CoreManual.xml
- [2] http://cvs.4suite.org/viewcvs/4Suite/Ft/Rdf/Util.py?view=markup

On Wed, 18 Oct 2006, Dan Connolly wrote:
> Splitting the editing work with Murray prompted me to look
> more closely at the formal guts of the specification and
> take out fluffy stuff like "preserve the meaning..."
> and formally define "GRDDL result".
> Consequently, I currently lean toward the less constrained
> position on issue-output-formats, i.e. yes, a GRDDL
> transformation may produce RDF in a format other than RDF/XML.
> The current text is:
> [[
> Stated more formally:
>      * An XML document whose root element has an attribute with a local
>        name of transformation and a namespace name of
>        http://www.w3.org/2003/g/data-view# has a GRDDL transformation
>        for each resource identified by a URI reference listed in the
>        value of the attribute (c.f. section 4.4.1. URI references in
>        [WEBARCH]).
>      * If ?D is an XML document with GRDDL transformation ?T, then the
>        result of applying ?T1 to ?D is a GRDDL result of ?D.
>      * If ?G1 and ?G2 are GRDDL results of ?D, then the merge of ?G1
>        and ?G2 is also a GRDDL result of ?D.
> ]]
> -- http://www.w3.org/2004/01/rdxh/spec#grddl-xml
> Even more formally, I worked out the details of those rules in N3.
> http://www.w3.org/2004/01/rdxh/grddl-rules.n3

Chimezie Ogbuji
Lead Systems Analyst
Thoracic and Cardiovascular Surgery
Cleveland Clinic Foundation
9500 Euclid Avenue/ W26
Cleveland, Ohio 44195
Office: (216)444-8593
Received on Friday, 20 October 2006 02:51:11 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 8 January 2008 14:11:46 GMT