Node Class Reference
from PyKDE4.soprano import *
Subclasses: DOM.Attr, DOM.CharacterData, DOM.Document, DOM.DocumentFragment, DOM.DocumentType, DOM.Element, DOM.Entity, DOM.EntityReference, DOM.Notation, DOM.ProcessingInstruction
Namespace: Soprano
Detailed Description
\class Node node.h Soprano/Node
A Node represents one RDF resource.
Nodes are the cornerstone of RDF data in %Soprano. Four Nodes form one Statement and a Model is essentially a set of Statements.
A Node can have one of four types: EmptyNode, ResourceNode, LiteralNode, and BlankNode. Resource nodes are identified through their URI (uri()), literal nodes have a LiteralValue (literal()) and an optional language string (language()), and blank nodes have a string identifier.
Empty nodes can be used as wildcards in methods such as Model.listStatements.
- Warning:
- Be aware that string literals in %Soprano always have type xsd:string. There is no direct support for rdfs:Literal. Backend implementations should honour this restriction.
Enumerations | |
Type | { EmptyNode, ResourceNode, LiteralNode, BlankNode } |
Methods | |
__init__ (self) | |
__init__ (self, QUrl uri) | |
__init__ (self, QString id) | |
__init__ (self, Soprano.LiteralValue value, QString language=QString()) | |
__init__ (self, Soprano.Node other) | |
QUrl | dataType (self) |
QString | identifier (self) |
bool | isBlank (self) |
bool | isEmpty (self) |
bool | isLiteral (self) |
bool | isResource (self) |
bool | isValid (self) |
QString | language (self) |
Soprano.LiteralValue | literal (self) |
bool | matches (self, Soprano.Node other) |
bool | operator != (self, Soprano.Node other) |
bool | operator == (self, Soprano.Node other) |
bool | operator == (self, QUrl other) |
bool | operator == (self, Soprano.LiteralValue other) |
QString | toN3 (self) |
QString | toString (self) |
Soprano.Node.Type | type (self) |
QUrl | uri (self) |
Static Methods | |
Soprano.Node | createBlankNode (QString id) |
Soprano.Node | createEmptyNode () |
Soprano.Node | createLiteralNode (Soprano.LiteralValue value, QString language) |
Soprano.Node | createResourceNode (QUrl uri) |
Method Documentation
__init__ | ( | self ) |
Default costructor. Creates an empty node.
\sa createEmptyNode()
__init__ | ( | self, | ||
QUrl | uri | |||
) |
Creates a resource node.
- Parameters:
-
uri The URI of the node. If empty the type will be ignored and an empty node will be created.
\sa createResourceNode()
__init__ | ( | self, | ||
QString | id | |||
) |
Creates a blank node.
- Parameters:
-
id An identifier for the blank node.
\sa createBlankNode()
__init__ | ( | self, | ||
Soprano.LiteralValue | value, | |||
QString | language=QString() | |||
) |
Creates a literal node.
- Parameters:
-
value The value of a node. If empty the node will become an empty node.
- Parameters:
-
language The language of the literal value.
\sa createLiteralNode()
__init__ | ( | self, | ||
Soprano.Node | other | |||
) |
Soprano.Node createBlankNode | ( | QString | id | |
) |
Convenience method to create a blank node. Using this method instead of the constructor may result in better readable code.
If you need to create a new blank node which is not used in the model yet and, thus, has a unique identifier see Model.createBlankNode().
- Parameters:
-
id An identifier for the blank node.
- Returns:
- A blank node or an empty Node if the specified identifier was empty.
Soprano.Node createEmptyNode | ( | ) |
Convenience method to create an empty node. Using this method instead of the default constructor may result in better readable code.
- Returns:
- An empty Node.
Soprano.Node createLiteralNode | ( | Soprano.LiteralValue | value, | |
QString | language | |||
) |
Convenience method to create a literal node. Using this method instead of the constructor may result in better readable code.
- Parameters:
-
value The value of a node. If empty the node will become an empty node.
- Parameters:
-
language The language of the literal value.
- Returns:
- A literal node or an empty node if the specified value was empty.
Soprano.Node createResourceNode | ( | QUrl | uri | |
) |
Convenience method to create a resource node. Using this method instead of the constructor may result in better readable code.
- Parameters:
-
uri The URI of the node. If empty the type will be ignored and an empty node will be created.
- Returns:
- A resource Node or an empty Node if the specified URI is empty.
QUrl dataType | ( | self ) |
- Returns:
- The datatype URI of a literal node, i.e. the XML schema type or an empty value if the node is not a literal.
QString identifier | ( | self ) |
Retrieve a blank node's identifier.
- Returns:
- The node's identifier if it is a blank node, a null string otherwise.
bool isBlank | ( | self ) |
- Returns:
- true if the Node is a Blank node (anonymous).
bool isEmpty | ( | self ) |
- Returns:
- true if the Node is empty.
bool isLiteral | ( | self ) |
- Returns:
- true if the Node is a Literal.
bool isResource | ( | self ) |
- Returns:
- true if the Node is a Resource.
bool isValid | ( | self ) |
- Returns:
- true if the Node is a Resource,Literal or Blank.
QString language | ( | self ) |
Each literal value can have an associated language, thus each property can be stored for different languages. An empty language refers to the default language.
- Returns:
- A string representing the language of the literal value or an empty string if the node is not a literal.
Soprano.LiteralValue literal | ( | self ) |
- Returns:
- The Literal value if the node is a Literal node. An null QString otherwise.
bool matches | ( | self, | ||
Soprano.Node | other | |||
) |
Match this node against other. The only difference to operator== is that empty nodes are matched as wildcards, i.e. they match any other node.
- Returns:
- true if this node matches other, false if not.
bool operator != | ( | self, | ||
Soprano.Node | other | |||
) |
bool operator == | ( | self, | ||
Soprano.Node | other | |||
) |
bool operator == | ( | self, | ||
QUrl | other | |||
) |
bool operator == | ( | self, | ||
Soprano.LiteralValue | other | |||
) |
QString toN3 | ( | self ) |
Convert a Node into N3 notation to be used in SPARQL graph patterns.
- Returns:
- A string representing the node in N3 encoding or an empty string for invalid nodes.
\sa toString()
- Since:
- 2.2
QString toString | ( | self ) |
Converts the Node to a string.
- Returns:
- A String representation of the Node, suitable for storage, not really suitable for user readable strings.
\sa LiteralValue.toString(), QUrl.toString(), toN3()
Soprano.Node.Type type | ( | self ) |
- Returns:
- The Node type.
QUrl uri | ( | self ) |
- Returns:
- The URI if the node is a Resource node. An null QUrl otherwise.
Enumeration Documentation
Type |
- Enumerator:
-
EmptyNode = 0 ResourceNode = 1 LiteralNode = 2 BlankNode = 3