PHP Classes

File: student_rdf.php

Recommend this page to a friend!
  Classes of Herman Veluwenkamp   HV Array To RDF Collection   student_rdf.php   Download  
File: student_rdf.php
Role: Example script
Content type: text/plain
Description: Example including metadata and custom RDF.
Class: HV Array To RDF Collection
Generate XML RDF documents from associative arrays
Author: By
Last change: Fixed typo.
Date: 19 years ago
Size: 2,262 bytes
 

Contents

Class file image Download
<?php
include 'HV_ArrayToRDFCollection.php';

$data = array();

$level1[1]['student'] = array('student_id' => 11,
                             
'student_givenname' => 'John',
                             
'student_familyname' => 'Smith',
                             
'student_registration' => 'Tuesday, 5 July 2005 12:34',
                             
'student_gender' => 'M',
                              );

$level1[2]['student'] = array('student_id' => 12,
                             
'student_givenname' => 'Sarah',
                             
'student_familyname' => 'Brown',
                             
'student_registration' => 'Wednesday, 9 February 2005 14:25',
                             
'student_gender' => 'F',
                              );
$level1[3]['student'] = array('student_id' => 3,
                             
'student_givenname' => 'Charles',
                             
'student_familyname' => 'Craft',
                             
'student_registration' => 'Thursday, 7 April 2005 09:13',
                             
'student_gender' => 'M',
                              );

$level1[4]['student'] = array('student_id' => 25,
                             
'student_givenname' => 'Kelly',
                             
'student_familyname' => 'James',
                             
'student_registration' => 'Friday, 8 April 2005 08:45',
                             
'student_gender' => 'F',
                              );
                             
$data['_seq'] = $level1;


// assign parseType metadata
$metadata['student_id']['parseType'] = 'Integer';
$metadata['student_registration']['parseType'] = 'Date';
$metadata['student_gender']['parseType'] = 'Resource';

HV_ArrayToRDFCollection::$metadata = $metadata;

// extra RDF used as lookup for gender
$extra = <<<EXTRA
<rdf:Description about="urn:resource:student_gender#M">
  <resource:label>Male</resource:label>
</rdf:Description>

<rdf:Description about="urn:resource:student_gender#F">
  <resource:label>Female</resource:label>
</rdf:Description>
EXTRA;

HV_ArrayToRDFCollection::$rdf_resource = $extra;

HV_ArrayToRDFCollection::output($data);

?>