Path to XML DTD for DBUnit in multi-module Java/Maven project?

Posted by HDave on Stack Overflow See other posts from Stack Overflow or by HDave
Published on 2010-06-10T19:37:16Z Indexed on 2010/06/10 19:42 UTC
Read the original article Hit count: 309

Filed under:
|
|
|

I have a multi-module maven project. Within the persist module I have a number of XML files data files that reference a DTD:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE myapp-data SYSTEM "myapp-data.dtd" >

<dataset>
      .....omitted for brevity....
</dataset>

The DTD is stored in the same directory with the XML files and even Eclipse reports these XML files as valid.

However, when I run the application, the DBUnit FlatXMLDataSet throws a FileNotFound exception because it cannot located the DTD. It is apparently looking for the DTD in the root project directory (e.g. myproject/). I would have expected it to look for the DTD in the same directory as the XML file itself (e.g. myproject/persist/target/test-data).

Looking at the DBUnit source code, it has this to say about it "Relative DOCTYPE uri are resolved from the current working dicrectory."

What's a good way to fix this?

© Stack Overflow or respective owner

Related posts about Xml

Related posts about maven