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 blank nodes have a string identifier.
Empty nodes can be used as wildcards in methods such as Model.listStatements.
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 | |||
) |
Creates a literal node.
- Parameters:
-
value The value of a node. If empty the node will become an empty node.
\sa createLiteralNode()
- Since:
- 2.3
SOPRANO_CONSTRUCTOR Node | ( | self, | ||
Soprano.LiteralValue | value, | |||
QString | language | |||
) |
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()
- Deprecated:
- Use Soprano.Node.Node( const LiteralValue& ) and Soprano.LiteralValue.createPlainLiteral( const QString&, const LanguageTag& )
__init__ | ( | self, | ||
Soprano.Node | other | |||
) |
Copy constructor.
__init__ | ( | self, | ||
Soprano.LiteralValue | value, | |||
QString | language | |||
) |
Format a blank node identifier as N3 string to be used in SPARQL queries.
- Returns:
- A string representing the blank identifier in N3 encoding or an empty string for invalid/empty ids.
Example:
_:blankNode
\sa toN3
- Since:
- 2.3
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 | |
) |
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.
- Returns:
- A literal node or an empty node if the specified value was empty.
- Since:
- 2.3
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.
- Deprecated:
- Use Soprano.Node.createLiteralNode( const LiteralValue& ) and Soprano.LiteralValue.createPlainLiteral( const QString&, const LanguageTag& )
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 LiteralNode.
QString identifier | ( | self ) |
Retrieve a blank node's identifier.
- Returns:
- The node's identifier if it is a BlankNode, a null string otherwise.
bool isBlank | ( | self ) |
- Returns:
- true if the node is a BlankNode (anonymous).
bool isEmpty | ( | self ) |
- Returns:
- true if the node is empty.
bool isLiteral | ( | self ) |
- Returns:
- true if the node is a LiteralNode.
bool isResource | ( | self ) |
- Returns:
- true if the node is a ResourceNode.
bool isValid | ( | self ) |
- Returns:
- true if the node is a ResourceNode, LiteralNode or BlankNode.
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.
- Deprecated:
- Language exists on the Soprano.LiteralValue. Use Soprano.Node.literal() and Soprano.LiteralValue.language().
Soprano.LiteralValue literal | ( | self ) |
- Returns:
- The literal value if the node is a LiteralNode. An null QString otherwise.
QString literalToN3 | ( | Soprano.LiteralValue | literal | |
) |
Format a literal value as N3 string to be used in SPARQL queries.
- Returns:
- A string representing the literal in N3 encoding or an empty string for invalid literals.
Examples:
"Hello World"^^<http://www.w3.org/2001/XMLSchema#string> "09-08-1977T17:42.234Z"^^<http://www.w3.org/2001/XMLSchema#dateTime>
\sa toN3
- Since:
- 2.3
bool matches | ( | self, | ||
Soprano.Node | other | |||
) |
Match this node against template node other. The only difference to operator== is that empty nodes are matched as wildcards, i.e. they match any other node.
Be aware that the following is NOT always true since only other is treated a a wildcard:
// NOT always true: a.matches(b) == b.matches(a)
- Returns:
- true if this node matches other, false if not.
\sa Statement.matches
bool operator != | ( | self, | ||
Soprano.Node | other | |||
) |
Comparision operator.
- Returns:
- true if this node and other differ.
bool operator == | ( | self, | ||
Soprano.Node | other | |||
) |
Comparision operator.
- Returns:
- true if this node and other are equal.
bool operator == | ( | self, | ||
QUrl | uri | |||
) |
Comparision operator.
- Returns:
- true if this node is a ResourceNode and has URI uri.
bool operator == | ( | self, | ||
Soprano.LiteralValue | other | |||
) |
Comparision operator.
- Returns:
- true if this node is a LiteralNode and has literal value other.
Format a resource URI as N3 string to be used in SPARQL queries.
- Returns:
- A string representing the resource in N3 encoding or an empty string for invalid URIs.
Example:
<http://soprano.sourceforce.net/>
\sa toN3
- Since:
- 2.3
QString toN3 | ( | self ) |
Convert a Node into N3 notation to be used in SPARQL graph patterns.
Examples:
<http://soprano.sourceforce.net/> "Hello World"^^<http://www.w3.org/2001/XMLSchema#string> "09-08-1977T17:42.234Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> _:blankNode
- 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 ResourceNode. An null QUrl otherwise.
Enumeration Documentation
Type |
- Enumerator:
-
EmptyNode = 0 ResourceNode = 1 LiteralNode = 2 BlankNode = 3