use of org.apache.jena.shex.ShexSchema in project jena by apache.
the class shex_parse method exec.
private void exec(String fn, boolean multipleFiles) {
ShexSchema shapes;
PrintStream out = System.out;
PrintStream err = System.err;
if (!FileOps.exists(fn)) {
err.println(fn + " : File not found");
return;
}
try {
shapes = Shex.readSchema(fn);
} catch (RiotException ex) {
/*ErrorHandler logged this */
return;
} catch (ShexParseException ex) {
if (multipleFiles)
err.println(fn + " : ");
err.println(ex.getMessage());
return;
}
boolean outputByPrev = false;
if (printText) {
outputByPrev = printText(out, err, shapes);
}
if (printCompact) {
if (outputByPrev) {
out.println("- - - - - - - - ");
outputByPrev = false;
}
outputByPrev = printCompact(out, err, shapes);
}
if (printRDF) {
if (outputByPrev) {
out.println("- - - - - - - - ");
outputByPrev = false;
}
outputByPrev = printRDF(out, err, shapes);
}
}
use of org.apache.jena.shex.ShexSchema in project jena by apache.
the class RunnerShexSyntax method shapesFromFileBadSyntax.
public static ShexSchema shapesFromFileBadSyntax(String filename) {
String str = IO.readWholeFileAsUTF8(filename);
InputStream input = new ByteArrayInputStream(str.getBytes(StandardCharsets.UTF_8));
try {
ShexSchema shapes = ShExC.parse(input, filename, null);
return shapes;
} catch (RuntimeException ex) {
System.out.print("-- ");
System.out.println(FileOps.basename(filename));
if (ex.getMessage() != null)
System.out.println(ex.getMessage());
else
System.out.println(ex.getClass().getSimpleName());
System.out.println(str);
throw ex;
}
}
use of org.apache.jena.shex.ShexSchema in project jena by apache.
the class ShExC method parse$.
// --------
private static ShexSchema parse$(ShExJavacc parser, String sourceURI, String baseURI, Context context) {
ParserProfile profile = new ParserProfileStd(RiotLib.factoryRDF(), ErrorHandlerFactory.errorHandlerStd, IRIxResolver.create(baseURI).build(), PrefixMapFactory.create(), context, false, false);
// addStandardPrefixes(profile.getPrefixMap());
sourceURI = IRILib.filenameToIRI(sourceURI);
parser.setProfile(profile);
// We don't use the StreamRDF.
parser.setDest(StreamRDFLib.sinkNull());
parser.setSourceAndBase(sourceURI, baseURI);
try {
parser.parseShapesStart();
parser.UnitShapes();
ShexSchema shapes = parser.parseShapesFinish();
validatePhase2(shapes);
return shapes;
} catch (ParseException ex) {
throw new ShexParseException(ex.getMessage(), ex.currentToken.beginLine, ex.currentToken.beginColumn);
} catch (TokenMgrError tErr) {
int col = parser.token.endColumn;
int line = parser.token.endLine;
throw new ShexParseException(tErr.getMessage(), line, col);
}
}
use of org.apache.jena.shex.ShexSchema in project jena by apache.
the class RunnerShexBadSyntax method fileBadSyntax.
public static ShexSchema fileBadSyntax(String filename) {
String str = IO.readWholeFileAsUTF8(filename);
InputStream input = new ByteArrayInputStream(str.getBytes(StandardCharsets.UTF_8));
try {
ShexSchema shapes = ShExC.parse(input, filename, null);
// Should not get here.
System.out.print("-- ");
System.out.println(FileOps.basename(filename));
System.out.println(str);
fail("Parsed negative syntax test");
return shapes;
} catch (ShexParseException ex) {
return null;
}
}
Aggregations