There are use cases where you might want to parse a flat file into an XML document for further processing. The example below shows such an implementation.
FlatFileAdapter_ConvertToXML_Example
Click here to download a simple example model that shows how to use the Flat File adapter to parse a flat file into an XML document in Scheer PAS Designer.
After having parsed the flat file and mapped the data to the XML document structure, you can use the classToXML() operation to serialize the flat file into the XML document (see XMLProductList. classToXML() in the example).
classToXML() takes any object and tries to map it to an XML document. The output is a blob object. You can transcode it to string (if needed) using transcodeToString().
The operation also receives an options parameter that can be used to configure compose options (see classToXML() Operation > XMLComposeOptions for a detailed description of these options).
You need these compose options to set the root name, prefix and namespace of the XML document (see XML Document Structure and Mapping and setXmlComposeOptions() in the example).
Troubleshooting
|
Problem / Error Message |
Possible Reason |
Solution |
|---|---|---|
|
Generated XML document has a wrong root name, like e.g. |
No root name set in the compose options of |
Provide compose options with classToXML() and set the Root Name property. |
|
Generated XML document has no root namespace. |
No namespace set in the compose options of |
Provide compose options with classToXML() and set the Root Namespace property. |
|
Missing fields in the XML structure. |
The flat file field and XML property names do not correspond. |
Change the XML document structure so that the property names match. |
|
Add extension XML Attribute or XML Element to the missing properties in the XML document structure, and set the External Name attribute to the name of the corresponding property in the flat file. |
||
|
The XML elements have no prefix. |
Missing namespace definition on the package the XML document resides in. |
Set a needed XML namespace (incl. prefix) for the XML elements on the package the XML structure resides in. The namespace will then be generated to the root element and the prefix applied to all elements. |
Related Content
Related Pages:
Related Documentation: