Tony; Attached please find an example script that adds a new prefix and modifies another prefix by removing the old prefix and adding a new one.

Hard to say what is happening in your script, but I'd guess that your prefix definitions don't exactly match your URIs.  One way to address this is to open your file in Composer, open a resource with the full URI in it, and use Assign Prefix to Namespace... (context triangle in upper-left of Form) to assign a prefix.

-- Scott

On 3/26/12 9:28 AM, abcoates wrote:
[Sorry Scott that I may have accidentally already replied to you directly.]

This issue is a year old, but I seem to be getting exactly the same issue.  I use sml:ModifyPrefixes to add new prefixes before creating URLs with those prefixes in sml:ApplyConstruct (using smf:buildUri to create the URIs dynamically).  I then use sml:ModifyPrefixes again to remove unwanted prefixes.

However, while my Turtle output contains the new prefix definitions, the constructed URLs themselves have been expanded into full URLs.  Additionally, the unwanted prefixes haven't been removed.  Is there some trick to getting sml:ModifyPrefixes to work correctly, something that isn't in the documentation?  Or is there a good example file showing its use?

Thanks, Cheers, Tony.

On Tuesday, March 29, 2011 4:12:55 PM UTC+1, Scott Henninger wrote:
Phil; You can use the sml:ModifyPrefixes module to add prefixes to
your output f]file.

