public class XmlDataSource
extends java.lang.Object
To learn more, visit the LINQ Reporting Engine documentation article.
Remarks:
To access data of the corresponding file or stream while generating a report, pass an instance of this class as a data source to one of ReportingEngine. buildReport overloads.
In template documents, if a top-level XML element contains only a list of elements of the same type, an XmlDataSource instance should be treated in the same way as if it was a DataTable instance. Otherwise, an XmlDataSource instance should be treated in the same way as if it was a DataRow instance. For more information, see template syntax reference(https://docs.aspose.com/display/wordsjava/Template+Syntax).
When XML Schema Definition is passed to a constructor of this class, data types of values of simple XML elements and attributes are determined according to the schema. So in template documents, you can work with typed values rather than just strings.
When XML Schema Definition is not passed to a constructor of this class, data types of values of simple XML elements and attributes are determined automatically upon their string representations. So in template documents, you can work with typed values in this case as well. The engine is capable to automatically recognize values of the following types:
long
double
boolean
Date
String
Note that for automatic recognition of data types to work, string representations of values of simple XML elements and attributes should be formed using invariant culture settings.
To override default behavior of XML data loading, initialize and pass a XmlDataLoadOptions instance to a constructor of this class.
Examples:
Show how to use XML as a data source (string).
Document doc = new Document(getMyDir() + "Reporting engine template - XML data destination (Java).docx");
XmlDataSource dataSource = new XmlDataSource(getMyDir() + "List of people.xml");
buildReport(doc, dataSource, "persons");
doc.save(getArtifactsDir() + "ReportingEngine.XmlDataString.docx");
Show how to use XML as a data source (stream).
Document doc = new Document(getMyDir() + "Reporting engine template - XML data destination (Java).docx");
InputStream stream = new FileInputStream(getMyDir() + "List of people.xml");
try {
XmlDataSource dataSource = new XmlDataSource(stream);
buildReport(doc, dataSource, "persons");
} finally {
stream.close();
}
doc.save(getArtifactsDir() + "ReportingEngine.XmlDataStream.docx");
| Constructor and Description |
|---|
XmlDataSource(java.io.InputStream xmlStream)
Initializes a new instance of this class.
|
XmlDataSource(java.io.InputStream xmlStream,
java.io.InputStream xmlSchemaStream)
Initializes a new instance of this class.
|
XmlDataSource(java.io.InputStream xmlStream,
java.io.InputStream xmlSchemaStream,
XmlDataLoadOptions options)
Initializes a new instance of this class.
|
XmlDataSource(java.io.InputStream xmlStream,
XmlDataLoadOptions options)
Initializes a new instance of this class.
|
XmlDataSource(java.lang.String xmlPath)
Creates a new data source with data from an XML file using default options for XML data loading.
|
XmlDataSource(java.lang.String xmlPath,
java.lang.String xmlSchemaPath)
Creates a new data source with data from an XML file using an XML Schema Definition file.
|
XmlDataSource(java.lang.String xmlPath,
java.lang.String xmlSchemaPath,
XmlDataLoadOptions options)
Creates a new data source with data from an XML file using an XML Schema Definition file.
|
XmlDataSource(java.lang.String xmlPath,
XmlDataLoadOptions options)
Creates a new data source with data from an XML file using the specified options for XML data loading.
|
public XmlDataSource(java.lang.String xmlPath)
throws java.lang.Exception
Examples:
Show how to use XML as a data source (string).
Document doc = new Document(getMyDir() + "Reporting engine template - XML data destination (Java).docx");
XmlDataSource dataSource = new XmlDataSource(getMyDir() + "List of people.xml");
buildReport(doc, dataSource, "persons");
doc.save(getArtifactsDir() + "ReportingEngine.XmlDataString.docx");
xmlPath - The path to the XML file to be used as the data source.java.lang.Exceptionpublic XmlDataSource(java.io.InputStream xmlStream)
throws java.lang.Exception
java.lang.Exceptionpublic XmlDataSource(java.lang.String xmlPath,
java.lang.String xmlSchemaPath)
throws java.lang.Exception
xmlPath - The path to the XML file to be used as the data source.xmlSchemaPath - The path to the XML Schema Definition file that provides schema for the XML file.java.lang.Exceptionpublic XmlDataSource(java.io.InputStream xmlStream,
java.io.InputStream xmlSchemaStream)
throws java.lang.Exception
java.lang.Exceptionpublic XmlDataSource(java.lang.String xmlPath,
XmlDataLoadOptions options)
throws java.lang.Exception
xmlPath - The path to the XML file to be used as the data source.options - Options for XML data loading.java.lang.Exceptionpublic XmlDataSource(java.io.InputStream xmlStream,
XmlDataLoadOptions options)
throws java.lang.Exception
java.lang.Exceptionpublic XmlDataSource(java.lang.String xmlPath,
java.lang.String xmlSchemaPath,
XmlDataLoadOptions options)
throws java.lang.Exception
xmlPath - The path to the XML file to be used as the data source.xmlSchemaPath - The path to the XML Schema Definition file that provides schema for the XML file.options - Options for XML data loading.java.lang.Exceptionpublic XmlDataSource(java.io.InputStream xmlStream,
java.io.InputStream xmlSchemaStream,
XmlDataLoadOptions options)
throws java.lang.Exception
java.lang.Exception