From b103dfc647c18626eea476392db0e8ff9de16792 Mon Sep 17 00:00:00 2001 From: Claus Stadler Date: Thu, 5 Sep 2024 17:49:25 +0200 Subject: [PATCH] Another improvement for --out-format --- .../cli/main/SparqlIntegrateCmdImpls.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/rdf-processing-toolkit-cli/src/main/java/org/aksw/sparql_integrate/cli/main/SparqlIntegrateCmdImpls.java b/rdf-processing-toolkit-cli/src/main/java/org/aksw/sparql_integrate/cli/main/SparqlIntegrateCmdImpls.java index 0e20596..e6e568f 100644 --- a/rdf-processing-toolkit-cli/src/main/java/org/aksw/sparql_integrate/cli/main/SparqlIntegrateCmdImpls.java +++ b/rdf-processing-toolkit-cli/src/main/java/org/aksw/sparql_integrate/cli/main/SparqlIntegrateCmdImpls.java @@ -244,14 +244,23 @@ public static int sparqlIntegrate(CmdSparqlIntegrateMain cmd) throws Exception { // If a format is given it takes precedence - otherwise try to use the filename String outFormat = cmd.outFormat; + + // Format source can be either a filename "foo.nt", a file extension "ttl" or a format string "turtle/pretty" String formatSource = outFormat == null ? outFilename : outFormat; - if (outFormat == null && formatSource != null) { + // Try to parse the format source as a file name or file extension + if (formatSource != null) { // Try to derive the outFormat from the filename - if given. FileName fn = fileNameParser.parse(formatSource); - outFormat = fn.getContentPart(); + String tmpOutFormat = fn.getContentPart(); + + // Replace the outFormat with the result of the successful parse + if (tmpOutFormat != null) { + outFormat = tmpOutFormat; + } + rawOutEncodings.addAll(fn.getEncodingParts()); }