All;  Attached is a script that creates a list of files and the names to convert to (see CreateFileList).  This iterates through the list and saves each to the filename specified in the :newName property.  Composer will save the file in the format specified {.n3, .owl, .rdf, .nt}.  The same sort of things can be done in a separate RDF file or spreadsheet, as Irene suggested.

This script is also set up as a Web service, so you can call it remotely via http://<host>/tbl/actions?action="">
...for TBC-ME, use "localhost:8083".  Using a Live server, specify the host name that Live is running on.

-- Scott

Arthur Keen wrote:
Naicong

I asked about this a couple of months back and I was quite surprised that Composer does not directly implement this capability.  I thought Holger's solution would work well for one-time or infrequent translation, but my challenge is that I have to keep the models in n3 and owl in synch throughout development through lots of changes.  I estimated that it would  take a longer time to learn SPARQLMotion than to simply code a solution in Java.    Creating a spreadsheet of all my files would be tedious and error prone because I have many models in a very deep file hierarchy and I would have to re-visit a spreadsheet of all models often because of frequent re-factoring.  So, I wrote a small Java utility that recurses through a source directory tree, creates an equivalent target directory tree, and on encountering .n3 files, loads them, and then saves them in RDF/XML into the equivalent location in the target directory structure.  Is this what you are looking for?

Arthur

On May 13, 2009, at 7:59 PM, Li, Naicong wrote:

Hi Irene,
 
I checked the SPARQLMotion functions list and did not see any obvious that I could use.  I check the old emails on this list and found this one below.  Do you mean I need to do something like what Holger is describing?
 
Thanks for the help.
Naicong
 
============================
<image001.gif>



Arthur 
 More options Feb 19, 5:23 pm







Is there an easy way in TopBraid to convert an entire project 
containing a large number of models in .N3 file format to another 
format e.g., .OWL?  The project contains about 50 models and the 
developers would feel more comfortable with xml trainer wheels.

    

<image001.gif>



Holger Knublauch 
 More options Feb 19, 6:15 pm







Not out of the box, only SPARQLMotion could help. You would need the   
list of file names though, somehow (e.g. from a spreadsheet). Then use   
a SM script to import that spreadsheet and iterate over all file   
names. Then use sml:ImportRDFFromWorkspace to load and the   
corresponding export module to save it back in the new format.

Holger

 
 
From: [email protected] [mailto:[email protected]] On Behalf Of Irene Polikoff
Sent: Tuesday, May 12, 2009 5:20 PM
To: [email protected]
Subject: [tbc-users] Re: File format conversion
 
Yes, of course, with a SPARQLMotion script
 
From: [email protected] [mailto:[email protected]] On Behalf Of Li, Naicong
Sent: Tuesday, May 12, 2009 7:58 PM
To: [email protected]
Subject: [tbc-users] File format conversion
 
Hi,
 
Because of our project needs, we need to convert the ontology format between .n3 and .owl quite often (sometimes to .allegro as well).  We have about 40 ontologies, and in the past we did the conversion a couple times by manually exporting each file to a different format and it’s very time consuming (and error prone).   Is there a way that we can do this in a batch?
 
Thanks.
Naicong
 
 
 

 







--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "TopBraid Composer Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [email protected]
For more options, visit this group at http://groups.google.com/group/topbraid-composer-users?hl=en
-~----------~----~----~----~------~----~------~--~---

# Saved by TopBraid on Thu May 14 00:34:35 CDT 2009
# baseURI: http://TQ_Demos.com/ImportExportFiles/ImportExportFiles
# imports: http://topbraid.org/sparqlmotionfunctions
# imports: http://topbraid.org/sparqlmotionlib

