This task was outlined in the project timeline at #1151286: Proposed Timeline for D7 Port as :

Provide the feature of importing and loading vocabulary by using the evoc module code

Comments

cygri’s picture

There are actually two parts to importing.

First, importing some vocabulary from the web or from a file in order to edit and host it in Neologism. For example, I might start developing an ontology in Protégé, and then decide to load it into Neologism so that it's nicely available on the web.

Second, loading an existing external vocabulary into Neologism so that one can use its classes and properties as superclasses/superproperties and so on. For example, I might load the FoaF vocabulary so that I can declare the my:Employee class in my own vocabulary as a subclass of foaf:Person.

I think we should initially focus on the first scenario. Both scenarios will share a lot of code but are also different: the first creates a new workspace; the second adds a non-main vocabulary to an existing workspace.

I'm going to describe how the first scenario is implemented in the D6 version.

  1. a menu hook for neologism/import in hook_menu
  2. the hook invokes neologism_import_form_callback in neologism.import.inc
  3. that function shows a form where one can specify the source to load from, using the form API
  4. the form is built in neologism_import_form; ignore the first part of the big if block; you only need the part starting here
  5. neologism_import_form_validate performs validation of the entered values, and as part of that actually loads and parses the vocabulary (more on that later); the parsed vocabulary is temporarily stored in $form_state['neologism_processed_vocabulary'] where the submit handler will find it again; you can ignore the part at “// Handle undefined namespaces
  6. the process of actually saving the vocabulary as nodes in the DB starts in neologism_import_form_submit and uses a number of additional functions in the neologism.import.inc file
  7. the actual loading from web/file and parsing all happens in evoc_get_from_file and evoc_get_from_file; both are defined in evoc.load_vocab.inc which is part of the evoc module
  8. they use ARC2 for parsing, and support multiple input formats (RDF/XML, Turtle, RDFa) – best to focus on RDF/XML first, and do the others only if time permits
  9. hopefully, most of the stuff in evoc.load_vocab.inc can be re-used without much change; I'd say just keep copying functions over to the new codebase until it no longer complains about undefined functions…
  10. evoc.load_vocab.inc roughly has two parts; the first half is concerned with loading and parsing the various formats; the second part (starting with evoc_get_from_file) is concerned with extracting RDFS and OWL schema information from the parsed RDF graph

Hope that helps!