MCPcopy Create free account
hub / github.com/Fedict/dcattools / main

Method main

tools/src/main/java/be/gov/data/tools/EDP.java:1131–1196  ·  view source on GitHub ↗

Main program @param args

(String[] args)

Source from the content-addressed store, hash-verified

1129 * @param args
1130 */
1131 public static void main(String[] args) {
1132 LOG.info("-- START --");
1133 if (args.length < 2) {
1134 LOG.error("No input or output file");
1135 System.exit(-1);
1136 }
1137
1138 Optional<RDFFormat> fmtin = Rio.getParserFormatForFileName(args[0]);
1139 if (!fmtin.isPresent()) {
1140 LOG.error("No parser for input {}", args[0]);
1141 System.exit(-2);
1142 }
1143
1144 Repository repo = new SailRepository(new MemoryStore());
1145
1146 Serializer s = getSerializer();
1147 s.setOutputFile(new File(args[1]));
1148
1149 try (RepositoryConnection con = repo.getConnection()) {
1150 ParserConfig cfg = new ParserConfig();
1151 cfg.set(BasicParserSettings.VERIFY_URI_SYNTAX, true);
1152 cfg.set(BasicParserSettings.VERIFY_RELATIVE_URIS, true);
1153 cfg.set(NTriplesParserSettings.FAIL_ON_INVALID_LINES, true);
1154
1155 con.setParserConfig(cfg);
1156 con.add(new File(args[0]), BASE_URI, fmtin.get());
1157
1158 checkCircular(con);
1159
1160 checkAllIRIs(con);
1161
1162 XMLStreamWriter w = s.getXMLStreamWriter();
1163
1164 w.writeStartDocument();
1165 writeCatalog(w, con);
1166 w.writeEndDocument();
1167
1168 w.close();
1169 } catch (IOException | XMLStreamException | SaxonApiException ex) {
1170 LOG.error("Error converting", ex);
1171 System.exit(-1);
1172 } finally {
1173 repo.shutDown();
1174 }
1175
1176 // verify once more
1177
1178 RDFParser parser = Rio.createParser(RDFFormat.RDFXML);
1179 ParserConfig cfg = new ParserConfig();
1180 cfg.set(BasicParserSettings.VERIFY_URI_SYNTAX, true);
1181 cfg.set(BasicParserSettings.VERIFY_RELATIVE_URIS, true);
1182 cfg.set(XMLParserSettings.FAIL_ON_INVALID_QNAME, true);
1183 cfg.set(XMLParserSettings.FAIL_ON_MISMATCHED_TAGS, true);
1184 cfg.set(XMLParserSettings.FAIL_ON_NON_STANDARD_ATTRIBUTES, true);
1185 cfg.set(XMLParserSettings.FAIL_ON_SAX_NON_FATAL_ERRORS, true);
1186 parser.setParserConfig(cfg);
1187 parser.setValueFactory(new ValidatingValueFactory());
1188

Callers

nothing calls this directly

Calls 8

getSerializerMethod · 0.95
checkCircularMethod · 0.95
checkAllIRIsMethod · 0.95
writeCatalogMethod · 0.95
exitMethod · 0.80
closeMethod · 0.80
addMethod · 0.45
parseMethod · 0.45

Tested by

no test coverage detected