@prefix sp:      <http://spinrdf.org/sp#> .
@prefix spin:    <http://spinrdf.org/spin#> .
@prefix xsd:     <http://www.w3.org/2001/XMLSchema#> .
@prefix afn:     <http://jena.hpl.hp.com/ARQ/function#> .
@prefix sml:     <http://topbraid.org/sparqlmotionlib#> .
@prefix sm:      <http://topbraid.org/sparqlmotion#> .
@prefix smf:     <http://topbraid.org/sparqlmotionfunctions#> .
@prefix rdfs:    <http://www.w3.org/2000/01/rdf-schema#> .
@prefix rdf:     <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix owl:     <http://www.w3.org/2002/07/owl#> .
@prefix :        <http://TQ_Demos.com/ImportExportFiles/ImportExportFiles#> .

<http://TQ_Demos.com/ImportExportFiles/ImportExportFiles>
      a       owl:Ontology ;
      owl:imports <http://topbraid.org/sparqlmotionlib> , 
<http://topbraid.org/sparqlmotionfunctions> ;
      owl:versionInfo "Created with TopBraid Composer"^^xsd:string .

:ApplyConstruct_1
      a       sml:ApplyConstruct ;
      rdfs:label "CreateFileList"^^xsd:string ;
      sm:next :ForEachFile ;
      sml:constructQuery
              [ a       sp:Construct ;
                sp:templates ([ sp:object 
"http://TQ_Demos.com/ImportExportFiles/unnamed0"; ;
                            sp:predicate :anItem ;
                            sp:subject _:b1
                          ] [ sp:object "a1.owl" ;
                            sp:predicate :newName ;
                            sp:subject _:b1
                          ] [ sp:object 
"http://TQ_Demos.com/ImportExportFiles/unnamed2"; ;
                            sp:predicate :anItem ;
                            sp:subject _:b2
                          ] [ sp:object "a2.n3" ;
                            sp:predicate :newName ;
                            sp:subject _:b2
                          ] [ sp:object 
"http://topquadrant.com/Test-movie-db.owl"; ;
                            sp:predicate :anItem ;
                            sp:subject _:b3
                          ] [ sp:object "new-movies.n3" ;
                            sp:predicate :newName ;
                            sp:subject _:b3
                          ]) ;
                sp:where ([ a       sp:Let ;
                            sp:expression
                                    [ a       smf:buildURI ;
                                      sp:arg1 "listNode"
                                    ] ;
                            sp:variable
                                    [ sp:varName "alist"^^xsd:string
                                    ]
                          ])
              ] .

:ForEachFile
      a       sml:IterateOverSelect ;
      rdfs:label "For each file"^^xsd:string ;
      sm:body :GetFileFromWorkspace ;
      sm:next :NullReturnForWebService ;
      sml:selectQuery
              [ a       sp:Select ;
                sp:resultVariables (_:b4 _:b5) ;
                sp:where ([ sp:object _:b4 ;
                            sp:predicate :anItem ;
                            sp:subject _:b6
                          ] [ sp:object _:b5 ;
                            sp:predicate :newName ;
                            sp:subject _:b6
                          ])
              ] .

:GetFileFromWorkspace
      a       sml:ImportRDFFromWorkspace ;
      rdfs:label "Get file from workspace"^^xsd:string ;
      sm:next :SaveFile ;
      sml:baseURI "{?fileURI}"^^xsd:string .

:ImportExportFileList
      a       spin:Function ;
      rdfs:comment "Address as localhost Web service as: 
http://localhost:8083/tbl/actions?action=sparqlmotion&id=ImportExportFileList"^^xsd:string
 ;
      rdfs:label "Save to OWL"^^xsd:string ;
      rdfs:subClassOf spin:Functions ;
      sm:returnModule :NullReturnForWebService .

:NullReturnForWebService
      a       sml:ReturnText ;
      rdfs:label "Null return for web service"^^xsd:string ;
      sml:mimeType "text"^^xsd:string ;
      sml:text "Script finished."^^xsd:string .

:SaveFile
      a       sml:ExportToRDFFile ;
      rdfs:label "Save file"^^xsd:string ;
      sml:baseURI "{?fileURI}"^^xsd:string ;
      sml:targetFilePath "{?name}"^^xsd:string .

_:b6  sp:varName "s"^^xsd:string .

_:b4  sp:varName "fileURI"^^xsd:string .

_:b5  sp:varName "name"^^xsd:string .

Reply via email to