How to generate dynamic XML metadata/schema

I will start off saying I am new to CloverETL with no formal training.

I have a job that runs an ExecuteScript component with a command that invokes Apple’s iTunes Connect Reporter Java tool to get the status of the report to let me know if it is ready or not to download. The message of the Java tool is in XML and I am writing that to an XML file using the UniversalDataWriter. The last component in the job kicks off another jobflow.

The next jobflow starts with an XMLExtract component that will map the XML from the file and send the message portion of the XML to a Condition component to look for whether or not the file is ready and split the condition to download the file if it is ready, or sleep and call the Java tool to get the status again after some time if it is not ready.

The ready status’s XML looks like this:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Status>
    <Message>Sales and Trends Reporter is currently available.</Message>
    <Code>0</Code>
</Status>

The unavailable status’s XML looks like this:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Error>
    <Code>1</Code>
    <Message>Sales and Trends is currently unavailable.  Please try again in 15 minutes.</Message>
    <Retry>875000</Retry>
</Error>

The output is dynamic and I am not sure how to format the metadata/schema to be able to handle either output. The message portion of the XML is the only thing that is important to me.

Hi KMac21,

A simple solution to your use case would be to leave the XML response as a string and use a SimpleCopy component to pass a copy to two XMLExtract component (output the data of the XML). You will want set the File URL property for both XMLExtracts to read from the port. In the XMLExtract’s Mapping property, it will ask you to “Generate tree structure” in the Source XML File use the ready status’s XML for one and the unavailable status XML for the other one, thus creating the structure for both cases. Finally, map the Message to the output port in both cases.

I have also taken the liberty of attaching a project of your use case.

Thank you so much for your help! I also realized that I could just pass the output of the xml from the java tool to the stdOut and feed that into a Reformat component where I then parsed out the message with substring. Both solutions work and is very helpful. Thanks again.