CellML Discussion List

Text archives Help


[cellml-discussion] Proposed CellML API Change: Exposing arbitrary serialisation on CellMLBootstrap


Chronological Thread 
  • From: ak.miller at auckland.ac.nz (Andrew Miller)
  • Subject: [cellml-discussion] Proposed CellML API Change: Exposing arbitrary serialisation on CellMLBootstrap
  • Date: Wed, 06 Sep 2006 14:06:43 +1200

Hi all,

Is there any objection to changing interface CellMLBootstrap to add a
method allowing serialisation of arbitrary DOM nodes (including
documents, but elements could also be serialised if only a fragment is
required)?

I propose the following be added to the end of interface CellMLBootstrap:

/**
* Serialises a DOM node into a string. The serialised node must have
* originated from the locally hosted DOM implementation.
* @param node The DOM node to serialise.
* @return The node, as a serialised string.
*/
dom::DOMString serialiseNode(dom::Node node);

Note that all CellML DOM implementations already need to include a
serialiser, in order to correctly support obtaining serialised RDF back.
This simply exposes it more conveniently to the application, and
therefore allows for code like this:

var el = model.getRDFRepresentation("http://www.cellml.org/RDFXML/DOM";).
QueryInterface(Components.interfaces.
cellml_api_IRDFXMLDOMRepresentation).data;
var od = el.ownerDocument;
var rnl =
od.getElementByTagNameNS("http://www.w3.org/1999/02/22-rdf-syntax-ns#";,
"RDF");
var l = rnl.length();
var i;
var td = od.implementation.createDocument(
"http://www.w3.org/1999/02/22-rdf-syntax-ns#";, "rdf:RDF", od.doctype);
for (i = 0; i < l; i++)
{
td.appendChild(td.importNode(rnl.item(i), true));
}
var str = window.context.cellmlBootstrap.serialiseNode(td);

in order to obtain str as a serialised RDF/XML document which contains
all triples in the entire model (obviously more work will be required if
we need to start pulling triples out of imported models too, but this
API change would still be useful in that case).

Best regards,
Andrew Miller





Archive powered by MHonArc 2.6.18.

Top of page