From 1d32c6e37bb4409719d6170c4b0e45cd3557df9a Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 3 Mar 2013 04:53:59 +0000 Subject: Don't write xsd:decimal literals to Turtle bare if they would not be read back with the same type. Run thru tests on manifest-based test suites. git-svn-id: http://svn.drobilla.net/serd/trunk@428 490d8e77-9747-427b-9fa3-0b8f29cee8a0 --- src/writer.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/writer.c b/src/writer.c index 3c94d087..380a561d 100644 --- a/src/writer.c +++ b/src/writer.c @@ -442,10 +442,18 @@ write_node(SerdWriter* writer, const char* type_uri = (const char*)datatype->buf; 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, "decimal") || !strcmp(type_uri + sizeof(NS_XSD) - 1, "integer"))) { sink(node->buf, node->n_bytes, writer); break; + } else if (!strcmp(type_uri + sizeof(NS_XSD) - 1, "decimal") && + strchr((const char*)node->buf, '.') && + node->buf[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 + prettier, but changes the text and breaks round tripping. + */ + sink(node->buf, node->n_bytes, writer); + break; } } if (writer->syntax != SERD_NTRIPLES -- cgit v1.2.1