aboutsummaryrefslogtreecommitdiffstats
path: root/src/writer.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/writer.c')
-rw-r--r--src/writer.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/writer.c b/src/writer.c
index 0fabb7af..4f4a76df 100644
--- a/src/writer.c
+++ b/src/writer.c
@@ -502,15 +502,13 @@ write_literal(SerdWriter* writer,
const char* node_str = serd_node_string(node);
const char* type_uri = datatype ? serd_node_string(datatype) : NULL;
if (supports_abbrev(writer) && type_uri) {
- if (!strncmp(type_uri, NS_XSD, sizeof(NS_XSD) - 1) &&
- (!strcmp(type_uri + sizeof(NS_XSD) - 1, "boolean") ||
- !strcmp(type_uri + sizeof(NS_XSD) - 1, "integer"))) {
+ if (serd_node_equals(datatype, writer->world->xsd_boolean) ||
+ serd_node_equals(datatype, writer->world->xsd_integer)) {
sink(node_str, node->n_bytes, writer);
return true;
}
- if (!strncmp(type_uri, NS_XSD, sizeof(NS_XSD) - 1) &&
- !strcmp(type_uri + sizeof(NS_XSD) - 1, "decimal") &&
+ if (serd_node_equals(datatype, writer->world->xsd_decimal) &&
strchr(node_str, '.') && node_str[node->n_bytes - 1] != '.') {
/* xsd:decimal literals without trailing digits, e.g. "5.", can
not be written bare in Turtle. We could add a 0 which is
@@ -573,11 +571,12 @@ write_uri_node(SerdWriter* const writer,
const char* node_str = serd_node_string(node);
const bool has_scheme = serd_uri_string_has_scheme(node_str);
if (supports_abbrev(writer)) {
- if (field == SERD_PREDICATE && !strcmp(node_str, NS_RDF "type")) {
+ if (field == SERD_PREDICATE &&
+ serd_node_equals(node, writer->world->rdf_type)) {
return sink("a", 1, writer) == 1;
}
- if (!strcmp(node_str, NS_RDF "nil")) {
+ if (serd_node_equals(node, writer->world->rdf_type)) {
return sink("()", 2, writer) == 2;
}
@@ -760,13 +759,13 @@ write_list_obj(SerdWriter* writer,
const SerdNode* predicate,
const SerdNode* object)
{
- if (!strcmp(serd_node_string(object), NS_RDF "nil")) {
+ if (serd_node_equals(object, writer->world->rdf_nil)) {
--writer->indent;
write_sep(writer, SEP_LIST_END);
return true;
}
- if (!strcmp(serd_node_string(predicate), NS_RDF "first")) {
+ if (serd_node_equals(predicate, writer->world->rdf_first)) {
write_sep(writer, SEP_LIST_SEP);
write_node(writer, object, SERD_OBJECT, flags);
}