From: Luca Dall'O. <lda...@un...> - 2003-05-08 06:58:00
|
I have really appreciated your enhancement to the Validator class including the useXMLSchema() method; now I can validate my xml using xsd schema. Still, I couldn't find out how to redirect the retrival of xsd files : they are always supposed to be in the project home directory (or the ant home, depending on the build tool I use). After some code digging I suppose that the current way to redirect files works only for DTDs, so I tried to extend it for xsd too. I have not written a clean solution but it seems to work, so I thought better to post it : perhaps it could be useful for others too. My solution is based on an extension of the DoctypeReader class (this way I can pass it to the Validator constructor) that parses the input, adds a couple of attributes to the root element with the xsd info and serializes it back to a string... very similar to the doctypeReader itself. I have written a simple helper class to use the assertXMLValid() interface, it can be useful as an example of the calling. This is the way I call it : private String xsdName = "ordinativoFirmato.xsd"; private String xsdPath = this.getClass().getResource(xsdName).toString(); ... MyXMLAssert.assertXMLValid(supposedNormalizedString, xsdName, xsdPath); I think that a much cleaner way to solve this problem would be to make use of oasis catalogs : http://www.oasis-open.org/committees/tc_home.php?wg_abbrev=entity An implementation can be downloaded at the apache site in the xml commons package, and IMVHO it should be rather straightforward to add it to xmlunit: http://xml.apache.org/commons/ If you are interested I can have a look at it, just let me know! greetings, Luca Dall'Olio (dal...@un...) |