.\" Automatically generated by Pod::Man 4.07 (Pod::Simple 3.32)
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings. \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote. \*(C+ will
.\" give a nicer C++. Capital omega is used to do unbreakable dashes and
.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
.\" nothing in troff, for use with C<>.
.tr \(*W-
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
. ds -- \(*W-
. ds PI pi
. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
. ds L" ""
. ds R" ""
. ds C` ""
. ds C' ""
'br\}
.el\{\
. ds -- \|\(em\|
. ds PI \(*p
. ds L" ``
. ds R" ''
. ds C`
. ds C'
'br\}
.\"
.\" Escape single quotes in literal strings from groff's Unicode transform.
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\"
.\" If the F register is >0, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
.\" entries marked with X<> in POD. Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.\"
.\" Avoid warning from groff about undefined register 'F'.
.de IX
..
.if !\nF .nr F 0
.if \nF>0 \{\
. de IX
. tm Index:\\$1\t\\n%\t"\\$2"
..
. if !\nF==2 \{\
. nr % 0
. nr F 2
. \}
.\}
.\"
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
.\" Fear. Run. Save yourself. No user-serviceable parts.
. \" fudge factors for nroff and troff
.if n \{\
. ds #H 0
. ds #V .8m
. ds #F .3m
. ds #[ \f1
. ds #] \fP
.\}
.if t \{\
. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
. ds #V .6m
. ds #F 0
. ds #[ \&
. ds #] \&
.\}
. \" simple accents for nroff and troff
.if n \{\
. ds ' \&
. ds ` \&
. ds ^ \&
. ds , \&
. ds ~ ~
. ds /
.\}
.if t \{\
. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
.\}
. \" troff and (daisy-wheel) nroff accents
.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
.ds ae a\h'-(\w'a'u*4/10)'e
.ds Ae A\h'-(\w'A'u*4/10)'E
. \" corrections for vroff
.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
. \" for low resolution devices (crt and lpr)
.if \n(.H>23 .if \n(.V>19 \
\{\
. ds : e
. ds 8 ss
. ds o a
. ds d- d\h'-1'\(ga
. ds D- D\h'-1'\(hy
. ds th \o'bp'
. ds Th \o'LP'
. ds ae ae
. ds Ae AE
.\}
.rm #[ #] #H #V #F C
.\" ========================================================================
.\"
.IX Title "RDF::aREF::Encoder 3pm"
.TH RDF::aREF::Encoder 3pm "2016-12-15" "perl v5.24.1" "User Contributed Perl Documentation"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
.nh
.SH "NAME"
RDF::aREF::Encoder \- encode RDF to another RDF Encoding Form
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
.Vb 2
\& use RDF::aREF::Encoder;
\& my $encoder = RDF::aREF::Encoder\->new;
\&
\& # encode parts of aREF
\&
\& my $qname = $encoder\->qname(\*(Aqhttp://schema.org/Review\*(Aq); # \*(Aqschema_Review\*(Aq
\&
\&
\& my $predicate = $encoder\->predicate({
\& type => \*(Aquri\*(Aq,
\& value => \*(Aqhttp://www.w3.org/1999/02/22\-rdf\-syntax\-ns#type\*(Aq
\& }); # \*(Aqa\*(Aq
\&
\& my $object = $encoder\->object({
\& type => \*(Aqliteral\*(Aq,
\& value => \*(Aqhello, world!\*(Aq,
\& lang => \*(Aqen\*(Aq
\& }); # \*(Aqhello, world!@en\*(Aq
\&
\& # method also accepts RDF::Trine::Node instances
\& my $object = $encoder\->object( RDF::Trine::Resource\->new($iri) );
\&
\& # encode RDF graphs (see also function \*(Aqencode_aref\*(Aq in RDF::aREF)
\& use RDF::Trine::Parser;
\& my $aref = { };
\& RDF::Trine::Parser\->parse_file ( $base_uri, $fh, sub {
\& my $s = shift;
\& $encoder\->triple( $s\->subject, $s\->predicate, $s\->object, $aref );
\& } );
.Ve
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
This module provides methods to encode \s-1RDF\s0 data in another \s-1RDF\s0 Encoding Form
(aREF). As aREF was designed to facilitate creation of \s-1RDF\s0 data, it may be
easier to create aREF \*(L"by hand\*(R" instead of using this module!
.SH "OPTIONS"
.IX Header "OPTIONS"
.SS "ns"
.IX Subsection "ns"
A default namespace map, given as version string of module \s-1RDF::NS\s0 for
stable qNames or as instance of \s-1RDF::NS\s0. The most recent installed version
of \s-1RDF::NS\s0 is used by default. The value \f(CW0\fR can be used to only use
required namespace mappings (rdf, rdfs, owl and xsd).
.SS "subject_map"
.IX Subsection "subject_map"
By default \s-1RDF\s0 graphs with common subject are encoded as aREF predicate map:
.PP
.Vb 3
\& {
\& _id => $subject, $predicate => $object
\& }
.Ve
.PP
Enable this option to always encode as aREF subject map:
.PP
.Vb 3
\& {
\& $subject => { $predicate => $object }
\& }
.Ve
.SH "METHODS"
.IX Header "METHODS"
Note that no syntax checking is applied, e.g. whether a given \s-1URI\s0 is a valid
\&\s-1URI\s0 or whether a given language is a valid language tag!
.ie n .SS "qname( $uri )"
.el .SS "qname( \f(CW$uri\fP )"
.IX Subsection "qname( $uri )"
Abbreviate an \s-1URI\s0 as qName or return \f(CW\*(C`undef\*(C'\fR. For instance
\&\f(CW\*(C`http://purl.org/dc/terms/title\*(C'\fR is abbreviated to "\f(CW\*(C`dct_title\*(C'\fR".
.ie n .SS "uri( $uri )"
.el .SS "uri( \f(CW$uri\fP )"
.IX Subsection "uri( $uri )"
Abbreviate an \s-1URI\s0 or as qName or enclose it in angular brackets.
.ie n .SS "literal( $value, $language_tag, $datatype_uri )"
.el .SS "literal( \f(CW$value\fP, \f(CW$language_tag\fP, \f(CW$datatype_uri\fP )"
.IX Subsection "literal( $value, $language_tag, $datatype_uri )"
Encode a literal \s-1RDF\s0 node by either appending "\f(CW\*(C`@\*(C'\fR\*(L" and an optional
language tag, or \*(R"\f(CW\*(C`^\*(C'\fR" and an datatype \s-1URI.\s0
.ie n .SS "bnode( $identifier )"
.el .SS "bnode( \f(CW$identifier\fP )"
.IX Subsection "bnode( $identifier )"
Encode a blank node by prepending "\f(CW\*(C`_:\*(C'\fR" to its identifier.
.ie n .SS "subject( $subject )"
.el .SS "subject( \f(CW$subject\fP )"
.IX Subsection "subject( $subject )"
.ie n .SS "predicate( $predicate )"
.el .SS "predicate( \f(CW$predicate\fP )"
.IX Subsection "predicate( $predicate )"
.ie n .SS "object( $object )"
.el .SS "object( \f(CW$object\fP )"
.IX Subsection "object( $object )"
Encode an \s-1RDF\s0 subject, predicate, or object respectively. The argument must
either be given as hash reference, as defined in
\&\s-1RDF/JSON\s0 format (see also method
\&\f(CW\*(C`as_hashref\*(C'\fR of RDF::Trine::Model), or as array reference as internally
used by RDF::Trine.
.PP
A hash reference is expected to have the following fields:
.IP "type" 4
.IX Item "type"
one of \f(CW\*(C`uri\*(C'\fR, \f(CW\*(C`literal\*(C'\fR or \f(CW\*(C`bnode\*(C'\fR (required)
.IP "value" 4
.IX Item "value"
the \s-1URI\s0 of the object, its lexical value or a blank node label depending on
whether the object is a uri, literal or bnode
.IP "lang" 4
.IX Item "lang"
the language of a literal value (optional but if supplied it must not be empty)
.IP "datatype" 4
.IX Item "datatype"
the datatype \s-1URI\s0 of the literal value (optional)
.PP
An array reference is expected to consists of
.IP "\(bu" 4
three elements (value, language tag, and datatype uri) for literal nodes,
.IP "\(bu" 4
two elements "\f(CW\*(C`URI\*(C'\fR" and the \s-1URI\s0 for \s-1URI\s0 nodes,
.IP "\(bu" 4
two elements "\f(CW\*(C`BLANK\*(C'\fR" and the blank node identifier for blank nodes.
.ie n .SS "triple( $subject, $predicate, $object, [, $aref ] )"
.el .SS "triple( \f(CW$subject\fP, \f(CW$predicate\fP, \f(CW$object\fP, [, \f(CW$aref\fP ] )"
.IX Subsection "triple( $subject, $predicate, $object, [, $aref ] )"
Encode an \s-1RDF\s0 triple, its elements given as explained for method \f(CW\*(C`subject\*(C'\fR,
\&\f(CW\*(C`predicate\*(C'\fR, and \f(CW\*(C`object\*(C'\fR. If an aREF data structure is given as fourth
argument, the triple is added to this structure, possibly changing an aREF
predicate map to an aRef subject map. Returns \f(CW\*(C`undef\*(C'\fR on failure.
.ie n .SS "add_hashref( $aref, $rdf )"
.el .SS "add_hashref( \f(CW$aref\fP, \f(CW$rdf\fP )"
.IX Subsection "add_hashref( $aref, $rdf )"
Add \s-1RDF\s0 given in \s-1RDF/JSON\s0 format (as returned
by method \f(CW\*(C`as_hashref\*(C'\fR in RDF::Trine::Model).
.ie n .SS "add_iterator( $aref, $iterator )"
.el .SS "add_iterator( \f(CW$aref\fP, \f(CW$iterator\fP )"
.IX Subsection "add_iterator( $aref, $iterator )"
Add a RDF::Trine::Iterator to an aREF subject map.
.PP
\&\fIexperimental\fR
.SH "SEE ALSO"
.IX Header "SEE ALSO"
RDF::aREF::Decoder, RDF::Trine::Node