| RDF::Redland::Node(3pm) | User Contributed Perl Documentation | RDF::Redland::Node(3pm) |
RDF::Redland::Node - Redland RDF Node (RDF Resource, Property, Literal) Class
use RDF::Redland;
my $node1=new RDF::Redland::Node("Hello, World!");
my $node2=new RDF::Redland::Node($uri); # $uri is an RDF::Redland::URI
my $node3=$node2->clone;
my $node4=new RDF::Redland::URINode("http://example.com/");
my $node5=new RDF::Redland::LiteralNode("Hello, World!");
my $node6=new RDF::Redland::XMLLiteral("<tag>content</tag>");
my $node7=new RDF::Redland::BlankNode("genid1");
# alternate more verbose ways:
my $node4=RDF::Redland::Node->new_from_uri("http://example.com/");
my $node5=RDF::Redland::Node->new_literal("Hello, World!");
my $node6=RDF::Redland::Node->new_xml_literal("<tag>content</tag>");
my $node7=RDF::Redland::Node->new_from_blank_identifier("genid1");
...
print $node4->uri->as_string,"\n"; # Using RDF::Redland::URI::as_string
print $node5->literal_value_as_latin1,"\n";
This class represents RDF URIs, literals and blank nodes in the RDF graph.
If a literal STRING is given, make a plain literal node. If a the argument is of type URI (perl URI or RDF::Redland::URI), make a resource node.
Otherwise if the argument is an RDF::Redland::Node NODE, copy it.
An alternative is:
new RDF::Redland::URINode("http://example.org/");
An alternative is:
new RDF::Redland::LiteralNode("Hello, World!");
new RDF::Redland::LiteralNode("Bonjour monde!", undef, "fr");
An alternative is:
new RDF::Redland::XMLLiteral("<tag>content</tag>");
An alternative is:
new RDF::Redland::BlankNode("id");
The current list of types that are supported are:
$RDF::Redland::Node::Type_Resource
$RDF::Redland::Node::Type_Literal
$RDF::Redland::Node::Type_Blank
Example:
if ($node->type == $RDF::Redland::Node::Type_Resource) {
print "Node is a resource with URI ", $node->uri->as_string, "\n";
} else {
...
}
This method remains but using new_literal is preferred. Instead, for plain literals use:
$node=new RDF::Redland::Node("blah")
$a=new RDF::Redland::Node->new_from_uri($uri_string)
$new_node=$old_node->clone
RDF::Redland::Statement
Dave Beckett - http://www.dajobe.org/
| 2025-01-24 | perl v5.40.0 |