NAME
RDF::aREF::Encoder - encode RDF to another RDF Encoding Form
SYNOPSIS
use RDF::aREF::Encoder;
my $encoder = RDF::aREF::Encoder->new;
my $qname = $encoder->qname('http://schema.org/Review'); # 'schema_Review'
my $predicate = $encoder->predicate(
'http://www.w3.org/1999/02/22-rdf-syntax-ns#type'
); # 'a'
my $object = $encoder->object({
type => 'literal',
value => 'hello, world!',
lang => 'en'
}); # 'hello, world!@en'
DESCRIPTION
This module provides methods to encode RDF data in another RDF Encoding Form (aREF). aREF was designed to facilitate creation of RDF data, so consider not using this module unless you already have RDF data.
OPTIONS
ns
A default namespace map, given either as hash reference or as version string of module RDF::NS. The most recent installed version of RDF::NS is used by default.
METHODS
qname( $uri )
Abbreviate an URI or return undef. For instance http://purl.org/dc/terms/title
is abbreviated to dct_title
.
predicate( $predicate )
Return an predicate URI as qname, if possible, or as given URI otherwise.
uri( $uri )
Abbreviate an URI or enclose it in angular brackets.
object( $object )
Encode an RDF object given in RDF/JSON format, that is a hash reference with the following fields:
- type
-
one of
uri
,literal
orbnode
(required) - value
-
the URI of the object, its lexical value or a blank node label depending on whether the object is a uri, literal or bnode
- lang
-
the language of a literal value (optional but if supplied it must not be empty)
- datatype
-
the datatype URI of the literal value (optional)
Please consider encoding by hand if you try to express non-RDF data in aREF: append "@
" and an optional language tag to literal strings, append "^
" and a datatype to datatype values, and abbreviate URIs as qualified names (see method qname) or put them in anglular brackets <...>
.