XML_converter_paige_to_cc
The XML_converter_paige_to_cc
program is designed to convert XML files from the PAIGE format to the CC (Content Central) XML format. It also handles PDF files by moving them to a specified destination folder. The program processes XML and PDF files, performs validation checks, logs events, and reads a CSV configuration file for mapping document types.
The program incorporates several key functionalities:
<executable_name>_log.txt
.The program expects five command-line arguments:
./converter <filename> <xml_source_folder> <xml_destination_folder> <config_file> <enable_logging>
Where:
<filename>
: Name of the file to process.<xml_source_folder>
: Directory containing the source XML files.<xml_destination_folder>
: Directory where converted XML files should be saved.<config_file>
: CSV file containing the document type mappings.<enable_logging>
: TRUE
to enable logging, FALSE
to disable it.The CSV configuration file maps PAIGE document types to CC catalog values and CC document types, ensuring accurate conversion.
The configuration file should be a standard CSV file with three columns:
PAIGE Document Type | CC Catalog Value | CC Document Type |
---|---|---|
Invoice | Financial | Accounts |
Report | Business | Analysis |
Contract | Legal | Agreement |
PAIGE Document Type
): Document type in the PAIGE XML.CC Catalog Value
): Corresponding catalog value for the CC XML.CC Document Type
): Corresponding document type for the CC XML.mapping.csv
)PAIGE Document Type,CC Catalog Value,CC Document Type
Invoice,Financial,Accounts
Report,Business,Analysis
Contract,Legal,Agreement
To create the CSV file:
Using a Text Editor:
mapping.csv
in comma-separated values (CSV) format.Using a Spreadsheet Editor:
CSV (Comma delimited) (*.csv)
.documentTypeMap
) to store document type mappings from the CSV file.logMessage(enableLogging bool, message string)
Handles logging of messages to a log file if logging is enabled.
getLogFileName()
Returns the log file's name based on the executable name.
isPaigeXML(paige PaigeExport) bool
Validates whether the provided XML follows the PAIGE format.
convertPaigeToCC(paige PaigeExport) CCXML
Converts a PAIGE XML struct to a CC XML struct.
loadConfig(configFile string) error
Reads the CSV configuration file and populates the document type mapping.
processFile(filename, sourceFolder, destinationFolder, configFile string, enableLogging bool)
Processes a file based on its type (PDF or XML):
main()
Handles command-line arguments, initializes logging, loads the configuration, and processes files.
Run the program with:
./converter filename.xml /source/path /destination/path config.csv TRUE
Example:
./converter sample.xml /home/user/source /home/user/destination mapping.csv TRUE
The <xml_destination_folder>
must be configured as an XML incoming folder in Content Central. This ensures that the converted CC XML files are properly ingested into the document management system for further processing. Refer to Ademero Support for instructions on configuring an XML capture job in Content Central.
Missing or Invalid Configuration File:
Invalid XML Format:
Unrecognized File Types:
.xml
or .pdf
is deleted.Logging Behavior:
✔ Robust Validation: Ensures PAIGE XML follows a correct format before processing.
✔ Modular Design: Functions are well-structured for easy maintenance.
✔ Error Handling: Uses structured error handling for missing files, incorrect mappings, etc.
✔ Logging Support: Provides detailed logs for tracking operations.
✔ CSV-Based Configuration: Allows dynamic mapping between document types.
🔹 Multi-File Processing: Currently, the program processes one file at a time. It could be enhanced to process multiple files in a directory.
🔹 Logging Optimization: Logs are written synchronously, which could slow down execution. Consider using buffered logging.
🔹 Parallel Processing: Utilizing Goroutines to process multiple files concurrently would improve performance.
The XML_converter_paige_to_cc
program is well-structured and effectively converts PAIGE XML to CC XML while handling PDFs. It includes a strong validation mechanism, logging, and configuration support. Proper configuration of the XML destination folder ensures seamless integration with Content Central.