|
From: Majumder, A. <Ana...@Om...> - 2007-05-03 15:18:15
|
Stefan:
I am all set with this, thank you very much for your help.
Anamika=20
-----Original Message-----
From: Stefan Bodewig [mailto:bo...@ap...]=20
Sent: Thursday, May 03, 2007 10:42 AM
To: xml...@li...; Majumder, Anamika
Subject: Re: [Xmlunit-general] Comparing two xml docs with an external
dtd
[please keep the list in CC so that the answers get archived]
> I have written a class implementing EntityResolver with the
> following method:
looks good at first glance.
> And my testcase looks like the following: My aim is to compare testf
> with controlf and the dtd (InfoSettlementResponse.dtd) resides in
> the same directory as the xml files.
If you are using XMLUnit 1.1 beta, simply use
XMLUnit.setControlEntityresolver and XMLUnit.setTestEntitiyResolver
and then invoke assertXMLEquals or Diff just as you did in your first
code examples.
Alternatively you (should work in 1.0 as well) can parse the XML files
yourself, while setting the EntityResolver, something like
> File controlf =3D new File("C:/Program
Files/xmlunit/tests/etc/InfoSettlementResponse_control.xml");
> =20
> DocumentBuilder dbCon =3D XMLUnit.getControlParser();
> OmgeoDTDEntityResolver er =3D new OmgeoDTDEntityResolver();
> dbCon.setEntityResolver(er);
Document docCon =3D dbCon.parse(new InputSource(new
FileInputStream(controlf)));
andd similar for the test document. I.e. you parse your document
under the control of the EntityResolver. The parser's going to call
back on your resolver when it encounters the DTD's public identifier.
See the jaxp docs for more details.
After you have Document instances you can use the Diff constructor
that accepts org.w3c.dom.Document as arguments.
Stefan
|