Skip to content

Commit

Permalink
Tuned the N3 output
Browse files Browse the repository at this point in the history
  • Loading branch information
egonw committed Apr 28, 2011
1 parent ab6f9bc commit 3966d53
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
19 changes: 13 additions & 6 deletions src/com/github/egonw/moldbvalid/RDFN3Handler.java
Expand Up @@ -24,6 +24,12 @@ public RDFN3Handler(OutputStream output) {
this.output = new PrintStream(output);
}
typesAlreadyProcessed = new HashMap<IValidationTestType,Integer>();

// output namespaces
this.output.println("@prefix : <http://egonw.github.com/moldbvalidator/> .");
this.output.println("@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .");
this.output.println("@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .");
this.output.println();
}

public void setFile(String filename) {
Expand All @@ -40,8 +46,7 @@ public void setSubject(String subject) {

public void handleError(String type, ValidationTest test) {
errorCounter++;
String error = ":hasError" + errorCounter;
output.println(currentSubject + " " + type + " " + error + " .");
String error = ":error" + errorCounter;
int currentType = 0;
IValidationTestType testType = test.getType();
if (typesAlreadyProcessed.containsKey(testType)) {
Expand All @@ -52,20 +57,22 @@ public void handleError(String type, ValidationTest test) {
typesAlreadyProcessed.put(testType, currentType);
// and also output to N3
String typeType = ":ValidationTestType" + typeCounter;
output.println(typeType + " rdfs:label \"" + testType.getError() + "\" ;");
output.println(typeType + " a :ValidationTestType ;");
output.println(" rdfs:label \"" + testType.getError() + "\" .");
}
output.println(currentSubject + " " + type + " " + error + " .");
String typeType = ":ValidationTestType" + typeCounter;
output.print(error + " a " + typeType);
if (test.getDetails().length() > 0) {
output.println(" .");
output.print(" :details \"" + test.getDetails());
output.println(" ;");
output.print(" :details \"" + test.getDetails() + "\"");
}
output.println(" .");
}

public void handleError(String type, String test) {
errorCounter++;
String error = ":hasError" + errorCounter;
String error = ":hasFileError" + errorCounter;
output.println(currentSubject + " " + type + " \"" + error + "\" .");
}

Expand Down
6 changes: 3 additions & 3 deletions src/com/github/egonw/moldbvalid/Validate.java
Expand Up @@ -82,10 +82,10 @@ public void validateFile(String fileName) throws Exception {

private void process(IReportHandler handler, ValidationReport report) {
for (ValidationTest test : report.getErrors())
handler.handleError(":error", test);
handler.handleError(":hasError", test);
for (ValidationTest test : report.getWarnings())
handler.handleError(":warning", test);
handler.handleError(":hasWarning", test);
for (ValidationTest test : report.getCDKErrors())
handler.handleError(":cdkError", test);
handler.handleError(":hasCDKError", test);
}
}

0 comments on commit 3966d53

Please sign in to comment.