org.dbunit.dataset.xml
Class FlatXmlDataSet

java.lang.Object
  extended by org.dbunit.dataset.AbstractDataSet
      extended by org.dbunit.dataset.CachedDataSet
          extended by org.dbunit.dataset.xml.FlatXmlDataSet
All Implemented Interfaces:
IDataSet, IDataSetConsumer

public class FlatXmlDataSet
extends CachedDataSet

Reads and writes flat XML dataset document. Each XML element corresponds to a table row. Each XML element name corresponds to a table name. The XML attributes correspond to table columns.

Flat XML dataset document sample:

 <!DOCTYPE dataset SYSTEM "my-dataset.dtd">
 <dataset>
     <TEST_TABLE COL0="row 0 col 0"
         COL1="row 0 col 1"
         COL2="row 0 col 2"/>
     <TEST_TABLE COL1="row 1 col 1"/>
     <SECOND_TABLE COL0="row 0 col 0"
           COL1="row 0 col 1" />
     <EMPTY_TABLE/>
 </dataset>

To specify null values, omit corresponding attribute. In the above example, missing COL0 and COL2 attributes of TEST_TABLE second row represents null values.

Table metadata is deduced from the first row of each table by default. Beware that DbUnit may think a table misses some columns if the first row of that table has one or more null values. You can do one of the following things to avoid this:

Since:
1.0 (Mar 12, 2002)
Version:
$Revision$ $Date$
Author:
Manuel Laflamme, gommma (gommma AT users.sourceforge.net), Last changed by: $Author$

Field Summary
 
Fields inherited from class org.dbunit.dataset.AbstractDataSet
_orderedTableNameMap
 
Constructor Summary
FlatXmlDataSet(File xmlFile)
          Deprecated. since 2.4.7 - use FlatXmlDataSetBuilder to create a FlatXmlDataSet
FlatXmlDataSet(File xmlFile, boolean dtdMetadata)
          Deprecated. since 2.4.7 - use FlatXmlDataSetBuilder to create a FlatXmlDataSet
FlatXmlDataSet(File xmlFile, boolean dtdMetadata, boolean columnSensing)
          Deprecated. since 2.4.7 - use FlatXmlDataSetBuilder to create a FlatXmlDataSet
FlatXmlDataSet(File xmlFile, boolean dtdMetadata, boolean columnSensing, boolean caseSensitiveTableNames)
          Deprecated. since 2.4.7 - use FlatXmlDataSetBuilder to create a FlatXmlDataSet
FlatXmlDataSet(FlatXmlProducer flatXmlProducer)
          Creates a new FlatXmlDataSet with the data of the given producer.
FlatXmlDataSet(InputSource source)
          Deprecated. since 2.4.7 - use FlatXmlDataSetBuilder to create a FlatXmlDataSet
FlatXmlDataSet(InputStream xmlStream)
          Deprecated. since 2.4.7 - use FlatXmlDataSetBuilder to create a FlatXmlDataSet
FlatXmlDataSet(InputStream xmlStream, boolean dtdMetadata)
          Deprecated. since 2.4.7 - use FlatXmlDataSetBuilder to create a FlatXmlDataSet
FlatXmlDataSet(InputStream xmlStream, IDataSet metaDataSet)
          Deprecated. since 2.4.7 - use FlatXmlDataSetBuilder to create a FlatXmlDataSet
FlatXmlDataSet(InputStream xmlStream, InputStream dtdStream)
          Deprecated. since 2.4.7 - use FlatXmlDataSetBuilder to create a FlatXmlDataSet
FlatXmlDataSet(Reader xmlReader)
          Deprecated. since 2.4.7 - use FlatXmlDataSetBuilder to create a FlatXmlDataSet
FlatXmlDataSet(Reader xmlReader, boolean dtdMetadata)
          Deprecated. since 2.4.7 - use FlatXmlDataSetBuilder to create a FlatXmlDataSet
FlatXmlDataSet(Reader xmlReader, boolean dtdMetadata, boolean columnSensing, boolean caseSensitiveTableNames)
          Deprecated. since 2.4.7 - use FlatXmlDataSetBuilder to create a FlatXmlDataSet
FlatXmlDataSet(Reader xmlReader, IDataSet metaDataSet)
          Deprecated. since 2.4.7 - use FlatXmlDataSetBuilder to create a FlatXmlDataSet
FlatXmlDataSet(Reader xmlReader, Reader dtdReader)
          Deprecated. since 2.4.7 - use FlatXmlDataSetBuilder to create a FlatXmlDataSet
FlatXmlDataSet(URL xmlUrl)
          Deprecated. since 2.4.7 - use FlatXmlDataSetBuilder to create a FlatXmlDataSet
FlatXmlDataSet(URL xmlUrl, boolean dtdMetadata)
          Deprecated. since 2.4.7 - use FlatXmlDataSetBuilder to create a FlatXmlDataSet
FlatXmlDataSet(URL xmlUrl, boolean dtdMetadata, boolean columnSensing)
          Deprecated. since 2.4.7 - use FlatXmlDataSetBuilder to create a FlatXmlDataSet
FlatXmlDataSet(URL xmlUrl, boolean dtdMetadata, boolean columnSensing, boolean caseSensitiveTableNames)
          Deprecated. since 2.4.7 - use FlatXmlDataSetBuilder to create a FlatXmlDataSet
 
Method Summary
static void write(IDataSet dataSet, OutputStream out)
          Write the specified dataset to the specified output stream as xml.
static void write(IDataSet dataSet, Writer writer)
          Write the specified dataset to the specified writer as xml.
static void write(IDataSet dataSet, Writer writer, String encoding)
          Write the specified dataset to the specified writer as xml.
static void writeDtd(IDataSet dataSet, OutputStream out)
          Deprecated. use FlatDtdDataSet.write(org.dbunit.dataset.IDataSet, java.io.OutputStream)
 
Methods inherited from class org.dbunit.dataset.CachedDataSet
createIterator, endDataSet, endTable, row, startDataSet, startTable
 
Methods inherited from class org.dbunit.dataset.AbstractDataSet
createTableNameMap, getTable, getTableMetaData, getTableNames, getTables, isCaseSensitiveTableNames, iterator, reverseIterator, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FlatXmlDataSet

public FlatXmlDataSet(FlatXmlProducer flatXmlProducer)
               throws DataSetException
Creates a new FlatXmlDataSet with the data of the given producer.

Parameters:
flatXmlProducer - The producer that provides the FlatXmlDataSet content
Throws:
DataSetException
Since:
2.4.7

FlatXmlDataSet

public FlatXmlDataSet(InputSource source)
               throws IOException,
                      DataSetException
Deprecated. since 2.4.7 - use FlatXmlDataSetBuilder to create a FlatXmlDataSet

Creates an FlatXmlDataSet object with the specified InputSource.

Throws:
IOException
DataSetException

FlatXmlDataSet

public FlatXmlDataSet(File xmlFile)
               throws IOException,
                      DataSetException
Deprecated. since 2.4.7 - use FlatXmlDataSetBuilder to create a FlatXmlDataSet

Creates an FlatXmlDataSet object with the specified xml file. Relative DOCTYPE uri are resolved from the xml file path.

Parameters:
xmlFile - the xml file
Throws:
IOException
DataSetException

FlatXmlDataSet

public FlatXmlDataSet(File xmlFile,
                      boolean dtdMetadata)
               throws IOException,
                      DataSetException
Deprecated. since 2.4.7 - use FlatXmlDataSetBuilder to create a FlatXmlDataSet

Creates an FlatXmlDataSet object with the specified xml file. Relative DOCTYPE uri are resolved from the xml file path.

Parameters:
xmlFile - the xml file
dtdMetadata - if false do not use DTD as metadata
Throws:
IOException
DataSetException

FlatXmlDataSet

public FlatXmlDataSet(File xmlFile,
                      boolean dtdMetadata,
                      boolean columnSensing)
               throws IOException,
                      DataSetException
Deprecated. since 2.4.7 - use FlatXmlDataSetBuilder to create a FlatXmlDataSet

Creates an FlatXmlDataSet object with the specified xml file. Relative DOCTYPE uri are resolved from the xml file path.

Parameters:
xmlFile - the xml file
dtdMetadata - if false do not use DTD as metadata
columnSensing - Whether or not the columns should be sensed automatically. Every XML row is scanned for columns that have not been there in a previous column.
Throws:
IOException
DataSetException

FlatXmlDataSet

public FlatXmlDataSet(File xmlFile,
                      boolean dtdMetadata,
                      boolean columnSensing,
                      boolean caseSensitiveTableNames)
               throws IOException,
                      DataSetException
Deprecated. since 2.4.7 - use FlatXmlDataSetBuilder to create a FlatXmlDataSet

Creates an FlatXmlDataSet object with the specified xml file. Relative DOCTYPE uri are resolved from the xml file path.

Parameters:
xmlFile - the xml file
dtdMetadata - if false do not use DTD as metadata
columnSensing - Whether or not the columns should be sensed automatically. Every XML row is scanned for columns that have not been there in a previous column.
caseSensitiveTableNames - Whether or not this dataset should use case sensitive table names
Throws:
IOException
DataSetException

FlatXmlDataSet

public FlatXmlDataSet(URL xmlUrl)
               throws IOException,
                      DataSetException
Deprecated. since 2.4.7 - use FlatXmlDataSetBuilder to create a FlatXmlDataSet

Creates an FlatXmlDataSet object with the specified xml URL. Relative DOCTYPE uri are resolved from the xml file path.

Parameters:
xmlUrl - the xml URL
Throws:
IOException
DataSetException

FlatXmlDataSet

public FlatXmlDataSet(URL xmlUrl,
                      boolean dtdMetadata)
               throws IOException,
                      DataSetException
Deprecated. since 2.4.7 - use FlatXmlDataSetBuilder to create a FlatXmlDataSet

Creates an FlatXmlDataSet object with the specified xml URL. Relative DOCTYPE uri are resolved from the xml file path.

Parameters:
xmlUrl - the xml URL
dtdMetadata - if false do not use DTD as metadata
Throws:
IOException
DataSetException

FlatXmlDataSet

public FlatXmlDataSet(URL xmlUrl,
                      boolean dtdMetadata,
                      boolean columnSensing)
               throws IOException,
                      DataSetException
Deprecated. since 2.4.7 - use FlatXmlDataSetBuilder to create a FlatXmlDataSet

Creates an FlatXmlDataSet object with the specified xml URL. Relative DOCTYPE uri are resolved from the xml file path.

Parameters:
xmlUrl - the xml URL
dtdMetadata - if false do not use DTD as metadata
columnSensing - Whether or not the columns should be sensed automatically. Every XML row is scanned for columns that have not been there in a previous column.
Throws:
IOException
DataSetException

FlatXmlDataSet

public FlatXmlDataSet(URL xmlUrl,
                      boolean dtdMetadata,
                      boolean columnSensing,
                      boolean caseSensitiveTableNames)
               throws IOException,
                      DataSetException
Deprecated. since 2.4.7 - use FlatXmlDataSetBuilder to create a FlatXmlDataSet

Creates an FlatXmlDataSet object with the specified xml file. Relative DOCTYPE uri are resolved from the xml file path.

Parameters:
xmlUrl - the xml file
dtdMetadata - if false do not use DTD as metadata
columnSensing - Whether or not the columns should be sensed automatically. Every XML row is scanned for columns that have not been there in a previous column.
caseSensitiveTableNames - Whether or not this dataset should use case sensitive table names
Throws:
IOException
DataSetException

FlatXmlDataSet

public FlatXmlDataSet(Reader xmlReader)
               throws IOException,
                      DataSetException
Deprecated. since 2.4.7 - use FlatXmlDataSetBuilder to create a FlatXmlDataSet

Creates an FlatXmlDataSet object with the specified xml reader. Relative DOCTYPE uri are resolved from the current working directory.

Parameters:
xmlReader - the xml reader
Throws:
IOException
DataSetException

FlatXmlDataSet

public FlatXmlDataSet(Reader xmlReader,
                      boolean dtdMetadata)
               throws IOException,
                      DataSetException
Deprecated. since 2.4.7 - use FlatXmlDataSetBuilder to create a FlatXmlDataSet

Creates an FlatXmlDataSet object with the specified xml reader. Relative DOCTYPE uri are resolved from the current working directory.

Parameters:
xmlReader - the xml reader
dtdMetadata - if false do not use DTD as metadata
Throws:
IOException
DataSetException

FlatXmlDataSet

public FlatXmlDataSet(Reader xmlReader,
                      boolean dtdMetadata,
                      boolean columnSensing,
                      boolean caseSensitiveTableNames)
               throws IOException,
                      DataSetException
Deprecated. since 2.4.7 - use FlatXmlDataSetBuilder to create a FlatXmlDataSet

Creates an FlatXmlDataSet object with the specified xml file. Relative DOCTYPE uri are resolved from the xml file path.

Parameters:
xmlReader - the xml reader
dtdMetadata - if false do not use DTD as metadata
columnSensing - Whether or not the columns should be sensed automatically. Every XML row is scanned for columns that have not been there in a previous column.
caseSensitiveTableNames - Whether or not this dataset should use case sensitive table names
Throws:
IOException
DataSetException
Since:
2.4.3

FlatXmlDataSet

public FlatXmlDataSet(Reader xmlReader,
                      Reader dtdReader)
               throws IOException,
                      DataSetException
Deprecated. since 2.4.7 - use FlatXmlDataSetBuilder to create a FlatXmlDataSet

Creates an FlatXmlDataSet object with the specified xml and dtd readers.

Parameters:
xmlReader - the xml reader
dtdReader - the dtd reader
Throws:
IOException
DataSetException

FlatXmlDataSet

public FlatXmlDataSet(Reader xmlReader,
                      IDataSet metaDataSet)
               throws IOException,
                      DataSetException
Deprecated. since 2.4.7 - use FlatXmlDataSetBuilder to create a FlatXmlDataSet

Creates an FlatXmlDataSet object with the specified xml reader.

Parameters:
xmlReader - the xml reader
metaDataSet - the dataset used as metadata source.
Throws:
IOException
DataSetException

FlatXmlDataSet

public FlatXmlDataSet(InputStream xmlStream)
               throws IOException,
                      DataSetException
Deprecated. since 2.4.7 - use FlatXmlDataSetBuilder to create a FlatXmlDataSet

Creates an FlatXmlDataSet object with the specified xml input stream. Relative DOCTYPE uri are resolved from the current working directory.

Parameters:
xmlStream - the xml input stream
Throws:
IOException
DataSetException

FlatXmlDataSet

public FlatXmlDataSet(InputStream xmlStream,
                      boolean dtdMetadata)
               throws IOException,
                      DataSetException
Deprecated. since 2.4.7 - use FlatXmlDataSetBuilder to create a FlatXmlDataSet

Creates an FlatXmlDataSet object with the specified xml input stream. Relative DOCTYPE uri are resolved from the current working directory.

Parameters:
xmlStream - the xml input stream
dtdMetadata - if false do not use DTD as metadata
Throws:
IOException
DataSetException

FlatXmlDataSet

public FlatXmlDataSet(InputStream xmlStream,
                      InputStream dtdStream)
               throws IOException,
                      DataSetException
Deprecated. since 2.4.7 - use FlatXmlDataSetBuilder to create a FlatXmlDataSet

Creates an FlatXmlDataSet object with the specified xml and dtd input stream.

Parameters:
xmlStream - the xml input stream
dtdStream - the dtd input stream
Throws:
IOException
DataSetException

FlatXmlDataSet

public FlatXmlDataSet(InputStream xmlStream,
                      IDataSet metaDataSet)
               throws IOException,
                      DataSetException
Deprecated. since 2.4.7 - use FlatXmlDataSetBuilder to create a FlatXmlDataSet

Creates an FlatXmlDataSet object with the specified xml input stream.

Parameters:
xmlStream - the xml input stream
metaDataSet - the dataset used as metadata source.
Throws:
IOException
DataSetException
Method Detail

write

public static void write(IDataSet dataSet,
                         OutputStream out)
                  throws IOException,
                         DataSetException
Write the specified dataset to the specified output stream as xml.

Throws:
IOException
DataSetException

write

public static void write(IDataSet dataSet,
                         Writer writer)
                  throws IOException,
                         DataSetException
Write the specified dataset to the specified writer as xml.

Throws:
IOException
DataSetException

write

public static void write(IDataSet dataSet,
                         Writer writer,
                         String encoding)
                  throws IOException,
                         DataSetException
Write the specified dataset to the specified writer as xml.

Throws:
IOException
DataSetException

writeDtd

public static void writeDtd(IDataSet dataSet,
                            OutputStream out)
                     throws IOException,
                            DataSetException
Deprecated. use FlatDtdDataSet.write(org.dbunit.dataset.IDataSet, java.io.OutputStream)

Write a DTD for the specified dataset to the specified output.

Throws:
IOException
DataSetException


Copyright © 2002–2014. All rights reserved.