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

Method writeSubjects

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

Write multiple references @param w XML writer @param con RDF triple store connection @param uri URI of the dataset @param pred RDF predicate @param el element name @throws XMLStreamException

(XMLStreamWriter w, RepositoryConnection con, Resource uri, IRI pred, 
			String el)

Source from the content-addressed store, hash-verified

441 * @throws XMLStreamException
442 */
443 private static void writeSubjects(XMLStreamWriter w, RepositoryConnection con, Resource uri, IRI pred,
444 String el) throws XMLStreamException {
445 try (RepositoryResult<Statement> res = con.getStatements(uri, pred, null)) {
446 while (res.hasNext()) {
447 Value val = res.next().getObject();
448 if (val instanceof IRI iri) {
449 w.writeEmptyElement(el);
450 w.writeAttribute("rdf:resource", iri.stringValue());
451 } else {
452 if (val != null) {
453 w.writeStartElement(el);
454 w.writeCharacters(val.stringValue());
455 w.writeEndElement();
456 }
457 }
458 }
459 }
460 }
461
462 /**
463 * Write RDF reference

Callers 1

writeResourceMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected