aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/serdi.c15
-rw-r--r--src/validate.c3
2 files changed, 14 insertions, 4 deletions
diff --git a/src/serdi.c b/src/serdi.c
index 0955079f..70c52682 100644
--- a/src/serdi.c
+++ b/src/serdi.c
@@ -56,6 +56,7 @@ print_usage(const char* name, bool error)
fprintf(os, "Read and write RDF syntax.\n");
fprintf(os, "Use - for INPUT to read from standard input.\n\n");
fprintf(os, " -I BASE_URI Input base URI.\n");
+ fprintf(os, " -V Validate inputs.\n");
fprintf(os, " -a Write ASCII output if possible.\n");
fprintf(os, " -b Fast bulk output for large serialisations.\n");
fprintf(os, " -c PREFIX Chop PREFIX from matching blank node IDs.\n");
@@ -147,6 +148,7 @@ main(int argc, char** argv)
bool bulk_write = false;
bool no_inline = false;
bool osyntax_set = false;
+ bool validate = false;
bool use_model = false;
bool quiet = false;
size_t stack_size = 4194304;
@@ -167,6 +169,8 @@ main(int argc, char** argv)
}
base = serd_new_uri(SERD_MEASURE_STRING(argv[a]));
+ } else if (argv[a][1] == 'V') {
+ validate = use_model = true;
} else if (argv[a][1] == 'a') {
writer_flags |= SERD_WRITE_ASCII;
} else if (argv[a][1] == 'b') {
@@ -314,9 +318,10 @@ main(int argc, char** argv)
SerdSink* inserter = NULL;
const SerdSink* sink = NULL;
if (use_model) {
- const SerdModelFlags flags = SERD_INDEX_SPO |
- (input_has_graphs ? SERD_INDEX_GRAPHS : 0u) |
- (no_inline ? 0u : SERD_INDEX_OPS);
+ const SerdModelFlags flags =
+ SERD_INDEX_SPO | (input_has_graphs ? SERD_INDEX_GRAPHS : 0u) |
+ (no_inline ? 0u : SERD_INDEX_OPS) | (validate ? SERD_STORE_CURSORS : 0u);
+
model = serd_model_new(world, flags);
inserter = serd_inserter_new(model, env, NULL);
sink = inserter;
@@ -391,6 +396,10 @@ main(int argc, char** argv)
}
free(prefix);
+ if (!st && validate) {
+ st = serd_validate(model);
+ }
+
if (st <= SERD_FAILURE && use_model) {
const SerdSink* writer_sink = serd_writer_sink(writer);
SerdRange* range = serd_model_all(model);
diff --git a/src/validate.c b/src/validate.c
index 2aaae607..46291b64 100644
--- a/src/validate.c
+++ b/src/validate.c
@@ -791,7 +791,8 @@ static void
init_uris(URIs* uris)
{
#define URI(prefix, suffix) \
- uris->prefix##_##suffix = serd_new_uri(NS_##prefix #suffix)
+ uris->prefix##_##suffix = \
+ serd_new_uri(SERD_STATIC_STRING(NS_##prefix #suffix))
URI(owl, Class);
URI(owl, DatatypeProperty);