#PODNAME: RDF::Lazy::Tutorial
#ABSTRACT: Tutorial to get started with RDF::Lazy
__END__
=pod
=head1 NAME
RDF::Lazy::Tutorial - Tutorial to get started with RDF::Lazy
=head1 VERSION
version 0.071
=encoding utf-8
=head1 A short introduction to RDF::Lazy as RDF templating system
=head2 Three kinds of nodes
The basic object in RDF::Lazy is a node (L). A node represents
an RDF node in an RDF graph. Every nody can be stringified to its value:
"$x" Perl syntax
[% x %] Template Toolkit syntax
{$x} Smarty syntax
There are three kinds of nodes:
=over 4
=item resource nodes
implemented by L and stringified to their URI, for
instance C.
=item literal nodes
implemented by L and stringified to their string value.
instance C.
=item blank nodes
implemented by L and stringified to C followed by
their internal blank node identifier, for instance C.
=back
Nodes have a couple of useful methods. For instance you can check the kind
of a node C with the methods C (or its alias C),
C, and C:
$x->is_literal Perl syntax
[% x.is_literal %] Template Toolkit syntax
{$x->is_literal} or {$x.is_literal} Smarty syntax
The method C is automatically called to stringify a node, so C
and C<str>> are equivalent. In HTML templates you can use the method
C to HTML/XML-escape the stringified node value:
[% x.esc %] Template Toolkit syntax
{$x->esc} or {$x.esc} Smarty syntax
=head2 No nodes without graph
Each node in RDF::Lazy belongs to a particular RDF graph (L). You
can access a node's graph by its C method, if needed. Graphs have some
factory methods to create new node objects:
$g->uri("http://example.org/foo") A resource node, belonging to $g
$g->literal("hello world") A literal node, belonging to $g
$g->blank("n0815") A blank node, belonging to $g
The graph methods C and C are handy o dump the whole graph in
Turtle syntax. The latter wraps and escapes Turtle for HTML output:
[% g.ttlpre %]
For instance you can show the number of triples in a node's graph like this:

The node's graph contains [% x.graph.size %] triples.

=head2 Traversing the graph
One can traverse the RDF graph from any node. For instance, given a
C node, one can get another resource linked via C:
if ( $x->type('foaf:Person') ) {
$another_person = $x->foaf_knows;
}
=head1 AUTHOR
Jakob Voß
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2011 by Jakob Voß.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=cut