facts-ss-to-erhf-facts.ttl 12.8 KB
# baseURI: http://www.reportinghub.no/test/flow_facts/transform/facts-ss-to-erhf-facts
# imports: file:///www.reportinghub.no/test/flow_facts/data/flow-facts-ss-schema
# imports: file:///www.reportinghub.no/test/flow_facts/data/trym-flow-facts.xls
# imports: http://spinrdf.org/spin
# imports: http://www.reportinghub.no/erhf/data/erh/facts
# imports: http://www.reportinghub.no/erhf/schema/1.0/erh-facts
# imports: http://www.reportinghub.no/np/data/npd

@prefix afn:     <http://jena.hpl.hp.com/ARQ/function#> .
@prefix facts-ss-to-erhf-facts:  <http://www.reportinghub.no/test/flow_facts/transform/facts-ss-to-erhf-facts#> .
@prefix fn:      <http://www.w3.org/2005/xpath-functions#> .
@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 smf:     <http://topbraid.org/sparqlmotionfunctions#> .
@prefix sp:      <http://spinrdf.org/sp#> .
@prefix spif:    <http://spinrdf.org/spif#> .
@prefix spin:    <http://spinrdf.org/spin#> .
@prefix spl:     <http://spinrdf.org/spl#> .
@prefix xsd:     <http://www.w3.org/2001/XMLSchema#> .

