amityadav1983 / probatron4j

Automatically exported from code.google.com/p/probatron4j
0 stars 0 forks source link

using schematron with external files for validation - FileNotFoundException #10

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I'm using probatron programatically in a jar, with the schematron file
included. Inside the schematron, I'm using a reference to another file that
contains a list of accepted values :

<iso:report test="document('./annex.xml')...>

When running probatron from the command line, with the schematron and
include file in the same folder, I have no issues at all.

However, when I try to use it programatically, the schematron.sch and
annex.xml files are located in :

src/main/resources/sch/

After the build, the classes folder structure is as follows :

bar/foo/myClass.class
sch/schematron.sch
sch/annex.xml

Within the code, I use the following to set the schemadoc :

    URL schemaLocation =
SumehrValidator.class.getResource(SCHEMATRON_FILE_NAME);
    theSession.setSchemaDoc(schemaLocation.toString());

Now, when I perform theSession.doValidation(filename), I get a
FileNotFoundException :

Recoverable error on line 1011 
  FODC0002: java.io.FileNotFoundException:
  C:\eclipse\workspace\bar\foo\annex.xml (The system cannot find
  the file specified)

As the included file is in the same directory as the schematron file, is
there a way to prevent the system from looking in the jar's root folder ?

Original issue reported on code.google.com by charloui...@gmail.com on 28 Apr 2010 at 9:42