1RDF::Redland::Node(3) User Contributed Perl DocumentationRDF::Redland::Node(3)
2
3
4

NAME

6       RDF::Redland::Node - Redland RDF Node (RDF Resource, Property, Literal)
7       Class
8

SYNOPSIS

10         use RDF::Redland;
11         my $node1=new RDF::Redland::Node("Hello, World!");
12         my $node2=new RDF::Redland::Node($uri); # $uri is an RDF::Redland::URI
13         my $node3=$node2->clone;
14
15         my $node4=new RDF::Redland::URINode("http://example.com/");
16         my $node5=new RDF::Redland::LiteralNode("Hello, World!");
17         my $node6=new RDF::Redland::XMLLiteral("<tag>content</tag>");
18         my $node7=new RDF::Redland::BlankNode("genid1");
19
20         # alternate more verbose ways:
21         my $node4=RDF::Redland::Node->new_from_uri("http://example.com/");
22         my $node5=RDF::Redland::Node->new_literal("Hello, World!");
23         my $node6=RDF::Redland::Node->new_xml_literal("<tag>content</tag>");
24         my $node7=RDF::Redland::Node->new_from_blank_identifier("genid1");
25         ...
26
27         print $node4->uri->as_string,"\n";  # Using RDF::Redland::URI::as_string
28         print $node5->literal_value_as_latin1,"\n";
29

DESCRIPTION

31       This class represents RDF URIs, literals and blank nodes in the RDF
32       graph.
33

CONSTRUCTORS

35       new [STRING | URI | NODE]
36           Create a new URI node, literal node or copy an existing node.
37
38           If a literal STRING is given, make a plain literal node.  If a the
39           argument is of type URI (perl URI or RDF::Redland::URI), make a
40           resource node.
41
42           Otherwise if the argument is an RDF::Redland::Node NODE, copy it.
43
44       new_from_uri URI
45           Create a new URI node.  URI can be either a RDF::Redland::URI
46           object, a perl URI class or a literal string.
47
48           An alternative is:
49
50             new RDF::Redland::URINode("http://example.org/");
51
52       new_literal STRING [DATATYPE [XML_LANGUAGE]]
53           Create a new literal node for a literal value STRING.  Optional
54           datatype URI DATATYPE (RDF::Redland::URI, perl URI or string) and
55           language (xml:lang attribute) XML_LANGUAGE may also be given.
56
57           An alternative is:
58
59              new RDF::Redland::LiteralNode("Hello, World!");
60              new RDF::Redland::LiteralNode("Bonjour monde!", undef, "fr");
61
62       new_xml_literal STRING
63           Create a new XML datatyped literal node for the XML in STRING.
64
65           An alternative is:
66
67             new RDF::Redland::XMLLiteral("<tag>content</tag>");
68
69       new_from_blank_identifier IDENTIFIER
70           Create a new blank node with blank node identifier IDENTIFIER.
71
72           An alternative is:
73
74             new RDF::Redland::BlankNode("id");
75
76       clone
77           Copy a RDF::Redland::Node.
78

METHODS

80       uri Get the current URI of the node as an RDF::Redland::URI object.
81
82       blank_identifier
83           Get the current blank identifier of the node
84
85       type
86           Get the node type.  It is recommended to use the is_resource,
87           is_literal or is_blank methods in preference to this (both simpler
88           and quicker).
89
90           The current list of types that are supported are:
91
92             $RDF::Redland::Node::Type_Resource
93             $RDF::Redland::Node::Type_Literal
94             $RDF::Redland::Node::Type_Blank
95
96           Example:
97
98             if ($node->type == $RDF::Redland::Node::Type_Resource) {
99               print "Node is a resource with URI ", $node->uri->as_string, "\n";
100             } else {
101               ...
102             }
103
104       is_resource
105           Return true if node is a resource (with a URI)
106
107       is_literal
108           Return true if node is a literal
109
110       is_blank
111           Return true if node is a blank nodeID
112
113       literal_value
114           Get the node literal value string as UTF-8 (when the node is of
115           type $RDF::Redland::Node::Type_Literal)
116
117       literal_value_as_latin1
118           Get the node literal value string converted from UTF-8 to ISO
119           Latin-1 (when the node is of type
120           $RDF::Redland::Node::Type_Literal)
121
122       literal_value_language
123           Get the node literal XML language (when the node is of type
124           $RDF::Redland::Node::Type_Literal) or undef if not present.
125
126       literal_value_is_wf_xml
127           Return non 0 if the literal string is well formed XML (when the
128           node is of type $RDF::Redland::Node::Type_Literal).
129
130       literal_datatype
131           Return the RDF::Redland::URI of the literal datatype or undef if it
132           is not a datatype.
133
134       as_string
135           Return the RDF::Redland::Node formatted as a string (UTF-8
136           encoded).
137
138       equals NODE
139           Return non zero if this node is equal to NODE
140

OLDER METHODS

142       new_from_literal STRING XML_LANGUAGE IS_WF
143           Create a new RDF::Redland::Node object for a literal value STRING
144           with XML language (xml:lang attribute) XML_LANGUAGE and if content
145           is well formed XML, when IS_WF is non 0.  XML_LANGUAGE is optional
146           can can be set to undef.
147
148           This method remains but using new_literal is prefered.  Instead,
149           for plain literals use:
150
151             $node=new RDF::Redland::Node("blah")
152
153       new_from_typed_literal STRING [DATATYPE [XML_LANGUAGE]]
154           Renamed to new_literal with same arguments.
155
156       new_from_uri_string URI_STRING
157           Create a new RDF::Redland::Node object for a resource with URI
158           URI_STRING.  It is equivalent to use the shorter:
159
160             $a=new RDF::Redland::Node->new_from_uri($uri_string)
161
162       new_from_node NODE
163           Create a new RDF::Redland::Node object from existing
164           RDF::Redland::Node NODE (copy constructor).  It is equivalent to
165           use:
166
167             $new_node=$old_node->clone
168

SEE ALSO

170       RDF::Redland::Statement
171

AUTHOR

173       Dave Beckett - http://www.dajobe.org/
174
175
176
177perl v5.28.0                      2011-05-09             RDF::Redland::Node(3)
Impressum