Keep in mind that the script only contains the triples from the
modules in the script "triple stream" (the series of modules connected
by sm:next).  Since the script file is not in the triple stream, no
prefixes or other triples from the script file will appear in the
output. (An exception to this is that if you run a script from TBC and
add the sml:ImportCurrentRDF to the triple stream, the script file's
data will be added to the triple stream.  However,
sml:ImportCurrentRDF has different interpretations in the context of
TBE sessions (the current session's graph) and Web service calls (a
"no current graph: exception).)

On Mar 29, 9:56 am, Phil <[email protected]> wrote:
> We have numerous non-rdf data sources (i.e. text files, spreadsheets,
> etc) where we use sparqlmotion to convert the data in those files to
> rdf.
>
> Our sparqlmotion scripts utilize the "smf:buildURI" to construct URIs
> using our targeted namespaces.  We have added these namespaces to the
> list of Namespace Prefixes in the sparqlmotion script to not only make
> our sparql constructs be more legible, but also with the assumption
> that those prefixes would be written into the rdf files produced from
> the "export to rdf" modules in our sparqlmotion script.
>
> However, the namespace prefixes are NOT be written to the .rdf files
> and this is causing problems when we import those .rdf files into our
> "federated.owl" file because TopBraid Composer ends up assigning "j.0"
> as the prefix for all of the .rdf files generated in this way,
> producing namespace prefix conflicts.
>
> How can get the sparqlmotion scripts to write out the prefix we want
> to use into the individual .rdf files so that when they are imported
> they use the prefix we want them to use (rather than TBC's arbitrary
> "j.0" prefix).
>
> I should note that we follow the practice whereby we do not use
> default namespaces in any of our rdf files so that we can have
> consistent prefixes no matter where the .rdf file is referenced.
>
> Thanks,
> Phil
--
You received this message because you are subscribed to the Google
Group "TopBraid Suite Users", the topics of which include Enterprise Vocabulary Network (EVN), TopBraid Composer,
TopBraid Live, TopBraid Ensemble, SPARQLMotion and SPIN.
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-users?hl=en

--
You received this message because you are subscribed to the Google
Group "TopBraid Suite Users", the topics of which include Enterprise Vocabulary Network (EVN), TopBraid Composer,
TopBraid Live, TopBraid Ensemble, SPARQLMotion and SPIN.
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-users?hl=en
# baseURI: http://support.tq.com/ModifyPrefixExample
# imports: http://topbraid.org/sparqlmotionfunctions
# imports: http://topbraid.org/sparqlmotionlib-tbc

@prefix ex:      <http://support.tq.com/ModifyPrefixExample#> .
@prefix geo:     <http://www.w3.org/2003/01/geo/wgs84_pos#> .
@prefix kennedys:  <http://topbraid.org/examples/kennedys#> .
@prefix owl:     <http://www.w3.org/2002/07/owl#> .
@prefix rdf:     <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs:    <http://www.w3.org/2000/01/rdf-schema#> .
@prefix rel:     <http://myexample.org/relations#> .
@prefix sm:      <http://topbraid.org/sparqlmotion#> .
@prefix sml:     <http://topbraid.org/sparqlmotionlib#> .
@prefix sp:      <http://spinrdf.org/sp#> .
@prefix spif:    <http://spinrdf.org/spif#> .
@prefix spin:    <http://spinrdf.org/spin#> .
@prefix xsd:     <http://www.w3.org/2001/XMLSchema#> .

<http://support.tq.com/ModifyPrefixExample>
      rdf:type owl:Ontology ;
      owl:imports <http://topbraid.org/sparqlmotionlib-tbc> , 
<http://topbraid.org/sparqlmotionfunctions> ;
      owl:versionInfo "Created with TopBraid Composer"^^xsd:string .

ex:AddRelationPrefix
      rdf:type sml:ModifyPrefixes ;
      rdfs:label "Add relation prefix"^^xsd:string ;
      sm:next ex:CreateUncles ;
      sml:addedPrefix "rel http://myexample.org/relations#"^^xsd:string .

ex:ChangeKennedyPrefix
      rdf:type sml:ModifyPrefixes ;
      rdfs:label "Change kennedy prefix"^^xsd:string ;
      sm:next ex:Kennedy_Return ;
      sm:nodeX 207 ;
      sm:nodeY 287 ;
      sml:addedPrefix "xyz http://topbraid.org/examples/kennedys#"^^xsd:string ;
      sml:deletedPrefix "kennedys 
http://topbraid.org/examples/kennedys#"^^xsd:string .

ex:CreateKennedyRelations
      rdf:type sm:Function ;
      rdfs:subClassOf sm:Functions ;
      sm:returnModule ex:Kennedy_Return .

ex:CreateUncles
      rdf:type sml:ApplyConstruct ;
      rdfs:label "Create uncles"^^xsd:string ;
      sm:next ex:ChangeKennedyPrefix ;
      sm:nodeX 306 ;
      sm:nodeY 179 ;
      sml:constructQuery
              [ rdf:type sp:Construct ;
                sp:templates ([ sp:object
                                    [ sp:varName "uncle"^^xsd:string
                                    ] ;
                            sp:predicate
                                    [ sp:varName "unclePred"^^xsd:string
                                    ] ;
                            sp:subject
                                    [ sp:varName "person"^^xsd:string
                                    ]
                          ]) ;
                sp:where ([ sp:object
                                    [ sp:varName "parent"^^xsd:string
                                    ] ;
                            sp:predicate kennedys:parent ;
                            sp:subject
                                    [ sp:varName "person"^^xsd:string
                                    ]
                          ] [ rdf:type sp:TriplePath ;
                            sp:object
                                    [ sp:varName "uncle"^^xsd:string
                                    ] ;
                            sp:path [ rdf:type sp:SeqPath ;
                                      sp:path1 kennedys:parent ;
                                      sp:path2 kennedys:child
                                    ] ;
                            sp:subject
                                    [ sp:varName "parent"^^xsd:string
                                    ]
                          ] [ sp:object kennedys:male ;
                            sp:predicate kennedys:gender ;
                            sp:subject
                                    [ sp:varName "uncle"^^xsd:string
                                    ]
                          ] [ rdf:type sp:Filter ;
                            sp:expression
                                    [ rdf:type sp:ne ;
                                      sp:arg1 [ sp:varName "uncle"^^xsd:string
                                              ] ;
                                      sp:arg2 [ sp:varName "parent"^^xsd:string
                                              ]
                                    ]
                          ] [ rdf:type sp:Bind ;
                            sp:expression
                                    [ rdf:type spif:buildURI ;
                                      sp:arg1 "rel:uncle"
                                    ] ;
                            sp:variable
                                    [ sp:varName "unclePred"^^xsd:string
                                    ]
                          ])
              ] .

<http://support.tq.com/ModifyPrefixExample#Import-kennedys.ttl_1>
      rdf:type sml:ImportRDFFromWorkspace ;
      rdfs:label "Import kennedys.ttl"^^xsd:string ;
      sm:next ex:CreateUncles ;
      sm:nodeX 165 ;
      sm:nodeY 20 ;
      sml:baseURI "http://topbraid.org/examples/kennedys"^^xsd:string .

ex:Kennedy_Return
      rdf:type sml:ReturnRDF ;
      sm:nodeX 406 ;
      sm:nodeY 369 ;
      sml:serialization sml:Turtle .

Reply via email to