A literal (text string) node in an RDF graph.
|
Literals are string values optionally tagged with a language or datatype URI.
An explicit conversion operator is defined from strings to literals as a convenience. The operator converts the string to a literal by returning a literal with that value, and null language and datatype.
The following examples create literal nodes.
C# Example |
Literal thing1 = new Literal("SemWeb: The C# Library"); Literal thing2 = (Literal)"SemWeb: The C# Library"; // explicit operator overload Literal thing3 = new Literal("SemWeb: The C# Library", "en", null); // with language Literal thing3 = new Literal("SemWeb: The C# Library", null, "http://www.w3.org/2001/XMLSchema#string"); // with datatype Console.WriteLine(thing1.Value); Console.WriteLine(thing2.Language); Console.WriteLine(thing3.DataType); |
See Also: Inherited members from Resource.
Creates a new Literal with the given string value. |
Creates a new Literal with the given value, language, and datatype. |
DataType [read-only] | string . The datatype URI of the literal. |
Language [read-only] | string . The language of the literal. |
Uri
[read-only]
abstract |
string . The URI of this resource. (Inherited from Resource.) |
Value [read-only] | string . The value of the literal. |
CompareTo
(Resource) Compares two resources. (Inherited from Resource.) |
|
static |
FromValue
(bool) Returns an XSD-typed boolean literal from the given value. |
static |
FromValue
(byte) Returns an XSD-typed (unsigned) byte literal from the given value. |
static |
FromValue
(DateTime) Returns an XSD-typed dateTime literal from the given value representing a date and UTC time. |
static |
FromValue
(decimal) Returns an XSD-typed decimal literal from the given value. |
static |
FromValue
(double) Returns an XSD-typed double-precision literal from the given value. |
static |
FromValue
(short) Returns an XSD-typed short literal from the given value. |
static |
FromValue
(int) Returns an XSD-typed int literal from the given value. |
static |
FromValue
(long) Returns an XSD-typed long literal from the given value. |
static |
FromValue
(sbyte) Returns an XSD-typed (signed) byte literal from the given value. |
static |
FromValue
(float) Returns an XSD-typed floating-point literal from the given value. |
static |
FromValue
(string) Returns an XSD-typed string literal from the given value. |
static |
FromValue
(TimeSpan) Returns an XSD-typed duration literal from the given value. |
static |
FromValue
(ushort) Returns an XSD-typed unsigned short literal from the given value. |
static |
FromValue
(uint) Returns an XSD-typed unsigned int literal from the given value. |
static |
FromValue
(ulong) Returns an XSD-typed boolean literal from the given value. |
static |
FromValue
(Uri) Returns an XSD-typed URI (anyURI) literal from the given value. |
static |
FromValue
(DateTime, bool, bool) Returns an XSD-typed date or dateTime literal from the given value. |
static |
FromValue
(TimeSpan, bool, bool) Returns an XSD-typed duration or time literal from the given value. |
GetResourceKey
(object) To be added. (Inherited from Resource.) |
|
Normalize
() Creates a normalized form of the literal. |
|
static |
Parse
(string, NamespaceManager) Parses a literal value. |
ParseValue
() Gets a native .NET type for the literl value using a XSD DataType. |
|
SetResourceKey
(object, object) To be added. (Inherited from Resource.) |
Conversion to SemWeb.Literal
(Explicit) Converts a string to a Literal object
whose language and datatype are null. |
Creates a new Literal with the given string value.
Creates a new Literal with the given value, language, and datatype.
The value of the literal.
The language of the literal.
The datatype URI of the literal.
Parses a literal value.
The encoded literal must be in the form of: "value"[@langcode | ^^datatypeURI].
If namespaces is null and a datatype was provided as a QName, or if the QName prefix was not found in the namespace manager, an ArgumentException is thrown.
Converts a string to a Literal object whose language and datatype are null.
Gets a native .NET type for the literl value using a XSD DataType.
If the DataType of the literal is not set, or if the DataType is not one of the following recognized types, the literal's string value is returned.
The recognized types below are all in the http://www.w3.org/2001/XMLSchema# namespace. That is, where it says "string" below, it means the DataType is http://www.w3.org/2001/XMLSchema#string.
DataType(s) | Return Value |
---|---|
string, normalizedString, anyURI | The literal's value, as a string. |
boolean | A bool, true if the literal's value is "true" or "1", false otherwise. |
decimal, integer, positiveInteger, nonPositiveInteger, negativeInteger, nonNegativeInteger | The literal's value as a decimal using System.Decimal.Parse(string). |
float or double | The literal's value as a float for float or double for double, using the appropriate Parse method. |
duration | The literal's value as a TimeSpan using System.TimeSpan.Parse(string). |
dateTime, time, date | The literal's value as a DateTime using System.DateTime.Parse(string). |
long, int, short, byte | The literal's value as a long, int, short, or sbyte using the appropriate Parse method. |
unsignedLong, unsignedInt, unsignedShort, unsignedByte | The literal's value as a ulong, uint, ushort, or byte using the appropriate Parse method. |
Creates a normalized form of the literal.
Returns an XSD-typed floating-point literal from the given value.
Returns an XSD-typed double-precision literal from the given value.
Returns an XSD-typed (unsigned) byte literal from the given value.
Returns an XSD-typed short literal from the given value.
Returns an XSD-typed int literal from the given value.
Returns an XSD-typed long literal from the given value.
Returns an XSD-typed (signed) byte literal from the given value.
Returns an XSD-typed unsigned short literal from the given value.
Returns an XSD-typed unsigned int literal from the given value.
Returns an XSD-typed boolean literal from the given value.
Returns an XSD-typed boolean literal from the given value.
Returns an XSD-typed string literal from the given value.
Returns an XSD-typed URI (anyURI) literal from the given value.
Returns an XSD-typed dateTime literal from the given value representing a date and UTC time.
Returns an XSD-typed date or dateTime literal from the given value.
Returns an XSD-typed duration literal from the given value.
Returns an XSD-typed duration or time literal from the given value.
Returns an XSD-typed decimal literal from the given value.