.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40) .\" .\" 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 .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "RDF::Closure::DatatypeHandling 3pm" .TH RDF::Closure::DatatypeHandling 3pm "2021-09-24" "perl v5.32.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::Closure::DatatypeHandling \- validate and canonicalise typed literals .SH "ANALOGOUS PYTHON" .IX Header "ANALOGOUS PYTHON" RDFClosure/DatatypeHandling.py .SH "DESCRIPTION" .IX Header "DESCRIPTION" Provides datatype handling functions for \s-1OWL 2 RL\s0 and \s-1RDFS\s0 datatypes. .SS "Functional Interface" .IX Subsection "Functional Interface" This module can export four functions: .IP "\(bu" 4 \&\f(CW\*(C`literal_canonical($lit)\*(C'\fR .Sp Given an RDF::Trine::Node::Literal, returns a literal with the canonical lexical value for its given datatype. If the literal is not a valid lexical form for its datatype throws an Error. .Sp If the literal is a plain literal, returns an rdf:PlainLiteral typed literal; if the literal is of an unrecognised datatype, simply returns the original literal. .Sp Note that as per \s-1OWL 2 RL\s0 rules, xsd:dateTime literals are \fInot\fR shifted to \s-1UTC,\s0 even though \s-1XSD\s0 says that \s-1UTC\s0 is the canonical form. By setting the \&\f(CW\*(C`force_utc\*(C'\fR to true, you can force XSD-style canonicalisation. (See the object-oriented interface.) .IP "\(bu" 4 \&\f(CW\*(C`literal_canonical_safe($lit)\*(C'\fR .Sp As per \f(CW\*(C`literal_canonical\*(C'\fR, but in the case where a literal is not a valid lexical form, simply returns the original literal. .IP "\(bu" 4 \&\f(CW\*(C`literal_valid($lit)\*(C'\fR .Sp Returns true iff the literal is a valid lexical form for its datatype. An example of an invalid literal might be: .Sp .Vb 1 \& "2011\-02\-29"^^xsd:date .Ve .IP "\(bu" 4 \&\f(CW\*(C`literals_identical($lit1, $lit2)\*(C'\fR .Sp Returns true iff the two literals are identical according to \s-1OWL 2 RL.\s0 Here are some example pairs that are identical: .Sp .Vb 3 \& # integers and decimals are drawn from the same pool of values \& "1.000"^^xsd:decimal \& "1"^^xsd:integer \& \& # different ways of writing the same datetime \& "2010\-01\-01T12:00:00.000Z"^^xsd:dateTime \& "2010\-01\-01T12:00:00+00:00"^^xsd:dateTime .Ve .Sp Here are some example literals that are not identical: .Sp .Vb 3 \& # floats and decimals are drawn from different pools of values \& "1.000"^^xsd:float \& "1"^^xsd:integer \& \& # according to OWL 2 these are "equal but not identical". \& "2010\-01\-01T12:00:00+00:00"^^xsd:dateTime \& "2010\-01\-01T11:00:00\-01:00"^^xsd:dateTime .Ve .Sp This latter example is affected by \f(CW\*(C`force_utc\*(C'\fR. .IP "\(bu" 4 \&\f(CW\*(C`literal_to_perl($lit)\*(C'\fR .Sp Returns a scalar value for the literal, or an appropriate object with overloaded operators (e.g. DateTime, Math::BigInt). .PP Variables \f(CW$RDF\fR, \f(CW$RDFS\fR, \f(CW$OWL\fR and \f(CW$XSD\fR may also be exported as a convenience. These are RDF::Trine::Namespace objects. Don't modify them. .SS "Object-Oriented Interface" .IX Subsection "Object-Oriented Interface" .Vb 2 \& use RDF::Trine; \& use RDF::Closure::DatatypeHandling qw[$XSD]; \& \& my $lit = RDF::Trine::Node::Literal\->new( \& "2010\-01\-01T11:00:00\-01:00", undef, $XSD\->dateTime); \& my $handler = RDF::Closure::DatatypeHandling\->new(force_utc => 1); \& print $handler\->literal_canonical($lit)\->as_ntriples; .Ve .SH "SEE ALSO" .IX Header "SEE ALSO" RDF::Closure. .PP . .SH "AUTHOR" .IX Header "AUTHOR" Toby Inkster . .SH "COPYRIGHT" .IX Header "COPYRIGHT" Copyright 2008\-2011 Ivan Herman .PP Copyright 2011\-2012 Toby Inkster .PP This library is free software; you can redistribute it and/or modify it under any of the following licences: .IP "\(bu" 4 The Artistic License 1.0 . .IP "\(bu" 4 The \s-1GNU\s0 General Public License Version 1 , or (at your option) any later version. .IP "\(bu" 4 The W3C Software Notice and License . .IP "\(bu" 4 The Clarified Artistic License . .SH "DISCLAIMER OF WARRANTIES" .IX Header "DISCLAIMER OF WARRANTIES" \&\s-1THIS PACKAGE IS PROVIDED \*(L"AS IS\*(R" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.\s0