| 1 | <?PHP | 
|---|
| 2 |  | 
|---|
| 3 | /* RDFInt.php - RDF Interfaces for PHP | 
|---|
| 4 | * Copyright 2011 netlabs.org | 
|---|
| 5 | * Author: Christian Langanke, Adrian Gschwend | 
|---|
| 6 | * | 
|---|
| 7 | * Licensed under the Apache License, Version 2.0 (the "License"); | 
|---|
| 8 | * you may not use this file except in compliance with the License. | 
|---|
| 9 | * You may obtain a copy of the License at | 
|---|
| 10 | * | 
|---|
| 11 | *     http://www.apache.org/licenses/LICENSE-2.0 | 
|---|
| 12 | * | 
|---|
| 13 | * Unless required by applicable law or agreed to in writing, software | 
|---|
| 14 | * distributed under the License is distributed on an "AS IS" BASIS, | 
|---|
| 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
|---|
| 16 | * See the License for the specific language governing permissions and | 
|---|
| 17 | * limitations under the License. | 
|---|
| 18 | */ | 
|---|
| 19 |  | 
|---|
| 20 | // load library setup | 
|---|
| 21 | require_once( '../sample_config.php'); | 
|---|
| 22 | define( 'RDFINT', getenv( 'PHP_LIBROOT_RDFINT')); | 
|---|
| 23 | require_once( RDFINT.'/rdfa.php'); | 
|---|
| 24 |  | 
|---|
| 25 | $debugger = \fDebug::getInstance(); | 
|---|
| 26 | const debugcontext = "RDFA_SAMPLE"; | 
|---|
| 27 |  | 
|---|
| 28 | $turtlefile = "sample.ttl"; | 
|---|
| 29 |  | 
|---|
| 30 | // --------------------------------------------------------------- | 
|---|
| 31 |  | 
|---|
| 32 | $aNamespace = array( 'rdf'      => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#', | 
|---|
| 33 | 'foaf'     => 'http://xmlns.com/foaf/0.1/', | 
|---|
| 34 | 'resource' => 'http://data.uduvudu.org/resource/'); | 
|---|
| 35 |  | 
|---|
| 36 | // setup data RDF object | 
|---|
| 37 | $rdfaData = new \rdfa\Data(); | 
|---|
| 38 |  | 
|---|
| 39 | // setup namespace mappings | 
|---|
| 40 | foreach ( $aNamespace as $prefix => $uriNamespace) { | 
|---|
| 41 | $rdfaData->setMapping( $prefix, $uriNamespace); | 
|---|
| 42 | } | 
|---|
| 43 |  | 
|---|
| 44 | // parse data | 
|---|
| 45 | $rdfaData->parse( $turtlefile); | 
|---|
| 46 |  | 
|---|
| 47 | $validTypes = array( 'application/rdf+xml', // same as 'application/rdfxml' | 
|---|
| 48 | 'text/turtle', | 
|---|
| 49 | 'application/x-turtle', | 
|---|
| 50 | 'text/n3', | 
|---|
| 51 | 'application/json'); | 
|---|
| 52 |  | 
|---|
| 53 | // these call must return a proper serialization | 
|---|
| 54 | foreach ( $validTypes as $type) { | 
|---|
| 55 | $doc = $rdfaData->_serialize( $type); | 
|---|
| 56 | $debugger->sendMessage( "Serialized as $type\n$doc", debugcontext); | 
|---|
| 57 | } | 
|---|
| 58 |  | 
|---|
| 59 | ?> | 
|---|