Do not use for production yet. Might change or rename at anytime. Please do report bugs!
OWL 2 JSON SCHEMA wants to build a bridge between the semantically XML web and the semantically JSON web and is a converter from OWL as RDF/XML to JSON Schema (currently draft 4). Full XML Schema support will come soon. For now an OWL Ontology is required.
Why?
Most ontologies on the web use OWL+RDF/XML or RDF/Turtle or RDF/NTriples (which translate 1:1 to RDF/XML).
spec.:
"The primary exchange syntax for OWL 2 is RDF/XML; this is indeed the only syntax that must be supported by all OWL 2 tools."
So RDF/XML Schema is Lingua Franca. Let us create a canonical JSON representation for this.
It is planned to support several proposals for JSON Schema v5 draft which close gaps between OWL and JSON Schema. For example
So whenever the documentation refers to "JSON Schema" it means :
"JSON Schema and hyperschema - including the above mentioned inofficial proposals".
This is nightly written from scratch, might currently contain bugs and is incomplete.
Currently working on: The resolving of external URIs and Ontologies.
node.js >= 0.10.0
For now
git clone https://github.com/redaktor/owl2jsonschema.js.git
cd owl2jsonschema.js
npm install
A demo is included. It will create the JSON Schemas of the dbpedia Ontology.
This will create the schema files in demo/OUTPUT:
node demo
var owl2jsonschema = require('owl2jsonschema');
var parser = new owl2jsonschema(/*[options object]*/);
and now parse url OR file OR string
// url, options, callback
parser.parse('http://mappings.dbpedia.org/server/ontology/export' /*, [callback function]*/ );
OR
// filepath, options, callback
(if filepath is relative then './' is the folder of your script)
parser.parse('./export.xml' /*, [callback function]*/);
OR
// string, options, callback
parser.parse('<?xml><rdf:RDF><owl:Ontology>...</owl:Ontology>...</rdf:RDF>' /*, [callback function]*/);
This will write JSON schema files - you can specify options - see the code for now. Several Database support is planned within the redaktor boilerplate.
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D
TODO: Write history
Once OWL/RDFS is transformed, this uses the logic of schema-org-gen by Geraint Luff.
TODO: Write license