I'm currently working on some software which trawls some proprietary data and generates an XML document according to a specified DTD. So far so good.
Now, I'm very keen on actually
testing what I produce, and the first step I'd like to do is to check that the generated XML validates against the DTD. I have installed
XML Unit, which has an "assertXMLValid" method for just this task.
Except I can't get it to work.
My XML looks like:
and I have placed the DTD in the file 'BTNB_TimeRecording.dtd' in the "current directory". I'm not at liberty to mess with the generated XML.
However, every time I try and do anything with my generated XML, I get an error:
Relative URI "BTNB_TimeRecording.dtd"; can not be resolved without a base URI Now I know that most parsers are smart enough to look in the same location as the XML file for a DTD, but how am I supposed to validate some XML in a freshly generated
String against a provided DTD?
Is there a way of globally telling a parser to try looking in the current directory for DTDs?
Or is there some way of "preloading" a parser with one or more DTDs so it doesn't need to look "outside" at all?
Or am I misunderstanding things so much that I simply can't see what I should be doing?
All help appreciated, thanks.