Combined proposed IDL for RDFa API

Hi All,

I'm aware that with all the open issues and conversations etc around the 
API that it's getting a bit confusing, thus here's a combined IDL from 
all proposals, issues, comments etc and I guess how I'm personally 
seeing the API at the minute should all issues be resolved in line with 
this:

interface RDFNode {
     readonly attribute stringifier DOMString value;

     DOMString  nodeType();
     boolean    equals( in RDFNode otherNode );
     DOMString  toNT();
};

interface RDFResource : RDFNode {
};

interface BlankNode : RDFResource {
};

interface IRI : RDFResource {
};

interface PlainLiteral : RDFNode {
     readonly attribute DOMString language;
};

interface TypedLiteral : RDFNode {
     readonly attribute IRI type;
};

interface RDFTriple {
     readonly attribute RDFResource subject;
     readonly attribute IRI         property;
     readonly attribute RDFNode     object;

     stringifier DOMString toString();
};


interface RDFGraph {
     readonly attribute unsigned long length;

     RDFTriple           get (in unsigned long index);
     void                add (in RDFTriple triple);
     sequence<RDFTriple> toArray();

     boolean             some(in RDFTripleFilter callback);
     boolean             every(in RDFTripleFilter callback);

     DataStore           filter (in RDFTripleFilter filter);
     void                forEach (in RDFTripleCallback callback);

     // one of the following two
     void                merge(in RDFGraph graph);
     RDFGraph            merge(in RDFGraph graph);
     // optional
     DataIterator        iterator();
};

[Callback]
interface RDFTripleCallback {
     void run (in RDFTriple triple, in optional unsigned long index, in 
optional RDFGraph graph);
};

[Callback]
interface RDFTripleFilter {
     boolean match (in RDFTriple triple, in optional unsigned long 
index, in optional RDFGraph graph);
};

// Data Interfaces

interface DataContext {
     void            setMapping (in DOMString prefix, in DOMString iri);
     IRI             resolveCurie (in DOMString curie);

     void            registerTypeConversion (in DOMString iri, in 
TypedLiteralConverter converter);
     any             convertTypedLiteral( in TypedLiteral typedliteral 
); // returns the TypedLiteral on failure, no exceptions

     IRI             createIRI (in DOMString iri); // iri or curie
     PlainLiteral    createPlainLiteral (in DOMString value, in optional 
DOMString language);
     TypedLiteral    createTypedLiteral (in any value, in optional 
DOMString type); // value can be a js type 123, true, new Date() etc
     BlankNode       createBlankNode ();
     RDFTriple       createTriple (in any subject, in any property, in 
any object); // see note below
     RDFGraph        createGraph (in optional sequence<RDFTriple> 
triples); // optionaly throw in an array of triples, counterpart of 
RDFGraph.toArray

};

createTriple note:
   subject can be RDFResource or string curie, string blank node or 
string IRI
   predicate can be IRI or string curie/iri
   object can be RDFNode, string bnode/curie/iri, native js value or a 
string plain literal


[Callback]
interface TypedLiteralConverter {
     any  convert (in DOMString value, in IRI inputType);
};

[Constructor(in DataContext context)]
interface DataParser {
     boolean parse (in any toparse, ParserCallback callback, in optional 
RDFTripleCallback filter, in optional RDFGraph graph); // note below
     boolean process (in any toparse, in DataProcessor processor, in 
optional RDFTripleCallback filter);
};

parse note:
setting the second param to a ParserCallback (below) ensures the API is 
async by default, if no graph is passed in (as fourth param) then a new 
graph is created, if graph is provided and callback is null then API 
flips in to sync mode (after parse completed graph is populated with 
triples from default graph after processing)

[Callback]
interface ParserCallback {
     void run(in RDFGraph graph);
};

[Callback]
interface DataProcessor {
     void process (RDFTriple triple);
};

[Constructor(in DataContext context)]
interface DataSerializer {
     boolean serialize (in RDFGraph graph);
};

[Constructor(in DataContext context)]
interface GraphQuery {
     boolean select (in DOMString query, in RDFGraph graph);
};


Unsure of the definition of the following interfaces or whether they 
should be part of the RDFa API or done under the banner of the 
(optional) RDF TripleStore API:

interface DataStore {
     ??
};

interface DataStoreQuery {
     ??
};

also unsure about the definition / need for DocumentData:

interface DocumentData {
     ??
}


Best and hope that helps in some way,

Nathan

Received on Monday, 1 November 2010 12:30:53 UTC