2018-10-20 05:44:13 +09:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2018-11-29 05:40:11 +09:00
|
|
|
"encoding/json"
|
|
|
|
"flag"
|
2018-10-20 05:44:13 +09:00
|
|
|
"fmt"
|
2018-11-29 09:22:56 +09:00
|
|
|
"github.com/cjslep/activity/tools/exp/rdf"
|
|
|
|
"github.com/cjslep/activity/tools/exp/rdf/owl"
|
|
|
|
"github.com/cjslep/activity/tools/exp/rdf/rdfs"
|
|
|
|
"github.com/cjslep/activity/tools/exp/rdf/schema"
|
|
|
|
"github.com/cjslep/activity/tools/exp/rdf/xsd"
|
2018-11-29 05:40:11 +09:00
|
|
|
"io/ioutil"
|
|
|
|
)
|
|
|
|
|
|
|
|
var registry *rdf.RDFRegistry
|
|
|
|
|
|
|
|
func mustAddOntology(o rdf.Ontology) {
|
|
|
|
if registry == nil {
|
|
|
|
registry = rdf.NewRDFRegistry()
|
|
|
|
}
|
|
|
|
if err := registry.AddOntology(o); err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
mustAddOntology(&xsd.XMLOntology{})
|
|
|
|
mustAddOntology(&owl.OWLOntology{})
|
|
|
|
mustAddOntology(&rdf.RDFOntology{})
|
|
|
|
mustAddOntology(&rdfs.RDFSchemaOntology{})
|
|
|
|
mustAddOntology(&schema.SchemaOntology{})
|
|
|
|
}
|
|
|
|
|
|
|
|
var (
|
|
|
|
input = flag.String("input", "spec.json", "Input JSON-LD specification used to generate Go code.")
|
2018-10-20 05:44:13 +09:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2018-11-29 05:40:11 +09:00
|
|
|
flag.Parse()
|
|
|
|
|
|
|
|
b, err := ioutil.ReadFile(*input)
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
var inputJSON map[string]interface{}
|
|
|
|
err = json.Unmarshal(b, &inputJSON)
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2018-12-06 07:50:20 +09:00
|
|
|
p, err := rdf.ParseVocabulary(registry, inputJSON)
|
2018-11-04 00:56:09 +09:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2018-12-06 07:50:20 +09:00
|
|
|
fmt.Printf("done\n%s\n", p)
|
2018-10-20 05:44:13 +09:00
|
|
|
}
|