<file:///www.reportinghub.no/test/flow_facts/data/flow-facts-ss-schema#flow-facts>
      spin:rule
              [ rdf:type sp:Construct ;
                sp:templates ([ sp:object <http://www.reportinghub.no/erhf/schema/erh-facts#Flow> ;
                            sp:predicate rdf:type ;
                            sp:subject
                                    [ sp:varName "flowuri"^^xsd:string
                                    ]
                          ] [ sp:object
                                    [ sp:varName "npdfield"^^xsd:string
                                    ] ;
                            sp:predicate <http://www.reportinghub.no/erhf/schema/erh-facts#flowPartOfField> ;
                            sp:subject
                                    [ sp:varName "flowuri"^^xsd:string
                                    ]
                          ] [ sp:object
                                    [ sp:varName "flowuid"^^xsd:string
                                    ] ;
                            sp:predicate <http://www.reportinghub.no/erhf/schema/erh-facts#erhid> ;
                            sp:subject
                                    [ sp:varName "flowuri"^^xsd:string
                                    ]
                          ] [ sp:object
                                    [ sp:varName "flowname"^^xsd:string
                                    ] ;
                            sp:predicate <http://www.reportinghub.no/erhf/schema/erh-facts#erhname> ;
                            sp:subject
                                    [ sp:varName "flowuri"^^xsd:string
                                    ]
                          ] [ sp:object
                                    [ sp:varName "flowkinduri"^^xsd:string
                                    ] ;
                            sp:predicate <http://www.reportinghub.no/erhf/schema/erh-facts#hasFlowKind> ;
                            sp:subject
                                    [ sp:varName "flowuri"^^xsd:string
                                    ]
                          ] [ sp:object
                                    [ sp:varName "flowqualuri"^^xsd:string
                                    ] ;
                            sp:predicate <http://www.reportinghub.no/erhf/schema/erh-facts#hasFlowQualifier> ;
                            sp:subject
                                    [ sp:varName "flowuri"^^xsd:string
                                    ]
                          ]) ;
                sp:where ([ sp:object <file:///www.reportinghub.no/test/flow_facts/data/flow-facts-ss-schema#flow-facts> ;
                            sp:predicate rdf:type ;
                            sp:subject spin:_this
                          ] [ sp:object
                                    [ sp:varName "kind"^^xsd:string
                                    ] ;
                            sp:predicate <file:///www.reportinghub.no/test/flow_facts/data/flow-facts-ss-schema#flowKind> ;
                            sp:subject spin:_this
                          ] [ sp:object
                                    [ sp:varName "fieldname"^^xsd:string
                                    ] ;
                            sp:predicate <file:///www.reportinghub.no/test/flow_facts/data/flow-facts-ss-schema#FieldNPDName> ;
                            sp:subject spin:_this
                          ] [ sp:object
                                    [ sp:varName "fieldname"^^xsd:string
                                    ] ;
                            sp:predicate <http://www.reportinghub.no/np/schema/npd#name> ;
                            sp:subject
                                    [ sp:varName "npdfield"^^xsd:string
                                    ]
                          ] [ sp:object <http://www.reportinghub.no/ep/schema/facility#Field> ;
                            sp:predicate rdf:type ;
                            sp:subject
                                    [ sp:varName "npdfield"^^xsd:string
                                    ]
                          ] [ sp:object
                                    [ sp:varName "fieldid"^^xsd:string
                                    ] ;
                            sp:predicate <http://www.reportinghub.no/np/schema/npd#id> ;
                            sp:subject
                                    [ sp:varName "npdfield"^^xsd:string
                                    ]
                          ] [ rdf:type sp:Optional ;
                            sp:elements ([ sp:object
                                                [ sp:varName "flowuid"^^xsd:string
                                                ] ;
                                        sp:predicate <file:///www.reportinghub.no/test/flow_facts/data/flow-facts-ss-schema#flowUID> ;
                                        sp:subject spin:_this
                                      ] [ sp:object
                                                [ sp:varName "flowname"^^xsd:string
                                                ] ;
                                        sp:predicate <file:///www.reportinghub.no/test/flow_facts/data/flow-facts-ss-schema#flowName> ;
                                        sp:subject spin:_this
                                      ])
                          ] [ rdf:type sp:Optional ;
                            sp:elements ([ sp:object
                                                [ sp:varName "flowkind"^^xsd:string
                                                ] ;
                                        sp:predicate <file:///www.reportinghub.no/test/flow_facts/data/flow-facts-ss-schema#flowKind> ;
                                        sp:subject spin:_this
                                      ] [ rdf:type sp:Bind ;
                                        sp:expression
                                                [ rdf:type afn:substr ;
                                                  sp:arg1 [ sp:varName "flowkind"^^xsd:string
                                                          ] ;
                                                  sp:arg2 [ rdf:type sp:add ;
                                                            sp:arg1 [ rdf:type spif:indexOf ;
                                                                      sp:arg1 [ sp:varName "flowkind"^^xsd:string
                                                                              ] ;
                                                                      sp:arg2 ":"
                                                                    ] ;
                                                            sp:arg2 1
                                                          ]
                                                ] ;
                                        sp:variable
                                                [ sp:varName "flowkindname"^^xsd:string
                                                ]
                                      ] [ rdf:type sp:Bind ;
                                        sp:expression
                                                [ rdf:type smf:buildURI ;
                                                  sp:arg1 "erhf:{?flowkindname}" ;
                                                  sp:arg2 [ sp:varName "flowkindname"^^xsd:string
                                                          ]
                                                ] ;
                                        sp:variable
                                                [ sp:varName "flowkinduri"^^xsd:string
                                                ]
                                      ])
                          ] [ rdf:type sp:Optional ;
                            sp:elements ([ sp:object
                                                [ sp:varName "flowqual"^^xsd:string
                                                ] ;
                                        sp:predicate <file:///www.reportinghub.no/test/flow_facts/data/flow-facts-ss-schema#flowQualifier> ;
                                        sp:subject spin:_this
                                      ] [ rdf:type sp:Bind ;
                                        sp:expression
                                                [ rdf:type afn:substr ;
                                                  sp:arg1 [ sp:varName "flowqual"^^xsd:string
                                                          ] ;
                                                  sp:arg2 [ rdf:type sp:add ;
                                                            sp:arg1 [ rdf:type spif:indexOf ;
                                                                      sp:arg1 [ sp:varName "flowqual"^^xsd:string
                                                                              ] ;
                                                                      sp:arg2 ":"
                                                                    ] ;
                                                            sp:arg2 1
                                                          ]
                                                ] ;
                                        sp:variable
                                                [ sp:varName "flowqualname"^^xsd:string
                                                ]
                                      ] [ rdf:type sp:Bind ;
                                        sp:expression
                                                [ rdf:type smf:buildURI ;
                                                  sp:arg1 "erhf:{?flowqualname}" ;
                                                  sp:arg2 [ sp:varName "flowqualname"^^xsd:string
                                                          ]
                                                ] ;
                                        sp:variable
                                                [ sp:varName "flowqualuri"^^xsd:string
                                                ]
                                      ])
                          ] [ rdf:type sp:Bind ;
                            sp:expression
                                    [ rdf:type fn:concat ;
                                      sp:arg1 "Field-" ;
                                      sp:arg2 [ sp:varName "fieldid"^^xsd:string
                                              ] ;
                                      sp:arg3 "-Flow-" ;
                                      sp:arg4 [ sp:varName "flowuid"^^xsd:string
                                              ]
                                    ] ;
                            sp:variable
                                    [ sp:varName "flowlocalname"^^xsd:string
                                    ]
                          ] [ rdf:type sp:Bind ;
                            sp:expression
                                    [ rdf:type smf:buildURI ;
                                      sp:arg1 "http://www.reportinghub.no/erhf/data/erh/facts/{?flowlocalname}" ;
                                      sp:arg2 [ sp:varName "flowlocalname"^^xsd:string
                                              ]
                                    ] ;
                            sp:variable
                                    [ sp:varName "flowuri"^^xsd:string
                                    ]
                          ])
              ] .

<http://www.reportinghub.no/test/flow_facts/transform/facts-ss-to-erhf-facts>
      rdf:type owl:Ontology ;
      owl:imports <file:///www.reportinghub.no/test/flow_facts/data/flow-facts-ss-schema> , <file:///www.reportinghub.no/test/flow_facts/data/trym-flow-facts.xls> , <http://spinrdf.org/spin> , <http://www.reportinghub.no/erhf/data/erh/facts> , <http://www.reportinghub.no/erhf/schema/1.0/erh-facts> , <http://www.reportinghub.no/np/data/npd> ;
      owl:versionInfo "Created with TopBraid Composer"^^xsd:string .