#!/usr/bin/perl
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

use RDFStore::NodeFactory;
use RDFStore::Parser::SiRPAC;
use RDFStore::Vocabulary::RDF;

my $factory = new RDFStore::NodeFactory();

my $p=new RDFStore::Parser::SiRPAC(
		Style => 'RDFStore::Parser::Styles::RDFStore::Model',
                NodeFactory =>          $factory,
                style_options   => { store_options => { FreeText => 1 } } );

my $model = $p->parsefile("http://www.kanzaki.com/info/rss.rdf");

#Stanford API
my $iterator = $model->find( undef, $RDFStore::Vocabulary::RDF::type, $factory->createResource("http://purl.org/rss/1.0/item") )->elements;

while ( my $st = $iterator->each ) {
	print "each: ",$st->toString,"\n";
	};

# or
for ( 	my $st = $iterator->first;
	$iterator->hasnext;
	$st = $iterator->next ) {
	print "for: ",$st->toString,"\n";
	};

#free-text Stanford API - i.e. literal contains 'XML' or 'recodings'
$iterator = $model->find( undef, $factory->createResource("http://purl.org/rss/1.0/title"), undef, undef, 0, 'xMl','recodings' )->elements;
while ( my $st = $iterator->each ) {
	print "freetext: ",$st->toString,"\n";
	};

#serialise back to some strawman RDF
my $strawman_rdf = $model->toStrawmanRDF;
