I create a DTD using the class FlatDtdWriter and the
ContentModel CHOICE. It generated a choice list in the
DTD similiar to the example below.
<!element dataset(
(TABLE_1|
TABLE_2|
TABLE_3)*)>
I use Eclipse and the plugin XMLBuddy to verify the
validity of the XML files using the DTD containing a
similiar choice list. When attempting to to run DBUnit
using this DTD, a NullPointerExceptioin is raised in
FlatDtdProducter.endDTD() as it does not parse through
the choice list successfully. I have modified
FlatDtdProducer.endDTD() to overcome the problem and
attached it
FlatDtdProcuder.java
Logged In: YES
user_id=291427
Originator: NO
Using v2.2 two years later I got bitten by this very bug.
The occurrence operators are not correctly removed ...
Can this fix be finally merged, please ?
Logged In: YES
user_id=1803108
Originator: NO
Hi there,
thanks for your submission and sorry for the long time dbunit has been dormant.
I investigated this and found that the root cause for your problem is not the bad parsing. Instead your DTD really is invalid because the ELEMENT declarations of TABLE_1/TABLE_2/TABLE_3 are missing (in Oxygen I get only a warning which is "The content model of element "dataset" refers to the undeclared element "TABLE_1").
A correct DTD would be this here:
<!ELEMENT dataset ( (TABLE_1|TABLE_2)* )><!ELEMENT TABLE_1 EMPTY><!ELEMENT TABLE_2 EMPTY>
I committed a change which throws a more meaningful exception now (SVN rev 793/trunk - upcoming 2.3 release):
"ELEMENT/ATTRIBUTE declaration for 'TABLE_1' is missing."
So the root cause is problably in the FlatDtdWriter. Could you please provide a testcase that reproduces the creation of your broken DTD?
Thanks and regards,
mat
Logged In: YES
user_id=1803108
Originator: NO
Actually I believe that this kind of DTD you provided above cannot be generated by dbunits FlatDtdWriter. The smallest possible DTD for 2 tables without any columns looks like the following one:
<!ELEMENT dataset (
(TABLE1|
TABLE2)*)>
<!ELEMENT TABLE1 EMPTY>
<!ATTLIST TABLE1
>
<!ELEMENT TABLE2 EMPTY>
<!ATTLIST TABLE2
>
If I am wrong please let me know.
Thanks and regards,
mat
Logged In: YES
user_id=1312539
Originator: NO
This Tracker item was closed automatically by the system. It was
previously set to a Pending status, and the original submitter
did not respond within 14 days (the time period specified by
the administrator of this Tracker).
The issue seems to be tables declared in schema that do not exist in the xml dataset. This is valid according to the dtd, but fails to parse. I think this should be reopened.
Reopened since feedback was given. Thx natenobility. I'll hopefully find the time soon to work on this
Could anybody please sketch a small example for this to let me reproduce this issue? Thx
The issue I originally encountered, the DTD file generated by FlatDtdWriter with a content model of FlatDtdWriter.CHOICE could not be read by FlatDtdProducer, was resolved in DBUnit 2.3.0.
However for anyone that is interested, below is a sample DTD file generated from an Oracle 10g Release 2 database and the exception that was encountered in DBUnit 2.1.
<!element dataset(
(TABLE_1|
TABLE_2|
TABLE_3)*)>
<!ELEMENT B_ACM_SORTIE EMPTY>
<!ATTLIST TABLE_1
COL1 CDATA #REQUIRED
COL2 CDATA #IMPLIED
>
<!ATTLIST TABLE_2
COL1 CDATA #REQUIRED
COL2 CDATA #IMPLIED
>
<!ATTLIST TABLE_3
COL1 CDATA #REQUIRED
COL2 CDATA #IMPLIED
>
The following exception was encountered.
java.lang.NullPointerException
at org.dbunit.dataset.xml.FlatDtdProduer.entDtd(FlatDtdProducer.java:224)
at com.sun.org.apache.xerces.internal.parser.AbstractSaxParser.entDtd(AbstractSAXParser.java:1097)
...
Closing this issue since it appears to be solved since dbunit 2.3. Thanks for the quick response.