summaryrefslogtreecommitdiff
path: root/schema/to-rdfxml.py
diff options
context:
space:
mode:
Diffstat (limited to 'schema/to-rdfxml.py')
-rw-r--r--schema/to-rdfxml.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/schema/to-rdfxml.py b/schema/to-rdfxml.py
new file mode 100644
index 00000000..fcfb92d6
--- /dev/null
+++ b/schema/to-rdfxml.py
@@ -0,0 +1,19 @@
+# Convert all definitions to RDF-XML.
+
+# RDF-XML isn't a very nice format, but it is widely understood by tools.
+
+import parse
+
+
+all_data = parse.load_all_morphologies(path='..')
+
+def serialize_to_rdf_xml(rdflib_graph):
+ # FIXME: there must be a way to make it use nice prefixes for the
+ # namespaces in the output instead of 'ns1', 'ns2' etc.
+ # FIXME: would be nice if it would output in a stable (sorted) order too. I
+ # think this requires a patch to the 'rdflib.plugins.serializers.rdfxml'
+ # module.
+ return rdflib_graph.serialize(format='application/rdf+xml')
+
+with open('definitions.rdfxml', 'w') as f:
+ f.write(serialize_to_rdf_xml(all_data))