relaxng / jing-trang

Schema validation and conversion based on RELAX NG
http://www.thaiopensource.com/relaxng/
Other
228 stars 69 forks source link

Validation fails with FileNotFoundException when a .rng file contains a link to another xml file. #249

Open eduardnegru opened 5 years ago

eduardnegru commented 5 years ago

My workspace looks like this:

/home/workspace/ contains java classes (including main) and data.xml /home/workspace/schemas/ contains schema.rng and schema2.rng

I have the following Java code that validates a .rng file against a .xml file.

public boolean validate() {
       InputSource xmlFileInputSource = new InputSource(new FileInputStream("data.xml"));
       ValidationDriver validationDriver = new ValidationDriver();
       InputSource xmlSchemaInputSource = new InputSource(new FileInputStream("./schemas/schema.rng"));
       validationDriver.loadSchema(xmlSchemaInputSource);
       return validationDriver.validate(xmlFileInputSource);
}

schema.rng contains a link to another rng file.

<include href="schema2.rng" />

Instead of searching for schema2.rng file in the folder of schema.rng, Jing searches the file schema2.rng in the folder the program is run and thus results in FileNotFoundException in /home/workspace/. The search path should be /home/workspace/schemas, where schema.rng file is located.