RDF::R...::Node(3pm)
π NAME π
RDF::Redland::Node β the Redland RDF Node class, aka your one-stop glow-up for RDF Resources, Properties and Literals π
So bestie, this is RDF::Redland::Node, and it lives in the RDF::Redland perl module fam (that's the 3pm situation, iykyk). Come thru β¨
π¦ SYNOPSIS π¦
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";
πΈ DESCRIPTION πΈ
This class is literally the main character of RDF URIs, literals and blank nodes in the RDF graph. That's the whole vibe. π
π CONSTRUCTORS π
New node, who dis? β¨
new[STRING | URI | NODE] β makes a brand new URI node, a literal node, or copies a node that already exists. Here's the tea π:- If you hand it a literal STRING, it makes a plain literal node.
- If the argument is of type URI (a perl URI or a
RDF::Redland::URI), it makes a resource node. - Otherwise, if the argument is an
RDF::Redland::NodeNODE, it copies it. Periodt.
new_from_uriURI β makes a new URI node. π« URI can be either aRDF::Redland::URIobject, a perl URI class, or just a literal string. No cap.
An alternative is:
new RDF::Redland::URINode("http://example.org/");
new_literalSTRING [DATATYPE [XML_LANGUAGE]] β makes a new literal node for a literal value STRING. You can also pass the optional datatype URI DATATYPE (which wants aRDF::Redland::URI, a perl URI, or a string) and the language (that's thexml:langattribute, bestie) XML_LANGUAGE. π«Ά
An alternative is:
new RDF::Redland::LiteralNode("Hello, World!");
new RDF::Redland::LiteralNode("Bonjour monde!", undef, "fr");
new_xml_literalSTRING β makes a new XML datatyped literal node for the XML inside STRING. Iconic behaviour fr fr. π§
An alternative is:
new RDF::Redland::XMLLiteral("<tag>content</tag>");
new_from_blank_identifierIDENTIFIER β makes a new blank node with blank node identifier IDENTIFIER. π
An alternative is:
new RDF::Redland::BlankNode("id");
cloneβ copies aRDF::Redland::Node. Twin energy, obsessed. π
β¨ METHODS β¨
Okay so here's where the actual slay happens π
uriβ gets the current URI of the node, as anRDF::Redland::URIobject.blank_identifierβ gets the current blank identifier of the node.typeβ gets the node type. β οΈ Lowkey important: it's recommended to use theis_resource,is_literaloris_blankmethods in preference to this one (they're both simpler and quicker, bestie β the way that they ate π).
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 {
...
}
is_resourceβ returns true if the node is a resource (with a URI). πis_literalβ returns true if the node is a literal. πΈis_blankβ returns true if the node is a blank nodeID.literal_valueβ gets the node literal value string as UTF-8 (when the node is of type$RDF::Redland::Node::Type_Literal). πliteral_value_as_latin1β gets the node literal value string converted from UTF-8 to ISO Latin-1 (when the node is of type$RDF::Redland::Node::Type_Literal). πliteral_value_languageβ gets the node literal XML language (when the node is of type$RDF::Redland::Node::Type_Literal), orundefif it's not present. πliteral_value_is_wf_xmlβ returns non 0 if the literal string is well formed XML (when the node is of type$RDF::Redland::Node::Type_Literal). β¨literal_datatypeβ returns theRDF::Redland::URIof the literal datatype, orundefif it isn't a datatype.as_stringβ returns theRDF::Redland::Nodeformatted as a string (UTF-8 encoded). π¦equalsNODE β returns non zero if this node is equal to NODE. Twin check β
π OLDER METHODS π
These are the legacy girlies. Still here, still valid, but there's a fresher way to do things now. π
new_from_literalSTRING XML_LANGUAGE IS_WF β creates a newRDF::Redland::Nodeobject for a literal value STRING with XML language (that's thexml:langattribute π) XML_LANGUAGE, and if the content is well formed XML, when IS_WF is non 0. XML_LANGUAGE is optional and can be set toundef.
This method remains, but using new_literal is preferred. Instead, for plain literals use:
$node=new RDF::Redland::Node("blah")
new_from_typed_literalSTRING [DATATYPE [XML_LANGUAGE]] β renamed tonew_literalwith same arguments. Same girl, new name πnew_from_uri_stringURI_STRING β creates a newRDF::Redland::Nodeobject for a resource with URI URI_STRING. It is equivalent to use the shorter:
$a=new RDF::Redland::Node->new_from_uri($uri_string)
new_from_nodeNODE β creates a newRDF::Redland::Nodeobject from an existingRDF::Redland::NodeNODE (copy constructor situation). It is equivalent to use:
$new_node=$old_node->clone
π₯ SEE ALSO π₯
RDF::Redland::Statementβ go give her a read too, bestie π«Ά
π AUTHOR π
Dave Beckett β http://www.dajobe.org/ π (hi Dave, you ate, no crumbs)
And that's the whole page, fr fr. This was perl v5.42.3, dated 2026-08-20, RDF::R...::Node(3pm) β stream it, screenshot it, tell your friends. Slay π
β¨π
π¦ where this page comes from
- ubuntu stonking: librdf-perl 1.0.17.1+dfsg-9build1 Β· LGPL-2.1-or-later OR Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms