com.groupdocs.assembly

Class XmlDataSource

  • java.lang.Object
    • com.groupdocs.assembly.XmlDataSource


  • public class XmlDataSource
    extends java.lang.Object
    Provides access to data of an XML file or stream to be used while assembling a document.

    To access data of the corresponding file or stream while assembling a document, pass an instance of this class as a data source to one of DocumentAssembler. assembleDocument 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.groupdocs.com/display/assemblyjava/Template+Syntax+-+Part+1+of+2#TemplateSyntax-Part1of2-UsingDataSources).

    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:

    • java.lang.Long
    • java.lang.Double
    • java.lang.Boolean
    • java.util.Date
    • java.lang.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.

    • Constructor Summary

      Constructors 
      Constructor and Description
      XmlDataSource(java.io.InputStream xmlStream)
      Creates a new data source with data from an XML stream.
      XmlDataSource(java.io.InputStream xmlStream, java.io.InputStream xmlSchemaStream)
      Creates a new data source with data from an XML stream using an XML Schema Definition stream.
      XmlDataSource(java.lang.String xmlPath)
      Creates a new data source with data from an XML file.
      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.
    • Method Summary

      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • XmlDataSource

        public XmlDataSource(java.lang.String xmlPath)
                      throws java.lang.Exception
        Creates a new data source with data from an XML file.
        Parameters:
        xmlPath - The path to the XML file to be used as the data source.
        Throws:
        java.lang.Exception
      • XmlDataSource

        public XmlDataSource(java.io.InputStream xmlStream)
                      throws java.lang.Exception
        Creates a new data source with data from an XML stream.
        Parameters:
        xmlStream - The stream of XML data to be used as the data source.
        Throws:
        java.lang.Exception
      • XmlDataSource

        public XmlDataSource(java.lang.String xmlPath,
                             java.lang.String xmlSchemaPath)
                      throws java.lang.Exception
        Creates a new data source with data from an XML file using an XML Schema Definition file.
        Parameters:
        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.
        Throws:
        java.lang.Exception
      • XmlDataSource

        public XmlDataSource(java.io.InputStream xmlStream,
                             java.io.InputStream xmlSchemaStream)
                      throws java.lang.Exception
        Creates a new data source with data from an XML stream using an XML Schema Definition stream.
        Parameters:
        xmlStream - The stream of XML data to be used as the data source.
        xmlSchemaStream - The stream of XML Schema Definition that provides schema for the XML data.
        Throws:
        java.lang.Exception