semsol / arc2

ARC RDF Classes for PHP
Other
332 stars 89 forks source link

RDF prefixes not parsed in turtle parser #59

Open samuell opened 10 years ago

samuell commented 10 years ago

Steps to reproduce:

  1. Place the following code in a PHP file, test.php, inside the ARC2 folder:
<?php

require_once('ARC2.php');

// Init parser
$parser = ARC2::getTurtleParser();

$turtle = <<<EOD

@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix cd: <http://www.recshop.fake/cd#> .
@prefix countries: <http://www.countries.org/onto/> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .

<http://www.recshop.fake/cd/Empire Burlesque>
    cd:artist "Bob Dylan" ;
    cd:country countries:USA ;
    cd:company "Columbia" ;
    cd:price "10.90" ;
    cd:year "1985" .

<http://www.recshop.fake/cd/Hide your heart>
    cd:artist "Bonnie Tyler" ;
    cd:country "UK" ;
    cd:company "CBS Records" ;
    cd:price "9.90" ;
    cd:year "1988" .

countries:USA
    rdfs:label "USA" .

countries:Albums
    rdfs:subClassOf countries:MediaCollections .

EOD;

$parser->parse( $turtle );

// Print out the name spaces array
print_r( $parser->nsp );
  1. Execute the php script:
php test.php

Expected result:

Array
(
    [http://www.w3.org/1999/02/22-rdf-syntax-ns#] => rdf
    [http://www.recshop.fake/cd#] => cd
    [http://www.countries.org/onto/] => countries
    [http://www.w3.org/2000/01/rdf-schema#] => rdfs
)

Actual result:

Array
(
    [http://www.w3.org/XML/1998/namespace] => xml
    [http://www.w3.org/1999/02/22-rdf-syntax-ns#] => rdf
    [http://www.w3.org/2001/XMLSchema#] => xsd
)