Search in sources :

Example 1 with ShexParseException

use of org.apache.jena.shex.parser.ShexParseException 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);
    }
}
Also used : PrintStream(java.io.PrintStream) RiotException(org.apache.jena.riot.RiotException) ShexParseException(org.apache.jena.shex.parser.ShexParseException) ShexSchema(org.apache.jena.shex.ShexSchema)

Example 2 with ShexParseException

use of org.apache.jena.shex.parser.ShexParseException 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;
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) ShexParseException(org.apache.jena.shex.parser.ShexParseException) ShexSchema(org.apache.jena.shex.ShexSchema)

Aggregations

ShexSchema (org.apache.jena.shex.ShexSchema)2 ShexParseException (org.apache.jena.shex.parser.ShexParseException)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 InputStream (java.io.InputStream)1 PrintStream (java.io.PrintStream)1 RiotException (org.apache.jena.riot.RiotException)1