I am trying to parse a set of records to extract relevant data.
The incoming stream can be divided into 2-3 subsets A, B, C. The subset will determine the extraction method. (The 3 tan boxes in the image below). Each subset will contain a key OuterXML field that identifies it: A = A_OuterXML, B = B_OuterXML, and C = C_OuterXML.
I have 2 source XML files. Source 1 includes A, B, and C. Source 2 only includes A and B. Presently, I have two separate macros that parse each Source. I want to combine the two macros into one that can account for the presence or absence of C.
How can I adjust my macro to account for the presence or absence of C (C_OuterXML)?
The macro current fails if C is not present. I can modify by adding an Ensure Field tool to the C box and then filter null values out -- bu then I have to add an Ensure Field tool for every missing xml field in the C workflow. I assume there is a better way.
I should add....
The presence or absence of C is only known after you attempt to parse for it
Hi @hellyars
Try this
-Convert this macro into a batch macro with a control parameter connected to disable container C if C_OuterXML if false.
-Embed this macro in a new macro which only looks for C_OuterXML. If found, pass true to the control parameter, otherwise pass false.
Dan
@danilang Can't argue with the logic, but I have no clue how to do that. I actually tried and got stuck.
The good news, I can parse and output everything I need. I am going back and trying to find synergies using macros etc. to reduce tools, steps, and in this case the # of workflows.
Hi @hellyars
Here's an example of how to disable a container in a macro based on the presence/absence of a field in the calling workflow
In the main workflow, the Logic to disable the container in the macro uses a Field Info tool to extract the field names and then counts the number of C_OuterXML fields. If the Count=0 then pass True to the Disabled attribute, else pass False. Change the config of "Field selector" to simulate the presence/absence of the C_OuterXML field. The "Empty C_OuterXML field" on the bottom is just to ensure that the field exists before passing it to the macro.
Inside the macro, the "C_OuterMXL Disabled?" parameter controls the state of the Disabled flag on the third container. If it's passed a "True", then the container is disabled. The rest of the macro is just to demonstrate the concept and have a variable output.
When c_OuterXML is present, the container is enabled in the macro and the output includes it
If it's missing, you get this
Dan