如何设置dbunit以在xml数据集标记中添加引用dtd文件的行?
在我的xml文件中,我将我的数据集重新设置为
<dataset>
<TABLE COLUMN="value ..."
...
但我想添加对dtd的引用(或其他方式)
<!DOCTYPE dataset SYSTEM "../my.dtd">
<TABLE COLUMN="value" ...
...
xml由以下基因处理:
FlatXmlDataSet.write(dataSet, out);
当我手动添加行时,我得到一个解析错误
java.lang.NullPointerException
at org.dbunit.dataset.xml.FlatXmlProducer.isNewTable(FlatXmlProducer.java:255)
at org.dbunit.dataset.xml.FlatXmlProducer.startElement(FlatXmlProducer.java:429)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:509)
at com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElement(AbstractXMLDocumentParser.java:182)
at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.emptyElement(XMLDTDValidator.java:766)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(XMLDocumentFragmentScannerImpl.java:1342)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$ContentDriver.scanRootElementHook(XMLDocumentScannerImpl.java:1292)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:3122)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:880)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:606)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:510)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:848)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:777)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:649)
at org.dbunit.dataset.xml.FlatXmlProducer.produce(FlatXmlProducer.java:365)
at org.dbunit.dataset.CachedDataSet.<init>(CachedDataSet.java:97)
at org.dbunit.dataset.xml.FlatXmlDataSet.<init>(FlatXmlDataSet.java:110)
at org.dbunit.dataset.xml.FlatXmlDataSetBuilder.buildInternal(FlatXmlDataSetBuilder.java:264)
at org.dbunit.dataset.xml.FlatXmlDataSetBuilder.build(FlatXmlDataSetBuilder.java:111)
at test.de.planta.server.DBUnitHelper.readDataSet(DBUnitHelper.java:243)
at test.de.planta.server.DBUnitHelper.insertDataFromXMLIntoH2(DBUnitHelper.java:202)
at test.de.planta.server.DBUnitHelper.CleanInsertData(DBUnitHelper.java:95)
at test.de.planta.server.DBUnitHelper.doCleanImport(DBUnitHelper.java:64)
at test.de.planta.server.DBUnitHelper.main(DBUnitHelper.java:57)
答案 0 :(得分:3)
您错过了实际的<dataset>
元素。
文件应如下所示:
<!DOCTYPE dataset SYSTEM "../my.dtd">
<dataset>
<TABLE COLUMN="value" ...